34 #include "libmesh/quadrature.h"
35 #include "libmesh/boundary_info.h"
48 context.get_element_fe(this->_flow_vars.u())->get_xyz();
49 context.get_element_fe(this->_flow_vars.u())->get_phi();
55 (
bool compute_jacobian,
59 const std::vector<libMesh::Real> &JxW =
60 context.get_element_fe(this->_flow_vars.u())->get_JxW();
63 const std::vector<std::vector<libMesh::Real> >& u_phi =
64 context.get_element_fe(this->_flow_vars.u())->get_phi();
66 const std::vector<libMesh::Point>& u_qpoint =
67 context.get_element_fe(this->_flow_vars.u())->get_xyz();
70 const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
73 libMesh::DenseSubMatrix<libMesh::Number> &Kuu = context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.u());
74 libMesh::DenseSubMatrix<libMesh::Number> &Kuv = context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.v());
75 libMesh::DenseSubMatrix<libMesh::Number> &Kvu = context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.u());
76 libMesh::DenseSubMatrix<libMesh::Number> &Kvv = context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.v());
78 libMesh::DenseSubMatrix<libMesh::Number>* Kwu = NULL;
79 libMesh::DenseSubMatrix<libMesh::Number>* Kwv = NULL;
80 libMesh::DenseSubMatrix<libMesh::Number>* Kww = NULL;
81 libMesh::DenseSubMatrix<libMesh::Number>* Kuw = NULL;
82 libMesh::DenseSubMatrix<libMesh::Number>* Kvw = NULL;
84 libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(this->_flow_vars.u());
85 libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(this->_flow_vars.v());
86 libMesh::DenseSubVector<libMesh::Number>* Fw = NULL;
88 if( this->_flow_vars.dim() == 3 )
90 Kuw = &context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.w());
91 Kvw = &context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.w());
93 Kwu = &context.get_elem_jacobian(this->_flow_vars.w(), this->_flow_vars.u());
94 Kwv = &context.get_elem_jacobian(this->_flow_vars.w(), this->_flow_vars.v());
95 Kww = &context.get_elem_jacobian(this->_flow_vars.w(), this->_flow_vars.w());
96 Fw = &context.get_elem_residual(this->_flow_vars.w());
99 unsigned int n_qpoints = context.get_element_qrule().n_points();
101 for (
unsigned int qp=0; qp != n_qpoints; qp++)
104 libMesh::Number u, v;
105 u = context.interior_value(this->_flow_vars.u(), qp);
106 v = context.interior_value(this->_flow_vars.v(), qp);
108 libMesh::NumberVectorValue U(u,v);
109 if (this->_flow_vars.dim() == 3)
110 U(2) = context.interior_value(this->_flow_vars.w(), qp);
112 libMesh::NumberVectorValue F;
113 libMesh::NumberTensorValue dFdU;
114 libMesh::NumberTensorValue* dFdU_ptr =
115 compute_jacobian ? &dFdU : NULL;
116 if (!this->compute_force(u_qpoint[qp], context.time, U, F, dFdU_ptr))
119 libMesh::Real jac = JxW[qp];
121 for (
unsigned int i=0; i != n_u_dofs; i++)
123 const libMesh::Number jac_i = jac * u_phi[i][qp];
128 if( this->_flow_vars.dim() == 3 )
129 (*Fw)(i) += F(2)*jac_i;
131 if( compute_jacobian )
133 for (
unsigned int j=0; j != n_u_dofs; j++)
135 const libMesh::Number jac_ij =
136 jac_i * context.get_elem_solution_derivative() *
138 Kuu(i,j) += jac_ij * dFdU(0,0);
139 Kuv(i,j) += jac_ij * dFdU(0,1);
140 Kvu(i,j) += jac_ij * dFdU(1,0);
141 Kvv(i,j) += jac_ij * dFdU(1,1);
143 if( this->_flow_vars.dim() == 3 )
145 (*Kuw)(i,j) += jac_ij * dFdU(0,2);
146 (*Kvw)(i,j) += jac_ij * dFdU(1,2);
147 (*Kwu)(i,j) += jac_ij * dFdU(2,0);
148 (*Kwv)(i,j) += jac_ij * dFdU(2,1);
149 (*Kww)(i,j) += jac_ij * dFdU(2,2);
virtual void init_context(AssemblyContext &context)
Initialize context for added physics variables.
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context)
Time dependent part(s) of physics for element interiors.
INSTANTIATE_INC_NS_SUBCLASS(VelocityDrag)