10 #ifdef MOOSE_MFEM_ENABLED 20 params.
addClassDescription(
"Transfers variable values from one MFEM application to another using " 21 "shape function evaluations.");
29 checkValidTransferProblemTypes<Moose::FEBackend::MFEM, Moose::FEBackend::MFEM>();
47 auto transformTargetPointsToSourceFrame =
48 [
this](mfem::Vector & point_coordinates,
const unsigned int dimension)
50 mooseAssert(dimension == 2 || dimension == 3,
"Target finite element space must be 2D or 3D");
52 const auto n_points = point_coordinates.Size() / dimension;
55 Point point_in_target_frame;
57 point_in_target_frame(d) = point_coordinates[i + d * n_points];
61 point_coordinates[i + d * n_points] = point_in_source_frame(d);
67 const std::string &
name,
68 bool & is_complex) -> mfem::ParGridFunction &
80 mooseError(
"No real or complex variable named '",
name,
"' found.");
85 bool is_from_complex{
false};
86 mfem::ParGridFunction & from_gf =
88 mfem::ParFiniteElementSpace & from_pfespace = *from_gf.ParFESpace();
89 from_pfespace.GetParMesh()->EnsureNodes();
91 bool is_to_complex{
false};
95 mfem::Ordering::Type point_ordering = mfem::Ordering::Type::byNODES;
97 mfem::Ordering::Type to_gf_ordering = mfem::Ordering::Type::byVDIM;
99 mfem::Vector interp_vals;
104 mfem::ParGridFunction & to_gf =
106 mfem::ParFiniteElementSpace & to_pfespace = *to_gf.ParFESpace();
107 to_pfespace.GetParMesh()->EnsureNodes();
111 const int dim = to_pfespace.GetParMesh()->Dimension();
112 transformTargetPointsToSourceFrame(vxyz,
dim);
114 to_gf_ordering = to_pfespace.GetOrdering();
121 _mfem_interpolator.Interpolate(vxyz, from_gf, interp_vals, point_ordering, to_gf_ordering);
126 mfem::ParGridFunction & to_gf =
128 mfem::ParFiniteElementSpace & to_pfespace = *to_gf.ParFESpace();
133 mfem::ParGridFunction & to_gf_im =
137 mfem::ParGridFunction & from_gf_im =
140 vxyz, from_gf_im, interp_vals, point_ordering, to_pfespace.GetOrdering());
std::shared_ptr< mfem::ParGridFunction > getGridFunction(const std::string &name)
Virtual base class for MultiApp transfers to and/or from MFEMProblems.
virtual void transferVariables(bool is_target_local) override
Transfer all variables from active source problem to active destination problem.
void projectNodalValues(const mfem::Vector &nodal_vals, const mfem::Ordering::Type &nodal_val_ordering, mfem::ParGridFunction &gridfunction)
Project a vector of values provided at projection points (nodes) to set GridFunction DoFs...
Moose::MFEM::ComplexGridFunctions cmplx_gridfunctions
MFEMProblemData & getProblemData()
Method to get the current MFEMProblemData object storing the current data specifying the FE problem...
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
MultiApp transfer between MFEM variables, via shape function evaluation.
virtual FEProblemBase & getActiveFromProblem()
Getter for current problem containing source variables.
registerMooseObject("MooseApp", MultiAppMFEMShapeEvaluationTransfer)
virtual FEProblemBase & getActiveToProblem()
Getter for current problem containing destination variables.
mfem::FindPointsGSLIB _mfem_interpolator
Object to perform pointwise interpolation of source MFEM GridFunctions.
const std::string & name() const
Get the name of the class.
unsigned int numToVar() const
Return for the number of destination variables.
MFEMNodalProjector _mfem_projector
Object to extract node positions and perform projections on destination MFEM GridFunctions.
MultiAppMFEMShapeEvaluationTransfer(InputParameters const ¶ms)
void extractNodePositions(const mfem::ParFiniteElementSpace &fespace, mfem::Vector &node_positions, mfem::Ordering::Type &node_ordering)
Extract node positions from MFEM FESpace at which projection will take place.
virtual MFEMProblem & getActiveFromProblem() override
Set current MFEM problem to fetch source variables from.
std::shared_ptr< mfem::ParComplexGridFunction > getComplexGridFunction(const std::string &name)
mfem::real_t getMFEMOutOfMeshValue() const
Getter for default value for transfers evaluated at points outside source mesh.
const VariableName & getFromVarName(int i) const
Getter for source variable name.
static InputParameters validParams()
libMesh::Point mapPointToActiveSourceFrame(const Point &point_in_target_frame) const
Map a point in the active destination app frame to the active source app frame.
const VariableName & getToVarName(int i) const
Getter for destination variable name.
static InputParameters validParams()
IntRange< T > make_range(T beg, T end)
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...
virtual MFEMProblem & getActiveToProblem() override
Set current MFEM problem to fetch destination variables from.
Moose::MFEM::GridFunctions gridfunctions