10 #ifdef MOOSE_MFEM_ENABLED 36 "The scalar coefficient to sample.");
38 "The points where the coefficient is evaluated.");
45 _coefficient(nullptr),
46 _interp_vals(_query_points.size()),
47 _declared_vals(declareVector(getParam<MFEMScalarCoefficientName>(
"coefficient")))
56 if (dynamic_cast<mfem::QuadratureFunctionCoefficient *>(
_coefficient))
58 "Quadrature-function-backed coefficients can only be evaluated at the quadrature " 59 "points configured by their quadrature rule and cannot be sampled at arbitrary " 64 const auto & point_codes =
_finder.GetCode();
70 " on an element boundary. An arbitrary coefficient may be discontinuous " 71 "there, so the element selected by GSLIB will supply the sampled value.");
77 mfem::Array<unsigned int> received_elements;
78 mfem::Array<unsigned int> received_codes;
79 mfem::Vector received_reference_points;
80 _finder.DistributePointInfoToOwningMPIRanks(
81 received_elements, received_reference_points, received_codes);
83 const auto mesh_dim =
_mesh.Dimension();
84 mfem::Vector evaluated_values(received_elements.Size());
85 for (
const auto i :
make_range(received_elements.Size()))
87 mfem::IntegrationPoint integration_point;
89 integration_point.Set1(received_reference_points[i]);
90 else if (mesh_dim == 2)
91 integration_point.Set2(received_reference_points[2 * i],
92 received_reference_points[2 * i + 1]);
94 integration_point.Set3(received_reference_points[3 * i],
95 received_reference_points[3 * i + 1],
96 received_reference_points[3 * i + 2]);
98 auto & transformation = *
_mesh.GetElementTransformation(received_elements[i]);
99 transformation.SetIntPoint(&integration_point);
100 evaluated_values[i] =
_coefficient->Eval(transformation, integration_point);
104 _finder.DistributeInterpolatedValues(evaluated_values, 1, mfem::Ordering::byVDIM,
_interp_vals);
110 const auto *
const interp_vals =
_interp_vals.HostRead();
115 #endif // MOOSE_MFEM_ENABLED
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
mfem::Vector _interp_vals
Values evaluated on owning ranks and returned to the querying ranks.
virtual MFEMMesh & mesh() override
Overwritten mesh() method from base MooseMesh to retrieve the correct mesh type, in this case MFEMMes...
void initialSetup() override
Checks point locations and warns when GSLIB selects an element at a boundary.
Samples a real scalar MFEM coefficient at specified points.
void mooseWarning(Args &&... args) const
MFEMPointScalarCoefficientValueSampler(const InputParameters ¶meters)
void initialSetup() override
Checks that all query points were found.
std::string typeAndName() const
Get the class's combined type and name; useful in error handling.
Abstract base class for sampling MFEM quantities at points.
mfem::ParMesh & _mesh
MFEM mesh on which the sampled quantity is defined.
Generic class for solving transient nonlinear problems.
mfem::ParMesh & getMFEMParMesh()
Accessors for the _mfem_par_mesh object.
mfem::FindPointsGSLIB _finder
GSLIB point finder used to locate and interpolate the query points.
PointLocationCode
Classification returned by GSLIB for a query point's location.
registerMooseObject("MooseApp", MFEMPointScalarCoefficientValueSampler)
static InputParameters validParams()
mfem::Coefficient & getScalarCoefficient(const std::string &name)
Retrieve a scalar MFEM coefficient using the value of an input parameter.
IntRange< T > make_range(T beg, T end)
static InputParameters validParams()
VectorPostprocessorValue & _declared_vals
VectorPostprocessor output column for the coefficient.
const std::vector< Point > _query_points
Original query points used for point-location diagnostics.
mfem::Coefficient * _coefficient
Scalar coefficient being sampled, resolved after all coefficient-declaring objects exist...
void finalizeValues() override
Copies interpolated values into the subclass VPP vectors.
auto index_range(const T &sizable)
const Elem & get(const ElemType type_in)
void execute() override
Evaluates the coefficient in each point's owning element.