www.mooseframework.org
UserObject.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #ifndef USEROBJECT_H
16 #define USEROBJECT_H
17 
18 // MOOSE includes
19 #include "DistributionInterface.h"
20 #include "FunctionInterface.h"
21 #include "MeshChangedInterface.h"
22 #include "MooseObject.h"
23 #include "MooseTypes.h"
24 #include "Restartable.h"
25 #include "ScalarCoupleable.h"
26 #include "SetupInterface.h"
27 
28 #include "libmesh/parallel.h"
29 
30 // Forward declarations
31 class UserObject;
32 class FEProblemBase;
33 class SubProblem;
34 class Assembly;
35 
36 template <>
38 
42 class UserObject : public MooseObject,
43  public SetupInterface,
44  public FunctionInterface,
45  public DistributionInterface,
46  public Restartable,
47  public MeshChangedInterface,
48  public ScalarCoupleable
49 {
50 public:
51  UserObject(const InputParameters & params);
52  virtual ~UserObject();
53 
57  virtual void execute() = 0;
58 
62  virtual void initialize() = 0;
63 
68  virtual void finalize() = 0;
69 
74  virtual void load(std::ifstream & stream);
75 
80  virtual void store(std::ofstream & stream);
81 
86  SubProblem & getSubProblem() const { return _subproblem; }
87 
93 
99  virtual Real spatialValue(const Point & /*p*/) const
100  {
101  mooseError(name(), " does not satisfy the Spatial UserObject interface!");
102  }
103 
110  virtual void threadJoin(const UserObject & uo) = 0;
111 
118  template <typename T>
119  void gatherSum(T & value)
120  {
121  _communicator.sum(value);
122  }
123 
124  template <typename T>
125  void gatherMax(T & value)
126  {
127  _communicator.max(value);
128  }
129 
130  template <typename T>
131  void gatherMin(T & value)
132  {
133  _communicator.min(value);
134  }
135 
136  template <typename T1, typename T2>
137  void gatherProxyValueMax(T1 & value, T2 & proxy)
138  {
139  unsigned int rank;
140  _communicator.maxloc(value, rank);
141  _communicator.broadcast(proxy, rank);
142  }
143 
144 protected:
147 
150 
154 
157 
159 };
160 
161 #endif /* USEROBJECT_H */
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:47
virtual void load(std::ifstream &stream)
Load user data object from a stream.
Definition: UserObject.C:73
const bool _duplicate_initial_execution
Definition: UserObject.h:158
virtual void store(std::ofstream &stream)
Store user data object to a stream.
Definition: UserObject.C:78
void gatherProxyValueMax(T1 &value, T2 &proxy)
Definition: UserObject.h:137
A class for creating restricted objects.
Definition: Restartable.h:31
Assembly & _assembly
Definition: UserObject.h:153
Keeps track of stuff related to assembling.
Definition: Assembly.h:63
void gatherMax(T &value)
Definition: UserObject.h:125
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void gatherMin(T &value)
Definition: UserObject.h:131
THREAD_ID _tid
Thread ID of this postprocessor.
Definition: UserObject.h:152
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
SubProblem & _subproblem
Reference to the Subproblem for this user object.
Definition: UserObject.h:146
virtual void execute()=0
Execute method.
Interface for notifications that the mesh has changed.
void gatherSum(T &value)
Gather the parallel sum of the variable passed in.
Definition: UserObject.h:119
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:36
InputParameters validParams< UserObject >()
Definition: UserObject.C:23
Interface for objects that need to use distributions.
virtual void initialize()=0
Called before execute() is ever called so that data can be cleared.
CoordinateSystemType
Definition: MooseTypes.h:212
virtual ~UserObject()
Definition: UserObject.C:70
const Moose::CoordinateSystemType & _coord_sys
Coordinate system.
Definition: UserObject.h:156
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:53
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
Definition: UserObject.h:149
UserObject(const InputParameters &params)
Definition: UserObject.C:53
bool shouldDuplicateInitialExecution() const
Returns whether or not this user object should be executed twice during the initial condition when de...
Definition: UserObject.h:92
virtual void finalize()=0
Finalize.
Interface for objects that needs scalar coupling capabilities.
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
SubProblem & getSubProblem() const
Returns a reference to the subproblem that this postprocessor is tied to.
Definition: UserObject.h:86
Interface for objects that need to use functions.
Base class for user-specific data.
Definition: UserObject.h:42
unsigned int THREAD_ID
Definition: MooseTypes.h:79
virtual Real spatialValue(const Point &) const
Optional interface function for "evaluating" a UserObject at a spatial position.
Definition: UserObject.h:99
virtual void threadJoin(const UserObject &uo)=0
Must override.