https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMComplexDivAux.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 "MFEMComplexDivAux.h"
13#include "MFEMProblem.h"
14
16
19{
21 params.addClassDescription("Calculates the divergence of a complex H(div) conforming RT source "
22 "variable and stores the result"
23 " on an L2 conforming result complex auxvariable");
24 MFEMExecutedObject::addRequiredDependencyParam<VariableName>(
25 params, "source", "Vector H(div) MFEMComplexVariable to take the divergence of.");
26 params.addParam<mfem::real_t>(
27 "scale_factor_real", 1.0, "Real part of the factor to scale result auxvariable by.");
28 params.addParam<mfem::real_t>(
29 "scale_factor_imag", 0.0, "Imaginary part of the factor to scale result auxvariable by.");
30
31 return params;
32}
33
35 : MFEMComplexAuxKernel(parameters),
36 _source_var_name(getParam<VariableName>("source")),
37 _source_var(*getMFEMProblem().getComplexGridFunction(_source_var_name)),
38 _scale_factor(getParam<mfem::real_t>("scale_factor_real"),
39 getParam<mfem::real_t>("scale_factor_imag")),
40 _div(_source_var.ParFESpace(), _result_var.ParFESpace())
41{
42 _sequence = _source_var.GetSequence() + _result_var.GetSequence();
43 _div.Assemble();
44 _div.Finalize();
45}
46
47// Computes the auxvariable.
48void
50{
51 update();
52 _div.AddMult(_source_var.real(), _result_var.real() = 0);
53 _div.AddMult(_source_var.imag(), _result_var.imag() = 0);
54
56}
57
58void
60{
61 if (long sequence = _source_var.GetSequence() + _result_var.GetSequence() > _sequence)
62 {
63 _sequence = sequence;
64 _div.Update();
65 _div.Assemble();
66 _div.Finalize();
67 }
68}
69
70#endif
registerMooseObject("MooseApp", MFEMComplexDivAux)
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 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.
mfem::ParComplexGridFunction & _result_var
Reference to result complex gridfunction.
long _sequence
Counter to keep track of FE space updates.
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.
static InputParameters validParams()
Class to set an L2 auxvariable to be the divergence of an H(div) vector variable.
virtual void execute() override
Computes the auxvariable.
const std::complex< mfem::real_t > _scale_factor
Scalar factor to multiply the result by.
mfem::ParComplexGridFunction & _source_var
Reference to source gridfunction.
static InputParameters validParams()
MFEMComplexDivAux(const InputParameters &parameters)
mfem::common::ParDiscreteDivOperator _div
Divergence operator.
virtual void update() override
Method called to update any owned objects upon an FE space update.