IOSS 2.0
Loading...
Searching...
No Matches
Ioss_EntityBlock.h
Go to the documentation of this file.
1// Copyright(C) 1999-2020, 2022, 2023, 2024 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#pragma once
8
9#include "Ioss_GroupingEntity.h" // for GroupingEntity
10#include "Ioss_Property.h" // for Property
11#include <cstddef> // for size_t
12#include <string> // for string
13
14#include "ioss_export.h"
15
16namespace Ioss {
17 class DatabaseIO;
18} // namespace Ioss
19namespace Ioss {
20 class ElementTopology;
21} // namespace Ioss
22
23namespace Ioss {
24 class ElementBlock;
25
26 /** \brief Base class for all 'block'-type grouping entities, which means all
27 * members of the block are similar or have the same topology.
28 *
29 * The following derived classes are typical:
30 *
31 * -- NodeBlock -- grouping of 'similar' nodes (same degree of freedom, ...)
32 *
33 * -- ElementBlock -- grouping of 'similar' elements (same element topology,
34 * attributes, ...)
35 * 0d, 1d, 2d, 3d topology possible -- e.g., sphere, bar, quad, hex
36 */
37 class IOSS_EXPORT EntityBlock : public GroupingEntity
38 {
39 public:
40 EntityBlock &operator=(const EntityBlock &) = delete;
41
42 IOSS_NODISCARD Property get_implicit_property(const std::string &my_name) const override = 0;
43
44 /** \brief Get the topology of the entities in the block.
45 *
46 * \returns The topology.
47 */
48 IOSS_NODISCARD const ElementTopology *topology() const { return topology_; }
49
50 /** \brief Determine whether the block contains the entity with a given id.
51 *
52 * \param[in] local_id The id to check.
53 * \returns True if the block contains the entity.
54 */
55 IOSS_NODISCARD bool contains(size_t local_id) const
56 {
57 return idOffset < local_id && local_id <= idOffset + entityCount;
58 }
59 /** \brief Set the 'offset' for the block.
60 *
61 * The 'offset' is used to map an element location within an
62 * element block to the element 'file descriptor'.
63 * For example, the file descriptor of the 37th element in the 4th
64 * block is calculated by:
65 *
66 * file_descriptor = offset of block 4 + 37
67 *
68 * This can also be used to determine which element block
69 * an element with a file_descriptor maps into. An particular
70 * element block contains all elements in the range:
71 *
72 * offset < file_descriptor <= offset+number_elements_per_block
73 */
74 void set_offset(size_t offset) { idOffset = offset; }
75
76 /** \brief Get the 'offset' for the block.
77 *
78 * The 'offset' is used to map an element location within an
79 * element block to the element 'file descriptor'.
80 * For example, the file descriptor of the 37th element in the 4th
81 * block is calculated by:
82 *
83 * file_descriptor = offset of block 4 + 37
84 *
85 * This can also be used to determine which element block
86 * an element with a file_descriptor maps into. An particular
87 * element block contains all elements in the range:
88 *
89 * offset < file_descriptor <= offset+number_elements_per_block
90 */
91 IOSS_NODISCARD size_t get_offset() const { return idOffset; }
92
93 IOSS_NODISCARD bool operator==(const Ioss::EntityBlock &rhs) const;
94 IOSS_NODISCARD bool operator!=(const Ioss::EntityBlock &rhs) const;
95 IOSS_NODISCARD bool equal(const Ioss::EntityBlock &rhs) const;
96
97 protected:
98 EntityBlock(DatabaseIO *io_database, const std::string &my_name, const std::string &entity_type,
99 size_t entity_cnt);
100
101 EntityBlock(const EntityBlock &) = default;
102
103 ElementTopology *topology_{nullptr};
104
105 size_t idOffset{0};
106
107 bool equal_(const Ioss::EntityBlock &rhs, bool quiet) const;
108 };
109} // namespace Ioss
#define IOSS_NODISCARD
Definition Ioss_CodeTypes.h:54
An input or output Database.
Definition Ioss_DatabaseIO.h:63
Represents an element topology.
Definition Ioss_ElementTopology.h:69
Base class for all 'block'-type grouping entities, which means all members of the block are similar o...
Definition Ioss_EntityBlock.h:38
void set_offset(size_t offset)
Set the 'offset' for the block.
Definition Ioss_EntityBlock.h:74
EntityBlock(const EntityBlock &)=default
EntityBlock & operator=(const EntityBlock &)=delete
IOSS_NODISCARD size_t get_offset() const
Get the 'offset' for the block.
Definition Ioss_EntityBlock.h:91
IOSS_NODISCARD const ElementTopology * topology() const
Get the topology of the entities in the block.
Definition Ioss_EntityBlock.h:48
IOSS_NODISCARD bool contains(size_t local_id) const
Determine whether the block contains the entity with a given id.
Definition Ioss_EntityBlock.h:55
Base class for all 'grouping' entities. The following derived classes are typical:
Definition Ioss_GroupingEntity.h:67
A named value that has a known type.
Definition Ioss_Property.h:27
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40