Line data Source code
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 : #pragma once 13 : #include "MFEMAuxKernel.h" 14 : 15 : /** 16 : * AuxKernel to compute a running time average of an MFEMVariable 17 : * using a linear blend. 18 : * 19 : * avg_new(x) = (1 - w) * avg_old(x) + w * src(x), w = dt / (t - s), t > s 20 : */ 21 : class MFEMScalarTimeAverageAux : public MFEMAuxKernel 22 : { 23 : public: 24 : static InputParameters validParams(); 25 : 26 : MFEMScalarTimeAverageAux(const InputParameters & parameters); 27 : 28 14 : virtual ~MFEMScalarTimeAverageAux() override = default; 29 : 30 : /// Computes the auxvariable. 31 : virtual void execute() override; 32 : 33 : protected: 34 : /// Name of source MFEMVariable to take the time average of. 35 : const VariableName _source_var_name; 36 : /// Reference to source gridfunction coefficient. 37 : mfem::Coefficient & _source_var_coefficient; 38 : /// Reference to result gridfunction coefficient. 39 : mfem::Coefficient & _result_var_coefficient; 40 : /// Placeholder gridfunction to avoid read/write aliasing during projection. 41 : mfem::ParGridFunction _average_var; 42 : /// Time before the averaging starts. 43 : const Real & _skip; 44 : /// The current time. 45 : const Real & _time; 46 : /// Time step size. 47 : const Real & _dt; 48 : }; 49 : 50 : #endif