本文整理汇总了C++中AssemblyContext::get_elem_solution_rate方法的典型用法代码示例。如果您正苦于以下问题:C++ AssemblyContext::get_elem_solution_rate方法的具体用法?C++ AssemblyContext::get_elem_solution_rate怎么用?C++ AssemblyContext::get_elem_solution_rate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssemblyContext
的用法示例。
在下文中一共展示了AssemblyContext::get_elem_solution_rate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nonlocal_mass_residual
void ScalarODE::nonlocal_mass_residual(bool compute_jacobian,
AssemblyContext& context,
CachedValues& /* cache */ )
{
libMesh::DenseSubMatrix<libMesh::Number> &Kss =
context.get_elem_jacobian(_scalar_ode_var, _scalar_ode_var); // R_{s},{s}
libMesh::DenseSubVector<libMesh::Number> &Fs =
context.get_elem_residual(_scalar_ode_var); // R_{s}
const libMesh::Number mass_res =
(*mass_residual_function)(context, libMesh::Point(0),
context.get_time());
Fs(0) -= mass_res;
if (compute_jacobian)
{
// FIXME: we should replace this hacky FDM with a hook to the
// AD fparser stuff
libMesh::DenseSubVector<libMesh::Number> &Us =
const_cast<libMesh::DenseSubVector<libMesh::Number>&>
(context.get_elem_solution_rate(_scalar_ode_var)); // U_{s}
const libMesh::Number s = Us(0);
Us(0) = s + this->_epsilon;
libMesh::Number mass_residual_jacobian =
(*mass_residual_function)(context, libMesh::Point(0),
context.get_time());
Us(0) = s - this->_epsilon;
mass_residual_jacobian -=
(*mass_residual_function)(context, libMesh::Point(0),
context.get_time());
Us(0) = s;
mass_residual_jacobian /= (2*this->_epsilon);
Kss(0,0) -= mass_residual_jacobian *
context.get_elem_solution_rate_derivative();
}
return;
}
示例2: Us
void AveragedTurbine<Mu>::nonlocal_mass_residual( 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 libMesh::DenseSubVector<libMesh::Number> &Us =
context.get_elem_solution_rate(this->fan_speed_var());
const libMesh::Number& fan_speed = Us(0);
Fs(0) -= this->moment_of_inertia * fan_speed;
if (compute_jacobian)
{
Kss(0,0) -= this->moment_of_inertia * context.get_elem_solution_rate_derivative();
}
return;
}
示例3: u_gradphi
void ElasticCableRayleighDamping<StressStrainLaw>::damping_residual( bool compute_jacobian,
AssemblyContext& context,
CachedValues& /*cache*/)
{
// First, do the "mass" contribution
this->mass_residual_impl(compute_jacobian,
context,
&libMesh::FEMContext::interior_rate,
&libMesh::DiffContext::get_elem_solution_rate_derivative,
_mu_factor);
// Now do the stiffness contribution
const unsigned int n_u_dofs = context.get_dof_indices(this->_disp_vars.u()).size();
const std::vector<libMesh::Real> &JxW =
this->get_fe(context)->get_JxW();
// Residuals that we're populating
libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(this->_disp_vars.u());
libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(this->_disp_vars.v());
libMesh::DenseSubVector<libMesh::Number> &Fw = context.get_elem_residual(this->_disp_vars.w());
//Grab the Jacobian matrix as submatrices
//libMesh::DenseMatrix<libMesh::Number> &K = context.get_elem_jacobian();
libMesh::DenseSubMatrix<libMesh::Number> &Kuu = context.get_elem_jacobian(this->_disp_vars.u(),this->_disp_vars.u());
libMesh::DenseSubMatrix<libMesh::Number> &Kuv = context.get_elem_jacobian(this->_disp_vars.u(),this->_disp_vars.v());
libMesh::DenseSubMatrix<libMesh::Number> &Kuw = context.get_elem_jacobian(this->_disp_vars.u(),this->_disp_vars.w());
libMesh::DenseSubMatrix<libMesh::Number> &Kvu = context.get_elem_jacobian(this->_disp_vars.v(),this->_disp_vars.u());
libMesh::DenseSubMatrix<libMesh::Number> &Kvv = context.get_elem_jacobian(this->_disp_vars.v(),this->_disp_vars.v());
libMesh::DenseSubMatrix<libMesh::Number> &Kvw = context.get_elem_jacobian(this->_disp_vars.v(),this->_disp_vars.w());
libMesh::DenseSubMatrix<libMesh::Number> &Kwu = context.get_elem_jacobian(this->_disp_vars.w(),this->_disp_vars.u());
libMesh::DenseSubMatrix<libMesh::Number> &Kwv = context.get_elem_jacobian(this->_disp_vars.w(),this->_disp_vars.v());
libMesh::DenseSubMatrix<libMesh::Number> &Kww = context.get_elem_jacobian(this->_disp_vars.w(),this->_disp_vars.w());
unsigned int n_qpoints = context.get_element_qrule().n_points();
// All shape function gradients are w.r.t. master element coordinates
const std::vector<std::vector<libMesh::Real> >& dphi_dxi = this->get_fe(context)->get_dphidxi();
const libMesh::DenseSubVector<libMesh::Number>& u_coeffs = context.get_elem_solution( this->_disp_vars.u() );
const libMesh::DenseSubVector<libMesh::Number>& v_coeffs = context.get_elem_solution( this->_disp_vars.v() );
const libMesh::DenseSubVector<libMesh::Number>& w_coeffs = context.get_elem_solution( this->_disp_vars.w() );
const libMesh::DenseSubVector<libMesh::Number>& dudt_coeffs = context.get_elem_solution_rate( this->_disp_vars.u() );
const libMesh::DenseSubVector<libMesh::Number>& dvdt_coeffs = context.get_elem_solution_rate( this->_disp_vars.v() );
const libMesh::DenseSubVector<libMesh::Number>& dwdt_coeffs = context.get_elem_solution_rate( this->_disp_vars.w() );
// Need these to build up the covariant and contravariant metric tensors
const std::vector<libMesh::RealGradient>& dxdxi = this->get_fe(context)->get_dxyzdxi();
const unsigned int dim = 1; // The cable dimension is always 1 for this physics
for (unsigned int qp=0; qp != n_qpoints; qp++)
{
// Gradients are w.r.t. master element coordinates
libMesh::Gradient grad_u, grad_v, grad_w;
libMesh::Gradient dgradu_dt, dgradv_dt, dgradw_dt;
for( unsigned int d = 0; d < n_u_dofs; d++ )
{
libMesh::RealGradient u_gradphi( dphi_dxi[d][qp] );
grad_u += u_coeffs(d)*u_gradphi;
grad_v += v_coeffs(d)*u_gradphi;
grad_w += w_coeffs(d)*u_gradphi;
dgradu_dt += dudt_coeffs(d)*u_gradphi;
dgradv_dt += dvdt_coeffs(d)*u_gradphi;
dgradw_dt += dwdt_coeffs(d)*u_gradphi;
}
libMesh::RealGradient grad_x( dxdxi[qp](0) );
libMesh::RealGradient grad_y( dxdxi[qp](1) );
libMesh::RealGradient grad_z( dxdxi[qp](2) );
libMesh::TensorValue<libMesh::Real> a_cov, a_contra, A_cov, A_contra;
libMesh::Real lambda_sq = 0;
this->compute_metric_tensors( qp, *(this->get_fe(context)), context,
grad_u, grad_v, grad_w,
a_cov, a_contra, A_cov, A_contra,
lambda_sq );
// Compute stress tensor
libMesh::TensorValue<libMesh::Real> tau;
ElasticityTensor C;
this->_stress_strain_law.compute_stress_and_elasticity(dim,a_contra,a_cov,A_contra,A_cov,tau,C);
libMesh::Real jac = JxW[qp];
for (unsigned int i=0; i != n_u_dofs; i++)
{
libMesh::RealGradient u_gradphi( dphi_dxi[i][qp] );
libMesh::Real u_diag_factor = _lambda_factor*this->_A*jac*tau(0,0)*dgradu_dt(0)*u_gradphi(0);
libMesh::Real v_diag_factor = _lambda_factor*this->_A*jac*tau(0,0)*dgradv_dt(0)*u_gradphi(0);
libMesh::Real w_diag_factor = _lambda_factor*this->_A*jac*tau(0,0)*dgradw_dt(0)*u_gradphi(0);
const libMesh::Real C1 = _lambda_factor*this->_A*jac*C(0,0,0,0)*u_gradphi(0);
const libMesh::Real gamma_u = (grad_x(0)+grad_u(0));
//.........这里部分代码省略.........