18#ifndef LIBMESH_COMPOSITE_FUNCTION_H
19#define LIBMESH_COMPOSITE_FUNCTION_H
22#include "libmesh/dense_vector.h"
23#include "libmesh/function_base.h"
24#include "libmesh/int_range.h"
25#include "libmesh/libmesh.h"
26#include "libmesh/point.h"
48template <
typename Output=Number>
83 std::vector<unsigned int> index_map)
85 const unsigned int subfunction_index =
91 unsigned int max_index =
92 *std::max_element(index_map.begin(), index_map.end());
107 std::make_pair(subfunction_index, j);
128 const Real time = 0)
override
137 libmesh_assert_greater_equal (output.
size(),
170 virtual std::unique_ptr<FunctionBase<Output>>
clone()
const override
172 auto returnval = std::make_unique<CompositeFunction>();
A function that returns a vector whose components are defined by multiple functions.
virtual Output operator()(const Point &p, const Real time=0) override
CompositeFunction(const CompositeFunction &)=delete
This class contains unique_ptr members so it can't be default copied or assigned.
CompositeFunction(CompositeFunction &&)=default
This class can be default move constructed and assigned.
virtual Output component(unsigned int i, const Point &p, Real time) override
virtual ~CompositeFunction()=default
The subfunctions vector is automatically cleaned up.
std::vector< std::vector< unsigned int > > index_maps
virtual std::unique_ptr< FunctionBase< Output > > clone() const override
void attach_subfunction(const FunctionBase< Output > &f, std::vector< unsigned int > index_map)
Attach a new subfunction, along with a map from the indices of the attached subfunction to the indice...
std::vector< std::pair< unsigned int, unsigned int > > reverse_index_map
unsigned int n_subfunctions() const
unsigned int n_components() const
std::vector< std::unique_ptr< FunctionBase< Output > > > subfunctions
CompositeFunction & operator=(CompositeFunction &&)=default
CompositeFunction()=default
Defines a dense vector for use in Finite Element-type computations.
void resize(const unsigned int n)
Resize the vector.
virtual void zero() override final
Set every element in the vector to 0.
virtual unsigned int size() const override final
Base class for functors that can be evaluated at a point and (optionally) time.
virtual std::unique_ptr< FunctionBase< Output > > clone() const =0
bool is_time_dependent() const
bool _is_time_dependent
Cache whether or not this function is actually time-dependent.
A Point defines a location in LIBMESH_DIM dimensional Real space.
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real