Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
FunctorTimes.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 "FunctorTimes.h"
11 
13 
16 {
19  params.addClassDescription(
20  "Times created by evaluating a functor at the (0,0,0) point and the current time");
21 
22  params.addRequiredParam<MooseFunctorName>("functor", "Functor to evaluate to provide the time");
23  params.addParam<MooseFunctorName>("factor", 1, "Factor to multiply the evaluated time with");
24 
25  // Times are known for all processes already
26  params.set<bool>("auto_broadcast") = false;
27  // Timestep_begin seems like a decent default here
28  params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_BEGIN;
29 
30  return params;
31 }
32 
34  : Times(parameters),
36  _functor(getFunctor<Real>("functor")),
37  _factor(getFunctor<Real>("factor"))
38 {
39 }
40 
41 void
43 {
45  // Locate the origin on the mesh
46  Point p(0, 0, 0);
47  auto pl = _fe_problem.mesh().getMesh().sub_point_locator();
48  auto * elem = (*pl)(p);
49  if (!elem)
50  mooseError("Origin point not in local mesh, cannot evaluate the functor there");
51  Moose::ElemArg elem_origin = makeElemArg(elem);
52 
53  const auto t = determineState();
54  // Initialize is by default what is called by ::execute()
55  _times.push_back(_factor(elem_origin, t) * _functor(elem_origin, t));
56  // if this is performed multiple times (fixed point iterations, similar results at various
57  // execution flags) it will be caught by our logic to make the vector hold unique times
58 }
An interface for accessing Moose::Functors for systems that do not care about automatic differentiati...
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
const Moose::Functor< Real > & _factor
Factor to multiply the functor with.
Definition: FunctorTimes.h:33
FunctorTimes(const InputParameters &parameters)
Definition: FunctorTimes.C:33
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
Times objects are under the hood Reporters, but limited to a vector of Real.
Definition: Times.h:18
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...
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
Helper method to create an elemental argument for a functor that includes whether to perform skewness...
void errorIfDistributedMesh(std::string name) const
Generate a unified error message if the underlying libMesh mesh is a DistributedMesh.
Definition: MooseMesh.C:3586
virtual void initialize() override
In charge of computing / loading the times, unless all that could be done there is done in the constr...
Definition: FunctorTimes.C:42
static InputParameters validParams()
Definition: Times.C:14
static InputParameters validParams()
Definition: FunctorTimes.C:15
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3417
const ExecFlagType EXEC_TIMESTEP_BEGIN
Definition: Moose.C:34
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:51
A structure that is used to evaluate Moose functors logically at an element/cell center.
registerMooseObject("MooseApp", FunctorTimes)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
Definition: UserObject.h:209
virtual MooseMesh & mesh() override
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
Times created by evaluating a functor.
Definition: FunctorTimes.h:19
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...
static InputParameters validParams()
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...
const Moose::Functor< Real > & _functor
Functor to evaluate the time to append to the Times vector.
Definition: FunctorTimes.h:31
std::vector< Real > & _times
The vector holding the times.
Definition: Times.h:72