https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
24namespace libMesh
25{
26class Elem;
27class QBase;
28}
29
44 public BlockRestrictable,
47 public TransientInterface,
48 public RandomInterface,
50{
51public:
53
55
56 void execute() override final;
57
61 virtual void executeOnElement() {}
62
66 virtual void executeOnBoundary() {}
67
71 virtual void executeOnInternalSide() {}
72
76 virtual void executeOnExternalSide(const Elem * /*elem*/, unsigned int /*side*/) {}
77
81 virtual void executeOnInterface() {}
82
87
92
97
102
108 bool shouldExecuteOnBoundary(bool is_external_side) const;
109
113 bool shouldExecuteOnInterface() const;
114
115 void checkVariable(const MooseVariableBase & variable) const override;
116
117protected:
118 const MooseArray<Point> & qPoints() const { return *_current_q_point; }
119 const QBase & qRule() const { return *_current_q_rule; }
120 const MooseArray<Real> & JxW() const { return *_current_JxW; }
121 const MooseArray<Real> & coord() const { return _coord; }
122 const MooseArray<Point> & normals() const { return _normals; }
123
136 getInterfaceFieldVar(const std::string & var_name,
137 unsigned int comp,
138 const std::set<BoundaryID> * interfaces = nullptr);
139
142
144 const Elem * const & _current_elem;
145
148
151 const unsigned int & _current_side;
152
155 const Elem * const & _current_side_elem;
156
160
162 const Elem * const & _neighbor_elem;
163
167
170
174
176 std::set<BoundaryID> _interface_bnd_ids;
177
179 std::set<BoundaryID> _boundary_execution_ids;
180
183
185 std::map<BoundaryID, std::set<SubdomainID>> _interface_connected_blocks;
186
187private:
188 void setVolumeData();
189
190 void setFaceData();
191
195 const QBase * _current_q_rule;
198
202 const QBase * const & _qrule;
205
209 const QBase * const & _qrule_face;
212
216
218 std::map<VariableName, std::set<BoundaryID>> _var_interfaces;
219};
220
221inline void
223{
224 mooseError("Users of DomainUserObjects should call "
225 "executeOnElement/executeOnBoundary/executeOnInternalSide");
226}
227
228inline void
233
234inline void
239
240inline void
245
246inline void
251
252inline void
259
260inline void
267
268inline bool
269DomainUserObject::shouldExecuteOnBoundary(const bool is_external_side) const
270{
271 // If the current boundary is selected as an interface boundary, executeOnBoundary should not run
272 // on it because it is handled by executeOnInterface.
274 {
275 // An interface boundary must not contain an external side because every interface side must
276 // have a neighbor.
277 if (is_external_side)
278 paramError("interface_boundaries",
279 "Boundary ",
281 " contains an external side, but interface boundaries must contain neighbors.");
282
283 return false;
284 }
285
286 // We execute on a boundary in two cases: (1) when this user object is not boundary restricted,
287 // and (2) when the current boundary ID is selected. We must not require the current side to be
288 // external because executeOnBoundary() is also allowed to run on internal sides, such as a
289 // boundary created by a subdomain split.
291}
292
293inline bool
boundary_id_type BoundaryID
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
An interface that restricts an object to subdomains via the 'blocks' input parameter.
This user object allows related evaluations on elements, boundaries, internal sides,...
std::set< BoundaryID > _interface_bnd_ids
The set of boundary IDs on which this object should perform executeOnInterface.
const MooseArray< Point > & _q_point_face
The quadrature points in physical space used on the element side/face.
const Elem *const & _current_side_elem
Current side of the current element (available during executeOnInternalSide() and executeOnBoundary()...
std::map< VariableName, std::set< BoundaryID > > _var_interfaces
A map storing the set of boundaries where variables we wish to evaluate.
bool shouldExecuteOnInterface() const
Return whether this object should run executeOnInterface.
const MooseArray< Point > & qPoints() const
virtual void executeOnBoundary()
execute method that is called during ComputeUserObjects::onBoundary
const MooseArray< Real > & _JxW
The elemental Jacobian times quadrature weights in the element interior.
const Real & _current_elem_volume
The current element volume (available during all execute functions)
virtual void executeOnExternalSide(const Elem *, unsigned int)
execute method that is called during ComputeUserObjects::onExternalSide
virtual void executeOnElement()
execute method that is called during ComputeUserObjects::onElement
const QBase * _current_q_rule
A pointer to the current volume/face quadrature rule.
bool shouldExecuteOnBoundary(bool is_external_side) const
Return whether this object should run executeOnBoundary on the given side topology.
const QBase *const & _qrule_face
The quadrature rule used on the element side/face.
const MooseArray< Real > & _JxW_face
The side element Jacobian times quadrature weights on the element side/face.
const BoundaryID & _current_boundary_id
The boundary ID (available during executeOnBoundary() and executeOnInterface())
const bool _boundary_restricted
Whether boundary execution is restricted to explicitly selected boundary IDs.
const MooseArray< Real > & coord() const
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.
void checkVariable(const MooseVariableBase &variable) const override
Helper for checking that the ids for this object are in agreement with the variables on the supplied ...
const MooseArray< Point > * _current_q_point
A pointer to the current volume/face quadrature points.
void preExecuteOnElement()
method that is called right before executeOnElement; sets the data to volumetric
const QBase *const & _qrule
The quadrature rule used in the element interior.
const MooseArray< Real > * _current_JxW
A pointer to the current JxW.
const Real & _current_neighbor_volume
the neighboring element's volume (available during executeOnInternalSide() and executeOnInterface())
std::set< BoundaryID > _boundary_execution_ids
The boundary IDs on which this object should perform executeOnBoundary.
const Elem *const & _current_elem
The current element pointer (available during all execute functions)
const Real & _current_side_volume
Current side volume (available during executeOnInternalSide() and executeOnBoundary() and executeOnIn...
const MooseArray< Real > & _coord
An array representing coordinate system volume modifications.
void preExecuteOnInternalSide()
method that is called right before executeOnInternalSide; sets the data to face
MooseMesh & _mesh
the Moose mesh
const Elem *const & _neighbor_elem
The neighboring element (available during executeOnInternalSide() and executeOnInterface())
void preExecuteOnBoundary()
method that is called right before executeOnBoundary; sets the data to face
static InputParameters validParams()
const MooseArray< Point > & normals() const
virtual void executeOnInterface()
execute method that is called during ComputeUserObjects::onInterface
const MooseArray< Point > & _normals
The unit norm at quadrature points on the element side/face from the current element perpendicular to...
void execute() override final
Execute method.
const MooseArray< Point > & _q_point
The quadrature points in physical space used in the element interior.
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...
void preExecuteOnInterface()
method that is called right before executeOnInterface; sets the data to face
virtual void executeOnInternalSide()
execute method that is called during ComputeUserObjects::onInternalSide
const unsigned int & _current_side
Current side of the current element (available during executeOnInternalSide() and executeOnBoundary()...
const MooseArray< Real > & JxW() const
const QBase & qRule() const
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
forward declarations
Definition MooseArray.h:18
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition MooseBase.h:466
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition MooseMesh.h:95
Base variable class.
This class provides an interface for common operations on field variables of both FE and FV types wit...
Intermediate base class that ties together all the interfaces for getting MooseVariables with the Moo...
Interface for objects that need parallel consistent random numbers without patterns over the course o...
This interface is designed currently for DomainUserObject where material properties on element,...
Interface for objects that needs transient capabilities.
Base class for user-specific data.
Definition UserObject.h:20
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...