https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMInnerProductAux.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 "MFEMInnerProductAux.h"
13#include "MFEMProblem.h"
14
16
19{
21 params.addClassDescription("Projects $s \\vec u \\cdot \\vec v$ onto a scalar MFEM auxvariable");
22 params.addRequiredParam<MFEMVectorCoefficientName>("first_source_vec", "Vector coefficient");
23 params.addRequiredParam<MFEMVectorCoefficientName>("second_source_vec", "Vector coefficient");
24 params.addParam<MFEMScalarCoefficientName>(
25 "coefficient", "1.", "Name of scalar coefficient s to scale the inner product by");
26 return params;
27}
28
30 : MFEMAuxKernel(parameters),
31 _inner(getVectorCoefficient("first_source_vec"), getVectorCoefficient("second_source_vec")),
32 _scaled_inner(getScalarCoefficient("coefficient"), _inner)
33{
34 // The target variable's finite element space
35 mfem::ParFiniteElementSpace * fes = _result_var.ParFESpace();
36
37 // Must be scalar L2
38 if (!dynamic_cast<const mfem::L2_FECollection *>(fes->FEColl()) || fes->GetVDim() != 1)
39 mooseError("MFEMInnerProductAux requires the target variable to be scalar L2.");
40
41 // Must have no shared/constrained DOFs (pure interior DOFs)
42 if (fes->GetTrueVSize() != fes->GetVSize())
43 mooseError("MFEMInnerProductAux currently supports only L2 spaces with interior DOFs "
44 "(no shared/constrained DOFs).");
45}
46
47void
49{
50 _result_var.ProjectCoefficient(_scaled_inner);
51}
52
53#endif // MOOSE_MFEM_ENABLED
registerMooseObject("MooseApp", MFEMInnerProductAux)
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 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...
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.
Project onto a scalar MFEM auxvariable.
static InputParameters validParams()
MFEMInnerProductAux(const InputParameters &parameters)
void execute() override
Perform the main work for this object.
mfem::ProductCoefficient _scaled_inner
Final coefficient that applies a scaling factor to the inner product.