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