本文整理汇总了C++中AssemblyContext::get_system方法的典型用法代码示例。如果您正苦于以下问题:C++ AssemblyContext::get_system方法的具体用法?C++ AssemblyContext::get_system怎么用?C++ AssemblyContext::get_system使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssemblyContext
的用法示例。
在下文中一共展示了AssemblyContext::get_system方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Fs
void AveragedTurbine<Mu>::nonlocal_time_derivative(bool compute_jacobian,
AssemblyContext& context,
CachedValues& /* cache */ )
{
libMesh::DenseSubMatrix<libMesh::Number> &Kss =
context.get_elem_jacobian(this->fan_speed_var(), this->fan_speed_var()); // R_{s},{s}
libMesh::DenseSubVector<libMesh::Number> &Fs =
context.get_elem_residual(this->fan_speed_var()); // R_{s}
const std::vector<libMesh::dof_id_type>& dof_indices =
context.get_dof_indices(this->fan_speed_var());
const libMesh::Number fan_speed =
context.get_system().current_solution(dof_indices[0]);
const libMesh::Number output_torque =
this->torque_function(libMesh::Point(0), fan_speed);
Fs(0) += output_torque;
if (compute_jacobian)
{
// FIXME: we should replace this FEM with a hook to the AD fparser stuff
const libMesh::Number epsilon = 1e-6;
const libMesh::Number output_torque_deriv =
(this->torque_function(libMesh::Point(0), fan_speed+epsilon) -
this->torque_function(libMesh::Point(0), fan_speed-epsilon)) / (2*epsilon);
Kss(0,0) += output_torque_deriv * context.get_elem_solution_derivative();
}
return;
}
示例2: rhocpU
void HeatTransferStabilizationHelper::compute_res_energy_steady_and_derivs
( AssemblyContext& context,
unsigned int qp,
const libMesh::Real rho,
const libMesh::Real Cp,
const libMesh::Real k,
libMesh::Real &res,
libMesh::Real &d_res_dT,
libMesh::Gradient &d_res_dgradT,
libMesh::Tensor &d_res_dhessT,
libMesh::Gradient &d_res_dU
) const
{
libMesh::Gradient grad_T = context.fixed_interior_gradient(this->_temp_vars.T_var(), qp);
libMesh::Tensor hess_T = context.fixed_interior_hessian(this->_temp_vars.T_var(), qp);
libMesh::RealGradient rhocpU( rho*Cp*context.fixed_interior_value(this->_flow_vars.u_var(), qp),
rho*Cp*context.fixed_interior_value(this->_flow_vars.v_var(), qp) );
if(context.get_system().get_mesh().mesh_dimension() == 3)
rhocpU(2) = rho*Cp*context.fixed_interior_value(this->_flow_vars.w_var(), qp);
res = rhocpU*grad_T - k*(hess_T(0,0) + hess_T(1,1) + hess_T(2,2));
d_res_dT = 0;
d_res_dgradT = rhocpU;
d_res_dhessT = 0;
d_res_dhessT(0,0) = -k;
d_res_dhessT(1,1) = -k;
d_res_dhessT(2,2) = -k;
d_res_dU = rho * Cp * grad_T;
}
示例3: compute_res_energy_steady
libMesh::Real HeatTransferStabilizationHelper::compute_res_energy_steady( AssemblyContext& context,
unsigned int qp,
const libMesh::Real rho,
const libMesh::Real Cp,
const libMesh::Real k ) const
{
libMesh::Gradient grad_T = context.fixed_interior_gradient(this->_temp_vars.T_var(), qp);
libMesh::Tensor hess_T = context.fixed_interior_hessian(this->_temp_vars.T_var(), qp);
libMesh::RealGradient rhocpU( rho*Cp*context.fixed_interior_value(this->_flow_vars.u_var(), qp),
rho*Cp*context.fixed_interior_value(this->_flow_vars.v_var(), qp) );
if(context.get_system().get_mesh().mesh_dimension() == 3)
rhocpU(2) = rho*Cp*context.fixed_interior_value(this->_flow_vars.w_var(), qp);
return rhocpU*grad_T - k*(hess_T(0,0) + hess_T(1,1) + hess_T(2,2));
}
示例4: compute_res_spalart_steady
libMesh::Real SpalartAllmarasStabilizationHelper::compute_res_spalart_steady( AssemblyContext& context,
unsigned int qp, const libMesh::Real rho, const libMesh::Real mu, const libMesh::Real distance_qp ) const
{
// The flow velocity
libMesh::Number u,v;
u = context.interior_value(this->_flow_vars.u_var(), qp);
v = context.interior_value(this->_flow_vars.v_var(), qp);
libMesh::NumberVectorValue U(u,v);
if ( context.get_system().get_mesh().mesh_dimension() == 3 )
U(2) = context.interior_value(this->_flow_vars.w_var(), qp);
libMesh::RealGradient grad_u = context.fixed_interior_gradient(this->_flow_vars.u_var(), qp);
libMesh::RealGradient grad_v = context.fixed_interior_gradient(this->_flow_vars.v_var(), qp);
libMesh::Number nu_value = context.interior_value(this->_turbulence_vars.nu_var(), qp);
libMesh::RealGradient grad_nu = context.fixed_interior_gradient(this->_turbulence_vars.nu_var(), qp);
libMesh::RealTensor hess_nu = context.fixed_interior_hessian(this->_turbulence_vars.nu_var(), qp);
// The convection term
libMesh::Number rhoUdotGradnu = rho*(U*grad_nu);
// The diffusion term
libMesh::Number inv_sigmadivnuplusnuphysicalGradnu = (1./this->_sa_params.get_sigma())*(grad_nu*grad_nu + ((nu_value + mu)*(hess_nu(0,0) + hess_nu(1,1) + (this->_dim == 3)?hess_nu(2,2):0)) + this->_sa_params.get_cb2()*grad_nu*grad_nu);
// The source term
libMesh::Real vorticity_value_qp = this->_spalart_allmaras_helper.vorticity(context, qp);
libMesh::Real S_tilde = this->_sa_params.source_fn(nu_value, mu, distance_qp, vorticity_value_qp);
libMesh::Real source_term = this->_sa_params.get_cb1()*S_tilde*nu_value;
// The destruction term
libMesh::Real fw = this->_sa_params.destruction_fn(nu_value, distance_qp, S_tilde);
libMesh::Real destruction_term = this->_sa_params.get_cw1()*fw*pow(nu_value/distance_qp, 2.);
return rhoUdotGradnu + source_term + inv_sigmadivnuplusnuphysicalGradnu - destruction_term;
}
示例5: element_time_derivative
//.........这里部分代码省略.........
for (unsigned int qp=0; qp != n_qpoints; qp++){
libMesh::Number
c = context.interior_value(_c_var, qp),
zc = context.interior_value(_zc_var, qp),
fc = context.interior_value(_fc_var, qp);
libMesh::Gradient
grad_c = context.interior_gradient(_c_var, qp),
grad_zc = context.interior_gradient(_zc_var, qp),
grad_fc = context.interior_gradient(_fc_var, qp);
//location of quadrature point
const libMesh::Real ptx = q_points[qp](0);
const libMesh::Real pty = q_points[qp](1);
int xind, yind;
libMesh::Real xdist = 1.e10; libMesh::Real ydist = 1.e10;
for(int ii=0; ii<x_pts.size(); ii++){
libMesh::Real tmp = std::abs(ptx - x_pts[ii]);
if(xdist > tmp){
xdist = tmp;
xind = ii;
}
else
break;
}
for(int jj=0; jj<y_pts[xind].size(); jj++){
libMesh::Real tmp = std::abs(pty - y_pts[xind][jj]);
if(ydist > tmp){
ydist = tmp;
yind = jj;
}
else
break;
}
libMesh::Real u = vel_field[xind][yind](0);
libMesh::Real v = vel_field[xind][yind](1);
libMesh::NumberVectorValue U (u, v);
// First, an i-loop over the degrees of freedom.
for (unsigned int i=0; i != n_c_dofs; i++){
Rc(i) += JxW[qp]*(-_k*grad_zc*dphi[i][qp] + U*grad_zc*phi[i][qp] + 2*_R*zc*c*phi[i][qp]);
Rzc(i) += JxW[qp]*(-_k*grad_c*dphi[i][qp] - U*grad_c*phi[i][qp] + _R*c*c*phi[i][qp] + fc*phi[i][qp]);
Rfc(i) += JxW[qp]*(_beta*grad_fc*dphi[i][qp] + zc*phi[i][qp]);
if (compute_jacobian){
for (unsigned int j=0; j != n_c_dofs; j++){
J_c_zc(i,j) += JxW[qp]*(-_k*dphi[j][qp]*dphi[i][qp] + U*dphi[j][qp]*phi[i][qp]
+ 2*_R*phi[j][qp]*c*phi[i][qp]);
J_c_c(i,j) += JxW[qp]*(2*_R*zc*phi[j][qp]*phi[i][qp]);
J_zc_c(i,j) += JxW[qp]*(-_k*dphi[j][qp]*dphi[i][qp] - U*dphi[j][qp]*phi[i][qp]
+ 2*_R*c*phi[j][qp]*phi[i][qp]);
J_zc_fc(i,j) += JxW[qp]*(phi[j][qp]*phi[i][qp]);
J_fc_zc(i,j) += JxW[qp]*(phi[j][qp]*phi[i][qp]);
J_fc_fc(i,j) += JxW[qp]*(_beta*dphi[j][qp]*dphi[i][qp]);
} // end of the inner dof (j) loop
} // end - if (compute_jacobian && context.get_elem_solution_derivative())
} // end of the outer dof (i) loop
} // end of the quadrature point (qp) loop
for(unsigned int dnum=0; dnum<datavals.size(); dnum++){
libMesh::Point data_point = datapts[dnum];
if(context.get_elem().contains_point(data_point)){
libMesh::Number cpred = context.point_value(_c_var, data_point);
libMesh::Number cstar = datavals[dnum];
unsigned int dim = context.get_system().get_mesh().mesh_dimension();
libMesh::FEType fe_type = context.get_element_fe(_c_var)->get_fe_type();
//go between physical and reference element
libMesh::Point c_master = libMesh::FEInterface::inverse_map(dim, fe_type, &context.get_elem(), data_point);
std::vector<libMesh::Real> point_phi(n_c_dofs);
for (unsigned int i=0; i != n_c_dofs; i++){
//get value of basis function at mapped point in reference (master) element
point_phi[i] = libMesh::FEInterface::shape(dim, fe_type, &context.get_elem(), i, c_master);
}
for (unsigned int i=0; i != n_c_dofs; i++){
Rc(i) += (cpred - cstar)*point_phi[i];
if (compute_jacobian){
for (unsigned int j=0; j != n_c_dofs; j++)
J_c_c(i,j) += point_phi[j]*point_phi[i] ;
}
}
}
}
return;
}