11#if defined PARALLEL_AWARE_EXODUS
16#include "ioex_export.h"
17#if !defined(NO_PARMETIS_SUPPORT)
22#if !defined(NO_ZOLTAN_SUPPORT)
23#include <zoltan_cpp.h>
34 struct IOEX_EXPORT BlockFieldData
39 std::vector<size_t> var_index;
41 BlockFieldData() :
id(0), comp_count(0) {}
42 BlockFieldData(
const int64_t id_) :
id(id_), comp_count(0) {}
43 BlockFieldData(
const int64_t id_,
size_t comp_count_) :
id(id_), comp_count(comp_count_) {}
46 class IOEX_EXPORT DecompositionDataBase
50 DecompositionDataBase(
const DecompositionDataBase &) =
delete;
51 DecompositionDataBase &operator=(
const DecompositionDataBase &) =
delete;
53 virtual ~DecompositionDataBase() =
default;
55 virtual void decompose_model(
int filePtr,
const std::string &filename) = 0;
74 int m_processorCount{0};
76 std::vector<Ioss::BlockDecompositionData> el_blocks;
77 std::vector<Ioss::SetDecompositionData> node_sets;
78 std::vector<Ioss::SetDecompositionData> side_sets;
81 ex_entity_id
id)
const;
84 void communicate_node_data(T *file_data, T *ioss_data,
size_t comp_count)
const;
87 void communicate_element_data(T *file_data, T *ioss_data,
size_t comp_count)
const;
89 void get_block_connectivity(
int filePtr,
void *data, int64_t
id,
size_t blk_seq,
92 void read_elem_proc_map(
int filePtr,
void *data)
const;
97 int get_set_mesh_var(
int filePtr, ex_entity_type type, ex_entity_id
id,
100 int get_set_mesh_double(
int filePtr, ex_entity_type type, ex_entity_id
id,
101 const Ioss::Field &field,
double *ioss_data)
const;
105 virtual int get_node_coordinates(
int filePtr,
double *ioss_data,
107 virtual int get_one_attr(
int exoid, ex_entity_type obj_type, ex_entity_id obj_id,
108 int attrib_index,
double *attrib)
const = 0;
109 virtual int get_attr(
int exoid, ex_entity_type obj_type, ex_entity_id obj_id,
size_t attr_count,
110 double *attrib)
const = 0;
111 virtual int get_var(
int filePtr,
int step, ex_entity_type type,
int var_index, ex_entity_id
id,
112 int64_t num_entity, std::vector<double> &data)
const = 0;
113 virtual int get_user_map(
int exoid, ex_entity_type obj_type, ex_entity_id
id,
int map_index,
114 size_t offset,
size_t num_entity,
void *map_data)
const = 0;
117 template <
typename INT>
class DecompositionData :
public DecompositionDataBase
124 void decompose_model(
int filePtr,
const std::string &filename);
126 IOSS_NODISCARD int spatial_dimension()
const {
return m_decomposition.m_spatialDimension; }
128 IOSS_NODISCARD size_t global_node_count()
const {
return m_decomposition.global_node_count(); }
129 IOSS_NODISCARD size_t global_elem_count()
const {
return m_decomposition.global_elem_count(); }
131 IOSS_NODISCARD size_t ioss_node_count()
const {
return m_decomposition.ioss_node_count(); }
132 IOSS_NODISCARD size_t ioss_elem_count()
const {
return m_decomposition.ioss_elem_count(); }
134 IOSS_NODISCARD size_t decomp_node_offset()
const {
return m_decomposition.file_node_offset(); }
135 IOSS_NODISCARD size_t decomp_node_count()
const {
return m_decomposition.file_node_count(); }
136 IOSS_NODISCARD size_t decomp_elem_offset()
const {
return m_decomposition.file_elem_offset(); }
137 IOSS_NODISCARD size_t decomp_elem_count()
const {
return m_decomposition.file_elem_count(); }
139 IOSS_NODISCARD std::vector<double> ¢roids() {
return m_decomposition.m_centroids; }
140 IOSS_NODISCARD std::vector<float> &weights() {
return m_decomposition.m_weights; }
142 template <
typename T>
143 void communicate_element_data(T *file_data, T *ioss_data,
size_t comp_count)
const
145 m_decomposition.communicate_element_data(file_data, ioss_data, comp_count);
148 template <
typename T>
150 size_t comp_count)
const
152 m_decomposition.communicate_set_data(file_data, ioss_data, set, comp_count);
155 template <
typename T>
156 void communicate_node_data(T *file_data, T *ioss_data,
size_t comp_count)
const
158 m_decomposition.communicate_node_data(file_data, ioss_data, comp_count);
161 void get_block_connectivity(
int filePtr, INT *data, int64_t
id,
size_t blk_seq,
166 return m_decomposition.m_nodeCommMap.size() / 2;
169 int get_attr(
int filePtr, ex_entity_type obj_type, ex_entity_id
id,
size_t attr_count,
170 double *attrib)
const;
171 int get_one_attr(
int filePtr, ex_entity_type obj_type, ex_entity_id
id,
int attrib_index,
172 double *attrib)
const;
174 int get_var(
int filePtr,
int step, ex_entity_type type,
int var_index, ex_entity_id
id,
175 int64_t num_entity, std::vector<double> &data)
const;
177 int get_user_map(
int exoid, ex_entity_type obj_type, ex_entity_id
id,
int map_index,
178 size_t offset,
size_t num_entity,
void *map_data)
const;
180 template <
typename T>
181 int get_set_mesh_var(
int filePtr, ex_entity_type type, ex_entity_id
id,
184 IOSS_NODISCARD size_t get_block_seq(ex_entity_type type, ex_entity_id
id)
const;
185 IOSS_NODISCARD size_t get_block_element_count(
size_t blk_seq)
const;
186 IOSS_NODISCARD size_t get_block_element_offset(
size_t blk_seq)
const;
188 void create_implicit_global_map(
const std::vector<int> &owning_proc,
189 std::vector<int64_t> &global_implicit_map,
Ioss::Map &node_map,
190 int64_t *locally_owned_count, int64_t *processor_offset);
195 IOSS_NODISCARD size_t node_global_to_local(
size_t global_index)
const
197 return m_decomposition.node_global_to_local(global_index);
200 IOSS_NODISCARD size_t elem_global_to_local(
size_t global_index)
const
202 return m_decomposition.elem_global_to_local(global_index);
206#if !defined(NO_ZOLTAN_SUPPORT)
207 void zoltan_decompose(
const std::string &method);
210#if !defined(NO_PARMETIS_SUPPORT)
211 void metis_decompose(
const std::string &method,
const std::vector<INT> &element_dist);
213 void internal_metis_decompose(
const std::string &method, idx_t *element_dist, idx_t *pointer,
214 idx_t *adjacency, idx_t *elem_partition);
217 void simple_decompose(
const std::string &method,
const std::vector<INT> &element_dist)
219 m_decomposition.simple_decompose(method, element_dist);
222 void simple_node_decompose(
const std::string &method,
const std::vector<INT> &node_dist);
224 template <
typename T>
225 int handle_sset_df(
int filePtr, ex_entity_id
id,
const Ioss::Field &field, T *ioss_data)
const;
227 int get_one_set_attr(
int filePtr, ex_entity_type type, ex_entity_id
id,
int attr_index,
228 double *ioss_data)
const;
229 int get_one_node_attr(
int filePtr, ex_entity_id
id,
int attr_index,
double *ioss_data)
const;
230 int get_one_elem_attr(
int filePtr, ex_entity_id
id,
int attr_index,
double *ioss_data)
const;
232 int get_set_attr(
int filePtr, ex_entity_type type, ex_entity_id
id,
size_t comp_count,
233 double *ioss_data)
const;
234 int get_node_attr(
int filePtr, ex_entity_id
id,
size_t comp_count,
double *ioss_data)
const;
235 int get_elem_attr(
int filePtr, ex_entity_id
id,
size_t comp_count,
double *ioss_data)
const;
237 int get_elem_map(
int filePtr, ex_entity_id blk_id,
int map_index,
size_t offset,
size_t count,
238 void *ioss_data)
const;
239 int get_node_map(
int filePtr,
int map_index,
size_t offset,
size_t count,
240 void *ioss_data)
const;
242 int get_node_var(
int filePtr,
int step,
int var_index, ex_entity_id
id, int64_t num_entity,
243 std::vector<double> &ioss_data)
const;
245 int get_elem_var(
int filePtr,
int step,
int var_index, ex_entity_id
id, int64_t num_entity,
246 std::vector<double> &ioss_data)
const;
248 int get_set_var(
int filePtr,
int step,
int var_index, ex_entity_type type, ex_entity_id
id,
249 int64_t num_entity, std::vector<double> &ioss_data)
const;
254 return m_decomposition.i_own_node(node);
260 return m_decomposition.i_own_elem(elem);
263 void build_global_to_local_elem_map() { m_decomposition.build_global_to_local_elem_map(); }
265 void get_element_block_communication()
267 m_decomposition.get_element_block_communication(el_blocks);
272 void get_common_set_data(
int filePtr, ex_entity_type set_type,
273 std::vector<Ioss::SetDecompositionData> &sets,
274 const std::string &set_type_name);
276 void get_nodeset_data(
int filePtr,
size_t set_count);
278 void get_sideset_data(
int filePtr,
size_t set_count);
280 void calculate_element_centroids(
int filePtr,
const std::vector<INT> &node_dist);
281#if !defined(NO_ZOLTAN_SUPPORT)
282 void get_local_element_list(
const ZOLTAN_ID_PTR &export_global_ids,
size_t export_count);
285 void get_shared_node_list() { m_decomposition.get_shared_node_list(); }
287 int get_node_coordinates(
int filePtr,
double *ioss_data,
const Ioss::Field &field)
const;
289 void get_local_node_list() { m_decomposition.get_local_node_list(); }
295 class IOEX_EXPORT ElementBlockBatchReader
298 ElementBlockBatchReader(
const DecompositionDataBase *decompDB);
301 get_connectivity_size(
const std::vector<int64_t> &blocks_subset_index)
const;
304 get_connectivity(
int filePtr,
const std::vector<int64_t> &blocks_subset_index,
308 get_offset(
const std::vector<int64_t> &blocks_subset_index,
309 const std::vector<int> &block_component_count)
const;
311 void get_field_data(
int filePtr,
void *data,
const std::vector<int64_t> &blocks_subset_index,
312 size_t step,
const std::vector<BlockFieldData> &block_data)
const;
315 const DecompositionDataBase *m_decompositionDB{
nullptr};
318 template <
typename INT>
319 std::vector<size_t> get_connectivity_impl(
int filePtr,
320 const std::vector<int64_t> &blocks_subset_index,
323 template <
typename INT>
324 void get_field_data_impl(
int filePtr,
void *iossData,
325 const std::vector<int64_t> &blocks_subset_index,
size_t step,
326 const std::vector<BlockFieldData> &block_data)
const;
328 template <
typename INT>
330 get_connectivity_file_offset(
const std::vector<int64_t> &blocks_subset_index)
const;
332 template <
typename INT>
333 std::vector<size_t> get_file_offset(
const std::vector<int64_t> &blocks_subset_index,
334 const std::vector<int> &block_component_count)
const;
337 get_connectivity_component_count(
const std::vector<int64_t> &blocks_subset_index)
const;
340 get_block_component_count(
const std::vector<int64_t> &blockSubsetIndex,
341 const std::vector<BlockFieldData> &blockFieldData)
const;
343 template <
typename INT>
344 void load_field_data(
int filePtr,
double *fileData,
345 const std::vector<int64_t> &blockSubsetIndex,
size_t step,
346 const std::vector<BlockFieldData> &blockFieldData,
347 const std::vector<int> &blockComponentCount,
348 const std::vector<size_t> &fileConnOffset)
const;
#define IOSS_NODISCARD
Definition Ioss_CodeTypes.h:55
int Ioss_MPI_Comm
Definition Ioss_CodeTypes.h:64
Definition Ioss_Decomposition.h:180
Definition Ioss_Decomposition.h:140
Holds metadata for bulk data associated with a GroupingEntity.
Definition Ioss_Field.h:25
A collection of Ioss::Property objects.
Definition Ioss_PropertyManager.h:36
Definition Ioss_Decomposition.h:92
A namespace for the exodus database format.
Definition Ioex_BaseDatabaseIO.C:209
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40
Ioss::NameList NameList
Definition Ioss_ChangeSetFactory.h:25
std::vector< int64_t > MapContainer
Definition Ioss_Map.h:29
int64_t id(Ioss::GroupingEntity *entity)
Definition io_info.C:133