bool MAST::HeatConductionElementBase:: surface_convection_residual(bool request_jacobian, RealVectorX& f, RealMatrixX& jac, const unsigned int s, MAST::BoundaryConditionBase& p) { // prepare the side finite element std::auto_ptr<libMesh::FEBase> fe; std::auto_ptr<libMesh::QBase> qrule; _get_side_fe_and_qrule(get_elem_for_quadrature(), s, fe, qrule); // get the function from this boundary condition const MAST::FieldFunction<Real> &coeff = p.get<MAST::FieldFunction<Real> >("convection_coeff"), &T_amb = p.get<MAST::FieldFunction<Real> >("ambient_temperature"); const std::vector<Real> &JxW = fe->get_JxW(); const std::vector<libMesh::Point>& qpoint = fe->get_xyz(); const std::vector<std::vector<Real> >& phi = fe->get_phi(); const unsigned int n_phi = (unsigned int)phi.size(); RealVectorX phi_vec = RealVectorX::Zero(n_phi); RealMatrixX mat = RealMatrixX::Zero(n_phi, n_phi); Real temp, amb_temp, h_coeff; libMesh::Point pt; MAST::FEMOperatorMatrix Bmat; for (unsigned int qp=0; qp<qpoint.size(); qp++) { _local_elem->global_coordinates_location (qpoint[qp], pt); // now set the shape function values for ( unsigned int i_nd=0; i_nd<n_phi; i_nd++ ) phi_vec(i_nd) = phi[i_nd][qp]; // value of flux coeff(pt, _time, h_coeff); T_amb(pt, _time, amb_temp); temp = phi_vec.dot(_sol); // normal flux is given as: // qi_ni = h_coeff * (T - T_amb) // f += JxW[qp] * phi_vec * h_coeff * (temp - amb_temp); if (request_jacobian) { Bmat.reinit(1, phi_vec); Bmat.right_multiply_transpose(mat, Bmat); jac += JxW[qp] * mat * h_coeff; } } return request_jacobian; }
bool MAST::HeatConductionElementBase:: surface_radiation_residual(bool request_jacobian, RealVectorX& f, RealMatrixX& jac, MAST::BoundaryConditionBase& p) { // get the function from this boundary condition const MAST::FieldFunction<Real> &emissivity = p.get<MAST::FieldFunction<Real> >("emissivity"); const MAST::Parameter &T_amb = p.get<MAST::Parameter>("ambient_temperature"), &T_ref_zero = p.get<MAST::Parameter>("reference_zero_temperature"), &sb_const = p.get<MAST::Parameter>("stefan_bolzmann_constant"); const std::vector<Real> &JxW = _fe->get_JxW(); const std::vector<libMesh::Point>& qpoint = _fe->get_xyz(); const std::vector<std::vector<Real> >& phi = _fe->get_phi(); const unsigned int n_phi = (unsigned int)phi.size(); RealVectorX phi_vec = RealVectorX::Zero(n_phi); RealMatrixX mat = RealMatrixX::Zero(n_phi, n_phi); const Real sbc = sb_const(), amb_temp = T_amb(), zero_ref = T_ref_zero(); Real temp, emiss; libMesh::Point pt; MAST::FEMOperatorMatrix Bmat; for (unsigned int qp=0; qp<qpoint.size(); qp++) { _local_elem->global_coordinates_location (qpoint[qp], pt); // now set the shape function values for ( unsigned int i_nd=0; i_nd<n_phi; i_nd++ ) phi_vec(i_nd) = phi[i_nd][qp]; // value of flux emissivity(pt, _time, emiss); temp = phi_vec.dot(_sol); f += JxW[qp] * phi_vec * sbc * emiss * (pow(temp-zero_ref, 4.) - pow(amb_temp-zero_ref, 4.)); if (request_jacobian) { Bmat.reinit(1, phi_vec); Bmat.right_multiply_transpose(mat, Bmat); jac += JxW[qp] * mat * sbc * emiss * 4. * pow(temp-zero_ref, 3.); } } return request_jacobian; }
void MAST::HeatConductionElementBase:: _initialize_mass_fem_operator(const unsigned int qp, MAST::FEMOperatorMatrix& Bmat) { const std::vector<std::vector<Real> >& phi_fe = _fe->get_phi(); const unsigned int n_phi = (unsigned int)phi_fe.size(); RealVectorX phi = RealVectorX::Zero(n_phi); // shape function values // N for ( unsigned int i_nd=0; i_nd<n_phi; i_nd++ ) phi(i_nd) = phi_fe[i_nd][qp]; Bmat.reinit(1, phi); }