diff --git a/contrib/hephaestus b/contrib/hephaestus index ff359ff3..b9b6fd46 160000 --- a/contrib/hephaestus +++ b/contrib/hephaestus @@ -1 +1 @@ -Subproject commit ff359ff38f1706fa0a960367c20dc1f712ca29f2 +Subproject commit b9b6fd46f1863fcd2a2d25b6a819bb09c08fcde2 diff --git a/examples/TEAM/Problem_7/team7_closed_coil_frequency_domain.i b/examples/TEAM/Problem_7/team7_closed_coil_frequency_domain.i index af884d9f..886479c7 100644 --- a/examples/TEAM/Problem_7/team7_closed_coil_frequency_domain.i +++ b/examples/TEAM/Problem_7/team7_closed_coil_frequency_domain.i @@ -77,6 +77,18 @@ [] [] +[AuxKernels] + [LineSampler] + type = MFEMLineSamplerAux + filename = 'bfield.csv' + variable = magnetic_flux_density_real + num_points = 100 + start_point = '0.09 0.072 0.034' + end_point = '0.1 0.072 0.034' + header = 't (s), x (m), y (m), z (m), B_x (T), B_y (T), B_z (T)' + [] +[] + [Sources] [SourceCoil] type = MFEMClosedCoilSource diff --git a/include/auxkernels/MFEMLineSamplerAux.h b/include/auxkernels/MFEMLineSamplerAux.h new file mode 100644 index 00000000..28bd594a --- /dev/null +++ b/include/auxkernels/MFEMLineSamplerAux.h @@ -0,0 +1,32 @@ +#pragma once + +#include "MFEMAuxSolver.h" +#include "MFEMVariable.h" + +class MFEMLineSamplerAux : public MFEMAuxSolver +{ +public: + static InputParameters validParams(); + + MFEMLineSamplerAux(const InputParameters & parameters); + virtual ~MFEMLineSamplerAux(); + + virtual void execute() override {} + virtual void initialize() override {} + virtual void finalize() override {} + + inline std::shared_ptr getAuxSolver() const override + { + return _line_sampler_aux; + } + +protected: + const MFEMVariable & _mfem_variable; + const Point _start_point; + const Point _end_point; + mfem::Vector _start_vec; + mfem::Vector _end_vec; + unsigned int _num_points; + + std::shared_ptr _line_sampler_aux{nullptr}; +}; diff --git a/include/mesh/ExclusiveMFEMMesh.h b/include/mesh/ExclusiveMFEMMesh.h index d84ad692..6326ecd9 100644 --- a/include/mesh/ExclusiveMFEMMesh.h +++ b/include/mesh/ExclusiveMFEMMesh.h @@ -24,7 +24,7 @@ #include "libmesh/numeric_vector.h" #include "libmesh/system.h" #include "libmesh/vtk_io.h" -#include "mfem.hpp" +#include "hephaestus.hpp" /** * ExclusiveMFEMMesh @@ -92,4 +92,7 @@ class ExclusiveMFEMMesh : public FileMesh */ std::shared_ptr _mfem_mesh; std::shared_ptr _mfem_par_mesh; + mfem::H1_FECollection default_nodal_fecoll; + std::shared_ptr default_nodal_fespace{nullptr}; + // std::shared_ptr default_nodal_fespace(pmesh.get(), &fecm, 3); }; diff --git a/src/auxkernels/MFEMLineSamplerAux.C b/src/auxkernels/MFEMLineSamplerAux.C new file mode 100644 index 00000000..f193913c --- /dev/null +++ b/src/auxkernels/MFEMLineSamplerAux.C @@ -0,0 +1,39 @@ +#include "MFEMLineSamplerAux.h" + +registerMooseObject("ApolloApp", MFEMLineSamplerAux); + +InputParameters +MFEMLineSamplerAux::validParams() +{ + InputParameters params = MFEMAuxSolver::validParams(); + params.addRequiredParam("start_point", "The beginning of the line"); + params.addRequiredParam("end_point", "The end of the line"); + params.addRequiredParam("num_points", + "The number of points to sample along the line"); + params.addRequiredParam( + "variable", "The FESpace associated with the test variable the source will be applied to."); + params.addRequiredParam("header", "Header for the output CSV."); + params.addRequiredParam("filename", "Name of the output CSV."); + return params; +} + +MFEMLineSamplerAux::MFEMLineSamplerAux(const InputParameters & parameters) + : MFEMAuxSolver(parameters), + _mfem_variable(getUserObject("variable")), + _start_point(getParam("start_point")), + _end_point(getParam("end_point")), + _start_vec({_start_point(0), _start_point(1), _start_point(2)}), + _end_vec({_end_point(0), _end_point(1), _end_point(2)}), + _num_points(getParam("num_points")), + _line_sampler_aux{ + std::make_shared(_mfem_variable.name(), + _start_vec, + _end_vec, + _num_points, + getParam("filename"), + getParam("header"))} +{ + _line_sampler_aux->SetPriority(99); +} + +MFEMLineSamplerAux::~MFEMLineSamplerAux() {} diff --git a/src/mesh/CoupledMFEMMesh.C b/src/mesh/CoupledMFEMMesh.C index ff1d4a9e..6e0e70c4 100644 --- a/src/mesh/CoupledMFEMMesh.C +++ b/src/mesh/CoupledMFEMMesh.C @@ -438,6 +438,9 @@ CoupledMFEMMesh::buildMFEMParMesh() convertSerialDofMappingsToParallel(*_mfem_mesh.get(), *_mfem_par_mesh.get()); _mfem_mesh.reset(); // Lower reference count of serial mesh since no longer needed. + default_nodal_fespace = + std::make_shared(_mfem_par_mesh.get(), &default_nodal_fecoll, 3); + _mfem_par_mesh->SetNodalFESpace(default_nodal_fespace.get()); } void diff --git a/src/mesh/ExclusiveMFEMMesh.C b/src/mesh/ExclusiveMFEMMesh.C index 95f6e4b6..a1f44751 100644 --- a/src/mesh/ExclusiveMFEMMesh.C +++ b/src/mesh/ExclusiveMFEMMesh.C @@ -18,7 +18,10 @@ ExclusiveMFEMMesh::validParams() return params; } -ExclusiveMFEMMesh::ExclusiveMFEMMesh(const InputParameters & parameters) : FileMesh(parameters) {} +ExclusiveMFEMMesh::ExclusiveMFEMMesh(const InputParameters & parameters) + : FileMesh(parameters), default_nodal_fecoll(1, 3) +{ +} ExclusiveMFEMMesh::~ExclusiveMFEMMesh() {} @@ -62,6 +65,9 @@ ExclusiveMFEMMesh::buildMFEMParMesh() { _mfem_par_mesh = std::make_shared(MPI_COMM_WORLD, getMFEMMesh()); _mfem_mesh.reset(); // Lower reference count of serial mesh since no longer needed. + default_nodal_fespace = + std::make_shared(_mfem_par_mesh.get(), &default_nodal_fecoll, 3); + _mfem_par_mesh->SetNodalFESpace(default_nodal_fespace.get()); } MFEMMesh &