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 coefficient projected onto an auxvariable");
23  params.addRequiredParam<MFEMScalarCoefficientName>("source", "Scalar coefficient to average");
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_coefficient(getScalarCoefficient("source")),
32  _result_coefficient(getScalarCoefficientByName(_result_var_name)),
33  _average_var(_result_var.ParFESpace()),
34  _skip(getParam<Real>("time_skip")),
35  _time(getMFEMProblem().time()),
36  _dt(getMFEMProblem().dt())
37 {
38 }
39 
40 void
42 {
43  if (_time <= _skip)
44  return;
45 
46  // Linear blend: (1 - w) * avg_old + w * src
47  const mfem::real_t w = _dt / (_time - _skip);
48  mfem::SumCoefficient blend(_result_coefficient, _source_coefficient, 1.0 - w, w);
49  _average_var.ProjectCoefficient(blend);
50 
52 }
53 
54 #endif
MFEMScalarTimeAverageAux(const InputParameters &parameters)
const Real & _skip
Time before the averaging starts.
virtual void execute() override
Computes the auxvariable.
mfem::Coefficient & _result_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:38
mfem::Coefficient & _source_coefficient
Reference to source coefficient.
Class to construct an auxiliary solver used to update a real 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 a scalar coefficient 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.
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...