https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
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
41void
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}
registerMooseObject("MooseApp", FunctorTimes)
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_TIMESTEP_BEGIN
Definition Moose.C:37
A MultiMooseEnum object to hold "execute_on" flags.
virtual MooseMesh & mesh() override
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...
Times created by evaluating a functor.
const Moose::Functor< Real > & _functor
Functor to evaluate the time to append to the Times vector.
virtual void initialize() override
In charge of computing / loading the times, unless all that could be done there is done in the constr...
static InputParameters validParams()
FunctorTimes(const InputParameters &parameters)
const Moose::Functor< Real > & _factor
Factor to multiply the functor with.
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.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
const std::string & type() const
Get the type of this class.
Definition MooseBase.h:93
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3549
void errorIfDistributedMesh(std::string name) const
Generate a unified error message if the underlying libMesh mesh is a DistributedMesh.
Definition MooseMesh.C:3718
An interface for accessing Moose::Functors for systems that do not care about automatic differentiati...
static InputParameters validParams()
Times objects are under the hood Reporters, but limited to a vector of Real.
Definition Times.h:19
static InputParameters validParams()
Definition Times.C:14
std::vector< Real > & _times
The vector holding the times.
Definition Times.h:74
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
A structure that is used to evaluate Moose functors logically at an element/cell center.