WRApplication
External kratos "application" for multiscale time integration.
|
Unix-inspired pipes in C++. More...
Classes | |
class | ModelPartFromModel |
Get a ModelPart from a Model by name. More... | |
struct | ProcessInfoFromModelPart |
Get the ProcessInfo of a ModelPart. More... | |
class | VariableFromProcessInfo |
Get a variable from ProcessInfo. More... | |
struct | TimeFromProcessInfo |
Get TIME from a ProcessInfo. More... | |
struct | StepFromProcessInfo |
Get STEP from a ProcessInfo. More... | |
class | Comparison |
Perform a comparison operation on the input as the left hand side. More... | |
class | IntervalPredicate |
Pipe wrapper for Detail::IntervalUtility. More... | |
class | Modulo |
Compute the mod of the input. More... | |
class | Add |
Add a constant value to the input. More... | |
class | ConstPredicate |
Return a bool regardless of the input. More... | |
struct | Traits |
Metaclass containing type information every pipe must inherit from. More... | |
class | CompoundPipe |
A composable pipe that takes the output of one pipe and feeds its result into another. More... | |
class | SingleSegmentPipeline |
An adaptor class for pipelines consisting of a single segment. More... | |
Typedefs | |
template<class TPipe > | |
using | IsPipe = std::integral_constant< bool, std::is_same_v< decltype(std::declval< const TPipe >().operator()(std::declval< typename TPipe::InputType >())), typename TPipe::OutputType > &&!std::is_same_v< typename TPipe::InputType, void > &&!std::is_same_v< typename TPipe::OutputType, void > > |
Bool constant checking whether TPipe satisfies the requirements of a pipe. More... | |
template<class ... TPipes> | |
using | Pipeline = decltype((...|std::declval< TPipes >())) |
Convenience type alias for complex pipes. More... | |
Functions | |
template<class TInput , class TPipe , std::enable_if_t< IsPipe< TPipe >::value &&std::is_convertible_v< TInput, typename TPipe::InputType >, bool > = true> | |
TPipe::OutputType | operator>> (TInput &&rInput, const TPipe &rPipe) |
Operator for calling operator() of the pipe. More... | |
template<class TInputPipe , class TOutputPipe , std::enable_if_t< IsPipe< TInputPipe >::value &&IsPipe< TOutputPipe >::value, bool > = true> | |
CompoundPipe< TInputPipe, TOutputPipe > | operator| (TInputPipe &&rInputPipe, TOutputPipe &&rOutputPipe) |
Construct a pipe that takes the output of an input pipe and feeds it into an output pipe. More... | |
template<class TInputPipe , class TOutputPipe , std::enable_if_t< IsPipe< TInputPipe >::value &&IsPipe< TOutputPipe >::value, bool > = true> | |
CompoundPipe< TInputPipe, TOutputPipe > | operator| (const TInputPipe &rInputPipe, const TOutputPipe &rOutputPipe) |
Construct a pipe that takes the output of an input pipe and feeds it into an output pipe. More... | |
Unix-inspired pipes in C++.
A pipe is a modular sequence of operations that takes an immutable input and produces an output. Modularity is provided via static polymorphism (templates) to avoid the overhead incurred by virtual functions. Therefore, there is no base class for a pipe; rather, a class must satisfy a set of requirements to be considered a Pipe. These requirements are:
[optional]: should be constructible from Parameters (required for CompoundPipe).
Pipes are meant to be stitched together to form a pipeline capable of performing more complex tasks. Two operators can be used for this purpose:
Kratos::Pipes::operator>> feeds an input into a pipe. It is equivalent to calling operator(), but is more readable when pushing through multiple pipes. Example:
The benefit of this approach over operator| is that no compound pipe instance is constructed.
When defining a new pipe class, make sure to derive from Traits, which defines the necessary type aliases for your new class to be considered a pipe. The integral constant IsPipe checks whether a type is a valid pipe. Usage:
. A type must satisfy the pipe requirements in order to be usable in operator| and operator>>.
Pipes that are constructible from Parameters can be used with CompoundPipe. CompoundPipe recursively constructs each pipe segment by passing the same Parameters instance. This can be very handy for constructing longer pipes or using pipes in generic templates.