https://mooseframework.inl.gov
AverageVariableChange.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 #include "AverageVariableChange.h"
11 #include "MooseUtils.h"
12 
14 
17 {
19 
20  params.addClassDescription("Computes the volume-weighted L1 or L2 norm of the change of a "
21  "variable over a time step or between nonlinear iterations.");
22 
23  MooseEnum change_over("time_step nonlinear_iteration");
25  "change_over", change_over, "Interval over which to compute the change");
26 
27  MooseEnum norm("L1 L2");
28  params.addRequiredParam<MooseEnum>("norm", norm, "Type of norm to compute");
29 
30  return params;
31 }
32 
35  _change_over(getParam<MooseEnum>("change_over")),
36  _u_change_old(_change_over == "time_step" ? coupledValueOld("variable")
37  : coupledValuePreviousNL("variable")),
38  _norm(getParam<MooseEnum>("norm")),
39  _norm_exponent(_norm == "L1" ? 1 : 2),
40  _volume(0)
41 {
42 }
43 
44 void
46 {
48  _volume = 0;
49 }
50 
51 void
53 {
56 }
57 
58 void
60 {
62  const auto & pps = static_cast<const AverageVariableChange &>(y);
63  _volume += pps._volume;
64 }
65 
66 void
68 {
71 }
72 
73 Real
75 {
76  mooseAssert(!MooseUtils::absoluteFuzzyEqual(_volume, 0.0), "Volume must be nonzero.");
78 }
79 
80 Real
82 {
84 }
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
Definition: EigenADReal.h:42
virtual void finalize() override
This is called after execute() and after threadJoin()! This is probably where you want to do MPI comm...
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
Definition: MooseUtils.h:380
This postprocessor computes a volume integral of the specified variable.
const VariableValue & _u_change_old
"Old" solution value in the change
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const Real & _current_elem_volume
The current element volume (available during execute())
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...
virtual void threadJoin(const UserObject &y) override
Must override.
static InputParameters validParams()
void gatherSum(T &value)
Gather the parallel sum of the variable passed in.
Definition: UserObject.h:126
virtual void execute() override
Execute method.
const VariableValue & _u
Holds the solution at current quadrature points.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
auto norm(const T &a) -> decltype(std::abs(a))
virtual void execute() override
Execute method.
virtual Real computeQpIntegral() override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
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...
virtual void threadJoin(const UserObject &y) override
Must override.
registerMooseObject("MooseApp", AverageVariableChange)
Real _volume
Subdomain(s) volume.
const unsigned int _norm_exponent
Norm exponent.
MooseUnits pow(const MooseUnits &, int)
Definition: Units.C:537
Computes the volume-weighted L1 or L2 norm of the change of a variable over a time step or between no...
AverageVariableChange(const InputParameters &parameters)
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
Base class for user-specific data.
Definition: UserObject.h:40