20 #include "libmesh/dof_map.h" 21 #include "libmesh/elem.h" 22 #include "libmesh/equation_systems.h" 23 #include "libmesh/fe_base.h" 24 #include "libmesh/fem_context.h" 25 #include "libmesh/fem_system.h" 26 #include "libmesh/libmesh_logging.h" 27 #include "libmesh/mesh_base.h" 28 #include "libmesh/numeric_vector.h" 29 #include "libmesh/quadrature.h" 30 #include "libmesh/sparse_matrix.h" 31 #include "libmesh/time_solver.h" 32 #include "libmesh/unsteady_solver.h" 43 return request_jacobian;
45 libmesh_not_implemented();
48 FEMContext & context = cast_ref<FEMContext &>(c);
51 libmesh_assert_equal_to (
_mesh_sys,
this);
62 const unsigned int mesh_xyz_var = n_x_dofs ?
_mesh_x_var :
72 context.element_fe_var[mesh_xyz_var]);
74 context.element_fe_var[mesh_xyz_var]);
76 context.element_fe_var[mesh_xyz_var]);
78 const std::vector<std::vector<Real>> & psi =
79 context.element_fe_var[mesh_xyz_var]->get_phi();
98 libmesh_not_implemented();
103 if (this->time_solver->is_steady())
104 return request_jacobian;
106 unsteady = cast_ptr<UnsteadySolver*>(this->time_solver.get());
108 const std::vector<Real> & JxW =
109 context.element_fe_var[var]->get_JxW();
111 const std::vector<std::vector<Real>> & phi =
112 context.element_fe_var[var]->get_phi();
114 const std::vector<std::vector<RealGradient>> & dphi =
115 context.element_fe_var[var]->get_dphi();
117 const unsigned int n_u_dofs = context.dof_indices_var[var].size();
123 context.elem_subjacobians[var][
_mesh_x_var] :
nullptr;
125 context.elem_subjacobians[var][
_mesh_y_var] :
nullptr;
127 context.elem_subjacobians[var][
_mesh_z_var] :
nullptr;
129 std::vector<Real> delta_x(n_x_dofs, 0.);
130 std::vector<Real> delta_y(n_y_dofs, 0.);
131 std::vector<Real> delta_z(n_z_dofs, 0.);
133 for (
unsigned int i = 0; i != n_x_dofs; ++i)
135 unsigned int j = context.dof_indices_var[
_mesh_x_var][i];
140 for (
unsigned int i = 0; i != n_y_dofs; ++i)
142 unsigned int j = context.dof_indices_var[
_mesh_y_var][i];
147 for (
unsigned int i = 0; i != n_z_dofs; ++i)
149 unsigned int j = context.dof_indices_var[
_mesh_z_var][i];
154 for (
unsigned int qp = 0; qp != n_qpoints; ++qp)
159 for (
unsigned int i = 0; i != n_x_dofs; ++i)
160 convection(0) += delta_x[i] * psi[i][qp];
161 for (
unsigned int i = 0; i != n_y_dofs; ++i)
162 convection(1) += delta_y[i] * psi[i][qp];
163 for (
unsigned int i = 0; i != n_z_dofs; ++i)
164 convection(2) += delta_z[i] * psi[i][qp];
166 for (
unsigned int i = 0; i != n_u_dofs; ++i)
168 Number JxWxPhiI = JxW[qp] * phi[i][qp];
169 Fu(i) += (convection * grad_u) * JxWxPhiI;
170 if (request_jacobian)
172 Number JxWxPhiI = JxW[qp] * phi[i][qp];
173 for (
unsigned int j = 0; j != n_u_dofs; ++j)
174 Kuu(i,j) += JxWxPhiI * (convection * dphi[j][qp]);
176 Number JxWxPhiIoverDT = JxWxPhiI/this->deltat;
178 Number JxWxPhiIxDUDXoverDT = JxWxPhiIoverDT * grad_u(0);
179 for (
unsigned int j = 0; j != n_x_dofs; ++j)
180 (*Kux)(i,j) += JxWxPhiIxDUDXoverDT * psi[j][qp];
182 Number JxWxPhiIxDUDYoverDT = JxWxPhiIoverDT * grad_u(1);
183 for (
unsigned int j = 0; j != n_y_dofs; ++j)
184 (*Kuy)(i,j) += JxWxPhiIxDUDYoverDT * psi[j][qp];
186 Number JxWxPhiIxDUDZoverDT = JxWxPhiIoverDT * grad_u(2);
187 for (
unsigned int j = 0; j != n_z_dofs; ++j)
188 (*Kuz)(i,j) += JxWxPhiIxDUDZoverDT * psi[j][qp];
195 return request_jacobian;
203 FEMContext & context = cast_ref<FEMContext &>(c);
212 FEBase * elem_fe =
nullptr;
215 const std::vector<Real> & JxW = elem_fe->
get_JxW();
217 const std::vector<std::vector<Real>> & phi = elem_fe->
get_phi();
219 const unsigned int n_dofs = cast_int<unsigned int>
225 for (
unsigned int qp = 0; qp != n_qpoints; ++qp)
229 const Number JxWxU = JxW[qp] * uprime;
230 for (
unsigned int i = 0; i != n_dofs; ++i)
232 Fu(i) -= JxWxU * phi[i][qp];
235 const Number JxWxPhiIxDeriv = JxW[qp] * phi[i][qp] *
237 Kuu(i,i) -= JxWxPhiIxDeriv * phi[i][qp];
238 for (
unsigned int j = i+1; j < n_dofs; ++j)
240 const Number Kij = JxWxPhiIxDeriv * phi[j][qp];
249 return request_jacobian;
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
unsigned int _mesh_x_var
Variables from which to acquire moving mesh information.
This class provides all data required for a physics package (e.g.
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Number old_nonlinear_solution(const dof_id_type global_dof_number) const
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
The libMesh namespace provides an interface to certain functionality in the library.
Defines a dense subvector for use in finite element computations.
Gradient interior_gradient(unsigned int var, unsigned int qp) const
Real elem_solution_rate_derivative
The derivative of elem_solution_rate with respect to the current nonlinear solution, for use by systems with non default mass_residual terms.
Defines a dense submatrix for use in Finite Element-type computations.
System * _mesh_sys
System from which to acquire moving mesh information.
virtual_for_inffe const std::vector< Real > & get_JxW() const
This class provides all data required for a physics package (e.g.
const std::vector< dof_id_type > & get_dof_indices() const
Accessor for element dof indices.
unsigned int n_points() const
virtual bool eulerian_residual(bool request_jacobian, DiffContext &context) override
Adds a pseudo-convection contribution on elem to elem_residual, if the nodes of elem are being transl...
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual.
This is a generic class that defines a solver to handle time integration of DifferentiableSystems.
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
void get_element_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for interior finite element object for variable var for the largest dimension in the mesh...
virtual bool mass_residual(bool request_jacobian, DiffContext &) override
Subtracts a mass vector contribution on elem from elem_residual.
bool is_time_evolving(unsigned int var) const
unsigned int n_vars() const
Number of variables in solution.
void interior_rate(unsigned int var, unsigned int qp, OutputType &u) const
This class forms the foundation from which generic finite elements may be derived.
const QBase & get_element_qrule() const
Accessor for element interior quadrature rule for the dimension of the current _elem.
const std::vector< std::vector< OutputShape > > & get_phi() const