35 #include "libmesh/quadrature.h"
43 _parsed_velocity_source_x_index(0),
44 _parsed_velocity_source_y_index(0),
45 _parsed_velocity_source_z_index(0)
59 context.get_element_fe(this->_flow_vars.u())->get_xyz();
60 context.get_element_fe(this->_flow_vars.u())->get_phi();
69 std::string section =
"Physics/"+this->_physics_name+
"/output_vars";
71 std::string vel_source =
"vel_source";
73 if( input.have_variable(section) )
75 unsigned int n_vars = input.vector_variable_size(section);
77 for(
unsigned int v = 0; v < n_vars; v++ )
79 std::string name = input(section,
"DIE!",v);
81 if( name == std::string(
"parsed_velocity_source") )
83 _parsed_velocity_source_x_index =
86 _parsed_velocity_source_y_index =
89 _parsed_velocity_source_z_index =
94 std::cerr <<
"Error: Invalue output_vars value for "+this->_physics_name << std::endl
95 <<
" Found " << name << std::endl
96 <<
" Acceptable values are: parsed_velocity_source" << std::endl;
107 (
bool compute_jacobian,
111 const std::vector<libMesh::Real> &JxW =
112 context.get_element_fe(this->_flow_vars.u())->get_JxW();
115 const std::vector<std::vector<libMesh::Real> >& u_phi =
116 context.get_element_fe(this->_flow_vars.u())->get_phi();
118 const std::vector<libMesh::Point>& u_qpoint =
119 context.get_element_fe(this->_flow_vars.u())->get_xyz();
122 const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
125 libMesh::DenseSubMatrix<libMesh::Number> &Kuu = context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.u());
126 libMesh::DenseSubMatrix<libMesh::Number> &Kuv = context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.v());
127 libMesh::DenseSubMatrix<libMesh::Number> &Kvu = context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.u());
128 libMesh::DenseSubMatrix<libMesh::Number> &Kvv = context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.v());
130 libMesh::DenseSubMatrix<libMesh::Number>* Kwu = NULL;
131 libMesh::DenseSubMatrix<libMesh::Number>* Kwv = NULL;
132 libMesh::DenseSubMatrix<libMesh::Number>* Kww = NULL;
133 libMesh::DenseSubMatrix<libMesh::Number>* Kuw = NULL;
134 libMesh::DenseSubMatrix<libMesh::Number>* Kvw = NULL;
136 libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(this->_flow_vars.u());
137 libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(this->_flow_vars.v());
138 libMesh::DenseSubVector<libMesh::Number>* Fw = NULL;
140 if( this->_flow_vars.dim() == 3 )
142 Kuw = &context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.w());
143 Kvw = &context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.w());
145 Kwu = &context.get_elem_jacobian(this->_flow_vars.w(), this->_flow_vars.u());
146 Kwv = &context.get_elem_jacobian(this->_flow_vars.w(), this->_flow_vars.v());
147 Kww = &context.get_elem_jacobian(this->_flow_vars.w(), this->_flow_vars.w());
148 Fw = &context.get_elem_residual(this->_flow_vars.w());
151 unsigned int n_qpoints = context.get_element_qrule().n_points();
153 for (
unsigned int qp=0; qp != n_qpoints; qp++)
155 libMesh::NumberVectorValue F;
156 libMesh::NumberTensorValue dFdU;
157 libMesh::NumberTensorValue* dFdU_ptr =
158 compute_jacobian ? &dFdU : NULL;
159 if (!this->compute_force(u_qpoint[qp], context.time, context, F, dFdU_ptr))
162 const libMesh::Real jac = JxW[qp];
164 for (
unsigned int i=0; i != n_u_dofs; i++)
166 const libMesh::Number jac_i = jac * u_phi[i][qp];
171 if( this->_flow_vars.dim() == 3 )
173 (*Fw)(i) += F(2)*jac_i;
176 if( compute_jacobian )
178 for (
unsigned int j=0; j != n_u_dofs; j++)
180 const libMesh::Number jac_ij = context.get_elem_solution_derivative() * jac_i * u_phi[j][qp];
181 Kuu(i,j) += jac_ij * dFdU(0,0);
182 Kuv(i,j) += jac_ij * dFdU(0,1);
183 Kvu(i,j) += jac_ij * dFdU(1,0);
184 Kvv(i,j) += jac_ij * dFdU(1,1);
186 if( this->_flow_vars.dim() == 3 )
188 (*Kuw)(i,j) += jac_ij * dFdU(0,2);
189 (*Kvw)(i,j) += jac_ij * dFdU(1,2);
191 (*Kwu)(i,j) += jac_ij * dFdU(2,0);
192 (*Kwv)(i,j) += jac_ij * dFdU(2,1);
193 (*Kww)(i,j) += jac_ij * dFdU(2,2);
204 const libMesh::Point& point,
205 libMesh::Real& value )
207 libMesh::DenseVector<libMesh::Number> output_vec(3);
209 if( quantity_index == this->_parsed_velocity_source_x_index )
211 (*this->velocity_source_function)(context, point, context.time, output_vec);
213 value = output_vec(0);
215 else if( quantity_index == this->_parsed_velocity_source_y_index )
217 (*this->velocity_source_function)(context, point, context.time, output_vec);
219 value = output_vec(1);
221 else if( quantity_index == this->_parsed_velocity_source_z_index )
223 (*this->velocity_source_function)(context, point, context.time, output_vec);
225 value = output_vec(2);
virtual void register_postprocessing_vars(const GetPot &input, PostProcessedQuantities< libMesh::Real > &postprocessing)
Register postprocessing variables for ParsedVelocitySource.
unsigned int register_quantity(std::string name)
Register quantity to be postprocessed.
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.
virtual void compute_postprocessed_quantity(unsigned int quantity_index, const AssemblyContext &context, const libMesh::Point &point, libMesh::Real &value)
INSTANTIATE_INC_NS_SUBCLASS(ParsedVelocitySource)