https://mooseframework.inl.gov
BlockRestrictable.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 "ParallelUniqueId.h"
19 #include "MaterialData.h"
20 #include "MooseObject.h"
21 
22 #define usingBlockRestrictableMembers using BlockRestrictable::getBlockCoordSystem
23 
24 class FEProblemBase;
25 class MooseMesh;
26 
27 #ifdef MOOSE_KOKKOS_ENABLED
28 namespace Moose::Kokkos
29 {
30 class Mesh;
31 }
32 #endif
33 
35 
69 {
70 public:
80  BlockRestrictable(const MooseObject * moose_object, bool initialize = true);
81 
83 
91  BlockRestrictable(const MooseObject * moose_object, const std::set<BoundaryID> & boundary_ids);
92 
93 #ifdef MOOSE_KOKKOS_ENABLED
94 
98 #endif
99 
104  virtual ~BlockRestrictable() {}
105 
114  const std::vector<SubdomainName> & blocks() const;
115 
120  unsigned int numBlocks() const;
121 
127  virtual const std::set<SubdomainID> & blockIDs() const;
128 
132  unsigned int blocksMaxDimension() const;
133 
139  bool hasBlocks(const SubdomainName & name) const;
140 
146  bool hasBlocks(const std::vector<SubdomainName> & names) const;
147 
153  bool hasBlocks(const std::set<SubdomainName> & names) const;
154 
160  bool hasBlocks(SubdomainID id) const;
161 
167  bool hasBlocks(const std::vector<SubdomainID> & ids) const;
168 
175  bool hasBlocks(const std::set<SubdomainID> & ids) const;
176 
184  bool isBlockSubset(const std::set<SubdomainID> & ids) const;
185 
193  bool isBlockSubset(const std::vector<SubdomainID> & ids) const;
194 
207  template <typename T, bool is_ad = false>
208  bool hasBlockMaterialProperty(const std::string & prop_name);
209 
214  const std::set<SubdomainID> & meshBlockIDs() const;
215 
220  virtual bool blockRestricted() const;
221 
228  virtual void checkVariable(const MooseVariableFieldBase & variable) const;
229 
230 protected:
233 
239  virtual bool hasBlockMaterialPropertyHelper(const std::string & prop_name);
240 
244  void initializeBlockRestrictable(const MooseObject * moose_object);
245 
246 #ifdef MOOSE_KOKKOS_ENABLED
248 #endif
249 
255 
256 #ifdef MOOSE_KOKKOS_SCOPE
257 
261  KOKKOS_FUNCTION dof_id_type numKokkosBlockElements() const { return _kokkos_element_ids.size(); }
266  KOKKOS_FUNCTION dof_id_type numKokkosBlockNodes() const { return _kokkos_node_ids.size(); }
271  KOKKOS_FUNCTION dof_id_type numKokkosBlockSides() const
272  {
273  return _kokkos_element_side_ids.size();
274  }
281  {
282  return _kokkos_element_ids[tid];
283  }
289  KOKKOS_FUNCTION ContiguousElementID kokkosBlockNodeID(ThreadID tid) const
290  {
291  return _kokkos_node_ids[tid];
292  }
298  KOKKOS_FUNCTION auto kokkosBlockElementSideID(ThreadID tid) const
299  {
300  return _kokkos_element_side_ids[tid];
301  }
302 #endif
303 
304 private:
306  std::set<SubdomainID> _blk_ids;
307 
309  std::vector<SubdomainID> _vec_ids;
310 
312  std::vector<SubdomainName> _blocks;
313 
316 
319 
322 
324  const std::set<BoundaryID> _empty_boundary_ids;
325 
327  const std::set<BoundaryID> & _boundary_ids;
328 
331 
333  const std::string & _blk_name;
334 
336  unsigned int _blk_dim;
337 
340 
341 #ifdef MOOSE_KOKKOS_ENABLED
342 
355 #endif
356 };
357 
358 template <typename T, bool is_ad>
359 bool
360 BlockRestrictable::hasBlockMaterialProperty(const std::string & prop_name)
361 {
362  mooseAssert(_blk_material_data != NULL, "MaterialData pointer is not defined");
363  return hasBlockMaterialPropertyHelper(prop_name) &&
364  _blk_material_data->haveGenericProperty<T, is_ad>(prop_name);
365 }
KOKKOS_FUNCTION dof_id_type numKokkosBlockSides() const
Get the number of sides this Kokkos object is operating on.
unsigned int blocksMaxDimension() const
Return the largest mesh dimension of the elements in the blocks for this object.
unsigned int _blk_dim
Largest mesh dimension of the elements in the blocks for this object.
The Kokkos mesh object.
Definition: KokkosMesh.h:54
bool haveGenericProperty(const std::string &prop_name) const
Definition: MaterialData.h:362
unsigned int numBlocks() const
Return the number of blocks for this object.
const bool _blk_dual_restrictable
Flag for allowing dual restriction.
KOKKOS_FUNCTION ContiguousElementID kokkosBlockNodeID(ThreadID tid) const
Get the contiguous node index this Kokkos thread is operating on.
dof_id_type ThreadID
Definition: KokkosThread.h:18
dof_id_type ContiguousElementID
Definition: KokkosMesh.h:20
KOKKOS_FUNCTION auto kokkosBlockElementSideID(ThreadID tid) const
Get the contiguous element ID - side index pair this Kokkos thread is operating on.
Moose::CoordinateSystemType getBlockCoordSystem()
Check if the blocks this object operates on all have the same coordinate system, and if so return it...
FEProblemBase * _blk_feproblem
Pointer to FEProblemBase.
virtual void checkVariable(const MooseVariableFieldBase &variable) const
Helper for checking that the ids for this object are in agreement with the variables on the supplied ...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const MooseObject * _moose_object
Pointer to the MOOSE object.
This class provides an interface for common operations on field variables of both FE and FV types wit...
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object Note, if this is not block restricted, this function returns all mesh subdomain ids.
virtual bool blockRestricted() const
Returns true if this object has been restricted to a block.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
void initialize(EquationSystems &es, const std::string &system_name)
static InputParameters validParams()
bool isBlockSubset(const std::set< SubdomainID > &ids) const
Test if the class block ids are a subset of the supplied objects.
void initializeBlockRestrictable(const MooseObject *moose_object)
An initialization routine needed for dual constructors.
virtual ~BlockRestrictable()
Destructor: does nothing but needs to be marked as virtual since this class defines virtual functions...
std::vector< SubdomainID > _vec_ids
Vector of block ids supplied by the user via the input file (for error reporting) ...
KOKKOS_FUNCTION ContiguousElementID kokkosBlockElementID(ThreadID tid) const
Get the contiguous element ID this Kokkos thread is operating on.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:27
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:92
void initializeKokkosBlockRestrictable(const Moose::Kokkos::Mesh *mesh)
THREAD_ID _blk_tid
Thread id for this object.
std::vector< SubdomainName > _blocks
Vector the block names supplied by the user via the input file.
Moose::Kokkos::Array< Moose::Kokkos::Pair< ContiguousElementID, unsigned int > > _kokkos_element_side_ids
List of contiguous local element ID - side index pairs this Kokkos object is operating on...
Moose::Kokkos::Array< ContiguousElementID > _kokkos_element_ids
List of contiguous element IDs this Kokkos object is operating on.
bool hasBlockMaterialProperty(const std::string &prop_name)
Check if a material property is valid for all blocks of this object.
const MooseMesh * _blk_mesh
Pointer to Mesh.
const std::vector< SubdomainName > & blocks() const
Return the block names for this object.
const std::set< BoundaryID > _empty_boundary_ids
An empty set for referencing when boundary_ids is not included.
CoordinateSystemType
Definition: MooseTypes.h:810
const MaterialData * _blk_material_data
Pointer to the MaterialData class for this object.
KOKKOS_FUNCTION dof_id_type numKokkosBlockElements() const
Get the number of elements this Kokkos object is operating on.
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.
const std::set< SubdomainID > & meshBlockIDs() const
Return all of the SubdomainIDs for the mesh.
virtual bool hasBlockMaterialPropertyHelper(const std::string &prop_name)
A helper method to allow the Material object to specialize the behavior of hasBlockMaterialProperty.
const std::set< BoundaryID > & _boundary_ids
Reference to the boundary_ids, defaults to an empty set if not provided.
Proxy for accessing MaterialPropertyStorage.
Definition: MaterialData.h:37
Moose::Kokkos::Array< ContiguousNodeID > _kokkos_node_ids
List of contiguous node IDs this Kokkos object is operating on.
BlockRestrictable(const MooseObject *moose_object, bool initialize=true)
Class constructor Populates the &#39;block&#39; input parameters, see the general class documentation for det...
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error checking)
const std::string & _blk_name
Name of the object.
unsigned int THREAD_ID
Definition: MooseTypes.h:209
KOKKOS_FUNCTION dof_id_type numKokkosBlockNodes() const
Get the number of nodes this Kokkos object is operating on.
uint8_t dof_id_type