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_MeshType.h>
48 #include <Ioss_PropertyManager.h>
49 #include <Ioss_StructuredBlock.h>
50 #include <cgns/Iocgns_StructuredZoneData.h>
51
52 #include <cgnslib.h>
53
54 #if 0
55 #if !defined(NO_PARMETIS_SUPPORT)
56 #include <parmetis.h>
57 #endif
58 #endif
59
60 #undef MPICPP
61 #if !defined(NO_ZOLTAN_SUPPORT)
62 #include <zoltan_cpp.h>
63 #endif
64 namespace Ioss {
65 class Field;
66 template <typename INT> class Decomposition;
67 } // namespace Ioss
68
69 namespace Iocgns {
70
71 class ZoneData
72 {
73 public:
74 std::string m_name;
75 size_t m_nodeOffset;
76 size_t m_nodeCount;
77 size_t m_elementOffset;
78 };
79
80 class DecompositionDataBase
81 {
82 public:
83 DecompositionDataBase() {}
84
85 virtual ~DecompositionDataBase();
86 virtual void decompose_model(int filePtr, Ioss::MeshType mesh_type) = 0;
87 virtual size_t ioss_node_count() const = 0;
88 virtual size_t ioss_elem_count() const = 0;
89 virtual int int_size() const = 0;
90
91 virtual int spatial_dimension() const = 0;
92 virtual size_t global_node_count() const = 0;
93 virtual size_t global_elem_count() const = 0;
94
95 virtual size_t decomp_node_offset() const = 0;
96 virtual size_t decomp_node_count() const = 0;
97 virtual size_t decomp_elem_offset() const = 0;
98 virtual size_t decomp_elem_count() const = 0;
99
100 virtual std::vector<double> &centroids() = 0;
101
102 virtual size_t get_commset_node_size() const = 0;
103
104 virtual void get_node_coordinates(int filePtr, double *ioss_data,
105 const Ioss::Field &field) const = 0;
106
107 void get_block_connectivity(int filePtr, void *data, int blk_seq) const;
108
109 void get_element_field(int filePtr, int solution_index, int blk_seq, int field_index,
110 double *data) const;
111
112 void get_node_field(int filePtr, int solution_index, int field_index, double *data) const;
113
114 void get_node_entity_proc_data(void *entity_proc, const Ioss::MapContainer &node_map,
115 bool do_map) const;
116
117 template <typename T>
118 void communicate_element_data(T *file_data, T *ioss_data, size_t comp_count) const;
119
120 template <typename T>
121 void communicate_node_data(T *file_data, T *ioss_data, size_t comp_count) const;
122
123 void get_sideset_element_side(int filePtr, const Ioss::SetDecompositionData &sset,
124 void *data) const;
125
126 std::vector<ZoneData> m_zones;
127 std::vector<Ioss::BlockDecompositionData> m_elementBlocks;
128 std::vector<Ioss::SetDecompositionData> m_sideSets;
129 std::vector<Iocgns::StructuredZoneData *> m_structuredZones;
130
131 // Maps nodes shared between zones.
132 // TODO: Currently each processor has same map; need to figure out how to reduce size
133 std::unordered_map<cgsize_t, cgsize_t> m_zoneSharedMap;
134 };
135
136 template <typename INT> class DecompositionData : public DecompositionDataBase
137 {
138 public:
139 DecompositionData(const Ioss::PropertyManager &props, MPI_Comm communicator);
140 ~DecompositionData() {}
141
142 int int_size() const { return sizeof(INT); }
143
144 void decompose_model(int filePtr, Ioss::MeshType mesh_type);
145
146 int spatial_dimension() const { return m_decomposition.m_spatialDimension; }
147
148 size_t global_node_count() const { return m_decomposition.global_node_count(); }
149 size_t global_elem_count() const { return m_decomposition.global_elem_count(); }
150
151 size_t ioss_node_count() const { return m_decomposition.ioss_node_count(); }
152 size_t ioss_elem_count() const { return m_decomposition.ioss_elem_count(); }
153
154 size_t decomp_node_offset() const { return m_decomposition.file_node_offset(); }
155 size_t decomp_node_count() const { return m_decomposition.file_node_count(); }
156 size_t decomp_elem_offset() const { return m_decomposition.file_elem_offset(); }
157 size_t decomp_elem_count() const { return m_decomposition.file_elem_count(); }
158
159 std::vector<double> &centroids() { return m_decomposition.m_centroids; }
160
161 template <typename T>
162 void communicate_element_data(T *file_data, T *ioss_data, size_t comp_count) const
163 {
164 m_decomposition.communicate_element_data(file_data, ioss_data, comp_count);
165 }
166
167 void communicate_set_data(INT *file_data, INT *ioss_data, const Ioss::SetDecompositionData &set,
168 size_t comp_count) const
169 {
170 m_decomposition.communicate_set_data(file_data, ioss_data, set, comp_count);
171 }
172
173 template <typename T>
174 void communicate_node_data(T *file_data, T *ioss_data, size_t comp_count) const
175 {
176 m_decomposition.communicate_node_data(file_data, ioss_data, comp_count);
177 }
178
179 template <typename U, typename T>
180 void communicate_block_data(U *file_data, T *ioss_data,
181 const Ioss::BlockDecompositionData &block, size_t comp_count) const
182 {
183 m_decomposition.communicate_block_data(file_data, ioss_data, block, comp_count);
184 }
185
186 void get_block_connectivity(int filePtr, INT *data, int blk_seq) const;
187
188 void get_element_field(int filePtr, int solution_index, int blk_seq, int field_index,
189 double *data) const;
190
191 void get_node_field(int filePtr, int solution_index, int field_index, double *data) const;
192
193 size_t get_commset_node_size() const { return m_decomposition.m_nodeCommMap.size() / 2; }
194
195 void get_sideset_element_side(int filePtr, const Ioss::SetDecompositionData &sset,
196 INT *data) const;
197
198 private:
199 void decompose_structured(int filePtr);
200 void decompose_unstructured(int filePtr);
201
202 void get_sideset_data(int filePtr);
203 void generate_zone_shared_nodes(int filePtr, INT min_node, INT max_node);
204
205 bool i_own_node(size_t node)
206 const // T/F if node with global index node owned by this processors ioss-decomp.
207 {
208 return m_decomposition.i_own_node(node);
209 }
210
211 bool i_own_elem(size_t elem)
212 const // T/F if node with global index elem owned by this processors ioss-decomp.
213 {
214 return m_decomposition.i_own_elem(elem);
215 }
216
217 // global_index is 1-based index into global list of nodes [1..global_node_count]
218 // return value is 1-based index into local list of nodes on this
219 // processor (ioss-decomposition)
220 size_t node_global_to_local(size_t global_index) const
221 {
222 return m_decomposition.node_global_to_local(global_index);
223 }
224
225 size_t elem_global_to_local(size_t global_index) const
226 {
227 return m_decomposition.elem_global_to_local(global_index);
228 }
229
230 void build_global_to_local_elem_map()
231 {
232 return m_decomposition.build_global_to_local_elem_map();
233 }
234
235 void get_element_block_communication()
236 {
237 m_decomposition.get_element_block_communication(m_elementBlocks);
238 }
239
240 void generate_adjacency_list(int fileId, Ioss::Decomposition<INT> &decomposition);
241
242 void calculate_element_centroids(int filePtr, std::vector<double> &centroids);
243
244 void get_shared_node_list() { m_decomposition.get_shared_node_list(); }
245
246 void get_local_node_list() { m_decomposition.get_local_node_list(); }
247
248 void get_file_node_coordinates(int filePtr, int direction, double *ioss_data) const;
249 void get_node_coordinates(int filePtr, double *ioss_data, const Ioss::Field &field) const;
250
251 double m_loadBalanceThreshold{1.4};
252 std::string m_lineDecomposition{};
253
254 public:
255 Ioss::Decomposition<INT> m_decomposition;
256 };
257
258 } // namespace Iocgns
259 #endif
Iocgns::DecompositionData::get_local_node_list
void get_local_node_list()
Definition: Iocgns_DecompositionData.h:246
Ioss_CodeTypes.h
Iocgns::DecompositionData::global_node_count
size_t global_node_count() const
Definition: Iocgns_DecompositionData.h:148
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:1245
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:252
Iocgns::DecompositionData::centroids
std::vector< double > & centroids()
Definition: Iocgns_DecompositionData.h:159
Iocgns::DecompositionData::decompose_unstructured
void decompose_unstructured(int filePtr)
Definition: Iocgns_DecompositionData.C:369
Ioss
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:66
Iocgns::DecompositionDataBase
Definition: Iocgns_DecompositionData.h:80
Iocgns::DecompositionDataBase::m_structuredZones
std::vector< Iocgns::StructuredZoneData * > m_structuredZones
Definition: Iocgns_DecompositionData.h:129
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:1213
Ioss::SetDecompositionData
Definition: Ioss_Decomposition.h:104
Iocgns::DecompositionData::get_sideset_data
void get_sideset_data(int filePtr)
Definition: Iocgns_DecompositionData.C:775
Iocgns
A namespace for the CGNS database format.
Definition: Iocgns_DatabaseIO.C:444
Iocgns::DecompositionDataBase::communicate_element_data
void communicate_element_data(T *file_data, T *ioss_data, size_t comp_count) const
Definition: Iocgns_DecompositionData.C:1165
Iocgns::DecompositionData::int_size
int int_size() const
Definition: Iocgns_DecompositionData.h:142
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:1105
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:930
Iocgns::DecompositionData::DecompositionData
DecompositionData(const Ioss::PropertyManager &props, MPI_Comm communicator)
Definition: Iocgns_DecompositionData.C:215
Iocgns::DecompositionDataBase::m_zones
std::vector< ZoneData > m_zones
Definition: Iocgns_DecompositionData.h:126
Iocgns::DecompositionData::node_global_to_local
size_t node_global_to_local(size_t global_index) const
Definition: Iocgns_DecompositionData.h:220
Iocgns::DecompositionDataBase::communicate_node_data
void communicate_node_data(T *file_data, T *ioss_data, size_t comp_count) const
Definition: Iocgns_DecompositionData.C:1137
Ioss_PropertyManager.h
Ioss_MeshType.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:174
Iocgns::DecompositionData::decomp_node_count
size_t decomp_node_count() const
Definition: Iocgns_DecompositionData.h:155
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:180
Iocgns::DecompositionData::build_global_to_local_elem_map
void build_global_to_local_elem_map()
Definition: Iocgns_DecompositionData.h:230
Iocgns::DecompositionData::decomp_elem_offset
size_t decomp_elem_offset() const
Definition: Iocgns_DecompositionData.h:156
Iocgns::DecompositionDataBase::m_zoneSharedMap
std::unordered_map< cgsize_t, cgsize_t > m_zoneSharedMap
Definition: Iocgns_DecompositionData.h:133
Iocgns::DecompositionDataBase::DecompositionDataBase
DecompositionDataBase()
Definition: Iocgns_DecompositionData.h:83
Iocgns::DecompositionData
Definition: Iocgns_DecompositionData.h:136
Ioss_StructuredBlock.h
Iocgns::ZoneData::m_nodeCount
size_t m_nodeCount
Definition: Iocgns_DecompositionData.h:76
Iocgns::DecompositionData::i_own_elem
bool i_own_elem(size_t elem) const
Definition: Iocgns_DecompositionData.h:211
Iocgns::ZoneData::m_elementOffset
size_t m_elementOffset
Definition: Iocgns_DecompositionData.h:77
Iocgns::DecompositionData::generate_zone_shared_nodes
void generate_zone_shared_nodes(int filePtr, INT min_node, INT max_node)
Definition: Iocgns_DecompositionData.C:496
Iocgns::DecompositionDataBase::m_elementBlocks
std::vector< Ioss::BlockDecompositionData > m_elementBlocks
Definition: Iocgns_DecompositionData.h:127
Iocgns::DecompositionData::decomp_node_offset
size_t decomp_node_offset() const
Definition: Iocgns_DecompositionData.h:154
Iocgns::DecompositionDataBase::int_size
virtual int int_size() const =0
Iocgns::DecompositionDataBase::decomp_node_count
virtual size_t decomp_node_count() const =0
Iocgns::DecompositionDataBase::decompose_model
virtual void decompose_model(int filePtr, Ioss::MeshType mesh_type)=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:1229
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:886
Iocgns::DecompositionData::~DecompositionData
~DecompositionData()
Definition: Iocgns_DecompositionData.h:140
Iocgns::DecompositionData::get_sideset_element_side
void get_sideset_element_side(int filePtr, const Ioss::SetDecompositionData &sset, INT *data) const
Definition: Iocgns_DecompositionData.C:1024
Iocgns::ZoneData::m_nodeOffset
size_t m_nodeOffset
Definition: Iocgns_DecompositionData.h:75
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:162
Iocgns::DecompositionData::ioss_elem_count
size_t ioss_elem_count() const
Definition: Iocgns_DecompositionData.h:152
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:980
Iocgns::DecompositionData::elem_global_to_local
size_t elem_global_to_local(size_t global_index) const
Definition: Iocgns_DecompositionData.h:225
Ioss::Decomposition
Definition: Iocgns_DecompositionData.h:66
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:146
Iocgns::DecompositionData::m_decomposition
Ioss::Decomposition< INT > m_decomposition
Definition: Iocgns_DecompositionData.h:255
Iocgns::DecompositionData::global_elem_count
size_t global_elem_count() const
Definition: Iocgns_DecompositionData.h:149
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:1181
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:251
Ioss::BlockDecompositionData
Definition: Ioss_Decomposition.h:57
Iocgns::DecompositionDataBase::m_sideSets
std::vector< Ioss::SetDecompositionData > m_sideSets
Definition: Iocgns_DecompositionData.h:128
Iocgns::DecompositionData::get_block_connectivity
void get_block_connectivity(int filePtr, INT *data, int blk_seq) const
Definition: Iocgns_DecompositionData.C:1068
Iocgns::DecompositionData::get_commset_node_size
size_t get_commset_node_size() const
Definition: Iocgns_DecompositionData.h:193
Iocgns::DecompositionData::decomp_elem_count
size_t decomp_elem_count() const
Definition: Iocgns_DecompositionData.h:157
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:167
Ioss::Field
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
Iocgns::DecompositionDataBase::~DecompositionDataBase
virtual ~DecompositionDataBase()
Definition: Iocgns_DecompositionData.C:1120
Iocgns::DecompositionData::calculate_element_centroids
void calculate_element_centroids(int filePtr, std::vector< double > &centroids)
MPI_Comm
int MPI_Comm
Definition: Ioss_CodeTypes.h:88
Iocgns::ZoneData::m_name
std::string m_name
Definition: Iocgns_DecompositionData.h:74
Iocgns::DecompositionData::ioss_node_count
size_t ioss_node_count() const
Definition: Iocgns_DecompositionData.h:151
Iocgns::DecompositionData::decompose_structured
void decompose_structured(int filePtr)
Definition: Iocgns_DecompositionData.C:260
Ioss::MeshType
MeshType
The mesh type – structured, unstructured, hybrid (future), or unknown.
Definition: Ioss_MeshType.h:39
Iocgns::DecompositionData::i_own_node
bool i_own_node(size_t node) const
Definition: Iocgns_DecompositionData.h:205
Iocgns::DecompositionData::get_shared_node_list
void get_shared_node_list()
Definition: Iocgns_DecompositionData.h:244
Iocgns::DecompositionData::get_element_block_communication
void get_element_block_communication()
Definition: Iocgns_DecompositionData.h:235
Iocgns::DecompositionData::decompose_model
void decompose_model(int filePtr, Ioss::MeshType mesh_type)
Definition: Iocgns_DecompositionData.C:236
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:1198
Iocgns::DecompositionDataBase::spatial_dimension
virtual int spatial_dimension() const =0
Iocgns_StructuredZoneData.h
Iocgns::ZoneData
Definition: Iocgns_DecompositionData.h:71
Iocgns::DecompositionData::generate_adjacency_list
void generate_adjacency_list(int fileId, Ioss::Decomposition< INT > &decomposition)
Definition: Iocgns_DecompositionData.C:608
Iocgns::DecompositionDataBase::get_node_coordinates
virtual void get_node_coordinates(int filePtr, double *ioss_data, const Ioss::Field &field) const =0