https://mooseframework.inl.gov
MFEMScalarTimeAverageAux.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  "Calculates a running time average of a scalar MFEM variable projected onto an auxvariable");
23  params.addRequiredParam<VariableName>("source", "Scalar MFEMVariable to take the average of.");
24  params.addParam<mfem::real_t>("time_skip", 0.0, "Time to skip before beginning the average.");
25 
26  return params;
27 }
28 
30  : MFEMAuxKernel(parameters),
31  _source_var_name(getParam<VariableName>("source")),
32  _source_var_coefficient(getScalarCoefficientByName(_source_var_name)),
33  _result_var_coefficient(getScalarCoefficientByName(_result_var_name)),
34  _average_var(_result_var.ParFESpace()),
35  _skip(getParam<Real>("time_skip")),
36  _time(getMFEMProblem().time()),
37  _dt(getMFEMProblem().dt())
38 {
39 }
40 
41 void
43 {
44  if (_time <= _skip)
45  return;
46 
47  // Linear blend: (1 - w) * avg_old + w * src
48  const mfem::real_t w = _dt / (_time - _skip);
49  mfem::SumCoefficient blend(_result_var_coefficient, _source_var_coefficient, 1.0 - w, w);
50  _average_var.ProjectCoefficient(blend);
51 
53 }
54 
55 #endif
MFEMScalarTimeAverageAux(const InputParameters &parameters)
const Real & _skip
Time before the averaging starts.
virtual void execute() override
Computes the auxvariable.
mfem::Coefficient & _result_var_coefficient
Reference to result gridfunction coefficient.
const Real & _dt
Time step size.
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...
mfem::ParGridFunction & _result_var
Reference to result gridfunction.
Definition: MFEMAuxKernel.h:36
Class to construct an auxiliary solver used to update an auxvariable.
Definition: MFEMAuxKernel.h:20
const Real & _time
The current time.
static InputParameters validParams()
Definition: MFEMAuxKernel.C:16
AuxKernel to compute a running time average of an MFEMVariable using a linear blend.
static InputParameters validParams()
registerMooseObject("MooseApp", MFEMScalarTimeAverageAux)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
mfem::ParGridFunction _average_var
Placeholder gridfunction to avoid read/write aliasing during projection.
mfem::Coefficient & _source_var_coefficient
Reference to source gridfunction coefficient.
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...