https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMElementAverageValue.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 MFEMExecutedObject::addRequiredDependencyParam<VariableName>(
23 params, "variable", "Name of the scalar variable to average.");
24 params.addClassDescription("Computes the volumetric average of a scalar MFEM variable.");
25 return params;
26}
27
29 : MFEMPostprocessor(parameters),
30 MFEMBlockRestrictable(parameters,
31 getMFEMProblem().getMFEMVariableMesh(getParam<VariableName>("variable"))),
32 _var(*getMFEMProblem().getGridFunction(getParam<VariableName>("variable"))),
33 _one(1.0),
34 _lf(_var.ParFESpace())
35{
37 _lf.AddDomainIntegrator(new mfem::DomainLFIntegrator(_one), getSubdomainMarkers());
38 else
39 _lf.AddDomainIntegrator(new mfem::DomainLFIntegrator(_one));
40}
41
42void
44{
45 _lf.Assemble();
46
47 const mfem::real_t integral = _lf(_var);
48
49 // Compute the volume of the domain (or restricted subdomains) by integrating
50 // the constant 1 projected onto the variable's FE space.
51 mfem::ParGridFunction ones(_var.ParFESpace());
52 ones.ProjectCoefficient(_one);
53 const mfem::real_t volume = _lf(ones);
54
55 _value = integral / volume;
56}
57
60{
61 return _value;
62}
63
64#endif
registerMooseObject("MooseApp", MFEMElementAverageValue)
Real PostprocessorValue
various MOOSE typedefs
Definition MooseTypes.h:230
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
Base class for construction of an object that is restricted to a subset of subdomains of the problem ...
static InputParameters validParams()
bool isSubdomainRestricted()
Returns a bool indicating if the object is restricted to a subset of subdomains.
mfem::Array< int > & getSubdomainMarkers()
Computes the volumetric average of a scalar MFEM variable over the mesh or a subset of subdomains.
mfem::ParGridFunction & _var
Reference to the MFEM grid function whose average is being computed.
mfem::ParLinearForm _lf
Linear form used to accumulate the integral of the variable over elements.
PostprocessorValue getValue() const override final
This will get called to actually grab the final value the postprocessor has calculated.
static InputParameters validParams()
mfem::real_t _value
Cached computed average value returned by getValue()
mfem::ConstantCoefficient _one
Constant coefficient of value 1 used in integration for volume calculation.
MFEMElementAverageValue(const InputParameters &parameters)
void execute() override
Perform the main work for this object.
Postprocessor for MFEM results.
static InputParameters validParams()