IOSS 2.0

Ioss_ZoneConnectivity.h
Go to the documentation of this file.
1 // Copyright(C) 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_ZoneConnectivity_h
34 #define IOSS_Ioss_ZoneConnectivity_h
35
36 #include <Ioss_CodeTypes.h>
37 #include <array>
38 #include <cassert>
39 #include <string>
40
41 #if defined(SEACAS_HAVE_CGNS) && !defined(SIERRA_PARALLEL_MPI)
42 #include <cgnstypes.h>
43 using INT = cgsize_t;
44 #else
45 // If this is not being built with CGNS, then default to using 32-bit integers.
46 // Currently there is no way to input/output a structured mesh without CGNS,
47 // so this block is simply to get things to compile and probably has no use.
48 using INT = int;
49 #endif
50
51 namespace Ioss {
52 class Region;
53
54 struct ZoneConnectivity
55 {
56 ZoneConnectivity(const std::string name, int owner_zone, const std::string donor_name,
57 int donor_zone, const Ioss::IJK_t p_transform, const Ioss::IJK_t range_beg,
58 const Ioss::IJK_t range_end, const Ioss::IJK_t donor_beg,
59 const Ioss::IJK_t donor_end, const Ioss::IJK_t owner_offset = IJK_t(),
60 const Ioss::IJK_t donor_offset = IJK_t())
61 : m_connectionName(std::move(name)), m_donorName(std::move(donor_name)),
62 m_transform(std::move(p_transform)), m_ownerRangeBeg(std::move(range_beg)),
63 m_ownerRangeEnd(std::move(range_end)), m_ownerOffset(std::move(owner_offset)),
64 m_donorRangeBeg(std::move(donor_beg)), m_donorRangeEnd(std::move(donor_end)),
65 m_donorOffset(std::move(donor_offset)), m_ownerZone(owner_zone), m_donorZone(donor_zone)
66 {
67 assert(is_valid());
68 m_intraBlock = m_ownerZone == m_donorZone;
69 m_ownsSharedNodes = m_ownerZone < m_donorZone || m_donorZone == -1;
70 m_isActive = has_faces();
71 }
72
73 ZoneConnectivity(const std::string name, int owner_zone, const std::string donor_name,
74 int donor_zone, const Ioss::IJK_t p_transform, const Ioss::IJK_t range_beg,
75 const Ioss::IJK_t range_end, const Ioss::IJK_t donor_beg,
76 const Ioss::IJK_t donor_end, bool owns_nodes, bool intra_block = false)
77 : m_connectionName(std::move(name)), m_donorName(std::move(donor_name)),
78 m_transform(std::move(p_transform)), m_ownerRangeBeg(std::move(range_beg)),
79 m_ownerRangeEnd(std::move(range_end)), m_donorRangeBeg(std::move(donor_beg)),
80 m_donorRangeEnd(std::move(donor_end)), m_ownerZone(owner_zone), m_donorZone(donor_zone),
81 m_ownsSharedNodes(owns_nodes), m_intraBlock(intra_block)
82 {
83 // NOTE: Originally thought that could deprecate this constructor and calculate the
84 // intra_block status via the `owner_zone` and `donor_zone`, but in parallel, we get the
85 // "non-adam" owner and donor zone, so even though it is intra_block (with same adam_zone), we
86 // can't determine that in the constructor. We can get rid of the `owns_nodes` argument, but
87 // then the constructors are ambiguous since both end with a boolean and can't tell which is
88 // which.
89 //
90 // Currently, only the decomposition process creates intra_block ZGC, so that function is
91 // calling this constructor correctly...
92 assert(is_valid());
93 m_isActive = has_faces();
94 }
95
96 ZoneConnectivity(const ZoneConnectivity &copy_from) = default;
97
98 // Return number of nodes in the connection shared with the donor zone.
99 size_t get_shared_node_count() const
100 {
101 size_t snc = 1;
102 for (int i = 0; i < 3; i++) {
103 snc *= (std::abs(m_ownerRangeEnd[i] - m_ownerRangeBeg[i]) + 1);
104 }
105 return snc;
106 }
107
108 // Validate zgc -- if is_active(), then must have non-zero entries for all ranges.
109 // transform must have valid entries.
110 bool is_valid() const;
111 bool has_faces() const;
112
113 std::array<INT, 9> transform_matrix() const;
114 Ioss::IJK_t transform(const Ioss::IJK_t &index_1) const;
115 Ioss::IJK_t inverse_transform(const Ioss::IJK_t &index_1) const;
116
117 std::vector<int> get_range(int ordinal) const;
118 friend std::ostream &operator<<(std::ostream &os, const ZoneConnectivity &zgc);
119
120 bool is_intra_block() const { return m_ownerZone == m_donorZone || m_intraBlock; }
121 bool is_active() const { return m_isActive && has_faces(); }
122
123 std::string m_connectionName; // Name of the connection; either generated or from file
124 std::string m_donorName; // Name of the zone (m_donorZone) to which this zone is connected via
125 // this connection.
126 Ioss::IJK_t m_transform; // The transform. In the same form as defined by CGNS
127
128 // The following are all subsetted down to the portion that is actually on this zone
129 // This can be different than m_ownerRange and m_donorRange in a parallel run if the
130 // decomposition splits the connection. In a serial run, they are the same.
131 //
132 // 1 of ijk should be the same for rangeBeg and rangeEnd defining a surface.
133 Ioss::IJK_t m_ownerRangeBeg{}; // ijk triplet defining beginning of range on this zone
134 Ioss::IJK_t m_ownerRangeEnd{}; // ijk triplet defining end of range on this zone
135 Ioss::IJK_t m_ownerOffset{}; // ijk triplet with offset of this zone. Used to convert
136 // rangeBeg and rangeEnd global indices to local indices
137 Ioss::IJK_t m_donorRangeBeg{}; // ijk triplet defining beginning of range on the connected zone
138 Ioss::IJK_t m_donorRangeEnd{}; // ijk triplet defining end of range on the connected zone
139 Ioss::IJK_t m_donorOffset{}; // ijk triplet with offset of the donor zone. Used to convert
140 // donorRangeBeg and End global indices to local indices
141
142 // NOTE: Shared nodes are "owned" by the zone with the lowest zone id.
143 int m_ownerZone{}; // "id" of zone that owns this connection
144 int m_donorZone{}; // "id" of zone that is donor (or other side) of this connection
145 size_t m_ownerGUID{}; // globally-unique id of owner
146 size_t m_donorGUID{}; // globally-unique id of donor
147 int m_ownerProcessor{-1}; // processor that owns the owner zone
148 int m_donorProcessor{-1}; // processor that owns the donor zone
149 bool m_sameRange{false}; // True if owner and donor range should always match...(special use
150 // during decomp)
151 // True if it is the "lower" zone id in the connection. Uses adam unless both have same adam.
152 bool m_ownsSharedNodes{false}; // Deprecate soon
153
154 // True if this zc is created due to processor decompositions in a parallel run
155 bool m_intraBlock{false}; // Deprecate use soon...
156
157 bool m_isActive{true}; // True if non-zero range. That is, it has at least one face
158 };
159 } // namespace Ioss
160 #endif
Ioss_CodeTypes.h
Ioss::ZoneConnectivity
Definition: Ioss_ZoneConnectivity.h:54
Ioss::ZoneConnectivity::operator<<
friend std::ostream & operator<<(std::ostream &os, const ZoneConnectivity &zgc)
Definition: Ioss_ZoneConnectivity.C:50
Ioss
The main namespace for the Ioss library.
Definition: Iocgns_DatabaseIO.h:50
Ioss::ZoneConnectivity::m_ownerRangeBeg
Ioss::IJK_t m_ownerRangeBeg
Definition: Ioss_ZoneConnectivity.h:133
Ioss::ZoneConnectivity::m_intraBlock
bool m_intraBlock
Definition: Ioss_ZoneConnectivity.h:155
Ioss::ZoneConnectivity::m_ownerGUID
size_t m_ownerGUID
Definition: Ioss_ZoneConnectivity.h:145
Ioss::ZoneConnectivity::m_ownerZone
int m_ownerZone
Definition: Ioss_ZoneConnectivity.h:143
Ioss::ZoneConnectivity::m_ownerOffset
Ioss::IJK_t m_ownerOffset
Definition: Ioss_ZoneConnectivity.h:135
Ioss::ZoneConnectivity::m_isActive
bool m_isActive
Definition: Ioss_ZoneConnectivity.h:157
Ioss::ZoneConnectivity::m_ownsSharedNodes
bool m_ownsSharedNodes
Definition: Ioss_ZoneConnectivity.h:152
Ioss::ZoneConnectivity::m_transform
Ioss::IJK_t m_transform
Definition: Ioss_ZoneConnectivity.h:126
Ioss::ZoneConnectivity::m_ownerProcessor
int m_ownerProcessor
Definition: Ioss_ZoneConnectivity.h:147
Ioss::ZoneConnectivity::m_ownerRangeEnd
Ioss::IJK_t m_ownerRangeEnd
Definition: Ioss_ZoneConnectivity.h:134
Ioss::ZoneConnectivity::transform_matrix
std::array< INT, 9 > transform_matrix() const
Definition: Ioss_ZoneConnectivity.C:176
Ioss::ZoneConnectivity::get_shared_node_count
size_t get_shared_node_count() const
Definition: Ioss_ZoneConnectivity.h:99
Ioss::ZoneConnectivity::has_faces
bool has_faces() const
Definition: Ioss_ZoneConnectivity.C:92
Ioss::ZoneConnectivity::is_active
bool is_active() const
Definition: Ioss_ZoneConnectivity.h:121
Ioss::ZoneConnectivity::is_intra_block
bool is_intra_block() const
Definition: Ioss_ZoneConnectivity.h:120
Ioss::IJK_t
std::array< int, 3 > IJK_t
Definition: Ioss_CodeTypes.h:46
Ioss::ZoneConnectivity::m_connectionName
std::string m_connectionName
Definition: Ioss_ZoneConnectivity.h:123
Ioss::ZoneConnectivity::transform
Ioss::IJK_t transform(const Ioss::IJK_t &index_1) const
Definition: Ioss_ZoneConnectivity.C:187
INT
int INT
Definition: Ioss_StructuredBlock.h:53
Ioss::ZoneConnectivity::ZoneConnectivity
ZoneConnectivity(const std::string name, int owner_zone, const std::string donor_name, int donor_zone, const Ioss::IJK_t p_transform, const Ioss::IJK_t range_beg, const Ioss::IJK_t range_end, const Ioss::IJK_t donor_beg, const Ioss::IJK_t donor_end, bool owns_nodes, bool intra_block=false)
Definition: Ioss_ZoneConnectivity.h:73
Ioss::ZoneConnectivity::m_donorZone
int m_donorZone
Definition: Ioss_ZoneConnectivity.h:144
Ioss::ZoneConnectivity::m_donorName
std::string m_donorName
Definition: Ioss_ZoneConnectivity.h:124
Ioss::ZoneConnectivity::get_range
std::vector< int > get_range(int ordinal) const
Definition: Ioss_ZoneConnectivity.C:160
Ioss::ZoneConnectivity::is_valid
bool is_valid() const
Definition: Ioss_ZoneConnectivity.C:112
Ioss::ZoneConnectivity::ZoneConnectivity
ZoneConnectivity(const std::string name, int owner_zone, const std::string donor_name, int donor_zone, const Ioss::IJK_t p_transform, const Ioss::IJK_t range_beg, const Ioss::IJK_t range_end, const Ioss::IJK_t donor_beg, const Ioss::IJK_t donor_end, const Ioss::IJK_t owner_offset=IJK_t(), const Ioss::IJK_t donor_offset=IJK_t())
Definition: Ioss_ZoneConnectivity.h:56
anonymous_namespace{io_info.C}::name
std::string name(Ioss::GroupingEntity *entity)
Definition: io_info.C:88
Ioss::ZoneConnectivity::m_donorRangeBeg
Ioss::IJK_t m_donorRangeBeg
Definition: Ioss_ZoneConnectivity.h:137
Ioss::ZoneConnectivity::inverse_transform
Ioss::IJK_t inverse_transform(const Ioss::IJK_t &index_1) const
Definition: Ioss_ZoneConnectivity.C:216
Ioss::ZoneConnectivity::m_sameRange
bool m_sameRange
Definition: Ioss_ZoneConnectivity.h:149
Ioss::ZoneConnectivity::m_donorOffset
Ioss::IJK_t m_donorOffset
Definition: Ioss_ZoneConnectivity.h:139
Ioss::ZoneConnectivity::m_donorProcessor
int m_donorProcessor
Definition: Ioss_ZoneConnectivity.h:148
Ioss::ZoneConnectivity::m_donorRangeEnd
Ioss::IJK_t m_donorRangeEnd
Definition: Ioss_ZoneConnectivity.h:138
Ioss::ZoneConnectivity::m_donorGUID
size_t m_donorGUID
Definition: Ioss_ZoneConnectivity.h:146