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;