$extrastylesheet
#include <composite_function.h>

Public Member Functions | |
| CompositeFunction () | |
| ~CompositeFunction () | |
| void | attach_subfunction (const FunctionBase< Output > &f, const std::vector< unsigned int > &index_map) |
| virtual Output | operator() (const Point &p, const Real time=0) |
| virtual void | operator() (const Point &p, const Real time, DenseVector< Output > &output) |
| virtual Output | component (unsigned int i, const Point &p, Real time) |
| virtual UniquePtr < FunctionBase< Output > > | clone () const |
| unsigned int | n_subfunctions () const |
| unsigned int | n_components () const |
| virtual void | init () |
| virtual void | clear () |
| void | operator() (const Point &p, DenseVector< Output > &output) |
| bool | initialized () const |
Protected Attributes | |
| const FunctionBase * | _master |
| bool | _initialized |
Private Attributes | |
| std::vector< FunctionBase < Output > * > | subfunctions |
| std::vector< std::vector < unsigned int > > | index_maps |
| std::vector< std::pair < unsigned int, unsigned int > > | reverse_index_map |
Definition at line 36 of file composite_function.h.
| libMesh::CompositeFunction< Output >::CompositeFunction | ( | ) | [inline, explicit] |
Definition at line 40 of file composite_function.h.
Referenced by libMesh::CompositeFunction< Output >::clone().
{}
| libMesh::CompositeFunction< Output >::~CompositeFunction | ( | ) | [inline] |
Definition at line 42 of file composite_function.h.
References libMesh::CompositeFunction< Output >::subfunctions.
{
for (unsigned int i=0; i != subfunctions.size(); ++i)
delete subfunctions[i];
}
| void libMesh::CompositeFunction< Output >::attach_subfunction | ( | const FunctionBase< Output > & | f, |
| const std::vector< unsigned int > & | index_map | ||
| ) | [inline] |
Definition at line 51 of file composite_function.h.
References libMesh::FunctionBase< Output >::clone(), libMesh::CompositeFunction< Output >::index_maps, libMesh::invalid_uint, libMesh::CompositeFunction< Output >::reverse_index_map, and libMesh::CompositeFunction< Output >::subfunctions.
Referenced by libMesh::CompositeFunction< Output >::clone().
{
const unsigned int subfunction_index = subfunctions.size();
libmesh_assert_equal_to(subfunctions.size(), index_maps.size());
subfunctions.push_back(f.clone().release());
index_maps.push_back(index_map);
unsigned int max_index =
*std::max_element(index_map.begin(), index_map.end());
if (max_index >= reverse_index_map.size())
reverse_index_map.resize
(max_index+1, std::make_pair(libMesh::invalid_uint,
libMesh::invalid_uint));
for (unsigned int j=0; j != index_map.size(); ++j)
{
libmesh_assert_less(index_map[j], reverse_index_map.size());
libmesh_assert_equal_to(reverse_index_map[index_map[j]].first,
libMesh::invalid_uint);
libmesh_assert_equal_to(reverse_index_map[index_map[j]].second,
libMesh::invalid_uint);
reverse_index_map[index_map[j]] =
std::make_pair(subfunction_index, j);
}
}
| virtual void libMesh::FunctionBase< Output >::clear | ( | ) | [inline, virtual, inherited] |
Clears the function.
Reimplemented in libMesh::ParsedFunction< Output, OutputGradient >, libMesh::MeshFunction, and libMesh::AnalyticFunction< Output >.
Definition at line 90 of file function_base.h.
{}
| virtual UniquePtr<FunctionBase<Output> > libMesh::CompositeFunction< Output >::clone | ( | ) | const [inline, virtual] |
Returns a new copy of the function. The new copy should be as ``deep'' as necessary to allow independent destruction and simultaneous evaluations of the copies in different threads.
Implements libMesh::FunctionBase< Output >.
Definition at line 127 of file composite_function.h.
References libMesh::CompositeFunction< Output >::attach_subfunction(), libMesh::CompositeFunction< Output >::CompositeFunction(), libMesh::CompositeFunction< Output >::index_maps, and libMesh::CompositeFunction< Output >::subfunctions.
{
CompositeFunction* returnval = new CompositeFunction();
for (unsigned int i=0; i != subfunctions.size(); ++i)
returnval->attach_subfunction(*subfunctions[i], index_maps[i]);
return UniquePtr<FunctionBase<Output> > (returnval);
}
| virtual Output libMesh::CompositeFunction< Output >::component | ( | unsigned int | i, |
| const Point & | p, | ||
| Real | time | ||
| ) | [inline, virtual] |
i at coordinate p and time time. Reimplemented from libMesh::FunctionBase< Output >.
Definition at line 111 of file composite_function.h.
References libMesh::invalid_uint, libMesh::CompositeFunction< Output >::reverse_index_map, and libMesh::CompositeFunction< Output >::subfunctions.
Referenced by libMesh::CompositeFunction< Output >::operator()().
{
if (i >= reverse_index_map.size() ||
reverse_index_map[i].first == libMesh::invalid_uint)
return 0;
libmesh_assert_less(reverse_index_map[i].first,
subfunctions.size());
libmesh_assert_not_equal_to(reverse_index_map[i].second,
libMesh::invalid_uint);
return subfunctions[reverse_index_map[i].first]->
component(reverse_index_map[i].second,p,time);
}
| virtual void libMesh::FunctionBase< Output >::init | ( | ) | [inline, virtual, inherited] |
The actual initialization process.
Reimplemented in libMesh::ParsedFunction< Output, OutputGradient >, libMesh::MeshFunction, and libMesh::AnalyticFunction< Output >.
Definition at line 85 of file function_base.h.
{}
| bool libMesh::FunctionBase< Output >::initialized | ( | ) | const [inline, inherited] |
true when this object is properly initialized and ready for use, false otherwise. Definition at line 198 of file function_base.h.
{
return (this->_initialized);
}
| unsigned int libMesh::CompositeFunction< Output >::n_components | ( | ) | const [inline] |
Definition at line 138 of file composite_function.h.
References libMesh::CompositeFunction< Output >::reverse_index_map.
{
return reverse_index_map.size();
}
| unsigned int libMesh::CompositeFunction< Output >::n_subfunctions | ( | ) | const [inline] |
Definition at line 134 of file composite_function.h.
References libMesh::CompositeFunction< Output >::subfunctions.
{
return subfunctions.size();
}
| virtual Output libMesh::CompositeFunction< Output >::operator() | ( | const Point & | p, |
| const Real | time = 0 |
||
| ) | [inline, virtual] |
p and time time, which defaults to zero. Purely virtual, so you have to overload it. Note that this cannot be a const method, check MeshFunction. Implements libMesh::FunctionBase< Output >.
Definition at line 80 of file composite_function.h.
References libMesh::CompositeFunction< Output >::component().
{
return this->component(0,p,time);
}
| virtual void libMesh::CompositeFunction< Output >::operator() | ( | const Point & | p, |
| const Real | time, | ||
| DenseVector< Output > & | output | ||
| ) | [inline, virtual] |
Return function for vectors. Returns in output the values of the data at the coordinate p and for time time. Purely virtual, so you have to overload it. Note that this cannot be a const method, check MeshFunction. Can optionally provide subdomain_ids which will restrict the function to operate on elements with subdomain id contained in the set. This is useful in cases where there are multiple dimensioned elements, for example.
Implements libMesh::FunctionBase< Output >.
Definition at line 86 of file composite_function.h.
References libMesh::CompositeFunction< Output >::index_maps, libMesh::DenseVector< T >::resize(), libMesh::CompositeFunction< Output >::reverse_index_map, libMesh::DenseVector< T >::size(), libMesh::CompositeFunction< Output >::subfunctions, and libMesh::DenseVector< T >::zero().
{
libmesh_assert_greater_equal (output.size(),
reverse_index_map.size());
// Necessary in case we have output components not covered by
// any subfunctions
output.zero();
DenseVector<Output> temp;
for (unsigned int i=0; i != subfunctions.size(); ++i)
{
temp.resize(index_maps[i].size());
(*subfunctions[i])(p, time, temp);
for (unsigned int j=0; j != temp.size(); ++j)
output(index_maps[i][j]) = temp(j);
}
}
| void libMesh::FunctionBase< Output >::operator() | ( | const Point & | p, |
| DenseVector< Output > & | output | ||
| ) | [inline, inherited] |
Return function for vectors. Returns in output the values of the data at the coordinate p.
Definition at line 220 of file function_base.h.
{
// Call the time-dependent function with t=0.
this->operator()(p, 0., output);
}
bool libMesh::FunctionBase< Output >::_initialized [protected, inherited] |
When init() was called so that everything is ready for calls to operator() (...), then this bool is true.
Definition at line 170 of file function_base.h.
Referenced by libMesh::AnalyticFunction< Output >::AnalyticFunction(), libMesh::ConstFunction< Output >::ConstFunction(), libMesh::ParsedFunction< Output, OutputGradient >::ParsedFunction(), and libMesh::WrappedFunction< Output >::WrappedFunction().
const FunctionBase* libMesh::FunctionBase< Output >::_master [protected, inherited] |
Const pointer to our master, initialized to NULL. There may be cases where multiple functions are required, but to save memory, one master handles some centralized data.
Definition at line 164 of file function_base.h.
std::vector<std::vector<unsigned int> > libMesh::CompositeFunction< Output >::index_maps [private] |
Definition at line 147 of file composite_function.h.
Referenced by libMesh::CompositeFunction< Output >::attach_subfunction(), libMesh::CompositeFunction< Output >::clone(), and libMesh::CompositeFunction< Output >::operator()().
std::vector<std::pair<unsigned int, unsigned int> > libMesh::CompositeFunction< Output >::reverse_index_map [private] |
std::vector<FunctionBase<Output> *> libMesh::CompositeFunction< Output >::subfunctions [private] |
Definition at line 144 of file composite_function.h.
Referenced by libMesh::CompositeFunction< Output >::attach_subfunction(), libMesh::CompositeFunction< Output >::clone(), libMesh::CompositeFunction< Output >::component(), libMesh::CompositeFunction< Output >::n_subfunctions(), libMesh::CompositeFunction< Output >::operator()(), and libMesh::CompositeFunction< Output >::~CompositeFunction().