IOSS  2.0
Ioss_ZoneConnectivity.h
Go to the documentation of this file.
1 // Copyright(C) 1999-2020 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 #ifndef IOSS_Ioss_ZoneConnectivity_h
8 #define IOSS_Ioss_ZoneConnectivity_h
9 
10 #include <Ioss_CodeTypes.h>
11 #include <array>
12 #include <cassert>
13 #include <string>
14 
15 #if defined(SEACAS_HAVE_CGNS) && !defined(BUILT_IN_SIERRA)
16 #include <cgnstypes.h>
17 using INT = cgsize_t;
18 #else
19 // If this is not being built with CGNS, then default to using 32-bit integers.
20 // Currently there is no way to input/output a structured mesh without CGNS,
21 // so this block is simply to get things to compile and probably has no use.
22 using INT = int;
23 #endif
24 
25 namespace Ioss {
26  class Region;
27 
29  {
30  ZoneConnectivity(const std::string name, int owner_zone, const std::string donor_name,
31  int donor_zone, const Ioss::IJK_t p_transform, const Ioss::IJK_t range_beg,
32  const Ioss::IJK_t range_end, const Ioss::IJK_t donor_beg,
33  const Ioss::IJK_t donor_end, const Ioss::IJK_t owner_offset = IJK_t(),
34  const Ioss::IJK_t donor_offset = IJK_t())
35  : m_connectionName(std::move(name)), m_donorName(std::move(donor_name)),
36  m_transform(std::move(p_transform)), m_ownerRangeBeg(std::move(range_beg)),
37  m_ownerRangeEnd(std::move(range_end)), m_ownerOffset(std::move(owner_offset)),
38  m_donorRangeBeg(std::move(donor_beg)), m_donorRangeEnd(std::move(donor_end)),
39  m_donorOffset(std::move(donor_offset)), m_ownerZone(owner_zone), m_donorZone(donor_zone)
40  {
41  assert(is_valid());
44  }
45 
46  ZoneConnectivity(const std::string name, int owner_zone, const std::string donor_name,
47  int donor_zone, const Ioss::IJK_t p_transform, const Ioss::IJK_t range_beg,
48  const Ioss::IJK_t range_end, const Ioss::IJK_t donor_beg,
49  const Ioss::IJK_t donor_end, bool owns_nodes, bool from_decomp)
50  : m_connectionName(std::move(name)), m_donorName(std::move(donor_name)),
51  m_transform(std::move(p_transform)), m_ownerRangeBeg(std::move(range_beg)),
52  m_ownerRangeEnd(std::move(range_end)), m_donorRangeBeg(std::move(donor_beg)),
53  m_donorRangeEnd(std::move(donor_end)), m_ownerZone(owner_zone), m_donorZone(donor_zone),
54  m_ownsSharedNodes(owns_nodes), m_fromDecomp(from_decomp)
55  {
56  // This constructor typically called from decomposition process.
57  assert(is_valid());
59  }
60 
61  ZoneConnectivity(const ZoneConnectivity &copy_from) = default;
62 
63  // Return number of nodes in the connection shared with the donor zone.
64  size_t get_shared_node_count() const
65  {
66  size_t snc = 1;
67  for (int i = 0; i < 3; i++) {
68  snc *= (std::abs(m_ownerRangeEnd[i] - m_ownerRangeBeg[i]) + 1);
69  }
70  return snc;
71  }
72 
73  // Validate zgc -- if is_active(), then must have non-zero entries for all ranges.
74  // transform must have valid entries.
75  bool is_valid() const;
76  bool has_faces() const;
77  bool retain_original() const; // True if need to retain in parallel decomp
78 
79  std::array<INT, 9> transform_matrix() const;
80  Ioss::IJK_t transform(const Ioss::IJK_t &index_1) const;
81  Ioss::IJK_t inverse_transform(const Ioss::IJK_t &index_1) const;
82 
83  std::vector<int> get_range(int ordinal) const;
84  friend std::ostream &operator<<(std::ostream &os, const ZoneConnectivity &zgc);
85 
86  bool is_from_decomp() const { return m_fromDecomp; }
87  bool is_active() const { return m_isActive && has_faces(); }
88 
89  std::string m_connectionName{}; // Name of the connection; either generated or from file
90  std::string m_donorName{}; // Name of the zone (m_donorZone) to which this zone is connected via
91  // this connection.
92  Ioss::IJK_t m_transform{}; // The transform. In the same form as defined by CGNS
93 
94  // The following are all subsetted down to the portion that is actually on this zone
95  // This can be different than m_ownerRange and m_donorRange in a parallel run if the
96  // decomposition splits the connection. In a serial run, they are the same.
97  //
98  // 1 of ijk should be the same for rangeBeg and rangeEnd defining a surface.
99  Ioss::IJK_t m_ownerRangeBeg{}; // ijk triplet defining beginning of range on this zone
100  Ioss::IJK_t m_ownerRangeEnd{}; // ijk triplet defining end of range on this zone
101  Ioss::IJK_t m_ownerOffset{}; // ijk triplet with offset of this zone. Used to convert
102  // rangeBeg and rangeEnd global indices to local indices
103  Ioss::IJK_t m_donorRangeBeg{}; // ijk triplet defining beginning of range on the connected zone
104  Ioss::IJK_t m_donorRangeEnd{}; // ijk triplet defining end of range on the connected zone
105  Ioss::IJK_t m_donorOffset{}; // ijk triplet with offset of the donor zone. Used to convert
106  // donorRangeBeg and End global indices to local indices
107 
108  size_t m_ownerGUID{}; // globally-unique id of owner
109  size_t m_donorGUID{}; // globally-unique id of donor
110 
111  // NOTE: Shared nodes are "owned" by the zone with the lowest zone id.
112  int m_ownerZone{}; // "id" of zone that owns this connection
113  int m_donorZone{}; // "id" of zone that is donor (or other side) of this connection
114  int m_ownerProcessor{-1}; // processor that owns the owner zone
115  int m_donorProcessor{-1}; // processor that owns the donor zone
116  bool m_sameRange{false}; // True if owner and donor range should always match...(special use
117  // during decomp)
118  // True if it is the "lower" zone id in the connection. Uses adam unless both have same adam.
119  bool m_ownsSharedNodes{false}; // Deprecate soon
120 
121  // True if this zc is created due to processor decompositions in a parallel run
122  bool m_fromDecomp{false};
123 
124  bool m_isActive{true}; // True if non-zero range. That is, it has at least one face
125  };
126 } // namespace Ioss
127 #endif
Ioss::ZoneConnectivity::m_ownsSharedNodes
bool m_ownsSharedNodes
Definition: Ioss_ZoneConnectivity.h:119
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:30
Ioss::ZoneConnectivity::get_shared_node_count
size_t get_shared_node_count() const
Definition: Ioss_ZoneConnectivity.h:64
Ioss::ZoneConnectivity::is_active
bool is_active() const
Definition: Ioss_ZoneConnectivity.h:87
Ioss::ZoneConnectivity::m_fromDecomp
bool m_fromDecomp
Definition: Ioss_ZoneConnectivity.h:122
Ioss::ZoneConnectivity::m_donorProcessor
int m_donorProcessor
Definition: Ioss_ZoneConnectivity.h:115
Ioss::ZoneConnectivity::m_connectionName
std::string m_connectionName
Definition: Ioss_ZoneConnectivity.h:89
Ioss
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:40
Ioss::ZoneConnectivity::m_donorName
std::string m_donorName
Definition: Ioss_ZoneConnectivity.h:90
Ioss::ZoneConnectivity::is_valid
bool is_valid() const
Definition: Ioss_ZoneConnectivity.C:114
Ioss::ZoneConnectivity
Definition: Ioss_ZoneConnectivity.h:29
Ioss::ZoneConnectivity::inverse_transform
Ioss::IJK_t inverse_transform(const Ioss::IJK_t &index_1) const
Definition: Ioss_ZoneConnectivity.C:218
Ioss::ZoneConnectivity::is_from_decomp
bool is_from_decomp() const
Definition: Ioss_ZoneConnectivity.h:86
Ioss::ZoneConnectivity::transform
Ioss::IJK_t transform(const Ioss::IJK_t &index_1) const
Definition: Ioss_ZoneConnectivity.C:189
Ioss::ZoneConnectivity::m_donorOffset
Ioss::IJK_t m_donorOffset
Definition: Ioss_ZoneConnectivity.h:105
INT
int INT
Definition: Ioss_StructuredBlock.h:27
Ioss::ZoneConnectivity::m_donorRangeEnd
Ioss::IJK_t m_donorRangeEnd
Definition: Ioss_ZoneConnectivity.h:104
Ioss::ZoneConnectivity::get_range
std::vector< int > get_range(int ordinal) const
Definition: Ioss_ZoneConnectivity.C:162
Ioss::ZoneConnectivity::m_donorRangeBeg
Ioss::IJK_t m_donorRangeBeg
Definition: Ioss_ZoneConnectivity.h:103
Ioss::ZoneConnectivity::retain_original
bool retain_original() const
Definition: Ioss_ZoneConnectivity.C:107
Ioss::ZoneConnectivity::transform_matrix
std::array< INT, 9 > transform_matrix() const
Definition: Ioss_ZoneConnectivity.C:178
Ioss::ZoneConnectivity::m_ownerZone
int m_ownerZone
Definition: Ioss_ZoneConnectivity.h:112
Ioss::ZoneConnectivity::m_donorZone
int m_donorZone
Definition: Ioss_ZoneConnectivity.h:113
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:46
Ioss::ZoneConnectivity::has_faces
bool has_faces() const
Definition: Ioss_ZoneConnectivity.C:87
Ioss::IJK_t
std::array< int, 3 > IJK_t
Definition: Ioss_CodeTypes.h:28
Ioss::ZoneConnectivity::ZoneConnectivity
ZoneConnectivity(const ZoneConnectivity &copy_from)=default
Ioss::ZoneConnectivity::operator<<
friend std::ostream & operator<<(std::ostream &os, const ZoneConnectivity &zgc)
Definition: Ioss_ZoneConnectivity.C:25
Ioss::ZoneConnectivity::m_ownerGUID
size_t m_ownerGUID
Definition: Ioss_ZoneConnectivity.h:108
Ioss::ZoneConnectivity::m_donorGUID
size_t m_donorGUID
Definition: Ioss_ZoneConnectivity.h:109
Ioss::ZoneConnectivity::m_isActive
bool m_isActive
Definition: Ioss_ZoneConnectivity.h:124
Ioss::ZoneConnectivity::m_transform
Ioss::IJK_t m_transform
Definition: Ioss_ZoneConnectivity.h:92
anonymous_namespace{io_info.C}::name
std::string name(const Ioss::GroupingEntity *entity)
Definition: io_info.C:65
Ioss::ZoneConnectivity::m_ownerProcessor
int m_ownerProcessor
Definition: Ioss_ZoneConnectivity.h:114
Ioss::ZoneConnectivity::m_ownerRangeEnd
Ioss::IJK_t m_ownerRangeEnd
Definition: Ioss_ZoneConnectivity.h:100
Ioss_CodeTypes.h
Ioss::ZoneConnectivity::m_sameRange
bool m_sameRange
Definition: Ioss_ZoneConnectivity.h:116
Ioss::ZoneConnectivity::m_ownerOffset
Ioss::IJK_t m_ownerOffset
Definition: Ioss_ZoneConnectivity.h:101
Ioss::ZoneConnectivity::m_ownerRangeBeg
Ioss::IJK_t m_ownerRangeBeg
Definition: Ioss_ZoneConnectivity.h:99