https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMGradAux.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 "MFEMGradAux.h"
13#include "MFEMProblem.h"
14
16
19{
22 "Calculates the gradient of an H1 conforming source variable and stores the result"
23 " on an H(curl) conforming ND result auxvariable");
24 MFEMExecutedObject::addRequiredDependencyParam<VariableName>(
25 params, "source", "Scalar H1 MFEMVariable to take the gradient of.");
26 params.addParam<mfem::real_t>("scale_factor", 1.0, "Factor to scale result auxvariable by.");
27 return params;
28}
29
31 : MFEMAuxKernel(parameters),
32 _source_var_name(getParam<VariableName>("source")),
33 _source_var(*getMFEMProblem().getGridFunction(_source_var_name)),
34 _scale_factor(getParam<mfem::real_t>("scale_factor")),
35 _grad(_source_var.ParFESpace(), _result_var.ParFESpace())
36{
37 _sequence = _source_var.GetSequence() + _result_var.GetSequence();
38 _grad.Assemble();
39 _grad.Finalize();
40}
41
42// Computes the auxvariable.
43void
49
50void
52{
53 if (long sequence = _source_var.GetSequence() + _result_var.GetSequence() > _sequence)
54 {
55 _sequence = sequence;
56 _grad.Update();
57 _grad.Assemble();
58 _grad.Finalize();
59 }
60}
61
62#endif
registerMooseObject("MooseApp", MFEMGradAux)
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 real auxvariable.
static InputParameters validParams()
long _sequence
Counter to keep track of FE space updates.
mfem::ParGridFunction & _result_var
Reference to result gridfunction.
Class to set an H(curl) auxvariable to be the gradient of a H1 scalar variable.
Definition MFEMGradAux.h:23
const mfem::real_t _scale_factor
Scalar factor to multiply the result by.
Definition MFEMGradAux.h:43
static InputParameters validParams()
Definition MFEMGradAux.C:18
virtual void execute() override
Computes the auxvariable.
Definition MFEMGradAux.C:44
virtual void update() override
Method called to update any owned objects upon an FE space update.
Definition MFEMGradAux.C:51
mfem::common::ParDiscreteGradOperator _grad
Grad operator.
Definition MFEMGradAux.h:45
MFEMGradAux(const InputParameters &parameters)
Definition MFEMGradAux.C:30
const mfem::ParGridFunction & _source_var
Reference to source gridfunction.
Definition MFEMGradAux.h:41