10 #ifdef MOOSE_MFEM_ENABLED 16 #include "mfem/fem/fespace.hpp" 21 MFEMVectorToPostprocessorPoints(
22 const mfem::Vector & mfem_points,
23 std::vector<std::reference_wrapper<VectorPostprocessorValue>> & points,
24 const unsigned int num_dims,
25 const mfem::Ordering::Type ordering)
27 const unsigned int num_points = mfem_points.Size() / num_dims;
28 for (
unsigned int i_point = 0; i_point < num_points; i_point++)
30 for (
unsigned int i_dim = 0; i_dim < num_dims; i_dim++)
34 points[i_dim].get()[i_point] = mfem_points(idx);
45 MFEMExecutedObject::addRequiredDependencyParam<VariableName>(
46 params,
"variable",
"The names of the variables that this VectorPostprocessor operates on");
47 MooseEnum ordering(
"NODES VDIM",
"VDIM",
false);
49 "point_ordering", ordering,
"Ordering style to use for point vector DoFs.");
55 const std::vector<Point> & points)
57 _var_name(getParam<VariableName>(
"variable")),
58 _var(*getMFEMProblem().getGridFunction(_var_name)),
59 _mesh(const_cast<mfem::ParMesh &>(getMFEMProblem().getMFEMVariableMesh(_var_name))),
60 _finder(this->comm().
get()),
61 _points_ordering(getParam<
MooseEnum>(
"point_ordering") ==
"NODES" ? mfem::Ordering::byNODES
62 : mfem::Ordering::byVDIM),
65 _interp_vals(points.size())
68 mooseError(
"MFEMValueSamplerBase does not yet support problems with displacement.");
76 mfem::Array<unsigned int> point_codes =
_finder.GetCode();
77 for (
size_t i = 0; i < points.size(); i++)
79 if (point_codes[i] > 1)
81 mooseError(
"MFEMValueSamplerBase could not find point at ", points[i],
".");
86 const auto mesh_dim =
_mesh.SpaceDimension();
87 for (
int i = 0; i < mesh_dim; i++)
89 std::reference_wrapper<VectorPostprocessorValue> declared_dim =
91 declared_dim.get().resize(points.size());
96 const auto val_dim =
_var.VectorDim();
97 for (
int i = 0; i < val_dim; i++)
99 std::reference_wrapper<VectorPostprocessorValue> declared_dim =
101 declared_dim.get().resize(points.size());
118 const auto mesh_dim =
_mesh.SpaceDimension();
120 const auto val_dims =
_var.VectorDim();
122 const auto val_fespace_ordering =
_var.FESpace()->GetOrdering();
123 for (
int i_dim = 0; i_dim < val_dims; i_dim++)
125 for (
size_t i_point = 0; i_point < num_points; i_point++)
127 const auto mfem_idx =
134 #endif // MOOSE_MFEM_ENABLED MFEMProblem & getMFEMProblem()
Return the owning MFEM problem.
static InputParameters validParams()
virtual void execute() override
Perform the interpolation in FindPointsGSLIB.
mfem::Vector libMeshPointsToMFEMVector(const std::vector< libMesh::Point > &points, const unsigned int num_dims, const mfem::Ordering::Type ordering)
Convert a vector of libMesh::Point objects to an mfem::Vector containing all points, given an ordering.
virtual void finalize() override
Store the result of the interpolation.
std::vector< std::reference_wrapper< VectorPostprocessorValue > > _declared_vals
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
VectorPostprocessorValue & declareVector(const std::string &vector_name)
Register a new vector to fill up.
const mfem::GridFunction & _var
std::size_t MFEMIndex(const std::size_t i_dim, const std::size_t i_point, const std::size_t num_dims, const std::size_t num_points, const mfem::Ordering::Type ordering)
Convert an index of a vector of libMesh::Points to an MFEM vector index, given an MFEM ordering...
const VariableName & _var_name
mfem::FindPointsGSLIB _finder
mfem::Vector _interp_vals
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
mfem::Ordering::Type _points_ordering
static InputParameters validParams()
std::vector< std::reference_wrapper< VectorPostprocessorValue > > _declared_points
MFEMValueSamplerBase(const InputParameters ¶meters, const std::vector< Point > &points)
const Elem & get(const ElemType type_in)