https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
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
40void
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
registerMooseObject("MooseApp", MFEMScalarTimeAverageAux)
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 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...
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()
mfem::ParGridFunction & _result_var
Reference to result gridfunction.
AuxKernel to compute a running time average of a scalar coefficient using a linear blend.
mfem::Coefficient & _result_coefficient
Reference to result gridfunction coefficient.
const Real & _time
The current time.
mfem::Coefficient & _source_coefficient
Reference to source coefficient.
const Real & _skip
Time before the averaging starts.
virtual void execute() override
Computes the auxvariable.
mfem::ParGridFunction _average_var
Placeholder gridfunction to avoid read/write aliasing during projection.
const Real & _dt
Time step size.
static InputParameters validParams()
MFEMScalarTimeAverageAux(const InputParameters &parameters)