https://mooseframework.inl.gov
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 {
21  params.addClassDescription(
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 
75 void
77 {
80 }
81 
82 #endif
registerMooseObject("MooseApp", MFEMNDtoRTAux)
void execute() override
Perform the main work for this object.
Definition: MFEMNDtoRTAux.C:76
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:467
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
MFEMNDtoRTAux(const InputParameters &parameters)
Definition: MFEMNDtoRTAux.C:35
mfem::ParGridFunction & _result_var
Reference to result gridfunction.
Definition: MFEMAuxKernel.h:38
Class to construct an auxiliary solver used to update a real auxvariable.
Definition: MFEMAuxKernel.h:20
static InputParameters validParams()
Definition: MFEMAuxKernel.C:16
static InputParameters validParams()
Definition: MFEMNDtoRTAux.C:18
const mfem::real_t _scale_factor
Definition: MFEMNDtoRTAux.h:28
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...
Definition: MooseBase.h:281
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...
const mfem::ParGridFunction & _nd_source_var
Definition: MFEMNDtoRTAux.h:27