https://mooseframework.inl.gov
DomainUserObject.h
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 #pragma once
11 
12 // MOOSE includes
13 #include "UserObject.h"
14 #include "BlockRestrictable.h"
17 #include "TransientInterface.h"
18 #include "RandomInterface.h"
19 #include "ElementIDInterface.h"
20 #include "MooseError.h"
21 
23 
24 namespace libMesh
25 {
26 class Elem;
27 class QBase;
28 }
29 
43  public BlockRestrictable,
46  public TransientInterface,
47  public RandomInterface,
48  public ElementIDInterface
49 {
50 public:
52 
54 
55  void execute() override final;
56 
60  virtual void executeOnElement() {}
61 
65  virtual void executeOnBoundary() {}
66 
70  virtual void executeOnInternalSide() {}
71 
75  virtual void executeOnExternalSide(const Elem * /*elem*/, unsigned int /*side*/) {}
76 
80  virtual void executeOnInterface() {}
81 
85  void preExecuteOnElement();
86 
90  void preExecuteOnBoundary();
91 
96 
100  void preExecuteOnInterface();
101 
105  bool shouldExecuteOnInterface() const;
106 
107  void checkVariable(const MooseVariableFieldBase & variable) const override;
108 
109 protected:
110  const MooseArray<Point> & qPoints() const { return *_current_q_point; }
111  const QBase & qRule() const { return *_current_q_rule; }
112  const MooseArray<Real> & JxW() const { return *_current_JxW; }
113  const MooseArray<Real> & coord() const { return _coord; }
114  const MooseArray<Point> & normals() const { return _normals; }
115 
127  const MooseVariableFieldBase *
128  getInterfaceFieldVar(const std::string & var_name,
129  unsigned int comp,
130  const std::set<BoundaryID> * interfaces = nullptr);
131 
134 
136  const Elem * const & _current_elem;
137 
140 
143  const unsigned int & _current_side;
144 
147  const Elem * const & _current_side_elem;
148 
152 
154  const Elem * const & _neighbor_elem;
155 
159 
162 
166 
168  std::set<BoundaryID> _interface_bnd_ids;
169 
171  std::map<BoundaryID, std::set<SubdomainID>> _interface_connected_blocks;
172 
173 private:
174  void setVolumeData();
175 
176  void setFaceData();
177 
181  const QBase * _current_q_rule;
184 
188  const QBase * const & _qrule;
191 
195  const QBase * const & _qrule_face;
198 
202 
204  std::map<VariableName, std::set<BoundaryID>> _var_interfaces;
205 };
206 
207 inline void
209 {
210  mooseError("Users of DomainUserObjects should call "
211  "executeOnElement/executeOnBoundary/executeOnInternalSide");
212 }
213 
214 inline void
216 {
217  setVolumeData();
218 }
219 
220 inline void
222 {
223  setFaceData();
224 }
225 
226 inline void
228 {
229  setFaceData();
230 }
231 
232 inline void
234 {
235  setFaceData();
236 }
237 
238 inline void
240 {
243  _current_JxW = &_JxW;
244 }
245 
246 inline void
248 {
252 }
253 
254 inline bool
256 {
258 }
Interface for objects that need parallel consistent random numbers without patterns over the course o...
const MooseArray< Point > & _q_point_face
The quadrature points in physical space used on the element side/face.
DomainUserObject(const InputParameters &parameters)
MooseMesh & _mesh
the Moose mesh
void execute() override final
Execute method.
bool shouldExecuteOnInterface() const
Return whether this object should run executeOnInterface.
Intermediate base class that ties together all the interfaces for getting MooseVariables with the Moo...
std::map< BoundaryID, std::set< SubdomainID > > _interface_connected_blocks
The set of blocks connected to our blocks through boundaries of the _interface_bnd_ids data member...
virtual void executeOnElement()
execute method that is called during ComputeUserObjects::onElement
const Elem *const & _neighbor_elem
The neighboring element (available during executeOnInternalSide() and executeOnInterface()) ...
const MooseArray< Real > & coord() const
const Real & _current_elem_volume
The current element volume (available during all execute functions)
const MooseArray< Point > & normals() const
std::map< VariableName, std::set< BoundaryID > > _var_interfaces
A map storing the set of boundaries where variables we wish to evaluate.
const MooseVariableFieldBase * getInterfaceFieldVar(const std::string &var_name, unsigned int comp, const std::set< BoundaryID > *interfaces=nullptr)
Routes through to Coupleable::getFieldVar, but also inserts the return variable into a set of field v...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const MooseArray< Real > & _JxW
The elemental Jacobian times quadrature weights in the element interior.
This class provides an interface for common operations on field variables of both FE and FV types wit...
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
const Real & _current_side_volume
Current side volume (available during executeOnInternalSide() and executeOnBoundary() and executeOnIn...
This user object allows related evaluations on elements, boundaries, internal sides, interfaces in one single place.
std::set< BoundaryID > _interface_bnd_ids
The set of boundary IDs on which this object should perform executeOnInterface.
const MooseArray< Real > & _coord
An array representing coordinate system volume modifications.
const MooseArray< Real > & _JxW_face
The side element Jacobian times quadrature weights on the element side/face.
const MooseArray< Point > & _normals
The unit norm at quadrature points on the element side/face from the current element perpendicular to...
virtual void executeOnInternalSide()
execute method that is called during ComputeUserObjects::onInternalSide
Interface for objects that needs transient capabilities.
const Elem *const & _current_side_elem
Current side of the current element (available during executeOnInternalSide() and executeOnBoundary()...
void preExecuteOnInterface()
method that is called right before executeOnInterface; sets the data to face
boundary_id_type BoundaryID
const MooseArray< Real > * _current_JxW
A pointer to the current JxW.
const MooseArray< Point > * _current_q_point
A pointer to the current volume/face quadrature points.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
static InputParameters validParams()
const MooseArray< Point > & qPoints() const
const Elem *const & _current_elem
The current element pointer (available during all execute functions)
void checkVariable(const MooseVariableFieldBase &variable) const override
Helper for checking that the ids for this object are in agreement with the variables on the supplied ...
const QBase * _current_q_rule
A pointer to the current volume/face quadrature rule.
This interface is designed currently for DomainUserObject where material properties on element...
void preExecuteOnBoundary()
method that is called right before executeOnBoundary; sets the data to face
const QBase *const & _qrule
The quadrature rule used in the element interior.
const MooseArray< Real > & JxW() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.
void preExecuteOnElement()
method that is called right before executeOnElement; sets the data to volumetric
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const InputParameters & parameters() const
Get the parameters of the object.
const unsigned int & _current_side
Current side of the current element (available during executeOnInternalSide() and executeOnBoundary()...
const QBase *const & _qrule_face
The quadrature rule used on the element side/face.
const MooseArray< Point > & _q_point
The quadrature points in physical space used in the element interior.
virtual void executeOnInterface()
execute method that is called during ComputeUserObjects::onInterface
const QBase & qRule() const
virtual void executeOnExternalSide(const Elem *, unsigned int)
execute method that is called during ComputeUserObjects::onExternalSide
const BoundaryID & _current_boundary_id
The boundary ID (available during executeOnBoundary() and executeOnInterface())
const Real & _current_neighbor_volume
the neighboring element&#39;s volume (available during executeOnInternalSide() and executeOnInterface()) ...
Base class for user-specific data.
Definition: UserObject.h:40
void preExecuteOnInternalSide()
method that is called right before executeOnInternalSide; sets the data to face
virtual void executeOnBoundary()
execute method that is called during ComputeUserObjects::onBoundary