34 #include "libmesh/getpot.h"
35 #include "libmesh/fem_system.h"
36 #include "libmesh/quadrature.h"
37 #include "libmesh/fe_base.h"
38 #include "libmesh/parsed_fem_function.h"
74 this->qoi_functional.reset(qf);
76 this->set_parameter(*qf, input,
77 "QoI/ParsedInterior/qoi_functional",
"DIE!");
82 libMesh::FEBase* element_fe;
83 context.get_element_fe<libMesh::Real>(0, element_fe);
84 element_fe->get_JxW();
85 element_fe->get_xyz();
91 const unsigned int qoi_index )
93 libMesh::FEBase* element_fe;
94 context.get_element_fe<libMesh::Real>(0, element_fe);
95 const std::vector<libMesh::Real> &JxW = element_fe->get_JxW();
97 const std::vector<libMesh::Point>& x_qp = element_fe->get_xyz();
99 unsigned int n_qpoints = context.get_element_qrule().n_points();
102 libMesh::Number& qoi = context.get_qois()[qoi_index];
104 for(
unsigned int qp = 0; qp != n_qpoints; qp++ )
106 const libMesh::Number func_val =
107 (*qoi_functional)(context, x_qp[qp], context.get_time());
109 qoi += func_val * JxW[qp];
114 const unsigned int qoi_index )
116 libMesh::FEBase* element_fe;
117 context.get_element_fe<libMesh::Real>(0, element_fe);
118 const std::vector<libMesh::Real> &JxW = element_fe->get_JxW();
120 const std::vector<libMesh::Point>& x_qp = element_fe->get_xyz();
123 const unsigned int n_u_dofs = context.get_dof_indices().size();
125 unsigned int n_qpoints = context.get_element_qrule().n_points();
129 libMesh::DenseVector<libMesh::Number>& elem_solution =
130 const_cast<libMesh::DenseVector<libMesh::Number>&
>
131 (context.get_elem_solution());
134 libMesh::DenseVector<libMesh::Number> &Qu =
135 context.get_qoi_derivatives()[qoi_index];
137 for(
unsigned int qp = 0; qp != n_qpoints; qp++ )
143 for(
unsigned int i = 0; i != n_u_dofs; ++i )
145 libMesh::Number ¤t_solution = elem_solution(i);
146 const libMesh::Number original_solution = current_solution;
148 current_solution = original_solution + libMesh::TOLERANCE;
150 const libMesh::Number plus_val =
151 (*qoi_functional)(context, x_qp[qp], context.get_time());
153 current_solution = original_solution - libMesh::TOLERANCE;
155 const libMesh::Number minus_val =
156 (*qoi_functional)(context, x_qp[qp], context.get_time());
158 Qu(i) += (plus_val - minus_val) *
159 (0.5 / libMesh::TOLERANCE) * JxW[qp];
162 current_solution = original_solution;
virtual ~ParsedInteriorQoI()
ParsedInteriorQoI()
User never call default constructor.
virtual void init(const GetPot &input, const MultiphysicsSystem &system, unsigned int qoi_num)
Initialize local variables.
Interface with libMesh for solving Multiphysics problems.
virtual void element_qoi(AssemblyContext &context, const unsigned int qoi_index)
Compute the qoi value.
virtual void element_qoi_derivative(AssemblyContext &context, const unsigned int qoi_index)
Compute the qoi derivative with respect to the solution.
virtual void init_context(AssemblyContext &context)
virtual QoIBase * clone() const
Required to provide clone (deep-copy) for adding QoI object to libMesh objects.
virtual void move_parameter(const libMesh::Number &old_parameter, libMesh::Number &new_parameter)
When cloning an object, we need to update parameter pointers.
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > qoi_functional