IOSS 2.0

Iocgns_DecompositionData.h
Go to the documentation of this file.
1 /*
2 * Copyright(C) 1999-2017 National Technology & Engineering Solutions
3 * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
4 * NTESS, the U.S. Government retains certain rights in this software.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 *
18 * * Neither the name of NTESS nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34 #ifndef IOCGNS_DECOMPOSITONDATA_H
35 #define IOCGNS_DECOMPOSITONDATA_H
36
37 #include <string>
38 #include <unordered_map>
39 #include <vector>
40
41 #include <cstddef>
42 #include <cstdint>
43
44 #include <Ioss_CodeTypes.h>
45 #include <Ioss_Decomposition.h>
46 #include <Ioss_Field.h>
47 #include <Ioss_PropertyManager.h>
48 #include <Ioss_StructuredBlock.h>
49 #include <cgns/Iocgns_StructuredZoneData.h>
50
51 #include <cgnslib.h>
52
53 #if 0
54 #if !defined(NO_PARMETIS_SUPPORT)
55 #include <parmetis.h>
56 #endif
57 #endif
58
59 #undef MPICPP
60 #if !defined(NO_ZOLTAN_SUPPORT)
61 #include <zoltan_cpp.h>
62 #endif
63 namespace Ioss {
64 class Field;
65 template <typename INT> class Decomposition;
66 } // namespace Ioss
67
68 namespace Iocgns {
69
70 class ZoneData
71 {
72 public:
73 std::string m_name;
74 size_t m_nodeOffset;
75 size_t m_nodeCount;
76 size_t m_elementOffset;
77 };
78
79 class DecompositionDataBase
80 {
81 public:
82 DecompositionDataBase(MPI_Comm comm) {}
83
84 virtual ~DecompositionDataBase();
85 virtual void decompose_model(int serFilePtr, int filePtr, CG_ZoneType_t common_zone_type) = 0;
86 virtual size_t ioss_node_count() const = 0;
87 virtual size_t ioss_elem_count() const = 0;
88 virtual int int_size() const = 0;
89
90 virtual int spatial_dimension() const = 0;
91 virtual size_t global_node_count() const = 0;
92 virtual size_t global_elem_count() const = 0;
93
94 virtual size_t decomp_node_offset() const = 0;
95 virtual size_t decomp_node_count() const = 0;
96 virtual size_t decomp_elem_offset() const = 0;
97 virtual size_t decomp_elem_count() const = 0;
98
99 virtual std::vector<double> &centroids() = 0;
100
101 virtual size_t get_commset_node_size() const = 0;
102
103 virtual void get_node_coordinates(int filePtr, double *ioss_data,
104 const Ioss::Field &field) const = 0;
105
106 void get_block_connectivity(int filePtr, void *data, int blk_seq) const;
107
108 void get_element_field(int filePtr, int solution_index, int blk_seq, int field_index,
109 double *data) const;
110
111 void get_node_field(int filePtr, int solution_index, int field_index, double *data) const;
112
113 void get_node_entity_proc_data(void *entity_proc, const Ioss::MapContainer &node_map,
114 bool do_map) const;
115
116 template <typename T>
117 void communicate_element_data(T *file_data, T *ioss_data, size_t comp_count) const;
118
119 template <typename T>
120 void communicate_node_data(T *file_data, T *ioss_data, size_t comp_count) const;
121
122 void get_sideset_element_side(int filePtr, const Ioss::SetDecompositionData &sset,
123 void *data) const;
124
125 std::vector<ZoneData> m_zones;
126 std::vector<Ioss::BlockDecompositionData> m_elementBlocks;
127 std::vector<Ioss::SetDecompositionData> m_sideSets;
128 std::vector<Iocgns::StructuredZoneData *> m_structuredZones;
129
130 // Maps nodes shared between zones.
131 // TODO: Currently each processor has same map; need to figure out how to reduce size
132 std::unordered_map<cgsize_t, cgsize_t> m_zoneSharedMap;
133 };
134
135 template <typename INT> class DecompositionData : public DecompositionDataBase
136 {
137 public:
138 DecompositionData(const Ioss::PropertyManager &props, MPI_Comm communicator);
139 ~DecompositionData() {}
140
141 int int_size() const { return sizeof(INT); }
142
143 void decompose_model(int serFilePtr, int filePtr, CG_ZoneType_t common_zone_type);
144
145 int spatial_dimension() const { return m_decomposition.m_spatialDimension; }
146
147 size_t global_node_count() const { return m_decomposition.global_node_count(); }
148 size_t global_elem_count() const { return m_decomposition.global_elem_count(); }
149
150 size_t ioss_node_count() const { return m_decomposition.ioss_node_count(); }
151 size_t ioss_elem_count() const { return m_decomposition.ioss_elem_count(); }
152
153 size_t decomp_node_offset() const { return m_decomposition.file_node_offset(); }
154 size_t decomp_node_count() const { return m_decomposition.file_node_count(); }
155 size_t decomp_elem_offset() const { return m_decomposition.file_elem_offset(); }
156 size_t decomp_elem_count() const { return m_decomposition.file_elem_count(); }
157
158 std::vector<double> &centroids() { return m_decomposition.m_centroids; }
159
160 template <typename T>
161 void communicate_element_data(T *file_data, T *ioss_data, size_t comp_count) const
162 {
163 m_decomposition.communicate_element_data(file_data, ioss_data, comp_count);
164 }
165
166 void communicate_set_data(INT *file_data, INT *ioss_data, const Ioss::SetDecompositionData &set,
167 size_t comp_count) const
168 {
169 m_decomposition.communicate_set_data(file_data, ioss_data, set, comp_count);
170 }
171
172 template <typename T>
173 void communicate_node_data(T *file_data, T *ioss_data, size_t comp_count) const
174 {
175 m_decomposition.communicate_node_data(file_data, ioss_data, comp_count);
176 }
177
178 template <typename U, typename T>
179 void communicate_block_data(U *file_data, T *ioss_data,
180 const Ioss::BlockDecompositionData &block, size_t comp_count) const
181 {
182 m_decomposition.communicate_block_data(file_data, ioss_data, block, comp_count);
183 }
184
185 void get_block_connectivity(int filePtr, INT *data, int blk_seq) const;
186
187 void get_element_field(int filePtr, int solution_index, int blk_seq, int field_index,
188 double *data) const;
189
190 void get_node_field(int filePtr, int solution_index, int field_index, double *data) const;
191
192 size_t get_commset_node_size() const { return m_decomposition.m_nodeCommMap.size() / 2; }
193
194 void get_sideset_element_side(int filePtr, const Ioss::SetDecompositionData &sset,
195 INT *data) const;
196
197 private:
198 void decompose_structured(int serFilePtr, int filePtr);
199 void decompose_unstructured(int filePtr);
200
201 void get_sideset_data(int filePtr);
202 void generate_zone_shared_nodes(int filePtr, INT min_node, INT max_node);
203
204 bool i_own_node(size_t node)
205 const // T/F if node with global index node owned by this processors ioss-decomp.
206 {
207 return m_decomposition.i_own_node(node);
208 }
209
210 bool i_own_elem(size_t elem)
211 const // T/F if node with global index elem owned by this processors ioss-decomp.
212 {
213 return m_decomposition.i_own_elem(elem);
214 }
215
216 // global_index is 1-based index into global list of nodes [1..global_node_count]
217 // return value is 1-based index into local list of nodes on this
218 // processor (ioss-decomposition)
219 size_t node_global_to_local(size_t global_index) const
220 {
221 return m_decomposition.node_global_to_local(global_index);
222 }
223
224 size_t elem_global_to_local(size_t global_index) const
225 {
226 return m_decomposition.elem_global_to_local(global_index);
227 }
228
229 void build_global_to_local_elem_map()
230 {
231 return m_decomposition.build_global_to_local_elem_map();
232 }
233
234 void get_element_block_communication()
235 {
236 m_decomposition.get_element_block_communication(m_elementBlocks);
237 }
238
239 void generate_adjacency_list(int fileId, Ioss::Decomposition<INT> &decomposition);
240
241 void calculate_element_centroids(int filePtr, std::vector<double> &centroids);
242
243 void get_shared_node_list() { m_decomposition.get_shared_node_list(); }
244
245 void get_local_node_list() { m_decomposition.get_local_node_list(); }
246
247 void get_file_node_coordinates(int filePtr, int direction, double *ioss_data) const;
248 void get_node_coordinates(int filePtr, double *ioss_data, const Ioss::Field &field) const;
249
250 double m_loadBalanceThreshold{1.4};
251 std::string m_lineDecomposition{};
252
253 public:
254 Ioss::Decomposition<INT> m_decomposition;
255 };
256
257 } // namespace Iocgns
258 #endif
Iocgns::DecompositionData::get_local_node_list
void get_local_node_list()
Definition: Iocgns_DecompositionData.h:245
Ioss_CodeTypes.h
Iocgns::DecompositionData::global_node_count
size_t global_node_count() const
Definition: Iocgns_DecompositionData.h:147
Iocgns::DecompositionDataBase::decomp_elem_count
virtual size_t decomp_elem_count() const =0
Iocgns::DecompositionDataBase::get_sideset_element_side
void get_sideset_element_side(int filePtr, const Ioss::SetDecompositionData &sset, void *data) const
Definition: Iocgns_DecompositionData.C:1525
Iocgns::DecompositionDataBase::get_commset_node_size
virtual size_t get_commset_node_size() const =0
Iocgns::DecompositionData::m_lineDecomposition
std::string m_lineDecomposition
Definition: Iocgns_DecompositionData.h:251
Iocgns::DecompositionData::centroids
std::vector< double > & centroids()
Definition: Iocgns_DecompositionData.h:158
Iocgns::DecompositionData::decompose_unstructured
void decompose_unstructured(int filePtr)
Definition: Iocgns_DecompositionData.C:665
Ioss
The main namespace for the Ioss library.
Definition: Iocgns_DatabaseIO.h:50
Iocgns::DecompositionDataBase
Definition: Iocgns_DecompositionData.h:79
Iocgns::DecompositionDataBase::m_structuredZones
std::vector< Iocgns::StructuredZoneData * > m_structuredZones
Definition: Iocgns_DecompositionData.h:128
Iocgns::DecompositionDataBase::get_element_field
void get_element_field(int filePtr, int solution_index, int blk_seq, int field_index, double *data) const
Definition: Iocgns_DecompositionData.C:1493
Ioss::SetDecompositionData
Definition: Ioss_Decomposition.h:104
Iocgns::DecompositionData::get_sideset_data
void get_sideset_data(int filePtr)
Definition: Iocgns_DecompositionData.C:1066
Iocgns
A namespace for the CGNS database format.
Definition: Iocgns_DatabaseIO.C:392
Iocgns::DecompositionDataBase::communicate_element_data
void communicate_element_data(T *file_data, T *ioss_data, size_t comp_count) const
Definition: Iocgns_DecompositionData.C:1445
Iocgns::DecompositionData::int_size
int int_size() const
Definition: Iocgns_DecompositionData.h:141
Iocgns::DecompositionData::get_element_field
void get_element_field(int filePtr, int solution_index, int blk_seq, int field_index, double *data) const
Definition: Iocgns_DecompositionData.C:1389
Iocgns::DecompositionDataBase::decomp_elem_offset
virtual size_t decomp_elem_offset() const =0
Iocgns::DecompositionData::get_node_coordinates
void get_node_coordinates(int filePtr, double *ioss_data, const Ioss::Field &field) const
Definition: Iocgns_DecompositionData.C:1218
Iocgns::DecompositionData::DecompositionData
DecompositionData(const Ioss::PropertyManager &props, MPI_Comm communicator)
Definition: Iocgns_DecompositionData.C:444
Iocgns::DecompositionDataBase::m_zones
std::vector< ZoneData > m_zones
Definition: Iocgns_DecompositionData.h:125
Iocgns::DecompositionData::node_global_to_local
size_t node_global_to_local(size_t global_index) const
Definition: Iocgns_DecompositionData.h:219
Iocgns::DecompositionDataBase::decompose_model
virtual void decompose_model(int serFilePtr, int filePtr, CG_ZoneType_t common_zone_type)=0
Iocgns::DecompositionDataBase::communicate_node_data
void communicate_node_data(T *file_data, T *ioss_data, size_t comp_count) const
Definition: Iocgns_DecompositionData.C:1419
Ioss_PropertyManager.h
Iocgns::DecompositionData::communicate_node_data
void communicate_node_data(T *file_data, T *ioss_data, size_t comp_count) const
Definition: Iocgns_DecompositionData.h:173
Iocgns::DecompositionData::decomp_node_count
size_t decomp_node_count() const
Definition: Iocgns_DecompositionData.h:154
Iocgns::DecompositionData::communicate_block_data
void communicate_block_data(U *file_data, T *ioss_data, const Ioss::BlockDecompositionData &block, size_t comp_count) const
Definition: Iocgns_DecompositionData.h:179
Iocgns::DecompositionData::build_global_to_local_elem_map
void build_global_to_local_elem_map()
Definition: Iocgns_DecompositionData.h:229
Iocgns::DecompositionData::decomp_elem_offset
size_t decomp_elem_offset() const
Definition: Iocgns_DecompositionData.h:155
Iocgns::DecompositionDataBase::m_zoneSharedMap
std::unordered_map< cgsize_t, cgsize_t > m_zoneSharedMap
Definition: Iocgns_DecompositionData.h:132
Iocgns::DecompositionData
Definition: Iocgns_DecompositionData.h:135
Ioss_StructuredBlock.h
Iocgns::ZoneData::m_nodeCount
size_t m_nodeCount
Definition: Iocgns_DecompositionData.h:75
Iocgns::DecompositionData::i_own_elem
bool i_own_elem(size_t elem) const
Definition: Iocgns_DecompositionData.h:210
Iocgns::ZoneData::m_elementOffset
size_t m_elementOffset
Definition: Iocgns_DecompositionData.h:76
Iocgns::DecompositionData::generate_zone_shared_nodes
void generate_zone_shared_nodes(int filePtr, INT min_node, INT max_node)
Definition: Iocgns_DecompositionData.C:789
Iocgns::DecompositionDataBase::m_elementBlocks
std::vector< Ioss::BlockDecompositionData > m_elementBlocks
Definition: Iocgns_DecompositionData.h:126
Iocgns::DecompositionData::decomp_node_offset
size_t decomp_node_offset() const
Definition: Iocgns_DecompositionData.h:153
Iocgns::DecompositionDataBase::DecompositionDataBase
DecompositionDataBase(MPI_Comm comm)
Definition: Iocgns_DecompositionData.h:82
Iocgns::DecompositionDataBase::int_size
virtual int int_size() const =0
Iocgns::DecompositionDataBase::decomp_node_count
virtual size_t decomp_node_count() const =0
Ioss::MapContainer
std::vector< int64_t > MapContainer
Definition: Ioss_Map.h:48
Iocgns::DecompositionDataBase::get_node_field
void get_node_field(int filePtr, int solution_index, int field_index, double *data) const
Definition: Iocgns_DecompositionData.C:1509
Ioss_Decomposition.h
Iocgns::DecompositionDataBase::decomp_node_offset
virtual size_t decomp_node_offset() const =0
Iocgns::DecompositionData::get_file_node_coordinates
void get_file_node_coordinates(int filePtr, int direction, double *ioss_data) const
Definition: Iocgns_DecompositionData.C:1177
Iocgns::DecompositionData::~DecompositionData
~DecompositionData()
Definition: Iocgns_DecompositionData.h:139
Iocgns::DecompositionData::get_sideset_element_side
void get_sideset_element_side(int filePtr, const Ioss::SetDecompositionData &sset, INT *data) const
Definition: Iocgns_DecompositionData.C:1312
Iocgns::ZoneData::m_nodeOffset
size_t m_nodeOffset
Definition: Iocgns_DecompositionData.h:74
Iocgns::DecompositionDataBase::centroids
virtual std::vector< double > & centroids()=0
Iocgns::DecompositionData::communicate_element_data
void communicate_element_data(T *file_data, T *ioss_data, size_t comp_count) const
Definition: Iocgns_DecompositionData.h:161
Iocgns::DecompositionData::decompose_model
void decompose_model(int serFilePtr, int filePtr, CG_ZoneType_t common_zone_type)
Definition: Iocgns_DecompositionData.C:465
Iocgns::DecompositionData::ioss_elem_count
size_t ioss_elem_count() const
Definition: Iocgns_DecompositionData.h:151
INT
int INT
Definition: Ioss_StructuredBlock.h:53
Iocgns::DecompositionData::get_node_field
void get_node_field(int filePtr, int solution_index, int field_index, double *data) const
Definition: Iocgns_DecompositionData.C:1268
Iocgns::DecompositionData::elem_global_to_local
size_t elem_global_to_local(size_t global_index) const
Definition: Iocgns_DecompositionData.h:224
Ioss::Decomposition
Definition: Iocgns_DecompositionData.h:65
Iocgns::DecompositionDataBase::global_node_count
virtual size_t global_node_count() const =0
Iocgns::DecompositionData::spatial_dimension
int spatial_dimension() const
Definition: Iocgns_DecompositionData.h:145
Iocgns::DecompositionData::m_decomposition
Ioss::Decomposition< INT > m_decomposition
Definition: Iocgns_DecompositionData.h:254
Iocgns::DecompositionData::global_elem_count
size_t global_elem_count() const
Definition: Iocgns_DecompositionData.h:148
Iocgns::DecompositionDataBase::ioss_elem_count
virtual size_t ioss_elem_count() const =0
Iocgns::DecompositionDataBase::get_node_entity_proc_data
void get_node_entity_proc_data(void *entity_proc, const Ioss::MapContainer &node_map, bool do_map) const
Definition: Iocgns_DecompositionData.C:1461
Ioss_Field.h
Iocgns::DecompositionDataBase::global_elem_count
virtual size_t global_elem_count() const =0
Iocgns::DecompositionDataBase::ioss_node_count
virtual size_t ioss_node_count() const =0
anonymous_namespace{cth_pressure_map.C}::data
std::vector< char > data
Definition: cth_pressure_map.C:73
Iocgns::DecompositionData::m_loadBalanceThreshold
double m_loadBalanceThreshold
Definition: Iocgns_DecompositionData.h:250
Ioss::BlockDecompositionData
Definition: Ioss_Decomposition.h:57
Iocgns::DecompositionDataBase::m_sideSets
std::vector< Ioss::SetDecompositionData > m_sideSets
Definition: Iocgns_DecompositionData.h:127
Iocgns::DecompositionData::get_block_connectivity
void get_block_connectivity(int filePtr, INT *data, int blk_seq) const
Definition: Iocgns_DecompositionData.C:1354
Iocgns::DecompositionData::get_commset_node_size
size_t get_commset_node_size() const
Definition: Iocgns_DecompositionData.h:192
Iocgns::DecompositionData::decomp_elem_count
size_t decomp_elem_count() const
Definition: Iocgns_DecompositionData.h:156
Iocgns::DecompositionData::communicate_set_data
void communicate_set_data(INT *file_data, INT *ioss_data, const Ioss::SetDecompositionData &set, size_t comp_count) const
Definition: Iocgns_DecompositionData.h:166
Ioss::Field
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
Iocgns::DecompositionData::decompose_structured
void decompose_structured(int serFilePtr, int filePtr)
Definition: Iocgns_DecompositionData.C:483
Iocgns::DecompositionDataBase::~DecompositionDataBase
virtual ~DecompositionDataBase()
Definition: Iocgns_DecompositionData.C:1404
Iocgns::DecompositionData::calculate_element_centroids
void calculate_element_centroids(int filePtr, std::vector< double > &centroids)
MPI_Comm
int MPI_Comm
Definition: Ioss_CodeTypes.h:80
Iocgns::ZoneData::m_name
std::string m_name
Definition: Iocgns_DecompositionData.h:73
Iocgns::DecompositionData::ioss_node_count
size_t ioss_node_count() const
Definition: Iocgns_DecompositionData.h:150
Iocgns::DecompositionData::i_own_node
bool i_own_node(size_t node) const
Definition: Iocgns_DecompositionData.h:204
Iocgns::DecompositionData::get_shared_node_list
void get_shared_node_list()
Definition: Iocgns_DecompositionData.h:243
Iocgns::DecompositionData::get_element_block_communication
void get_element_block_communication()
Definition: Iocgns_DecompositionData.h:234
Ioss::PropertyManager
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
Iocgns::DecompositionDataBase::get_block_connectivity
void get_block_connectivity(int filePtr, void *data, int blk_seq) const
Definition: Iocgns_DecompositionData.C:1478
Iocgns::DecompositionDataBase::spatial_dimension
virtual int spatial_dimension() const =0
Iocgns_StructuredZoneData.h
Iocgns::ZoneData
Definition: Iocgns_DecompositionData.h:70
Iocgns::DecompositionData::generate_adjacency_list
void generate_adjacency_list(int fileId, Ioss::Decomposition< INT > &decomposition)
Definition: Iocgns_DecompositionData.C:900
Iocgns::DecompositionDataBase::get_node_coordinates
virtual void get_node_coordinates(int filePtr, double *ioss_data, const Ioss::Field &field) const =0