10 #ifdef MOOSE_MFEM_ENABLED 14 #include "libmesh/mesh_function.h" 23 "libMesh application, using shape function evaluations.");
31 checkValidTransferProblemTypes<Moose::FEBackend::LibMesh, Moose::FEBackend::MFEM>();
45 std::vector<Point> & outgoing_libmesh_points)
49 auto var_num = to_var.
number();
50 auto sys_num = to_sys.
number();
51 auto & fe_type = to_var.
feType();
52 bool is_nodal = to_var.
isNodal();
55 if (fe_type.order >
CONSTANT && !is_nodal)
56 mooseError(
"Transfers of non-nodal FEs from MFEM to libMesh with order higher than " 57 "CONSTANT are not supported.");
61 for (
const auto & node : to_mesh.local_node_ptr_range())
62 if (node->n_dofs(sys_num, var_num))
63 outgoing_libmesh_points.push_back(*node);
68 for (
const auto & elem :
as_range(to_mesh.local_elements_begin(), to_mesh.local_elements_end()))
69 if (elem->n_dofs(sys_num, var_num))
70 outgoing_libmesh_points.push_back(elem->vertex_average());
81 auto var_num = to_var.
number();
82 auto sys_num = to_sys.
number();
83 auto & fe_type = to_var.
feType();
84 bool is_nodal = to_var.
isNodal();
86 unsigned int mfem_point_index = 0;
87 if (fe_type.order >
CONSTANT && !is_nodal)
88 mooseError(
"Transfers of non-nodal FEs from MFEM to libMesh with order higher than " 89 "CONSTANT are not supported.");
93 for (
const auto & node : to_mesh.local_node_ptr_range())
94 if (node->n_dofs(sys_num, var_num))
96 const auto dof_object_id = node->id();
97 const DofObject * dof_object = to_mesh.node_ptr(dof_object_id);
98 const auto dof = dof_object->dof_number(sys_num, var_num, 0);
99 const auto val = interp_vals[mfem_point_index];
107 for (
const auto & elem :
as_range(to_mesh.local_elements_begin(), to_mesh.local_elements_end()))
108 if (elem->n_dofs(sys_num, var_num))
110 const auto dof_object_id = elem->id();
111 const DofObject * dof_object = to_mesh.elem_ptr(dof_object_id);
112 const auto dof = dof_object->dof_number(sys_num, var_num, 0);
113 const auto val = interp_vals[mfem_point_index];
131 if (from_var.VectorDim() > 1)
132 mooseError(
"MultiAppMFEMTolibMeshShapeEvaluationTransfer does not support transfers of " 133 "vector variables from MFEM to libMesh-based subapps");
134 from_var.ParFESpace()->GetParMesh()->EnsureNodes();
136 const mfem::Ordering::Type ordering = mfem::Ordering::byVDIM;
137 mfem::Vector interp_vals;
138 mfem::Vector outgoing_mfem_points;
153 System & to_sys = *
find_sys(es, to_var_name);
155 std::vector<Point> outgoing_libmesh_points;
159 for (
auto &
point : outgoing_libmesh_points)
162 outgoing_libmesh_points, to_mesh.mesh_dimension(), ordering);
169 outgoing_mfem_points,
188 auto & out_sys = *
find_sys(out_es, to_var_name);
std::shared_ptr< mfem::ParGridFunction > getGridFunction(const std::string &name)
virtual bool isNodal() const
Is this variable nodal.
Virtual base class for MultiApp transfers to and/or from MFEMProblems.
const libMesh::FEType & feType() const
Get the type of finite element object.
libMesh::EquationSystems & getlibMeshEquationSystem(FEProblemBase &problem, bool use_displaced) const
Get libMesh EquationSystem, which may or may not be displaced.
unsigned int number() const
Get variable number coming from libMesh.
virtual void transferVariables(bool is_target_local) override
Transfer all variables from active MFEM source problem to active libMesh destination problem...
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.
This class provides an interface for common operations on field variables of both FE and FV types wit...
virtual FEProblemBase & getActiveFromProblem()
Getter for current problem containing source variables.
mfem::FindPointsGSLIB _mfem_interpolator
Object to perform pointwise interpolation of source MFEM GridFunctions.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const override
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
bool _displaced_target_mesh
True if displaced mesh is used for the target mesh, otherwise false.
MultiApp transfer from MFEM to libMesh variables, performed via evaluation of shape functions...
virtual FEProblemBase & getActiveToProblem()
Getter for current problem containing destination variables.
unsigned int number() const
unsigned int numToVar() const
Return for the number of destination variables.
void extractlibMeshNodePositions(libMesh::System &to_sys, const MooseVariableFieldBase &to_var, std::vector< Point > &outgoing_libmesh_points)
Extract all target points of the destination libMesh variable, needed to set DoFs in transfer...
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
static libMesh::System * find_sys(libMesh::EquationSystems &es, const std::string &var_name)
Small helper function for finding the system containing the variable.
std::unique_ptr< NumericVector< Number > > solution
void projectlibMeshNodalValues(libMesh::System &to_sys, const MooseVariableFieldBase &to_var, mfem::Vector &interp_vals)
Set DoFs of destination libMesh variable via projection, using a vector of interpolated values...
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.
MultiAppMFEMTolibMeshShapeEvaluationTransfer(InputParameters const ¶ms)
const VariableName & getToVarName(int i) const
Getter for destination variable name.
IntRange< T > make_range(T beg, T end)
virtual MooseMesh & mesh() override
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...
registerMooseObject("MooseApp", MultiAppMFEMTolibMeshShapeEvaluationTransfer)
const Elem & get(const ElemType type_in)
static InputParameters validParams()
virtual MFEMProblem & getActiveFromProblem() override
Set current MFEM problem to fetch source variables from.