https://mooseframework.inl.gov
IntegralPreservingFunctionIC.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 
11 #include "Function.h"
12 #include "UserObject.h"
13 
15 
18 {
20  params.addRequiredParam<PostprocessorName>(
21  "integral", "Postprocessor providing the integral of the function, for normalization");
22  params.addRequiredParam<Real>("magnitude",
23  "Desired magnitude of the initial condition upon integration");
24  params.addClassDescription("Function initial condition that preserves an integral");
25  return params;
26 }
27 
29  : FunctionIC(parameters),
30  _pp_name(getParam<PostprocessorName>("integral")),
31  _integral(getPostprocessorValue("integral")),
32  _magnitude(getParam<Real>("magnitude"))
33 {
34 }
35 
36 void
38 {
41  mooseError("The 'execute_on' parameter for the '" + _pp_name +
42  "' postprocessor must include 'initial'!");
43 }
44 
45 Real
47 {
49  mooseError("The integral of '" + _pp_name + "' cannot be zero!");
50 
51  return magnitude() * _func.value(_t, p) / _integral;
52 }
Defines an initial condition that forces the value to be a user specified function.
Definition: FunctionIC.h:17
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
Definition: EigenADReal.h:42
T & getUserObject(const std::string &name, unsigned int tid=0) const
Get the user object by its name.
static constexpr Real TOLERANCE
registerMooseObject("MooseApp", IntegralPreservingFunctionIC)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const Function & _func
Function to evaluate to form the initial condition.
Definition: FunctionIC.h:46
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...
Initial conditions specifying an initial condition as a general function while preserving a total int...
IntegralPreservingFunctionIC(const InputParameters &parameters)
const ExecFlagEnum & getExecuteOnEnum() const
Return the execute on MultiMooseEnum for this object.
const PostprocessorValue & _integral
Integral of the function.
static InputParameters validParams()
Definition: FunctionIC.C:16
bool isValueSet(const std::string &value) const
Methods for seeing if a value is set in the MultiMooseEnum.
const PostprocessorName & _pp_name
Name of postprocessor providing the integral of the function.
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
virtual Real value(const Point &p) override
The value of the variable at a point.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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 Real value(Real t, const Point &p) const
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
Definition: Function.C:44
Base class for user-specific data.
Definition: UserObject.h:40
const ExecFlagType EXEC_INITIAL
Definition: Moose.C:28