https://mooseframework.inl.gov
MFEMComplexInnerProductAux.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 
13 #include "MFEMProblem.h"
14 
16 
19 {
21  params.addClassDescription(
22  "Projects $s \\vec u \\cdot \\vec v*$ onto a complex scalar MFEM auxvariable");
23  MFEMExecutedObject::addRequiredDependencyParam<VariableName>(
24  params, "first_source_vec", "Complex vector variable");
25  MFEMExecutedObject::addRequiredDependencyParam<VariableName>(
26  params, "second_source_vec", "Complex vector variable");
27  params.addParam<mfem::real_t>("scale_factor_real", 1.0, "Real part of constant multiplier");
28  params.addParam<mfem::real_t>("scale_factor_imag", 0.0, "Imaginary part of constant multiplier");
29 
30  return params;
31 }
32 
34  : MFEMComplexAuxKernel(parameters),
35  _scale_factor(getParam<mfem::real_t>("scale_factor_real"),
36  getParam<mfem::real_t>("scale_factor_imag")),
37  _u_coef_real(getVectorCoefficientByName(getParam<VariableName>("first_source_vec") + "_real")),
38  _u_coef_imag(getVectorCoefficientByName(getParam<VariableName>("first_source_vec") + "_imag")),
39  _v_coef_real(getVectorCoefficientByName(getParam<VariableName>("second_source_vec") + "_real")),
40  _v_coef_imag(getVectorCoefficientByName(getParam<VariableName>("second_source_vec") + "_imag")),
41  _dot_ur_vr(_u_coef_real, _v_coef_real),
42  _dot_ur_vi(_u_coef_real, _v_coef_imag),
43  _dot_ui_vr(_u_coef_imag, _v_coef_real),
44  _dot_ui_vi(_u_coef_imag, _v_coef_imag),
45  _final_coef_real(_dot_ur_vr, _dot_ui_vi, 1.0, 1.0), // Accounting for hermitian conjugation
46  _final_coef_imag(_dot_ur_vi, _dot_ui_vr, -1.0, 1.0)
47 {
48  // The target variable's finite element space
49  mfem::ParFiniteElementSpace * fes = _result_var.ParFESpace();
50 
51  // Must be scalar L2
52  if (!dynamic_cast<const mfem::L2_FECollection *>(fes->FEColl()) || fes->GetVDim() != 1)
53  mooseError("MFEMComplexInnerProductAux requires the target variable to be scalar L2.");
54 
55  // Must have no shared/constrained DOFs (pure interior DOFs)
56  if (fes->GetTrueVSize() != fes->GetVSize())
57  mooseError("MFEMComplexInnerProductAux currently supports only L2 spaces with interior DOFs "
58  "(no shared/constrained DOFs).");
59 }
60 
61 void
63 {
64  _result_var.ProjectCoefficient(_final_coef_real, _final_coef_imag);
65 
67 }
68 
69 #endif // MOOSE_MFEM_ENABLED
Project onto a complex scalar MFEM auxvariable.
void execute() override
Perform the main work for this object.
registerMooseObject("MooseApp", MFEMComplexInnerProductAux)
const std::complex< mfem::real_t > _scale_factor
Scaling factor applied on the resulting field.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
void complexScale(mfem::ParComplexGridFunction &a, const std::complex< mfem::real_t > scale={1.0, 0.0})
Method to scale a complex variable by a complex constant.
MFEMComplexInnerProductAux(const InputParameters &parameters)
mfem::ParComplexGridFunction & _result_var
Reference to result complex gridfunction.
mfem::SumCoefficient _final_coef_real
Final coefficient that sums the inner product terms.
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
static InputParameters validParams()
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 complex auxvariable.