IOSS  2.0
Ioss_EntityBlock.h
Go to the documentation of this file.
1 // Copyright(C) 1999-2020 National Technology & Engineering Solutions
2 // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 // NTESS, the U.S. Government retains certain rights in this software.
4 //
5 // See packages/seacas/LICENSE for details
6 
7 #ifndef IOSS_Ioss_EntityBlock_h
8 #define IOSS_Ioss_EntityBlock_h
9 
10 #include <Ioss_GroupingEntity.h> // for GroupingEntity
11 #include <Ioss_Property.h> // for Property
12 #include <cstddef> // for size_t
13 #include <string> // for string
14 namespace Ioss {
15  class DatabaseIO;
16 } // namespace Ioss
17 namespace Ioss {
18  class ElementTopology;
19 } // namespace Ioss
20 
21 namespace Ioss {
22  class ElementBlock;
23 
24  /** \brief Base class for all 'block'-type grouping entities, which means all
25  * members of the block are similar or have the same topology.
26  *
27  * The following derived classes are typical:
28  *
29  * -- NodeBlock -- grouping of 'similar' nodes (same degree of freedom, ...)
30  *
31  * -- ElementBlock -- grouping of 'similar' elements (same element topology,
32  * attributes, ...)
33  * 0d, 1d, 2d, 3d topology possible -- e.g., sphere, bar, quad, hex
34  */
35  class EntityBlock : public GroupingEntity
36  {
37  public:
38  Property get_implicit_property(const std::string &my_name) const override = 0;
39 
40  /** \brief Get the topology of the entities in the block.
41  *
42  * \returns The topology.
43  */
44  const ElementTopology *topology() const { return topology_; }
45 
46  /** \brief Determine whether the block contains the entity with a given id.
47  *
48  * \param[in] local_id The id to check.
49  * \returns True if the block contains the entity.
50  */
51  bool contains(size_t local_id) const
52  {
53  return idOffset < local_id && local_id <= idOffset + entityCount;
54  }
55  /** \brief Set the 'offset' for the block.
56  *
57  * The 'offset' is used to map an element location within an
58  * element block to the element 'file descriptor'.
59  * For example, the file descriptor of the 37th element in the 4th
60  * block is calculated by:
61  *
62  * file_descriptor = offset of block 4 + 37
63  *
64  * This can also be used to determine which element block
65  * an element with a file_descriptor maps into. An particular
66  * element block contains all elements in the range:
67  *
68  * offset < file_descriptor <= offset+number_elements_per_block
69  */
70  void set_offset(size_t offset) { idOffset = offset; }
71 
72  /** \brief Get the 'offset' for the block.
73  *
74  * The 'offset' is used to map an element location within an
75  * element block to the element 'file descriptor'.
76  * For example, the file descriptor of the 37th element in the 4th
77  * block is calculated by:
78  *
79  * file_descriptor = offset of block 4 + 37
80  *
81  * This can also be used to determine which element block
82  * an element with a file_descriptor maps into. An particular
83  * element block contains all elements in the range:
84  *
85  * offset < file_descriptor <= offset+number_elements_per_block
86  */
87  size_t get_offset() const { return idOffset; }
88 
89  protected:
90  EntityBlock(DatabaseIO *io_database, const std::string &my_name, const std::string &entity_type,
91  size_t entity_cnt);
92 
93  EntityBlock(const EntityBlock &) = default;
94  EntityBlock &operator=(const EntityBlock &) = delete;
95 
97 
98  protected:
99  size_t idOffset{0};
100  };
101 } // namespace Ioss
102 #endif
Ioss_Property.h
Ioss::EntityBlock::operator=
EntityBlock & operator=(const EntityBlock &)=delete
Ioss
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:40
anonymous_namespace{Iovs_DatabaseIO.C}::entity_type
entity_type
Definition: Iovs_DatabaseIO.C:55
Ioss::EntityBlock::topology_
ElementTopology * topology_
Definition: Ioss_EntityBlock.h:96
Ioss::DatabaseIO
An input or output Database.
Definition: Ioss_DatabaseIO.h:59
Ioss::EntityBlock::topology
const ElementTopology * topology() const
Get the topology of the entities in the block.
Definition: Ioss_EntityBlock.h:44
Ioss::EntityBlock::get_implicit_property
Property get_implicit_property(const std::string &my_name) const override=0
Calculate and get an implicit property.
Definition: Ioss_EntityBlock.C:71
Ioss::EntityBlock
Base class for all 'block'-type grouping entities, which means all members of the block are similar o...
Definition: Ioss_EntityBlock.h:36
Ioss::EntityBlock::set_offset
void set_offset(size_t offset)
Set the 'offset' for the block.
Definition: Ioss_EntityBlock.h:70
Ioss::EntityBlock::contains
bool contains(size_t local_id) const
Determine whether the block contains the entity with a given id.
Definition: Ioss_EntityBlock.h:51
Ioss::EntityBlock::EntityBlock
EntityBlock(const EntityBlock &)=default
Ioss_GroupingEntity.h
Ioss::ElementTopology
Represents an element topology.
Definition: Ioss_ElementTopology.h:47
Ioss::EntityBlock::get_offset
size_t get_offset() const
Get the 'offset' for the block.
Definition: Ioss_EntityBlock.h:87
Ioss::EntityBlock::idOffset
size_t idOffset
Definition: Ioss_EntityBlock.h:99
Ioss::GroupingEntity::entityCount
int64_t entityCount
Definition: Ioss_GroupingEntity.h:276
Ioss::Property
A named value that has a known type.
Definition: Ioss_Property.h:24
Ioss::GroupingEntity
Base class for all 'grouping' entities. The following derived classes are typical:
Definition: Ioss_GroupingEntity.h:68
Ioss::EntityBlock::EntityBlock
EntityBlock(DatabaseIO *io_database, const std::string &my_name, const std::string &entity_type, size_t entity_cnt)
Constructor adds "name" and "entity_count" properties to the entity and specifies the topology type f...
Definition: Ioss_EntityBlock.C:31