https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMVectorQuadratureFunctionCoefficient.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#ifdef MOOSE_MFEM_ENABLED
11
13#include "libmesh/int_range.h"
14
16 mfem::QuadratureFunction & qf, UpdatePolicy update_policy, const std::string & name)
17 : mfem::VectorQuadratureFunctionCoefficient(qf),
18 MFEMQuadratureFunctionCoefficientBase(update_policy, name),
19 _source(nullptr),
20 _qf(qf)
21{
22}
23
24void
26{
27 mfem::VectorCoefficient::SetTime(t);
29}
30
31void
33 mfem::ElementTransformation & T,
34 const mfem::IntegrationPoint & ip)
35{
36 if (_dirty)
37 Refresh();
39 mfem::VectorQuadratureFunctionCoefficient::Eval(V, T, ip);
40}
41
42void
44{
45 if (_dirty)
46 Refresh();
47 mfem::VectorQuadratureFunctionCoefficient::Project(qf);
48}
49
50void
52{
53 // Equivalent to _source.Project(_qf), except performed with a caller-owned element
54 // transformation: the mesh-owned shared transformation used by mfem::VectorCoefficient::Project
55 // may belong to an in-flight assembly loop that is evaluating this coefficient, and
56 // projecting through it would corrupt that loop's state.
57 const mfem::QuadratureSpaceBase & qspace = *_qf.GetSpace();
58 const mfem::Mesh & mesh = *qspace.GetMesh();
59 mfem::IsoparametricTransformation T;
60 mfem::DenseMatrix values;
61 mfem::Vector col;
62 _qf.HostWrite();
63 for (const auto iel : make_range(qspace.GetNE()))
64 {
65 _qf.GetValues(iel, values);
66 const mfem::IntegrationRule & ir = qspace.GetIntRule(iel);
67 mesh.GetElementTransformation(iel, &T);
68 for (const auto iq : make_range(ir.Size()))
69 {
70 const mfem::IntegrationPoint & ip = ir[iq];
71 T.SetIntPoint(&ip);
72 values.GetColumnReference(iq, col);
73 _source->Eval(col, T, ip);
74 }
75 }
76 _dirty = false;
77}
78
79#endif
std::array< Real, 2 > values
Definition MortarUtils.C:52
Shared lazy-update state for quadrature function coefficients.
void MarkTimeChanged()
Mark the stored values as stale following a change of time.
bool _dirty
Whether the stored values are stale and must be re-projected before use.
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 quadratur...
void Eval(mfem::Vector &V, mfem::ElementTransformation &T, const mfem::IntegrationPoint &ip) override
Return the stored values at ip, re-projecting the source first if invalidated.
mfem::VectorCoefficient * _source
Source coefficient the stored values are projected from.
void Refresh()
Project the source coefficient into the quadrature function if invalidated.
mfem::QuadratureFunction & _qf
Storage for the projected values, shared with the owning MOOSE object.
void SetTime(mfem::real_t t) override
Set the time for the coefficient, invalidating the stored values unless the update policy is NONE.
MFEMVectorQuadratureFunctionCoefficient(mfem::QuadratureFunction &qf, UpdatePolicy update_policy, const std::string &name)
void Project(mfem::QuadratureFunction &qf) override
Copy the stored values into qf, re-projecting the source first if invalidated.
MeshBase & mesh