https://mooseframework.inl.gov
MFEMDotProductAux.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 "MFEMDotProductAux.h"
13 #include "MFEMProblem.h"
14 
16 
19 {
21  params.addClassDescription("Project s(x) * (U . V) onto a scalar MFEM auxvariable.");
22  params.addRequiredParam<VariableName>("first_source_vec", "Vector MFEMVariable U");
23  params.addRequiredParam<VariableName>("second_source_vec", "Vector MFEMVariable V");
24  params.addParam<mfem::real_t>(
25  "scale_factor", 1.0, "Constant multiplier applied to the dot product");
26  return params;
27 }
28 
30  : MFEMAuxKernel(parameters),
31  _u_var_name(getParam<VariableName>("first_source_vec")),
32  _v_var_name(getParam<VariableName>("second_source_vec")),
33  _u_var(*getMFEMProblem().getProblemData().gridfunctions.Get(_u_var_name)),
34  _v_var(*getMFEMProblem().getProblemData().gridfunctions.Get(_v_var_name)),
35  _scale_factor(getParam<mfem::real_t>("scale_factor")),
36  _u_coef(&_u_var),
37  _v_coef(&_v_var),
38  _dot_uv(_u_coef, _v_coef),
39  _scale_c(_scale_factor),
40  _final_coef(_scale_c, _dot_uv)
41 {
42  // Must be L2
43  mfem::ParFiniteElementSpace * fes = _result_var.ParFESpace();
44  if (!dynamic_cast<const mfem::L2_FECollection *>(fes->FEColl()))
45  paramError("variable", "The target variable must use L2_FECollection.");
46 
47  // Must have no shared/constrained DOFs
48  if (fes->GetTrueVSize() != fes->GetVSize())
49  mooseError("MFEMDotProductAux currently supports only L2 spaces with interior DOFs (no "
50  "shared/constrained DOFs).");
51 }
52 
53 void
55 {
56  // Project into the scalar aux result variable per element projection for L2
57  _result_var = 0.0;
58  _result_var.ProjectCoefficient(_final_coef);
59 }
60 
61 #endif // MOOSE_MFEM_ENABLED
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:439
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...
void execute() override
Execute method.
mfem::ParGridFunction & _result_var
Reference to result gridfunction.
Definition: MFEMAuxKernel.h:36
registerMooseObject("MooseApp", MFEMDotProductAux)
Class to construct an auxiliary solver used to update an auxvariable.
Definition: MFEMAuxKernel.h:20
static InputParameters validParams()
Definition: MFEMAuxKernel.C:16
MFEMDotProductAux(const InputParameters &parameters)
mfem::ProductCoefficient _final_coef
Final coefficient that applies the scale factor to the inner product.
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:271
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()
Project s(x) * (U .