20 #ifndef LIBMESH_WRAPPED_FUNCTION_H
21 #define LIBMESH_WRAPPED_FUNCTION_H
24 #include "libmesh/dense_vector.h"
25 #include "libmesh/equation_systems.h"
26 #include "libmesh/function_base.h"
27 #include "libmesh/libmesh_common.h"
28 #include "libmesh/point.h"
29 #include "libmesh/system.h"
30 #include "libmesh/auto_ptr.h"
50 template <
typename Output=Number>
61 const std::string & sys_name,
62 const std::string & unknown_name) =
nullptr,
64 unsigned int varnum=0)
88 virtual std::unique_ptr<FunctionBase<Output>>
clone ()
const override;
91 const Real time = 0.)
override;
99 Real time=0.)
override;
107 const std::string & sys_name,
108 const std::string & unknown_name);
120 template <
typename Output>
130 _sys.variable_name(_varnum));
134 template <
typename Output>
136 std::unique_ptr<FunctionBase<Output>>
139 return libmesh_make_unique<WrappedFunction<Output>>
140 (_sys, _fptr, _parameters, _varnum);
144 template <
typename Output>
155 libmesh_assert_equal_to (output.
size(), _sys.n_components());
159 const unsigned int n_vars = _sys.n_vars();
160 for (
unsigned int v = 0; v !=
n_vars; ++v)
162 const unsigned int n_components =
163 _sys.variable(v).n_components();
164 if (n_components == 1)
165 output(_sys.variable_scalar_number(v,0)) =
166 _fptr(p, *_parameters, _sys.name(), _sys.variable_name(v));
171 libmesh_assert_equal_to (_sys.variable(v).type().family,
SCALAR);
176 for (
unsigned int j=0; j != n_components; ++j)
177 output(_sys.variable_scalar_number(v,j)) =
178 _fptr(
Point(j,0,0), *_parameters,
179 _sys.name(), _sys.variable_name(v));
185 template <
typename Output>
196 const unsigned int n_vars = _sys.n_vars();
197 for (
unsigned int v = 0; v !=
n_vars; ++v)
199 const unsigned int n_components =
200 _sys.variable(v).n_components();
201 if (n_components == 1 &&
202 i == _sys.variable_scalar_number(v,0))
203 return _fptr(p, *_parameters, _sys.name(), _sys.variable_name(v));
204 else if (i >= _sys.variable_scalar_number(v,0) &&
205 i <= _sys.variable_scalar_number(v,n_components-1))
209 libmesh_assert_equal_to (_sys.variable(i).type().family,
SCALAR);
214 for (
unsigned int j=0; j != n_components; ++j)
215 if (i == _sys.variable_scalar_number(v,j))
216 return _fptr(
Point(j,0,0), *_parameters,
217 _sys.name(), _sys.variable_name(v));
221 libmesh_error_msg(
"Component index " << i <<
" not found in system " << _sys.name());
229 #endif // LIBMESH_WRAPPED_FUNCTION_H