https://mooseframework.inl.gov
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MFEMQuadratureFunctionCoefficientBase Class Reference

Shared lazy-update state for quadrature function coefficients. More...

#include <MFEMQuadratureFunctionCoefficientBase.h>

Inheritance diagram for MFEMQuadratureFunctionCoefficientBase:
[legend]

Public Member Functions

 CreateMooseEnumClass (UpdatePolicy, NONE, TIME, NONLINEAR)
 Policy controlling when the stored values are re-projected from the source coefficient. More...
 
 MFEMQuadratureFunctionCoefficientBase (UpdatePolicy update_policy, const std::string &name)
 
virtual ~MFEMQuadratureFunctionCoefficientBase ()=default
 
void MarkSolutionChanged ()
 Mark the stored values as stale following a change of solution variables, forcing the source to be re-projected on next use. More...
 

Protected Member Functions

void MarkTimeChanged ()
 Mark the stored values as stale following a change of time. More...
 
void CheckIntegrationRule (const mfem::QuadratureFunction &qf, mfem::ElementTransformation &T, const mfem::IntegrationPoint &ip) const
 Verify that the integration point ip supplied by a consuming integrator belongs to the same quadrature rule the values in qf are stored on. More...
 

Protected Attributes

const UpdatePolicy _update_policy
 When the stored values are re-projected from the source coefficient. More...
 
const std::string _name
 Name of the owning MOOSE object, used in error messages. More...
 
bool _dirty
 Whether the stored values are stale and must be re-projected before use. More...
 

Detailed Description

Shared lazy-update state for quadrature function coefficients.

Holds the update policy and a dirty flag marking whether the stored quadrature point values are stale and must be re-projected from the source coefficient before use. Provides a common polymorphic type so that scalar and vector quadrature function coefficients can be invalidated uniformly.

Definition at line 30 of file MFEMQuadratureFunctionCoefficientBase.h.

Constructor & Destructor Documentation

◆ MFEMQuadratureFunctionCoefficientBase()

MFEMQuadratureFunctionCoefficientBase::MFEMQuadratureFunctionCoefficientBase ( UpdatePolicy  update_policy,
const std::string &  name 
)
inline

Definition at line 42 of file MFEMQuadratureFunctionCoefficientBase.h.

43  : _update_policy(update_policy), _name(name), _dirty(true)
44  {
45  }
bool _dirty
Whether the stored values are stale and must be re-projected before use.
const UpdatePolicy _update_policy
When the stored values are re-projected from the source coefficient.
const std::string _name
Name of the owning MOOSE object, used in error messages.

◆ ~MFEMQuadratureFunctionCoefficientBase()

virtual MFEMQuadratureFunctionCoefficientBase::~MFEMQuadratureFunctionCoefficientBase ( )
virtualdefault

Member Function Documentation

◆ CheckIntegrationRule()

void MFEMQuadratureFunctionCoefficientBase::CheckIntegrationRule ( const mfem::QuadratureFunction &  qf,
mfem::ElementTransformation &  T,
const mfem::IntegrationPoint &  ip 
) const
protected

Verify that the integration point ip supplied by a consuming integrator belongs to the same quadrature rule the values in qf are stored on.

Errors, naming the quadrature order the coefficient should use, if the rules do not match. The stored values are indexed by quadrature point, so a mismatched rule would silently read values from the wrong points.

Definition at line 37 of file MFEMQuadratureFunctionCoefficientBase.C.

Referenced by MFEMScalarQuadratureFunctionCoefficient::Eval(), and MFEMVectorQuadratureFunctionCoefficient::Eval().

40 {
41  const mfem::QuadratureSpaceBase & qspace = *qf.GetSpace();
42  const int el_idx = qspace.GetEntityIndex(T);
43  // Entity not in this space (e.g. a boundary evaluation)
44  if (el_idx < 0)
45  return;
46 
47  const mfem::Geometry::Type geom = qspace.GetGeometry(el_idx);
48  const int dim = mfem::Geometry::Dimension[geom];
49  const mfem::IntegrationRule & stored_rule = qspace.GetIntRule(el_idx);
50  // Fast path: the consuming integrator's point at this index coincides with the stored rule's,
51  // so the rules match.
52  if (ip.index < stored_rule.Size() && SamePoint(stored_rule.IntPoint(ip.index), ip, dim))
53  return;
54 
55  // Rules differ. Recover the quadrature order the coefficient should have used by finding the
56  // lowest order whose rule for this geometry reproduces the consuming integrator's point at
57  // ip.index. This runs only on the error path.
58  const int stored_order = qspace.GetOrder();
59  int suggested_order = -1;
60  // The consuming integrator's order is not known here, but is realistically bounded. The upper
61  // limit is just a generous finite cap so this error-path search always terminates: a multiple
62  // of the stored order, plus a constant so low-order stored rules still search far enough. If the
63  // true order somehow exceeds the cap, suggested_order stays -1 and a generic message is emitted.
64  for (int order = 0; order <= 2 * stored_order + 64; ++order)
65  {
66  const mfem::IntegrationRule & candidate = mfem::IntRules.Get(geom, order);
67  if (ip.index < candidate.Size() && SamePoint(candidate.IntPoint(ip.index), ip, dim))
68  {
69  suggested_order = order;
70  break;
71  }
72  }
73 
74  if (suggested_order >= 0)
75  mooseError("MFEM quadrature function '",
76  _name,
77  "' stores values on the order-",
78  stored_order,
79  " quadrature rule (",
80  stored_rule.Size(),
81  " points on this element), but it is being evaluated by an integrator using a "
82  "different quadrature rule (",
83  mfem::IntRules.Get(geom, suggested_order).Size(),
84  " points). The stored values are indexed by quadrature point, so the orders must "
85  "match. Set 'order = ",
86  suggested_order,
87  "' on '",
88  _name,
89  "'.");
90  else
91  mooseError("MFEM quadrature function '",
92  _name,
93  "' stores values on the order-",
94  stored_order,
95  " quadrature rule, but it is being evaluated by an integrator using a different "
96  "quadrature rule. The stored values are indexed by quadrature point, so the orders "
97  "must match; adjust 'order' on '",
98  _name,
99  "' to match the consuming integrator.");
100 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:165
const std::string _name
Name of the owning MOOSE object, used in error messages.

◆ CreateMooseEnumClass()

MFEMQuadratureFunctionCoefficientBase::CreateMooseEnumClass ( UpdatePolicy  ,
NONE  ,
TIME  ,
NONLINEAR   
)

Policy controlling when the stored values are re-projected from the source coefficient.

NONE - the source never changes after initialization; project exactly once. TIME - the source changes with time only; re-project when the time is set. NONLINEAR - the source may additionally depend on solution variables; also re-project whenever trial variables are updated (i.e. on each nonlinear iteration).

◆ MarkSolutionChanged()

void MFEMQuadratureFunctionCoefficientBase::MarkSolutionChanged ( )
inline

Mark the stored values as stale following a change of solution variables, forcing the source to be re-projected on next use.

Definition at line 51 of file MFEMQuadratureFunctionCoefficientBase.h.

52  {
54  _dirty = true;
55  }
bool _dirty
Whether the stored values are stale and must be re-projected before use.
const UpdatePolicy _update_policy
When the stored values are re-projected from the source coefficient.

◆ MarkTimeChanged()

void MFEMQuadratureFunctionCoefficientBase::MarkTimeChanged ( )
inlineprotected

Mark the stored values as stale following a change of time.

Definition at line 59 of file MFEMQuadratureFunctionCoefficientBase.h.

Referenced by MFEMScalarQuadratureFunctionCoefficient::SetTime(), and MFEMVectorQuadratureFunctionCoefficient::SetTime().

60  {
61  if (_update_policy != UpdatePolicy::NONE)
62  _dirty = true;
63  }
bool _dirty
Whether the stored values are stale and must be re-projected before use.
const UpdatePolicy _update_policy
When the stored values are re-projected from the source coefficient.

Member Data Documentation

◆ _dirty

bool MFEMQuadratureFunctionCoefficientBase::_dirty
protected

◆ _name

const std::string MFEMQuadratureFunctionCoefficientBase::_name
protected

Name of the owning MOOSE object, used in error messages.

Definition at line 76 of file MFEMQuadratureFunctionCoefficientBase.h.

Referenced by CheckIntegrationRule().

◆ _update_policy

const UpdatePolicy MFEMQuadratureFunctionCoefficientBase::_update_policy
protected

When the stored values are re-projected from the source coefficient.

Definition at line 74 of file MFEMQuadratureFunctionCoefficientBase.h.

Referenced by MarkSolutionChanged(), and MarkTimeChanged().


The documentation for this class was generated from the following files: