https://mooseframework.inl.gov
MFEMCrossProductAux.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 "MFEMCrossProductAux.h"
13 #include "MFEMProblem.h"
14 
16 
19 {
21  params.addClassDescription("Projects $s \\vec u \\times \\vec v$ onto a vector MFEM auxvariable");
22  params.addRequiredParam<MFEMVectorCoefficientName>("first_source_vec", "Vector coeff (3D)");
23  params.addRequiredParam<MFEMVectorCoefficientName>("second_source_vec", "Vector coeff (3D)");
24  params.addParam<MFEMScalarCoefficientName>(
25  "coefficient", "1.", "Name of scalar coefficient s to scale the cross product by");
26  return params;
27 }
28 
30  : MFEMAuxKernel(parameters),
31  _cross(getVectorCoefficient("first_source_vec"), getVectorCoefficient("second_source_vec")),
32  _scaled_cross(getScalarCoefficient("coefficient"), _cross)
33 {
34  // The target variable's finite element space
35  mfem::ParFiniteElementSpace * fes = _result_var.ParFESpace();
36 
37  // Must be [L2]^3
38  if (!dynamic_cast<const mfem::L2_FECollection *>(fes->FEColl()) || fes->GetVDim() != 3)
39  mooseError("MFEMCrossProductAux requires the target variable to be vector [L2]^3.");
40 
41  // Must have no shared/constrained DOFs (pure interior DOFs)
42  if (fes->GetTrueVSize() != fes->GetVSize())
43  mooseError("MFEMCrossProductAux currently supports only L2 spaces with interior DOFs "
44  "(no shared/constrained DOFs).");
45 }
46 
47 void
49 {
50  _result_var.ProjectCoefficient(_scaled_cross);
51 }
52 
53 #endif // MOOSE_MFEM_ENABLED
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
mfem::ScalarVectorProductCoefficient _scaled_cross
Final coefficient that applies a scaling factor to the cross product.
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
Project onto a vector MFEM auxvariable.
void execute() override
Perform the main work for this object.
MFEMCrossProductAux(const InputParameters &parameters)
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...
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...
static InputParameters validParams()
registerMooseObject("MooseApp", MFEMCrossProductAux)