https://mooseframework.inl.gov
BoundaryRestrictable.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 #ifdef MOOSE_KOKKOS_ENABLED
13 #include "KokkosTypes.h"
14 #endif
15 
16 // MOOSE includes
17 #include "InputParameters.h"
18 #include "MaterialData.h"
19 
20 class MooseMesh;
21 
30 {
31 public:
33  enum TEST_TYPE
34  {
35  ALL,
37  };
38 
46  BoundaryRestrictable(const MooseObject * moose_object, bool nodal);
47 
49 
58  BoundaryRestrictable(const MooseObject * moose_object,
59  const std::set<SubdomainID> & block_ids,
60  bool nodal);
61 
62 #ifdef MOOSE_KOKKOS_ENABLED
63 
67 #endif
68 
73  static bool restricted(const std::set<BoundaryID> & ids);
74 
78  virtual ~BoundaryRestrictable();
79 
84  const virtual std::set<BoundaryID> & boundaryIDs() const;
85 
90  const std::vector<BoundaryName> & boundaryNames() const;
91 
96  unsigned int numBoundaryIDs() const;
97 
103  bool hasBoundary(const BoundaryName & name) const;
104 
110  bool hasBoundary(const std::vector<BoundaryName> & names) const;
111 
117  bool hasBoundary(const BoundaryID & id) const;
118 
127  bool hasBoundary(const std::vector<BoundaryID> & ids, TEST_TYPE type = ALL) const;
128 
139  bool hasBoundary(const std::set<BoundaryID> & ids, TEST_TYPE type = ALL) const;
140 
148  bool isBoundarySubset(const std::set<BoundaryID> & ids) const;
149 
150  /*
151  * Test if the class boundary ids are a subset of the supplied objects
152  * @param ids A std::set of Boundary IDs to check
153  * @return True if all of the boundary ids for this class are found within the given ids (opposite
154  * of hasBoundary)
155  * \see hasBoundary
156  */
157  bool isBoundarySubset(const std::vector<BoundaryID> & ids) const;
158 
169  template <typename T, bool is_ad = false>
170  bool hasBoundaryMaterialProperty(const std::string & prop_name) const;
171 
176  virtual bool boundaryRestricted() const;
177 
182  const std::set<BoundaryID> & meshBoundaryIDs() const;
183 
190  virtual bool checkVariableBoundaryIntegrity() const { return true; }
191 
192 private:
195 
198 
200  std::set<BoundaryID> _bnd_ids;
201 
203  std::vector<BoundaryID> _vec_ids;
204 
206  std::vector<BoundaryName> _boundary_names;
207 
210 
212  const std::set<SubdomainID> _empty_block_ids;
213 
215  const std::set<SubdomainID> & _block_ids;
216 
219 
222 
225 
228 
233 
234 #ifdef MOOSE_KOKKOS_ENABLED
236 #endif
237 
238 protected:
243  bool hasBoundaryMaterialPropertyHelper(const std::string & prop_name) const;
244 
245 #ifdef MOOSE_KOKKOS_SCOPE
246 
250  KOKKOS_FUNCTION dof_id_type numKokkosBoundaryNodes() const { return _kokkos_node_ids.size(); }
255  KOKKOS_FUNCTION dof_id_type numKokkosBoundarySides() const
256  {
257  return _kokkos_element_side_ids.size();
258  }
264  KOKKOS_FUNCTION ContiguousNodeID kokkosBoundaryNodeID(ThreadID tid) const
265  {
266  return _kokkos_node_ids[tid];
267  }
273  KOKKOS_FUNCTION auto kokkosBoundaryElementSideID(ThreadID tid) const
274  {
275  return _kokkos_element_side_ids[tid];
276  }
277 #endif
278 
279 #ifdef MOOSE_KOKKOS_ENABLED
280 private:
290 #endif
291 };
292 
293 template <typename T, bool is_ad>
294 bool
295 BoundaryRestrictable::hasBoundaryMaterialProperty(const std::string & prop_name) const
296 {
297  // If you get here the supplied property is defined on all boundaries, but is still subject
298  // existence in the MateialData class
299  return hasBoundaryMaterialPropertyHelper(prop_name) &&
300  _bnd_material_data.haveGenericProperty<T, is_ad>(prop_name);
301 }
Moose::Kokkos::Array< Moose::Kokkos::Pair< ContiguousElementID, unsigned int > > _kokkos_element_side_ids
List of contiguous element ID - side index pairs this Kokkos object is operating on.
bool haveGenericProperty(const std::string &prop_name) const
Definition: MaterialData.h:362
virtual bool checkVariableBoundaryIntegrity() const
Whether integrity/coverage checking should be conducted for moose variables used in this object...
virtual ~BoundaryRestrictable()
Empty class destructor.
KOKKOS_FUNCTION ContiguousNodeID kokkosBoundaryNodeID(ThreadID tid) const
Get the contiguous node ID this Kokkos thread is operating on.
bool isBoundarySubset(const std::set< BoundaryID > &ids) const
Test if the class boundary ids are a subset of the supplied objects.
void initializeBoundaryRestrictable()
An initialization routine needed for dual constructors.
virtual bool boundaryRestricted() const
Returns true if this object has been restricted to a boundary.
dof_id_type ThreadID
Definition: KokkosThread.h:18
MooseMesh * _bnd_mesh
Point to mesh.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
/class BoundaryRestrictable /brief Provides functionality for limiting the object to certain boundary...
const bool _bnd_dual_restrictable
Flag for allowing dual restriction with BlockRestrictable.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
KOKKOS_FUNCTION dof_id_type numKokkosBoundaryNodes() const
Get the number of nodes this Kokkos object is operating on.
bool hasBoundaryMaterialPropertyHelper(const std::string &prop_name) const
A helper method to avoid circular #include problems.
THREAD_ID _bnd_tid
Thread id for this object.
const std::set< SubdomainID > _empty_block_ids
An empty set for referencing when block_ids is not included.
static bool restricted(const std::set< BoundaryID > &ids)
Helper for determining if the object is boundary restricted.
dof_id_type ContiguousNodeID
Definition: KokkosMesh.h:21
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:27
boundary_id_type BoundaryID
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.
bool hasBoundaryMaterialProperty(const std::string &prop_name) const
Check if a material property is valid for all boundaries of this object.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:92
const std::set< BoundaryID > & meshBoundaryIDs() const
Returns the set of all boundary ids for the entire mesh.
unsigned int numBoundaryIDs() const
Return the number of boundaries for this object.
TEST_TYPE
A flag changing the behavior of hasBoundary.
bool _bnd_nodal
Whether or not this object is restricted to nodesets.
static InputParameters validParams()
std::vector< BoundaryID > _vec_ids
Vector of the boundary ids.
bool hasBoundary(const BoundaryName &name) const
Test if the supplied boundary name is valid for this object.
const MooseObject & _moose_object
The moose object that this is an interface for.
const MaterialData & _bnd_material_data
Pointer to MaterialData for boundary (.
std::vector< BoundaryName > _boundary_names
Vector the the boundary names.
KOKKOS_FUNCTION auto kokkosBoundaryElementSideID(ThreadID tid) const
Get the contiguous element ID - side index pair this Kokkos thread is operating on.
Moose::Kokkos::Array< ContiguousNodeID > _kokkos_node_ids
List of contiguous node IDs this Kokkos object is operating on.
Proxy for accessing MaterialPropertyStorage.
Definition: MaterialData.h:37
const std::set< SubdomainID > & _block_ids
Reference to the block_ids, defaults to an empty set if not provided.
FEProblemBase * _bnd_feproblem
Pointer to FEProblemBase.
BoundaryRestrictable(const MooseObject *moose_object, bool nodal)
Class constructor Populates the _bnd_ids for the given boundary names supplied with the &#39;boundary&#39; in...
void initializeKokkosBoundaryRestrictable(MooseMesh *mesh)
const std::vector< BoundaryName > & boundaryNames() const
Return the boundary names for this object.
KOKKOS_FUNCTION dof_id_type numKokkosBoundarySides() const
Get the number of sides this Kokkos object is operating on.
virtual const std::set< BoundaryID > & boundaryIDs() const
Return the boundary IDs for this object.
unsigned int THREAD_ID
Definition: MooseTypes.h:209
uint8_t dof_id_type