https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ChangeOverFixedPointPostprocessor.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// moose includes
12#include "Transient.h"
13
15
18{
20
21 params.addRequiredParam<PostprocessorName>("postprocessor", "The name of the postprocessor");
22 params.addParam<bool>("change_with_respect_to_initial",
23 false,
24 "Compute change with respect to value at the beginning of the FixedPoint "
25 "iterations instead of previous value");
26 params.addParam<bool>(
27 "compute_relative_change", false, "Compute magnitude of relative change instead of change");
28 params.addParam<bool>("take_absolute_value", false, "Option to take absolute value of change");
29
30 params.addClassDescription("Computes the change or relative change in a post-processor value "
31 "over a single or multiple fixed point iterations");
32
33 return params;
34}
35
37 const InputParameters & parameters)
38 : GeneralPostprocessor(parameters),
39 _change_with_respect_to_initial(getParam<bool>("change_with_respect_to_initial")),
40 _compute_relative_change(getParam<bool>("compute_relative_change")),
41 _take_absolute_value(getParam<bool>("take_absolute_value")),
42 _pps_value(getPostprocessorValue("postprocessor")),
43 _pps_value_old(0),
44 _pps_value_initial(declareRestartableData<Real>("pps_value_initial")),
45 _t_step_old(-1),
46 _value(0.0)
47{
49 {
50 // ensure dependent post-processor is executed on initial
51 const PostprocessorName & pp_name = getParam<PostprocessorName>("postprocessor");
52 const UserObject & pp = _fe_problem.getUserObject<UserObject>(pp_name);
54 mooseError("When 'change_with_respect_to_initial' is specified to be true, 'execute_on' for "
55 "the dependent post-processor ('" +
56 pp_name + "') must include 'initial'");
57
58 // ensure THIS post-processor is executed on initial
60 mooseError("When 'change_with_respect_to_initial' is specified to be true, 'execute_on' for "
61 "the ChangeOverFixedPointPostprocessor ('" +
62 name() + "') must include 'initial'");
63 }
64}
65
66void
70
71void
75
76void
78{
79 // detect the beginning of a new FixedPoint iteration process
80 // it can either a new time step or a failed time step
81 bool new_time_step = false;
83 {
84 // new time step
85 if (_t_step != _t_step_old)
86 {
87 new_time_step = true;
89
90 // copy initial value in case difference is measured against initial value
91 // or for a reset if the time step fails
93 }
94 // failed time step
95 else
97 }
98
99 // determine value which change is measured against
100 Real base_value;
102 base_value = _pps_value_initial;
103 else
104 {
105 // for a new time step, initial value is the reference
106 if (new_time_step)
107 base_value = _pps_value_initial;
108 else
109 base_value = _pps_value_old;
110 }
111
112 // Update previous value
114
115 // compute change in value
116 Real change;
118 change = (_pps_value - base_value) / base_value;
119 else
120 change = _pps_value - base_value;
121
123 _value = std::fabs(change);
124 else
125 _value = change;
126}
127
128Real
registerMooseObject("MooseApp", ChangeOverFixedPointPostprocessor)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const ExecFlagType EXEC_INITIAL
Definition Moose.C:30
Computes the change in a post-processor value, or the magnitude of its relative change,...
ChangeOverFixedPointPostprocessor(const InputParameters &parameters)
Real _value
The value of this post-processor.
const bool _compute_relative_change
option to compute the magnitude of relative change instead of change
const PostprocessorValue & _pps_value
current post-processor value
Real _pps_value_old
post-processor value at the previous fixed point iteration
const bool _take_absolute_value
option to take the absolute value of the change
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
Real & _pps_value_initial
initial post-processor value
virtual void execute() override
Execute method.
virtual void finalize() override
This is called after execute() and after threadJoin()! This is probably where you want to do MPI comm...
const bool _change_with_respect_to_initial
option to compute change with respect to initial value instead of previous time value
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
FixedPointSolve & fixedPointSolve()
T & getUserObject(const std::string &name, unsigned int tid=0) const
Get the user object by its name.
unsigned int numFixedPointIts() const
Get the number of fixed point iterations performed Because this returns the number of fixed point ite...
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
static InputParameters validParams()
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.
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition MooseApp.C:2015
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
bool isValueSet(const std::string &value) const
Methods for seeing if a value is set in the MultiMooseEnum.
const ExecFlagEnum & _execute_enum
Execute settings for this object.
const ExecFlagEnum & getExecuteOnEnum() const
Return the execute on MultiMooseEnum for this object.
int & _t_step
The number of the time step.
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
Base class for user-specific data.
Definition UserObject.h:20