https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMNDtoRTAux.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#ifdef MOOSE_MFEM_ENABLED
11
12#include "MFEMNDtoRTAux.h"
13#include "MFEMProblem.h"
14
16
19{
22 "Copies the DoFs of a 2D Nedelec H(curl) MFEM Variable "
23 "into a Raviart-Thomas H(div) MFEM Variable. In 2D ONLY this represents a 90 degree rotation "
24 "because the RT basis is the rotated ND basis.");
25 MFEMExecutedObject::addRequiredDependencyParam<VariableName>(
26 params, "source", "Name of H(curl) conforming ND variable to copy.");
27 params.addParam<mfem::real_t>(
28 "scale_factor",
29 1.0,
30 "Optional scale factor. Negative values can be used to flip the sign of the rotation.");
31
32 return params;
33}
34
36 : MFEMAuxKernel(parameters),
37 _nd_source_var_name(getParam<VariableName>("source")),
38 _nd_source_var(*getMFEMProblem().getGridFunction(_nd_source_var_name)),
39 _scale_factor(getParam<mfem::real_t>("scale_factor"))
40{
41 const mfem::ParFiniteElementSpace * source_fes = _nd_source_var.ParFESpace();
42 const mfem::ParFiniteElementSpace * target_fes = _result_var.ParFESpace();
43
44 mooseAssert(source_fes, "The source variable has no valid ParFiniteElementSpace.");
45 mooseAssert(target_fes, "The target variable has no valid ParFiniteElementSpace.");
46
47 const mfem::FiniteElementCollection * source_fec = source_fes->FEColl();
48 const mfem::FiniteElementCollection * target_fec = target_fes->FEColl();
49
50 if (!dynamic_cast<const mfem::ND_FECollection *>(source_fec))
51 paramError("source",
52 "The source variable must use an MFEM H(curl) Nedelec space. "
53 "Detected FE collection: ",
54 source_fec->Name(),
55 ".");
56 if (!dynamic_cast<const mfem::RT_FECollection *>(target_fec))
57 mooseError("The target variable must use an MFEM H(div) Raviart-Thomas space. "
58 "Detected FE collection: ",
59 target_fec->Name(),
60 ".");
61
62 if (source_fes->GetMesh()->Dimension() != 2 || target_fes->GetMesh()->Dimension() != 2)
63 mooseError("MFEMNDtoRTAux is only valid in 2D.");
64
65 if (_nd_source_var.Size() != _result_var.Size())
66 paramError("source",
67 "The source ND variable and target RT variable must have the same local DoF size. "
68 "Source size = ",
69 _nd_source_var.Size(),
70 ", target size = ",
71 _result_var.Size(),
72 ".");
73}
74
75void
81
82#endif
registerMooseObject("MooseApp", MFEMNDtoRTAux)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
Class to construct an auxiliary solver used to update a real auxvariable.
static InputParameters validParams()
mfem::ParGridFunction & _result_var
Reference to result gridfunction.
static InputParameters validParams()
void execute() override
Perform the main work for this object.
const mfem::ParGridFunction & _nd_source_var
const mfem::real_t _scale_factor
MFEMNDtoRTAux(const InputParameters &parameters)
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition MooseBase.h:457