void PracticeCDRinv::init_context( AssemblyContext& context){ context.get_element_fe(_c_var)->get_JxW(); context.get_element_fe(_c_var)->get_phi(); context.get_element_fe(_c_var)->get_dphi(); context.get_element_fe(_c_var)->get_xyz(); context.get_side_fe(_c_var)->get_JxW(); context.get_side_fe(_c_var)->get_phi(); context.get_side_fe(_c_var)->get_dphi(); context.get_side_fe(_c_var)->get_xyz(); return; }
void BoundaryConditions::apply_neumann_normal( AssemblyContext& context, const VariableIndex var, const libMesh::Real sign, const FEShape& value ) const { libMesh::FEGenericBase<FEShape>* side_fe = NULL; context.get_side_fe( var, side_fe ); // The number of local degrees of freedom in each variable. const unsigned int n_var_dofs = context.get_dof_indices(var).size(); // Element Jacobian * quadrature weight for side integration. const std::vector<libMesh::Real> &JxW_side = side_fe->get_JxW(); // The var shape functions at side quadrature points. const std::vector<std::vector<FEShape> >& var_phi_side = side_fe->get_phi(); libMesh::DenseSubVector<libMesh::Number> &F_var = context.get_elem_residual(var); // residual unsigned int n_qpoints = context.get_side_qrule().n_points(); for (unsigned int qp=0; qp != n_qpoints; qp++) { for (unsigned int i=0; i != n_var_dofs; i++) { F_var(i) += sign*value*var_phi_side[i][qp]*JxW_side[qp]; } } return; }
void HeatConduction<K>::init_context( AssemblyContext& context ) { // We should prerequest all the data // we will need to build the linear system // or evaluate a quantity of interest. context.get_element_fe(_temp_vars.T_var())->get_JxW(); context.get_element_fe(_temp_vars.T_var())->get_phi(); context.get_element_fe(_temp_vars.T_var())->get_dphi(); context.get_element_fe(_temp_vars.T_var())->get_xyz(); context.get_side_fe(_temp_vars.T_var())->get_JxW(); context.get_side_fe(_temp_vars.T_var())->get_phi(); context.get_side_fe(_temp_vars.T_var())->get_dphi(); context.get_side_fe(_temp_vars.T_var())->get_xyz(); return; }
void AxisymmetricHeatTransfer<Conductivity>::init_context( AssemblyContext& context ) { // We should prerequest all the data // we will need to build the linear system // or evaluate a quantity of interest. context.get_element_fe(_T_var)->get_JxW(); context.get_element_fe(_T_var)->get_phi(); context.get_element_fe(_T_var)->get_dphi(); context.get_element_fe(_T_var)->get_xyz(); context.get_side_fe(_T_var)->get_JxW(); context.get_side_fe(_T_var)->get_phi(); context.get_side_fe(_T_var)->get_dphi(); context.get_side_fe(_T_var)->get_xyz(); // _u_var is registered so can we assume things related to _u_var // are available in FEMContext return; }
void IncompressibleNavierStokesBase<Mu>::init_context( AssemblyContext& context ) { // We should prerequest all the data // we will need to build the linear system // or evaluate a quantity of interest. context.get_element_fe(_flow_vars.u_var())->get_JxW(); context.get_element_fe(_flow_vars.u_var())->get_phi(); context.get_element_fe(_flow_vars.u_var())->get_dphi(); context.get_element_fe(_flow_vars.u_var())->get_xyz(); context.get_element_fe(_flow_vars.p_var())->get_phi(); context.get_element_fe(_flow_vars.p_var())->get_xyz(); context.get_side_fe(_flow_vars.u_var())->get_JxW(); context.get_side_fe(_flow_vars.u_var())->get_phi(); context.get_side_fe(_flow_vars.u_var())->get_dphi(); context.get_side_fe(_flow_vars.u_var())->get_xyz(); return; }
void LowMachNavierStokes<Mu,SH,TC>::init_context( AssemblyContext& context ) { // First call base class LowMachNavierStokesBase<Mu,SH,TC>::init_context(context); // We also need the side shape functions, etc. context.get_side_fe(this->_u_var)->get_JxW(); context.get_side_fe(this->_u_var)->get_phi(); context.get_side_fe(this->_u_var)->get_dphi(); context.get_side_fe(this->_u_var)->get_xyz(); context.get_side_fe(this->_T_var)->get_JxW(); context.get_side_fe(this->_T_var)->get_phi(); context.get_side_fe(this->_T_var)->get_dphi(); context.get_side_fe(this->_T_var)->get_xyz(); return; }
bool GasRecombinationCatalyticWall<Chemistry>::eval_flux( bool compute_jacobian, AssemblyContext& context, libMesh::Real sign, bool is_axisymmetric ) { libMesh::FEGenericBase<libMesh::Real>* side_fe = NULL; context.get_side_fe( _reactant_var_idx, side_fe ); // The number of local degrees of freedom in each variable. const unsigned int n_var_dofs = context.get_dof_indices(_reactant_var_idx).size(); libmesh_assert_equal_to( n_var_dofs, context.get_dof_indices(_product_var_idx).size() ); // Element Jacobian * quadrature weight for side integration. const std::vector<libMesh::Real> &JxW_side = side_fe->get_JxW(); // The var shape functions at side quadrature points. const std::vector<std::vector<libMesh::Real> >& var_phi_side = side_fe->get_phi(); // Physical location of the quadrature points const std::vector<libMesh::Point>& var_qpoint = side_fe->get_xyz(); // reactant residual libMesh::DenseSubVector<libMesh::Number> &F_r_var = context.get_elem_residual(_reactant_var_idx); // product residual libMesh::DenseSubVector<libMesh::Number> &F_p_var = context.get_elem_residual(_product_var_idx); unsigned int n_qpoints = context.get_side_qrule().n_points(); for (unsigned int qp=0; qp != n_qpoints; qp++) { libMesh::Real jac = JxW_side[qp]; if(is_axisymmetric) { const libMesh::Number r = var_qpoint[qp](0); jac *= r; } std::vector<libMesh::Real> mass_fractions(this->_chem_ptr->n_species()); for( unsigned int s = 0; s < this->_chem_ptr->n_species(); s++ ) mass_fractions[s] = context.side_value(this->_species_vars[s], qp); libMesh::Real Y_r = mass_fractions[this->_reactant_species_idx]; libMesh::Real T = context.side_value(this->_T_var, qp); libMesh::Real R_mix = this->_chem_ptr->R_mix(mass_fractions); libMesh::Real rho = this->rho( T, this->_p0, R_mix ); const libMesh::Real r_value = this->compute_reactant_mass_flux(rho, Y_r, T); const libMesh::Real p_value = -r_value; for (unsigned int i=0; i != n_var_dofs; i++) { F_r_var(i) += sign*r_value*var_phi_side[i][qp]*jac; F_p_var(i) += sign*p_value*var_phi_side[i][qp]*jac; if( compute_jacobian ) libmesh_not_implemented(); } } // We're not computing the Jacobian yet return false; }
void GasRecombinationCatalyticWall<Chemistry>::apply_fluxes( AssemblyContext& context, const CachedValues& cache, const bool request_jacobian ) { libmesh_do_once(libmesh_deprecated()); libMesh::FEGenericBase<libMesh::Real>* side_fe = NULL; context.get_side_fe( _reactant_var_idx, side_fe ); // The number of local degrees of freedom in each variable. const unsigned int n_var_dofs = context.get_dof_indices(_reactant_var_idx).size(); libmesh_assert_equal_to( n_var_dofs, context.get_dof_indices(_product_var_idx).size() ); // Element Jacobian * quadrature weight for side integration. const std::vector<libMesh::Real> &JxW_side = side_fe->get_JxW(); // The var shape functions at side quadrature points. const std::vector<std::vector<libMesh::Real> >& var_phi_side = side_fe->get_phi(); // Physical location of the quadrature points const std::vector<libMesh::Point>& var_qpoint = side_fe->get_xyz(); // reactant residual libMesh::DenseSubVector<libMesh::Number> &F_r_var = context.get_elem_residual(_reactant_var_idx); // product residual libMesh::DenseSubVector<libMesh::Number> &F_p_var = context.get_elem_residual(_product_var_idx); unsigned int n_qpoints = context.get_side_qrule().n_points(); for (unsigned int qp=0; qp != n_qpoints; qp++) { libMesh::Real jac = JxW_side[qp]; if(Physics::is_axisymmetric()) { const libMesh::Number r = var_qpoint[qp](0); jac *= r; } const libMesh::Real rho = cache.get_cached_values(Cache::MIXTURE_DENSITY)[qp]; const libMesh::Real Y_r = cache.get_cached_vector_values(Cache::MASS_FRACTIONS)[qp][this->_reactant_species_idx]; const libMesh::Real T = cache.get_cached_values(Cache::TEMPERATURE)[qp]; const libMesh::Real r_value = this->compute_reactant_mass_flux(rho, Y_r, T); const libMesh::Real p_value = -r_value; for (unsigned int i=0; i != n_var_dofs; i++) { F_r_var(i) += r_value*var_phi_side[i][qp]*jac; F_p_var(i) += p_value*var_phi_side[i][qp]*jac; if( request_jacobian ) { libmesh_not_implemented(); } } } }
void BoundaryConditions::apply_neumann_axisymmetric( AssemblyContext& context, const CachedValues& cache, const bool request_jacobian, const VariableIndex var, const libMesh::Real sign, SharedPtr<NeumannFuncObj> neumann_func ) const { libMesh::FEGenericBase<libMesh::Real>* side_fe = NULL; context.get_side_fe( var, side_fe ); // The number of local degrees of freedom const unsigned int n_var_dofs = context.get_dof_indices(var).size(); // Element Jacobian * quadrature weight for side integration. const std::vector<libMesh::Real> &JxW_side = side_fe->get_JxW(); // The var shape functions at side quadrature points. const std::vector<std::vector<libMesh::Real> >& var_phi_side = side_fe->get_phi(); // Physical location of the quadrature points const std::vector<libMesh::Point>& var_qpoint = side_fe->get_xyz(); const std::vector<libMesh::Point> &normals = side_fe->get_normals(); libMesh::DenseSubVector<libMesh::Number> &F_var = context.get_elem_residual(var); // residual libMesh::DenseSubMatrix<libMesh::Number> &K_var = context.get_elem_jacobian(var,var); // jacobian unsigned int n_qpoints = context.get_side_qrule().n_points(); for (unsigned int qp=0; qp != n_qpoints; qp++) { const libMesh::Point bc_value = neumann_func->value( context, cache, qp ); libMesh::Point jac_value; if (request_jacobian) { jac_value = neumann_func->derivative( context, cache, qp ); } const libMesh::Number r = var_qpoint[qp](0); for (unsigned int i=0; i != n_var_dofs; i++) { F_var(i) += sign*r*JxW_side[qp]*bc_value*normals[qp]*var_phi_side[i][qp]; if (request_jacobian) { for (unsigned int j=0; j != n_var_dofs; j++) { K_var(i,j) += sign*r*JxW_side[qp]*jac_value*normals[qp]* var_phi_side[i][qp]*var_phi_side[j][qp]; } } } } // End quadrature loop // Now must take care of the case that the boundary condition depends on variables // other than var. std::vector<VariableIndex> other_jac_vars = neumann_func->get_other_jac_vars(); if( (other_jac_vars.size() > 0) && request_jacobian ) { for( std::vector<VariableIndex>::const_iterator var2 = other_jac_vars.begin(); var2 != other_jac_vars.end(); var2++ ) { libMesh::FEGenericBase<libMesh::Real>* side_fe2 = NULL; context.get_side_fe( *var2, side_fe2 ); libMesh::DenseSubMatrix<libMesh::Number> &K_var2 = context.get_elem_jacobian(var,*var2); // jacobian const unsigned int n_var2_dofs = context.get_dof_indices(*var2).size(); const std::vector<std::vector<libMesh::Real> >& var2_phi_side = side_fe2->get_phi(); for (unsigned int qp=0; qp != n_qpoints; qp++) { const libMesh::Number r = var_qpoint[qp](0); const libMesh::Point jac_value = neumann_func->derivative( context, cache, qp, *var2 ); for (unsigned int i=0; i != n_var_dofs; i++) { for (unsigned int j=0; j != n_var2_dofs; j++) { K_var2(i,j) += sign*r*JxW_side[qp]*jac_value*normals[qp]* var_phi_side[i][qp]*var2_phi_side[j][qp]; } } } } // End loop over auxillary Jacobian variables } return; }