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(BUILT_IN_SIERRA)
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_ownsSharedNodes = m_ownerZone < m_donorZone || m_donorZone == -1;
69 m_isActive = has_faces();
70 }
71
72 ZoneConnectivity(const std::string name, int owner_zone, const std::string donor_name,
73 int donor_zone, const Ioss::IJK_t p_transform, const Ioss::IJK_t range_beg,
74 const Ioss::IJK_t range_end, const Ioss::IJK_t donor_beg,
75 const Ioss::IJK_t donor_end, bool owns_nodes, bool from_decomp)
76 : m_connectionName(std::move(name)), m_donorName(std::move(donor_name)),
77 m_transform(std::move(p_transform)), m_ownerRangeBeg(std::move(range_beg)),
78 m_ownerRangeEnd(std::move(range_end)), m_donorRangeBeg(std::move(donor_beg)),
79 m_donorRangeEnd(std::move(donor_end)), m_ownerZone(owner_zone), m_donorZone(donor_zone),
80 m_ownsSharedNodes(owns_nodes), m_fromDecomp(from_decomp)
81 {
82 // This constructor typically called from decomposition process.
83 assert(is_valid());
84 m_isActive = has_faces();
85 }
86
87 ZoneConnectivity(const ZoneConnectivity &copy_from) = default;
88
89 // Return number of nodes in the connection shared with the donor zone.
90 size_t get_shared_node_count() const
91 {
92 size_t snc = 1;
93 for (int i = 0; i < 3; i++) {
94 snc *= (std::abs(m_ownerRangeEnd[i] - m_ownerRangeBeg[i]) + 1);
95 }
96 return snc;
97 }
98
99 // Validate zgc -- if is_active(), then must have non-zero entries for all ranges.
100 // transform must have valid entries.
101 bool is_valid() const;
102 bool has_faces() const;
103
104 std::array<INT, 9> transform_matrix() const;
105 Ioss::IJK_t transform(const Ioss::IJK_t &index_1) const;
106 Ioss::IJK_t inverse_transform(const Ioss::IJK_t &index_1) const;
107
108 std::vector<int> get_range(int ordinal) const;
109 friend std::ostream &operator<<(std::ostream &os, const ZoneConnectivity &zgc);
110
111 bool is_from_decomp() const { return m_fromDecomp; }
112 bool is_active() const { return m_isActive && has_faces(); }
113
114 std::string m_connectionName; // Name of the connection; either generated or from file
115 std::string m_donorName; // Name of the zone (m_donorZone) to which this zone is connected via
116 // this connection.
117 Ioss::IJK_t m_transform; // The transform. In the same form as defined by CGNS
118
119 // The following are all subsetted down to the portion that is actually on this zone
120 // This can be different than m_ownerRange and m_donorRange in a parallel run if the
121 // decomposition splits the connection. In a serial run, they are the same.
122 //
123 // 1 of ijk should be the same for rangeBeg and rangeEnd defining a surface.
124 Ioss::IJK_t m_ownerRangeBeg{}; // ijk triplet defining beginning of range on this zone
125 Ioss::IJK_t m_ownerRangeEnd{}; // ijk triplet defining end of range on this zone
126 Ioss::IJK_t m_ownerOffset{}; // ijk triplet with offset of this zone. Used to convert
127 // rangeBeg and rangeEnd global indices to local indices
128 Ioss::IJK_t m_donorRangeBeg{}; // ijk triplet defining beginning of range on the connected zone
129 Ioss::IJK_t m_donorRangeEnd{}; // ijk triplet defining end of range on the connected zone
130 Ioss::IJK_t m_donorOffset{}; // ijk triplet with offset of the donor zone. Used to convert
131 // donorRangeBeg and End global indices to local indices
132
133 // NOTE: Shared nodes are "owned" by the zone with the lowest zone id.
134 int m_ownerZone{}; // "id" of zone that owns this connection
135 int m_donorZone{}; // "id" of zone that is donor (or other side) of this connection
136 size_t m_ownerGUID{}; // globally-unique id of owner
137 size_t m_donorGUID{}; // globally-unique id of donor
138 int m_ownerProcessor{-1}; // processor that owns the owner zone
139 int m_donorProcessor{-1}; // processor that owns the donor zone
140 bool m_sameRange{false}; // True if owner and donor range should always match...(special use
141 // during decomp)
142 // True if it is the "lower" zone id in the connection. Uses adam unless both have same adam.
143 bool m_ownsSharedNodes{false}; // Deprecate soon
144
145 // True if this zc is created due to processor decompositions in a parallel run
146 bool m_fromDecomp{false};
147
148 bool m_isActive{true}; // True if non-zero range. That is, it has at least one face
149 };
150 } // namespace Ioss
151 #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:51
Ioss
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:66
Ioss::ZoneConnectivity::m_ownerRangeBeg
Ioss::IJK_t m_ownerRangeBeg
Definition: Ioss_ZoneConnectivity.h:124
Ioss::ZoneConnectivity::m_ownerGUID
size_t m_ownerGUID
Definition: Ioss_ZoneConnectivity.h:136
Ioss::ZoneConnectivity::m_ownerZone
int m_ownerZone
Definition: Ioss_ZoneConnectivity.h:134
Ioss::ZoneConnectivity::m_ownerOffset
Ioss::IJK_t m_ownerOffset
Definition: Ioss_ZoneConnectivity.h:126
Ioss::ZoneConnectivity::m_isActive
bool m_isActive
Definition: Ioss_ZoneConnectivity.h:148
Ioss::ZoneConnectivity::m_ownsSharedNodes
bool m_ownsSharedNodes
Definition: Ioss_ZoneConnectivity.h:143
Ioss::ZoneConnectivity::m_transform
Ioss::IJK_t m_transform
Definition: Ioss_ZoneConnectivity.h:117
Ioss::ZoneConnectivity::m_ownerProcessor
int m_ownerProcessor
Definition: Ioss_ZoneConnectivity.h:138
Ioss::ZoneConnectivity::m_ownerRangeEnd
Ioss::IJK_t m_ownerRangeEnd
Definition: Ioss_ZoneConnectivity.h:125
Ioss::ZoneConnectivity::transform_matrix
std::array< INT, 9 > transform_matrix() const
Definition: Ioss_ZoneConnectivity.C:197
Ioss::ZoneConnectivity::get_shared_node_count
size_t get_shared_node_count() const
Definition: Ioss_ZoneConnectivity.h:90
Ioss::ZoneConnectivity::has_faces
bool has_faces() const
Definition: Ioss_ZoneConnectivity.C:113
Ioss::ZoneConnectivity::is_active
bool is_active() const
Definition: Ioss_ZoneConnectivity.h:112
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:114
Ioss::ZoneConnectivity::transform
Ioss::IJK_t transform(const Ioss::IJK_t &index_1) const
Definition: Ioss_ZoneConnectivity.C:208
Ioss::ZoneConnectivity::m_fromDecomp
bool m_fromDecomp
Definition: Ioss_ZoneConnectivity.h:146
INT
int INT
Definition: Ioss_StructuredBlock.h:53
Ioss::ZoneConnectivity::m_donorZone
int m_donorZone
Definition: Ioss_ZoneConnectivity.h:135
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 from_decomp)
Definition: Ioss_ZoneConnectivity.h:72
Ioss::ZoneConnectivity::m_donorName
std::string m_donorName
Definition: Ioss_ZoneConnectivity.h:115
Ioss::ZoneConnectivity::get_range
std::vector< int > get_range(int ordinal) const
Definition: Ioss_ZoneConnectivity.C:181
Ioss::ZoneConnectivity::is_valid
bool is_valid() const
Definition: Ioss_ZoneConnectivity.C:133
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:87
Ioss::ZoneConnectivity::is_from_decomp
bool is_from_decomp() const
Definition: Ioss_ZoneConnectivity.h:111
Ioss::ZoneConnectivity::m_donorRangeBeg
Ioss::IJK_t m_donorRangeBeg
Definition: Ioss_ZoneConnectivity.h:128
Ioss::ZoneConnectivity::inverse_transform
Ioss::IJK_t inverse_transform(const Ioss::IJK_t &index_1) const
Definition: Ioss_ZoneConnectivity.C:237
Ioss::ZoneConnectivity::m_sameRange
bool m_sameRange
Definition: Ioss_ZoneConnectivity.h:140
Ioss::ZoneConnectivity::m_donorOffset
Ioss::IJK_t m_donorOffset
Definition: Ioss_ZoneConnectivity.h:130
Ioss::ZoneConnectivity::m_donorProcessor
int m_donorProcessor
Definition: Ioss_ZoneConnectivity.h:139
Ioss::ZoneConnectivity::m_donorRangeEnd
Ioss::IJK_t m_donorRangeEnd
Definition: Ioss_ZoneConnectivity.h:129
Ioss::ZoneConnectivity::m_donorGUID
size_t m_donorGUID
Definition: Ioss_ZoneConnectivity.h:137