26 #include "libmesh/dof_map.h" 31 const std::string& nm):
39 _perturbed_function(nullptr)
46 const std::string& nm):
87 n_vars =
_sys->n_vars();
90 (*_function)(p, t, v1);
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();
157 (*_perturbed_function)(p, t, v1);
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++)
174 const libMesh::Point& p,
179 libmesh_error_msg(
"To be implemented.");
188 init(
const libMesh::NumericVector<Real>& sol,
189 const libMesh::NumericVector<Real>* dsol) {
196 _sol = libMesh::NumericVector<Real>::build(
_sys->comm()).release();
205 _sol->init(sol.size(),
true, libMesh::SERIAL);
209 std::vector<unsigned int> vars;
210 _sys->get_all_variable_numbers(vars);
212 _function =
new libMesh::MeshFunction(
_sys->get_equation_systems(),
220 _dsol = libMesh::NumericVector<Real>::build(
_sys->comm()).release();
228 _dsol->init(dsol->size(),
true, libMesh::SERIAL);
229 dsol->localize(*
_dsol);
234 new libMesh::MeshFunction(
_sys->get_equation_systems(),
MeshFieldFunction(MAST::SystemInitialization &sys, const std::string &nm)
constructor
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::NumericVector< Real > * _sol
current solution that is going to be interpolated
libMesh::NumericVector< Real > * _dsol
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.
libMesh::MeshFunction * _function
the MeshFunction object that performs the interpolation
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...
libMesh::MeshFunction * _perturbed_function
virtual void clear_element_quadrature_point_solution()
clears the quadrature point solution provided by the corresponding set method above.
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...
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
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
bool _use_qp_sol
flag is set to true when the quadrature point solution is provided by an element
void init(const libMesh::NumericVector< Real > &sol, const libMesh::NumericVector< Real > *dsol=nullptr)
initializes the data structures to perform the interpolation function of sol.
libMesh::System * _sys
current system for which solution is to be interpolated
virtual ~MeshFieldFunction()
destructor