本文整理汇总了C++中AssemblyContext::get_time方法的典型用法代码示例。如果您正苦于以下问题:C++ AssemblyContext::get_time方法的具体用法?C++ AssemblyContext::get_time怎么用?C++ AssemblyContext::get_time使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssemblyContext
的用法示例。
在下文中一共展示了AssemblyContext::get_time方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: element_qoi_derivative
void ParsedInteriorQoI::element_qoi_derivative( AssemblyContext& context,
const unsigned int qoi_index )
{
libMesh::FEBase* element_fe;
context.get_element_fe<libMesh::Real>(0, element_fe);
const std::vector<libMesh::Real> &JxW = element_fe->get_JxW();
const std::vector<libMesh::Point>& x_qp = element_fe->get_xyz();
// Local DOF count and quadrature point count
const unsigned int n_u_dofs = context.get_dof_indices().size();
unsigned int n_qpoints = context.get_element_qrule().n_points();
// Local solution vector - non-const version for finite
// differenting purposes
libMesh::DenseVector<libMesh::Number>& elem_solution =
const_cast<libMesh::DenseVector<libMesh::Number>&>
(context.get_elem_solution());
/*! \todo Need to generalize this to the multiple QoI case */
libMesh::DenseVector<libMesh::Number> &Qu =
context.get_qoi_derivatives()[qoi_index];
for( unsigned int qp = 0; qp != n_qpoints; qp++ )
{
// Central finite differencing to approximate derivatives.
// FIXME - we should hook the FParserAD stuff into
// ParsedFEMFunction
for( unsigned int i = 0; i != n_u_dofs; ++i )
{
libMesh::Number ¤t_solution = elem_solution(i);
const libMesh::Number original_solution = current_solution;
current_solution = original_solution + libMesh::TOLERANCE;
const libMesh::Number plus_val =
(*qoi_functional)(context, x_qp[qp], context.get_time());
current_solution = original_solution - libMesh::TOLERANCE;
const libMesh::Number minus_val =
(*qoi_functional)(context, x_qp[qp], context.get_time());
Qu(i) += (plus_val - minus_val) *
(0.5 / libMesh::TOLERANCE) * JxW[qp];
// Don't forget to restore the correct solution...
current_solution = original_solution;
}
}
}
示例2: nonlocal_constraint
void ScalarODE::nonlocal_constraint(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 constraint =
(*constraint_function)(context, libMesh::Point(0),
context.get_time());
Fs(0) += constraint;
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(_scalar_ode_var)); // U_{s}
const libMesh::Number s = Us(0);
Us(0) = s + this->_epsilon;
libMesh::Number constraint_jacobian =
(*constraint_function)(context, libMesh::Point(0),
context.get_time());
Us(0) = s - this->_epsilon;
constraint_jacobian -=
(*constraint_function)(context, libMesh::Point(0),
context.get_time());
Us(0) = s;
constraint_jacobian /= (2*this->_epsilon);
Kss(0,0) += constraint_jacobian *
context.get_elem_solution_derivative();
}
return;
}
示例3: element_qoi
void ParsedInteriorQoI::element_qoi( AssemblyContext& context,
const unsigned int qoi_index )
{
libMesh::FEBase* element_fe;
context.get_element_fe<libMesh::Real>(0, element_fe);
const std::vector<libMesh::Real> &JxW = element_fe->get_JxW();
const std::vector<libMesh::Point>& x_qp = element_fe->get_xyz();
unsigned int n_qpoints = context.get_element_qrule().n_points();
/*! \todo Need to generalize this to the multiple QoI case */
libMesh::Number& qoi = context.get_qois()[qoi_index];
for( unsigned int qp = 0; qp != n_qpoints; qp++ )
{
const libMesh::Number func_val =
(*qoi_functional)(context, x_qp[qp], context.get_time());
qoi += func_val * JxW[qp];
}
}