10#ifdef MOOSE_MFEM_ENABLED
36 "The scalar coefficient to sample.");
38 "The points where the coefficient is evaluated.");
44 :
MFEMSamplerBase(parameters, parameters.get<
std::vector<Point>>(
"points"), mainMesh(parameters)),
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 "
68 mfem::Array<unsigned int> received_elements;
69 mfem::Array<unsigned int> received_codes;
70 mfem::Vector received_reference_points;
71 _finder.DistributePointInfoToOwningMPIRanks(
72 received_elements, received_reference_points, received_codes);
74 const auto mesh_dim =
_mesh.Dimension();
75 mfem::Vector evaluated_values(received_elements.Size());
76 for (
const auto i : make_range(received_elements.Size()))
78 mfem::IntegrationPoint integration_point;
79 integration_point.Set(&received_reference_points[mesh_dim * i], mesh_dim);
81 auto & transformation = *
_mesh.GetElementTransformation(received_elements[i]);
82 transformation.SetIntPoint(&integration_point);
83 evaluated_values[i] =
_coefficient->Eval(transformation, integration_point);
87 _finder.DistributeInterpolatedValues(evaluated_values, 1, mfem::Ordering::byVDIM,
_interp_vals);
93 const auto *
const interp_vals =
_interp_vals.HostRead();
registerMooseObject("MooseApp", MFEMScalarCoefficientPointValueSampler)
mfem::ParMesh & getMFEMParMesh()
Accessors for the _mfem_par_mesh object.
mfem::Coefficient & getScalarCoefficient(const std::string &name)
Retrieve a scalar MFEM coefficient using the value of an input parameter.
virtual MFEMMesh & mesh() override
Overwritten mesh() method from base MooseMesh to retrieve the correct mesh type, in this case MFEMMes...
Abstract base class for sampling MFEM quantities at points.
mfem::FindPointsGSLIB _finder
GSLIB point finder used to locate and interpolate the query points.
static InputParameters validParams()
mfem::ParMesh & _mesh
MFEM mesh on which the sampled quantity is defined.
const std::vector< Point > _query_points
Original query points used for point-location diagnostics.
void initialSetup() override
Checks that all query points were found.
Samples a real scalar MFEM coefficient at specified points.
mfem::Vector _interp_vals
Values evaluated on owning ranks and returned to the querying ranks.
mfem::Coefficient * _coefficient
Scalar coefficient being sampled, resolved after all coefficient-declaring objects exist.
VectorPostprocessorValue & _declared_vals
VectorPostprocessor output column for the coefficient.
void execute() override
Evaluates the coefficient in each point's owning element.
void finalizeValues() override
Copies interpolated values into the subclass VPP vectors.
void initialSetup() override
Checks point locations and warns when GSLIB selects an element at a boundary.
MFEMScalarCoefficientPointValueSampler(const InputParameters ¶meters)
static InputParameters validParams()
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 ...
Generic class for solving transient nonlinear problems.