https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
36void
38{
41 mooseError("The 'execute_on' parameter for the '" + _pp_name +
42 "' postprocessor must include 'initial'!");
43}
44
45Real
47{
48 if (std::abs(_integral) < libMesh::TOLERANCE)
49 mooseError("The integral of '" + _pp_name + "' cannot be zero!");
50
51 return magnitude() * _func.value(_t, p) / _integral;
52}
registerMooseObject("MooseApp", IntegralPreservingFunctionIC)
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
T & getUserObject(const std::string &name, unsigned int tid=0) const
Get the user object by its name.
Defines an initial condition that forces the value to be a user specified function.
Definition FunctionIC.h:18
const Function & _func
Function to evaluate to form the initial condition.
Definition FunctionIC.h:46
static InputParameters validParams()
Definition FunctionIC.C:16
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:30
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
Initial conditions specifying an initial condition as a general function while preserving a total int...
IntegralPreservingFunctionIC(const InputParameters &parameters)
const PostprocessorName & _pp_name
Name of postprocessor providing the integral of the function.
virtual Real value(const Point &p) override
The value of the variable at a point.
const PostprocessorValue & _integral
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.
bool isValueSet(const std::string &value) const
Methods for seeing if a value is set in the MultiMooseEnum.
const ExecFlagEnum & getExecuteOnEnum() const
Return the execute on MultiMooseEnum for this object.
Base class for user-specific data.
Definition UserObject.h:20
static constexpr Real TOLERANCE