IOSS 2.0

Ioss_EntityBlock.h
Go to the documentation of this file.
1 // Copyright(C) 1999-2017 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 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following
14 // disclaimer in the documentation and/or other materials provided
15 // with the distribution.
16 //
17 // * Neither the name of NTESS nor the names of its
18 // contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 #ifndef IOSS_Ioss_EntityBlock_h
34 #define IOSS_Ioss_EntityBlock_h
35
36 #include <Ioss_GroupingEntity.h> // for GroupingEntity
37 #include <Ioss_Property.h> // for Property
38 #include <cstddef> // for size_t
39 #include <string> // for string
40 namespace Ioss {
41 class DatabaseIO;
42 } // namespace Ioss
43 namespace Ioss {
44 class ElementTopology;
45 } // namespace Ioss
46
47 namespace Ioss {
48 class ElementBlock;
49
50 /** \brief Base class for all 'block'-type grouping entities, which means all
51 * members of the block are similar or have the same topology.
52 *
53 * The following derived classes are typical:
54 *
55 * -- NodeBlock -- grouping of 'similar' nodes (same degree of freedom, ...)
56 *
57 * -- ElementBlock -- grouping of 'similar' elements (same element topology,
58 * attributes, ...)
59 * 0d, 1d, 2d, 3d topology possible -- e.g., sphere, bar, quad, hex
60 */
61 class EntityBlock : public GroupingEntity
62 {
63 public:
64 Property get_implicit_property(const std::string &my_name) const override = 0;
65
66 /** \brief Get the topology of the entities in the block.
67 *
68 * \returns The topology.
69 */
70 const ElementTopology *topology() const { return topology_; }
71
72 /** \brief Determine whether the block contains the entity with a given id.
73 *
74 * \param[in] local_id The id to check.
75 * \returns True if the block contains the entity.
76 */
77 bool contains(size_t local_id) const
78 {
79 return idOffset < local_id && local_id <= idOffset + entityCount;
80 }
81 /** \brief Set the 'offset' for the block.
82 *
83 * The 'offset' is used to map an element location within an
84 * element block to the element 'file descriptor'.
85 * For example, the file descriptor of the 37th element in the 4th
86 * block is calculated by:
87 *
88 * file_descriptor = offset of block 4 + 37
89 *
90 * This can also be used to determine which element block
91 * an element with a file_descriptor maps into. An particular
92 * element block contains all elements in the range:
93 *
94 * offset < file_descriptor <= offset+number_elements_per_block
95 */
96 void set_offset(size_t offset) { idOffset = offset; }
97
98 /** \brief Get the 'offset' for the block.
99 *
100 * The 'offset' is used to map an element location within an
101 * element block to the element 'file descriptor'.
102 * For example, the file descriptor of the 37th element in the 4th
103 * block is calculated by:
104 *
105 * file_descriptor = offset of block 4 + 37
106 *
107 * This can also be used to determine which element block
108 * an element with a file_descriptor maps into. An particular
109 * element block contains all elements in the range:
110 *
111 * offset < file_descriptor <= offset+number_elements_per_block
112 */
113 size_t get_offset() const { return idOffset; }
114
115 protected:
116 EntityBlock(DatabaseIO *io_database, const std::string &my_name, const std::string &entity_type,
117 size_t entity_cnt);
118
119 EntityBlock(const EntityBlock &) = delete;
120 EntityBlock &operator=(const EntityBlock &) = delete;
121
122 ElementTopology *topology_;
123
124 protected:
125 size_t idOffset;
126 };
127 } // namespace Ioss
128 #endif
Ioss::ElementTopology
Represents an element topology.
Definition: Ioss_ElementTopology.h:72
Ioss::Property
A named value that has a known type.
Definition: Ioss_Property.h:47
Ioss_Property.h
Ioss
The main namespace for the Ioss library.
Definition: Iocgns_DatabaseIO.h:50
Ioss::DatabaseIO
An input or output Database.
Definition: Ioss_DatabaseIO.h:80
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:77
Ioss::GroupingEntity::entityCount
int64_t entityCount
Definition: Ioss_GroupingEntity.h:286
Ioss::GroupingEntity
Base class for all &#39;grouping&#39; entities. The following derived classes are typical: ...
Definition: Ioss_GroupingEntity.h:93
Ioss::EntityBlock::set_offset
void set_offset(size_t offset)
Set the &#39;offset&#39; for the block.
Definition: Ioss_EntityBlock.h:96
Ioss::EntityBlock::idOffset
size_t idOffset
Definition: Ioss_EntityBlock.h:125
Ioss::EntityBlock
Base class for all &#39;block&#39;-type grouping entities, which means all members of the block are similar o...
Definition: Ioss_EntityBlock.h:61
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:56
Ioss::EntityBlock::topology
const ElementTopology * topology() const
Get the topology of the entities in the block.
Definition: Ioss_EntityBlock.h:70
Ioss::EntityBlock::topology_
ElementTopology * topology_
Definition: Ioss_EntityBlock.h:122
Ioss::EntityBlock::operator=
EntityBlock & operator=(const EntityBlock &)=delete
anonymous_namespace{Iovs_DatabaseIO.C}::entity_type
entity_type
Definition: Iovs_DatabaseIO.C:81
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:96
Ioss::EntityBlock::get_offset
size_t get_offset() const
Get the &#39;offset&#39; for the block.
Definition: Ioss_EntityBlock.h:113
Ioss_GroupingEntity.h