| 1 |
// Copyright(C) 1999-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_ElementBlock.h" |
| 10 |
#include "Ioss_EntityBlock.h" // for EntityBlock |
| 11 |
#include "Ioss_EntityType.h" // for EntityType, etc |
| 12 |
#include "Ioss_Property.h" // for Property |
| 13 |
#include "Ioss_SideSet.h" |
| 14 |
#include <cstddef> // for size_t |
| 15 |
#include <cstdint> // for int64_t |
| 16 |
#include <string> // for string |
| 17 |
#include <vector> // for vector |
| 18 |
|
| 19 |
#include "Ioss_GroupingEntity.h" |
| 20 |
#include "ioss_export.h" |
| 21 |
|
| 22 |
namespace Ioss { |
| 23 |
class DatabaseIO; |
| 24 |
} // namespace Ioss |
| 25 |
namespace Ioss { |
| 26 |
class ElementTopology; |
| 27 |
} // namespace Ioss |
| 28 |
namespace Ioss { |
| 29 |
class Field; |
| 30 |
} // namespace Ioss |
| 31 |
|
| 32 |
namespace Ioss { |
| 33 |
|
| 34 |
/** \brief A collection of element sides having the same topology. |
| 35 |
*/ |
| 36 |
class IOSS_EXPORT SideBlock : public EntityBlock |
| 37 |
{ |
| 38 |
public: |
| 39 |
friend class SideSet; |
| 40 |
|
| 41 |
SideBlock(DatabaseIO *io_database, const std::string &my_name, const std::string &side_type, |
| 42 |
const std::string &element_type, size_t side_count); |
| 43 |
|
| 44 |
SideBlock(const SideBlock &other); |
| 45 |
|
| 46 |
/** |
| 47 |
* |
| 48 |
* For externally defined sidesets/sideblocks, attempt to provide |
| 49 |
* the sideblock name that will be generated if the database is |
| 50 |
* read and the sideblocks are generated from the sideset at the |
| 51 |
* read phase. Since sideblocks are not explicitly stored on some |
| 52 |
* of the database types (e.g. exodus), the IOSS code generates |
| 53 |
* the sideblocks from the sidesets when reading the database. We |
| 54 |
* want to maximize the possibility that the same sideblock names |
| 55 |
* will be generated at that read step as the application is using |
| 56 |
* for sideblocks that it generates internally to be output to a |
| 57 |
* restart file that is later read... |
| 58 |
* |
| 59 |
* \param[in] sideset_name The name of the sideset that this sideblock will be a member of. |
| 60 |
* \param[in] block_or_element Depending on the `SurfaceSplitType` |
| 61 |
* behavior for this database, this is either the name of the |
| 62 |
* element block that the sideblock is applied to |
| 63 |
* (SPLIT_BY_ELEMENT_BLOCK) or the topology name of the elements |
| 64 |
* that the sideblock faces are part of (SPLIT_BY_TOPOLOGIES) or |
| 65 |
* "UNKNOWN" if mixed topology (SPLIT_BY_DONT_SPLIT) |
| 66 |
* \param[in] face_topology_name The name of the topology of the |
| 67 |
* sideblock faces. "UNKNOWN" if not homogeneous. |
| 68 |
* \returns The generated sideblock name. |
| 69 |
*/ |
| 70 |
IOSS_NODISCARD static std::string |
| 71 |
generate_sideblock_name(const std::string &sideset_name, const std::string &block_or_element, |
| 72 |
const std::string &face_topology_name); |
| 73 |
|
| 74 |
IOSS_NODISCARD std::string type_string() const override { return "SideBlock"; } |
| 75 |
IOSS_NODISCARD std::string short_type_string() const override { return "sideblock"; } |
| 76 |
IOSS_NODISCARD std::string contains_string() const override { return "Element/Side pair"; } |
| 77 |
IOSS_NODISCARD EntityType type() const override { return SIDEBLOCK; } |
| 78 |
|
| 79 |
IOSS_NODISCARD const SideSet *owner() const { return owner_; } |
| 80 |
IOSS_NODISCARD const Ioss::GroupingEntity *contained_in() const override { return owner_; } |
| 81 |
|
| 82 |
void block_membership(Ioss::NameList &block_members) override; |
| 83 |
|
| 84 |
// Handle implicit properties -- These are calculated from data stored |
| 85 |
// in the grouping entity instead of having an explicit value assigned. |
| 86 |
// An example would be 'element_block_count' for a region. |
| 87 |
IOSS_NODISCARD Property get_implicit_property(const std::string &my_name) const override; |
| 88 |
|
| 89 |
// For faceblock, edgeblock, if they are split by element block, then this |
| 90 |
// will be non-nullptr and is a pointer to the parent element block for this |
| 91 |
// faceblock or edgeblock. Has no meaning for other EntityBlock types or split |
| 92 |
// types. |
| 93 |
IOSS_NODISCARD const ElementBlock *parent_element_block() const |
| 94 |
{ |
| 95 |
return dynamic_cast<const ElementBlock *>(parentBlock_); |
| 96 |
} |
| 97 |
|
| 98 |
void set_parent_element_block(const ElementBlock *element_block) |
| 99 |
{ |
| 100 |
parentBlock_ = element_block; |
| 101 |
} |
| 102 |
|
| 103 |
IOSS_NODISCARD const EntityBlock *parent_block() const { return parentBlock_; } |
| 104 |
void set_parent_block(const EntityBlock *block) { parentBlock_ = block; } |
| 105 |
|
| 106 |
// Describes the contained entities element block topology |
| 107 |
IOSS_NODISCARD const ElementTopology *parent_element_topology() const |
| 108 |
{ |
| 109 |
return parentTopology_; |
| 110 |
} |
| 111 |
|
| 112 |
// For faceblock, edgeblock, return whether the surface is applied |
| 113 |
// to the same face/edge for all elements in the surface. If not, |
| 114 |
// return 0; otherwise return the consistent face number. |
| 115 |
IOSS_NODISCARD int get_consistent_side_number() const; |
| 116 |
void set_consistent_side_number(int side) { consistentSideNumber = side; } |
| 117 |
|
| 118 |
IOSS_NODISCARD bool operator==(const SideBlock &rhs) const; |
| 119 |
IOSS_NODISCARD bool operator!=(const SideBlock &rhs) const; |
| 120 |
IOSS_NODISCARD bool equal(const SideBlock &rhs) const; |
| 121 |
|
| 122 |
protected: |
| 123 |
int64_t internal_get_field_data(const Field &field, void *data, |
| 124 |
size_t data_size) const override; |
| 125 |
|
| 126 |
int64_t internal_put_field_data(const Field &field, void *data, |
| 127 |
size_t data_size) const override; |
| 128 |
|
| 129 |
int64_t internal_get_zc_field_data(const Field &field, void **data, |
| 130 |
size_t *data_size) const override; |
| 131 |
|
| 132 |
private: |
| 133 |
bool equal_(const SideBlock &rhs, bool quiet) const; |
| 134 |
|
| 135 |
const SideSet *owner_{nullptr}; |
| 136 |
ElementTopology *parentTopology_{nullptr}; // Topology of parent element (if any) |
| 137 |
const EntityBlock *parentBlock_{nullptr}; |
| 138 |
|
| 139 |
// Pointer to the SideSet (if any) that contains this side block. |
| 140 |
Ioss::NameList blockMembership{}; // What element blocks do the |
| 141 |
// elements in this sideset belong to. |
| 142 |
mutable int consistentSideNumber{-1}; |
| 143 |
}; |
| 144 |
} // namespace Ioss |