void GRINS::BoundaryConditions::apply_neumann_axisymmetric( libMesh::FEMContext& context, const CachedValues& cache, const bool request_jacobian, const GRINS::VariableIndex var, const libMesh::Real sign, std::tr1::shared_ptr<GRINS::NeumannFuncObj> neumann_func ) const { // The number of local degrees of freedom const unsigned int n_var_dofs = context.dof_indices_var[var].size(); // Element Jacobian * quadrature weight for side integration. const std::vector<libMesh::Real> &JxW_side = context.side_fe_var[var]->get_JxW(); // The var shape functions at side quadrature points. const std::vector<std::vector<libMesh::Real> >& var_phi_side = context.side_fe_var[var]->get_phi(); // Physical location of the quadrature points const std::vector<libMesh::Point>& var_qpoint = context.side_fe_var[var]->get_xyz(); const std::vector<libMesh::Point> &normals = context.side_fe_var[var]->get_normals(); libMesh::DenseSubVector<libMesh::Number> &F_var = *context.elem_subresiduals[var]; // residual libMesh::DenseSubMatrix<libMesh::Number> &K_var = *context.elem_subjacobians[var][var]; // jacobian unsigned int n_qpoints = context.side_qrule->n_points(); for (unsigned int qp=0; qp != n_qpoints; qp++) { const libMesh::Point bc_value = neumann_func->value( context, cache, qp ); const libMesh::Point 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::DenseSubMatrix<libMesh::Number> &K_var2 = *context.elem_subjacobians[var][*var2]; // jacobian const unsigned int n_var2_dofs = context.dof_indices_var[*var2].size(); const std::vector<std::vector<libMesh::Real> >& var2_phi_side = context.side_fe_var[*var2]->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; }
void BoundaryConditions::apply_neumann_normal_axisymmetric( AssemblyContext& context, const CachedValues& cache, const bool request_jacobian, const VariableIndex var, const libMesh::Real sign, const 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(); 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::Real bc_value = neumann_func->normal_value( context, cache, qp ); libMesh::Real jac_value = 0.0; if(request_jacobian) { jac_value = neumann_func->normal_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*bc_value*var_phi_side[i][qp]*JxW_side[qp]; if (request_jacobian) { for (unsigned int j=0; j != n_var_dofs; j++) { K_var(i,j) += sign*r*jac_value* var_phi_side[i][qp]*var_phi_side[j][qp]*JxW_side[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::Real jac_value = neumann_func->normal_derivative( context, cache, qp, *var2 ); const libMesh::Number r = var_qpoint[qp](0); 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*jac_value* var_phi_side[i][qp]*var2_phi_side[j][qp]*JxW_side[qp]; } } } } // End loop over auxillary Jacobian variables } return; }