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::VectorCoefficient & source,
17 mfem::QuadratureFunction & qf,
18 UpdatePolicy update_policy,
19 const std::string & name)
20 : mfem::VectorQuadratureFunctionCoefficient(qf),
21 MFEMQuadratureFunctionCoefficientBase(update_policy, name),
22 _source(source),
23 _qf(qf)
24{
25}
26
27void
29{
30 mfem::VectorCoefficient::SetTime(t);
32}
33
34void
36 mfem::ElementTransformation & T,
37 const mfem::IntegrationPoint & ip)
38{
39 if (_dirty)
40 Refresh();
42 mfem::VectorQuadratureFunctionCoefficient::Eval(V, T, ip);
43}
44
45void
47{
48 if (_dirty)
49 Refresh();
50 mfem::VectorQuadratureFunctionCoefficient::Project(qf);
51}
52
53void
55{
56 // Equivalent to _source.Project(_qf), except performed with a caller-owned element
57 // transformation: the mesh-owned shared transformation used by mfem::VectorCoefficient::Project
58 // may belong to an in-flight assembly loop that is evaluating this coefficient, and
59 // projecting through it would corrupt that loop's state.
60 const mfem::QuadratureSpaceBase & qspace = *_qf.GetSpace();
61 const mfem::Mesh & mesh = *qspace.GetMesh();
62 mfem::IsoparametricTransformation T;
63 mfem::DenseMatrix values;
64 mfem::Vector col;
65 _qf.HostWrite();
66 for (const auto iel : libMesh::make_range(qspace.GetNE()))
67 {
68 _qf.GetValues(iel, values);
69 const mfem::IntegrationRule & ir = qspace.GetIntRule(iel);
70 mesh.GetElementTransformation(iel, &T);
71 for (const auto iq : libMesh::make_range(ir.Size()))
72 {
73 const mfem::IntegrationPoint & ip = ir[iq];
74 T.SetIntPoint(&ip);
75 values.GetColumnReference(iq, col);
76 _source.Eval(col, T, ip);
77 }
78 }
79 _dirty = false;
80}
81
82#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.
void Refresh()
Project the source coefficient into the quadrature function if invalidated.
mfem::VectorCoefficient & _source
Source coefficient the stored values are projected from.
mfem::QuadratureFunction & _qf
Storage for the projected values, shared with the owning MOOSE object.
MFEMVectorQuadratureFunctionCoefficient(mfem::VectorCoefficient &source, mfem::QuadratureFunction &qf, UpdatePolicy update_policy, const std::string &name)
void SetTime(mfem::real_t t) override
Set the time for the coefficient, invalidating the stored values unless the update policy is NONE.
void Project(mfem::QuadratureFunction &qf) override
Copy the stored values into qf, re-projecting the source first if invalidated.
MeshBase & mesh
IntRange< T > make_range(T beg, T end)