26 #include "libmesh/dof_map.h" 31 const std::string& nm,
32 libMesh::ParallelType p_type):
39 _perturbed_function (nullptr)
46 const std::string& nm,
47 libMesh::ParallelType p_type):
87 n_vars =
_sys->n_vars();
94 libmesh_assert_equal_to(v1.size(), n_vars);
97 v = RealVectorX::Zero(n_vars);
98 for (
unsigned int i=0; i<n_vars; i++)
120 n_vars =
_sys->n_vars();
122 std::vector<libMesh::Gradient> v1;
127 libmesh_assert_equal_to(v1.size(), n_vars);
130 v = RealMatrixX::Zero(n_vars, 3);
131 for (
unsigned int i=0; i<n_vars; i++)
132 for (
unsigned int j=0; j<3; j++)
154 n_vars =
_sys->n_vars();
161 libmesh_assert_equal_to(v1.size(), n_vars);
164 v = RealVectorX::Zero(n_vars);
165 for (
unsigned int i=0; i<n_vars; i++)
186 n_vars =
_sys->n_vars();
188 std::vector<libMesh::Gradient> v1;
193 libmesh_assert_equal_to(v1.size(), n_vars);
196 v = RealMatrixX::Zero(n_vars, 3);
197 for (
unsigned int i=0; i<n_vars; i++)
198 for (
unsigned int j=0; j<3; j++)
206 const libMesh::Point& p,
218 std::map<const MAST::FunctionBase*, MAST::MeshFieldFunction::SolFunc*>::const_iterator
225 n_vars =
_sys->n_vars();
228 (*it->second->_func)(p, t, v1);
232 libmesh_assert_equal_to(v1.size(), n_vars);
235 v = RealVectorX::Zero(n_vars);
236 for (
unsigned int i=0; i<n_vars; i++)
243 const libMesh::Point& p,
255 std::map<const MAST::FunctionBase*, MAST::MeshFieldFunction::SolFunc*>::const_iterator
262 n_vars =
_sys->n_vars();
264 std::vector<libMesh::Gradient> v1;
265 it->second->_func->gradient(p, t, v1);
269 libmesh_assert_equal_to(v1.size(), n_vars);
272 v = RealMatrixX::Zero(n_vars, 3);
273 for (
unsigned int i=0; i<n_vars; i++)
274 for (
unsigned int j=0; j<3; j++)
295 const libMesh::NumericVector<Real>& sol,
299 std::map<const MAST::FunctionBase*, MAST::MeshFieldFunction::SolFunc*>::const_iterator
330 std::map<const MAST::FunctionBase*, MAST::MeshFieldFunction::SolFunc*>::const_iterator
334 for ( ; it != end; it++)
367 const libMesh::NumericVector<Real> &sol,
371 libmesh_assert(!sol_func.
_func);
376 libmesh_assert_equal_to(sol.type(),
_p_type);
377 sol_func.
_sol = /
381 sol_func.
_cloned_sol = libMesh::NumericVector<Real>::build(
_sys->comm()).release();
386 case libMesh::SERIAL: {
387 sol_func.
_cloned_sol->init(sol.size(),
true, libMesh::SERIAL);
392 case libMesh::GHOSTED: {
395 _sys->n_local_dofs(),
396 _sys->get_dof_map().get_send_list(),
399 sol.localize(*sol_func.
_cloned_sol,
_sys->get_dof_map().get_send_list());
411 std::vector<unsigned int> vars;
412 _sys->get_all_variable_numbers(vars);
414 sol_func.
_func =
new libMesh::MeshFunction(
_sys->get_equation_systems(),
418 sol_func.
_func->init();
virtual void perturbation_gradient(const libMesh::Point &p, const Real t, RealMatrixX &v) const
calculates the value of the function at the specified point, p, and time, t, and returns it in v...
virtual void gradient(const libMesh::Point &p, const Real t, RealMatrixX &g) const
calculates the gradient of value of the function at the specified point, p, and time, t, and returns it in g.
virtual void perturbation(const libMesh::Point &p, const Real t, RealVectorX &v) const
calculates the value of perturbation in the function at the specified point, p, and time...
void init(const libMesh::NumericVector< Real > &sol, bool reuse_vector)
initializes the data structures to perform the interpolation function of sol.
void _init_sol_func(bool reuse_sol, const libMesh::NumericVector< Real > &sol, MAST::MeshFieldFunction::SolFunc &sol_func)
SolFunc * _function
current solution that is going to be interpolated
MeshFieldFunction(MAST::SystemInitialization &sys, const std::string &nm, libMesh::ParallelType p_type)
constructor
SolFunc * _perturbed_function
current perturbation solution that is going to be interpolated
virtual void derivative(const MAST::FunctionBase &f, const libMesh::Point &p, const Real t, RealVectorX &v) const
calculates the value of the function at the specified point, p, and time, t, and returns it in v...
libMesh::ParallelType _p_type
type of parallel vector required for this mesh function.
virtual void clear_element_quadrature_point_solution()
clears the quadrature point solution provided by the corresponding set method above.
libMesh::MeshFunction * _func
virtual void derivative_gradient(const MAST::FunctionBase &f, const libMesh::Point &p, const Real t, RealMatrixX &v) const
calculates the value of the function at the specified point, p, and time, t, and returns it in v...
libMesh::NumericVector< Real > * _cloned_sol
RealVectorX _qp_sol
quadrature point solution of the element
virtual void set_element_quadrature_point_solution(RealVectorX &sol)
When a mesh field function is attached to an assembly routine during system assembly, then the current solution can be provided by the element quadrature point update.
libMesh::DenseVector< Real > DenseRealVector
Matrix< Real, Dynamic, Dynamic > RealMatrixX
virtual void operator()(const libMesh::Point &p, const Real t, RealVectorX &v) const
calculates the value of the function at the specified point, p, and time, t, and returns it in v...
This creates the base class for functions that have a saptial and temporal dependence, and provide sensitivity operations with respect to the functions and parameters.
void clear()
clear the solution
Matrix< Real, Dynamic, 1 > RealVectorX
const libMesh::NumericVector< Real > * _sol
bool _use_qp_sol
flag is set to true when the quadrature point solution is provided by an element
void init_sens(const MAST::FunctionBase &f, const libMesh::NumericVector< Real > &dsol, bool reuse_vector)
initializes the the data structures for computation of sensitivity for the specified function...
libMesh::System * _sys
current system for which solution is to be interpolated
virtual ~MeshFieldFunction()
destructor
std::map< const MAST::FunctionBase *, MAST::MeshFieldFunction::SolFunc * > _function_sens
solution sensitivity for specified value