10#include "ioss_export.h"
25#if !defined(NO_PARMETIS_SUPPORT)
29#if !defined(NO_ZOLTAN_SUPPORT)
31#include <zoltan_cpp.h>
35#if defined DC_USE_HOPSCOTCH
37#elif defined DC_USE_ROBIN
61 size_t fileSectionOffset{0};
65 size_t globalCount{0};
67 size_t zoneNodeOffset{0};
68 std::string topologyType{
"unknown"};
69 int nodesPerEntity{0};
70 int attributeCount{0};
75 size_t localIossOffset{0};
101 MPI_Comm_free(&setComm_);
108 return ss_name_.empty() ? name_ : ss_name_;
122 std::string ss_name_{};
128 std::string topologyType{};
129 size_t parentBlockIndex{0};
131 int distributionFactorValsPerEntity{-1};
132 size_t distributionFactorCount{0};
133 double distributionFactorValue{
136 bool distributionFactorConstant{
false};
150 IOSS_NODISCARD size_t get_ioss_element_size(
const std::vector<int64_t> &blockSubsetIndex)
const;
153 get_ioss_offset(
const std::vector<int64_t> &blockSubsetIndex,
154 const std::vector<int> &blockComponentCount)
const;
157 get_import_offset(
const std::vector<int64_t> &blockSubsetIndex,
158 const std::vector<int> &blockComponentCount)
const;
161 get_connectivity_ioss_offset_size(
const std::vector<int64_t> &blockSubsetIndex)
const;
164 get_connectivity_ioss_component_count(
const std::vector<int64_t> &blockSubsetIndex)
const;
167 const std::vector<BlockDecompositionData> &
m_data;
169 IOSS_NODISCARD size_t get_ioss_offset_size(
const std::vector<int64_t> &blockSubsetIndex,
170 const std::vector<int> &blockComponentCount)
const;
173 get_connectivity_ioss_offset(
const std::vector<int64_t> &blockSubsetIndex)
const;
176 get_connectivity_import_offset(
const std::vector<int64_t> &blockSubsetIndex)
const;
212 return std::binary_search(
nodeGTL.begin(),
nodeGTL.end(), global_index);
219#if defined(DC_USE_VECTOR)
220 return std::binary_search(
221 elemGTL.begin(),
elemGTL.end(), std::pair<INT, INT>{global_index, 0},
222 [](
const std::pair<INT, INT> &lhs,
const std::pair<INT, INT> &val) ->
bool {
223 return lhs.first < val.first;
237 typename std::vector<INT>::const_iterator I =
240 return std::distance(
nodeGTL.begin(), I) + 1;
248#if defined(DC_USE_VECTOR)
249 auto I = lower_bound(
251 [](
const std::pair<INT, INT> &lhs, INT val) ->
bool { return lhs.first < val; });
252 assert(I !=
elemGTL.end() && I->first == (INT)global_index);
254 auto I =
elemGTL.find(global_index);
257 assert(I->first == (INT)global_index);
272#
if !defined(NO_ZOLTAN_SUPPORT)
275 std::vector<BlockDecompositionData> &element_blocks);
283 const std::vector<double> &z);
285#if !defined(NO_ZOLTAN_SUPPORT)
291#if !defined(NO_PARMETIS_SUPPORT)
293 std::vector<BlockDecompositionData> &el_blocks);
296 idx_t *element_dist, idx_t *pointer, idx_t *adjacency,
297 idx_t *elem_partition);
308 entity_proc[j++] = node_map[local_id];
327 template <
typename T>
339 std::copy(file_data, file_data + size, ioss_data);
348 if (comp_count == 1) {
351 export_data[i] = file_data[index];
368 ioss_data[i] = import_data[i];
380 for (
size_t j = 0; j < comp_count; j++) {
381 export_data[comp_count * i + j] = file_data[comp_count * index + j];
388 for (
size_t j = 0; j < comp_count; j++) {
390 file_data[comp_count * index + j];
400 export_count[i] *= comp_count;
401 export_disp[i] *= comp_count;
402 import_count[i] *= comp_count;
403 import_disp[i] *= comp_count;
407 Ioss::MY_Alltoallv(export_data, export_count, export_disp, import_data, import_count,
414 for (
size_t j = 0; j < comp_count; j++) {
415 ioss_data[comp_count * i + j] = import_data[comp_count * i + j];
422 for (
size_t j = 0; j < comp_count; j++) {
423 ioss_data[comp_count * (offset + i) + j] =
430 template <
typename T>
432 size_t comp_count)
const
435 std::vector<T> recv_data;
443 recv_data.resize(size);
445 std::copy(file_data, file_data + size, recv_data.begin());
452 if (comp_count == 1) {
454 for (
size_t i = 0; i < set.
ioss_count(); i++) {
456 ioss_data[i] = file_data[index];
461 for (
size_t i = 0; i < set.
ioss_count(); i++) {
463 ioss_data[i] = recv_data[index];
469 for (
size_t i = 0; i < set.
ioss_count(); i++) {
471 for (
size_t j = 0; j < comp_count; j++) {
472 ioss_data[comp_count * i + j] = file_data[comp_count * index + j];
478 for (
size_t i = 0; i < set.
ioss_count(); i++) {
480 for (
size_t j = 0; j < comp_count; j++) {
481 ioss_data[comp_count * i + j] = recv_data[comp_count * index + j];
488 template <
typename T,
typename U>
490 size_t comp_count)
const
500 auto size = block.
localMap.size() * comp_count;
501 std::copy(file_data, file_data + size, ioss_data);
505 std::vector<U> exports;
506 exports.reserve(comp_count * block.
exportMap.size());
507 std::vector<U> imports(comp_count * block.
importMap.size());
509 if (comp_count == 1) {
511 exports.push_back(file_data[i]);
519 for (
size_t i = 0; i < block.
localMap.size(); i++) {
523 for (
size_t i = 0; i < block.
importMap.size(); i++) {
524 ioss_data[block.
importMap[i]] = imports[i];
529 for (
size_t j = 0; j < comp_count; j++) {
530 exports.push_back(file_data[i * comp_count + j]);
540 export_count[i] *= comp_count;
541 export_disp[i] *= comp_count;
542 import_count[i] *= comp_count;
543 import_disp[i] *= comp_count;
547 Ioss::MY_Alltoallv(exports, export_count, export_disp, imports, import_count, import_disp,
552 for (
size_t i = 0; i < block.
localMap.size(); i++) {
553 for (
size_t j = 0; j < comp_count; j++) {
555 file_data[block.
localMap[i] * comp_count + j];
559 for (
size_t i = 0; i < block.
importMap.size(); i++) {
560 for (
size_t j = 0; j < comp_count; j++) {
561 ioss_data[block.
importMap[i] * comp_count + j] = imports[i * comp_count + j];
567 template <
typename T,
typename U>
569 T *file_data, U *ioss_data,
const std::vector<BlockDecompositionData> &blocks,
570 const std::vector<int64_t> &blockSubsetIndex,
const std::vector<size_t> &fileOffset,
571 const std::vector<int> &blockComponentCount)
const
573 size_t export_size = 0;
574 size_t import_size = 0;
576 for (
size_t bsi = 0; bsi < blockSubsetIndex.size(); bsi++) {
577 int64_t blk_seq = blockSubsetIndex[bsi];
580 size_t comp_count = blockComponentCount[bsi];
581 export_size += blk.
exportMap.size() * comp_count;
582 import_size += blk.
importMap.size() * comp_count;
585 std::vector<U> exports;
586 exports.reserve(export_size);
591 for (
int proc = 0; proc < nProc; proc++) {
592 for (
size_t bsi = 0; bsi < blockSubsetIndex.size(); bsi++) {
593 int64_t blk_seq = blockSubsetIndex[bsi];
595 size_t comp_count = blockComponentCount[bsi];
596 size_t fileDataOffset = fileOffset[bsi];
602 for (
size_t j = 0; j < comp_count; j++) {
603 size_t fileIndex = fileDataOffset + i * comp_count + j;
604 exports.push_back(file_data[fileIndex]);
610 std::vector<int64_t> export_count(nProc, 0);
611 std::vector<int64_t> export_disp(nProc, 0);
612 std::vector<int64_t> import_count(nProc, 0);
613 std::vector<int64_t> import_disp(nProc, 0);
615 for (
size_t bsi = 0; bsi < blockSubsetIndex.size(); bsi++) {
616 int64_t blk_seq = blockSubsetIndex[bsi];
618 size_t comp_count = blockComponentCount[bsi];
622 export_count[proc++] += comp_count * i;
627 import_count[proc++] += comp_count * i;
631 std::copy(export_count.begin(), export_count.end(), export_disp.begin());
632 std::copy(import_count.begin(), import_count.end(), import_disp.begin());
637 std::vector<U> imports(import_size);
638 Ioss::MY_Alltoallv(exports, export_count, export_disp, imports, import_count, import_disp,
643 std::vector<size_t> iossOffset =
645 std::vector<size_t> importOffset =
649 for (
size_t bsi = 0; bsi < blockSubsetIndex.size(); bsi++) {
650 int64_t blk_seq = blockSubsetIndex[bsi];
652 size_t comp_count = blockComponentCount[bsi];
654 for (
size_t i = 0; i < block.
localMap.size(); i++) {
655 for (
size_t j = 0; j < comp_count; j++) {
656 size_t fileIndex = fileOffset[bsi] + block.
localMap[i] * comp_count + j;
657 size_t iossIndex = iossOffset[bsi] + (i + block.
localIossOffset) * comp_count + j;
658 ioss_data[iossIndex] = file_data[fileIndex];
662 for (
size_t i = 0; i < block.
importMap.size(); i++) {
663 for (
size_t j = 0; j < comp_count; j++) {
664 size_t importIndex = importOffset[bsi] + i * comp_count + j;
666 size_t dataOffset = iossOffset[bsi];
667 size_t iossIndex = dataOffset + block.
importMap[i] * comp_count + j;
669 ioss_data[iossIndex] = imports[importIndex];
677 template <
typename T,
typename U>
679 T *file_data, U *ioss_data,
const std::vector<BlockDecompositionData> &blocks,
680 const std::vector<int64_t> &blockSubsetIndex,
const std::vector<size_t> &fileOffset,
681 const std::vector<int> &blockComponentCount)
const
688 auto size = fileOffset[blockSubsetIndex.size()];
689 std::copy(file_data, file_data + size, ioss_data);
692 return batchOffset.
get_ioss_offset(blockSubsetIndex, blockComponentCount);
697 fileOffset, blockComponentCount);
702 template <
typename T>
708 std::vector<T> export_data(
exportNodeMap.size() * comp_count);
709 std::vector<T> import_data(
importNodeMap.size() * comp_count);
711 if (comp_count == 1) {
715 export_data[i] = file_data[index];
734 ioss_data[index] = import_data[i];
741 for (
size_t j = 0; j < comp_count; j++) {
742 export_data[comp_count * i + j] = file_data[comp_count * index + j];
750 for (
size_t j = 0; j < comp_count; j++) {
752 file_data[comp_count * index + j];
762 export_count[i] *= comp_count;
763 export_disp[i] *= comp_count;
764 import_count[i] *= comp_count;
765 import_disp[i] *= comp_count;
769 Ioss::MY_Alltoallv(export_data, export_count, export_disp, import_data, import_count,
777 for (
size_t j = 0; j < comp_count; j++) {
778 ioss_data[comp_count * index + j] = import_data[comp_count * i + j];
895#if defined DC_USE_HOPSCOTCH
897#elif defined DC_USE_ROBIN
899#elif defined DC_USE_VECTOR
#define IOSS_NODISCARD
Definition Ioss_CodeTypes.h:55
int Ioss_MPI_Comm
Definition Ioss_CodeTypes.h:64
Definition Ioss_Decomposition.h:45
IOSS_NODISCARD size_t file_count() const
Definition Ioss_Decomposition.h:53
IOSS_NODISCARD int64_t id() const
Definition Ioss_Decomposition.h:52
IOSS_NODISCARD int zone() const
Definition Ioss_Decomposition.h:50
IOSS_NODISCARD const std::string & name() const
Definition Ioss_Decomposition.h:49
std::vector< int > localMap
Definition Ioss_Decomposition.h:76
IOSS_NODISCARD size_t global_count() const
Definition Ioss_Decomposition.h:55
std::vector< int > exportCount
Definition Ioss_Decomposition.h:81
IOSS_NODISCARD size_t ioss_count() const
Definition Ioss_Decomposition.h:54
IOSS_NODISCARD int section() const
Definition Ioss_Decomposition.h:51
size_t localIossOffset
Definition Ioss_Decomposition.h:75
std::vector< int > importIndex
Definition Ioss_Decomposition.h:88
std::vector< int > importMap
Definition Ioss_Decomposition.h:86
std::vector< int > exportIndex
Definition Ioss_Decomposition.h:82
std::vector< int > importCount
Definition Ioss_Decomposition.h:87
BlockDecompositionData()=default
std::vector< int > exportMap
Definition Ioss_Decomposition.h:80
Definition Ioss_Decomposition.h:180
IOSS_NODISCARD size_t global_elem_count() const
Definition Ioss_Decomposition.h:189
void metis_decompose(idx_t *pointer, idx_t *adjacency, std::vector< BlockDecompositionData > &el_blocks)
Definition Ioss_Decomposition.C:879
std::vector< INT > localElementMap
Definition Ioss_Decomposition.h:863
std::vector< INT > importNodeCount
Definition Ioss_Decomposition.h:884
std::vector< INT > exportElementMap
Definition Ioss_Decomposition.h:870
IOSS_NODISCARD size_t elem_global_to_local(size_t global_index) const
Definition Ioss_Decomposition.h:243
std::string m_method
Definition Ioss_Decomposition.h:788
void build_global_to_local_elem_map()
Definition Ioss_Decomposition.C:1271
IOSS_NODISCARD std::vector< size_t > communicate_entity_data(T *file_data, U *ioss_data, const std::vector< BlockDecompositionData > &blocks, const std::vector< int64_t > &blockSubsetIndex, const std::vector< size_t > &fileOffset, const std::vector< int > &blockComponentCount) const
Definition Ioss_Decomposition.h:678
std::vector< INT > exportNodeMap
Definition Ioss_Decomposition.h:878
std::vector< double > m_centroids
Definition Ioss_Decomposition.h:810
void communicate_element_data(T *file_data, T *ioss_data, size_t comp_count) const
Definition Ioss_Decomposition.h:328
bool m_retainFreeNodes
Definition Ioss_Decomposition.h:804
void guided_decompose()
Definition Ioss_Decomposition.C:684
std::vector< INT > importNodeIndex
Definition Ioss_Decomposition.h:885
std::vector< INT > m_elementDist
Definition Ioss_Decomposition.h:889
std::vector< INT > exportNodeCount
Definition Ioss_Decomposition.h:879
std::vector< int > m_elementToProc
Definition Ioss_Decomposition.h:809
IOSS_NODISCARD std::vector< size_t > do_communicate_entity_data(T *file_data, U *ioss_data, const std::vector< BlockDecompositionData > &blocks, const std::vector< int64_t > &blockSubsetIndex, const std::vector< size_t > &fileOffset, const std::vector< int > &blockComponentCount) const
Definition Ioss_Decomposition.h:568
std::vector< INT > nodeGTL
Definition Ioss_Decomposition.h:893
Ioss_MPI_Comm m_comm
Definition Ioss_Decomposition.h:784
bool m_showHWM
Definition Ioss_Decomposition.h:807
IOSS_NODISCARD size_t ioss_elem_count() const
Definition Ioss_Decomposition.h:191
void internal_metis_decompose(std::vector< BlockDecompositionData > &el_blocks, idx_t *element_dist, idx_t *pointer, idx_t *adjacency, idx_t *elem_partition)
Definition Ioss_Decomposition.C:993
std::vector< INT > m_nodeCommMap
Definition Ioss_Decomposition.h:815
std::vector< size_t > m_fileBlockIndex
Definition Ioss_Decomposition.h:821
size_t m_elementOffset
Definition Ioss_Decomposition.h:796
std::vector< INT > exportNodeIndex
Definition Ioss_Decomposition.h:880
void simple_node_decompose()
Definition Ioss_Decomposition.C:844
void get_element_block_communication(std::vector< BlockDecompositionData > &el_blocks)
Definition Ioss_Decomposition.C:336
void show_progress(const std::string &message) const
Definition Ioss_Decomposition.h:261
void get_node_entity_proc_data(INT *entity_proc, const Ioss::MapContainer &node_map, bool do_map) const
Definition Ioss_Decomposition.h:300
IOSS_NODISCARD size_t ioss_node_count() const
Definition Ioss_Decomposition.h:190
int m_processor
Definition Ioss_Decomposition.h:786
void get_local_element_list(const ZOLTAN_ID_PTR &export_global_ids, size_t export_count)
Definition Ioss_Decomposition.C:1233
int m_commonNodeCount
Definition Ioss_Decomposition.h:793
IOSS_NODISCARD bool i_own_elem(size_t global_index) const
Definition Ioss_Decomposition.h:216
size_t m_nodeOffset
Definition Ioss_Decomposition.h:801
void communicate_node_data(T *file_data, T *ioss_data, size_t comp_count) const
Definition Ioss_Decomposition.h:703
Decomposition(const Ioss::PropertyManager &props, Ioss_MPI_Comm comm)
Definition Ioss_Decomposition.C:285
size_t m_globalElementCount
Definition Ioss_Decomposition.h:794
void simple_decompose()
Definition Ioss_Decomposition.C:824
void decompose_model(Zoltan &zz, std::vector< BlockDecompositionData > &element_blocks)
Definition Ioss_Decomposition.C:418
std::vector< INT > m_nodeDist
Definition Ioss_Decomposition.h:890
size_t m_importPreLocalElemIndex
Definition Ioss_Decomposition.h:797
std::vector< INT > importElementMap
Definition Ioss_Decomposition.h:865
IOSS_NODISCARD size_t node_global_to_local(size_t global_index) const
Definition Ioss_Decomposition.h:230
IOSS_NODISCARD size_t file_elem_offset() const
Definition Ioss_Decomposition.h:198
Decomposition & operator=(Decomposition const &)=default
void generate_entity_distributions(size_t global_node_count, size_t global_element_count)
Definition Ioss_Decomposition.C:322
void communicate_block_data(T *file_data, U *ioss_data, const BlockDecompositionData &block, size_t comp_count) const
Definition Ioss_Decomposition.h:489
Decomposition(Decomposition const &)=default
IOSS_NODISCARD size_t file_node_count() const
Definition Ioss_Decomposition.h:195
std::vector< INT > m_adjacency
Definition Ioss_Decomposition.h:813
IOSS_NODISCARD bool needs_centroids() const
Definition Ioss_Decomposition.h:200
bool m_showProgress
Definition Ioss_Decomposition.h:806
void communicate_set_data(T *file_data, T *ioss_data, const SetDecompositionData &set, size_t comp_count) const
Definition Ioss_Decomposition.h:431
std::vector< INT > importElementCount
Definition Ioss_Decomposition.h:866
IOSS_NODISCARD size_t file_elem_count() const
Definition Ioss_Decomposition.h:196
Ioss::ParallelUtils m_pu
Definition Ioss_Decomposition.h:785
size_t m_importPreLocalNodeIndex
Definition Ioss_Decomposition.h:802
std::vector< INT > exportElementIndex
Definition Ioss_Decomposition.h:874
std::string m_decompExtra
Definition Ioss_Decomposition.h:789
Decomposition(Decomposition &&)=default
std::vector< INT > nodeIndex
Definition Ioss_Decomposition.h:876
size_t m_nodeCount
Definition Ioss_Decomposition.h:800
std::vector< INT > m_pointer
Definition Ioss_Decomposition.h:812
std::vector< INT > localNodeMap
Definition Ioss_Decomposition.h:887
IOSS_NODISCARD bool i_own_node(size_t global_index) const
Definition Ioss_Decomposition.h:209
std::vector< std::pair< INT, INT > > elemGTL
Definition Ioss_Decomposition.h:900
bool m_lineDecomp
Definition Ioss_Decomposition.h:805
std::vector< INT > exportElementCount
Definition Ioss_Decomposition.h:872
void zoltan_decompose(Zoltan &zz)
Definition Ioss_Decomposition.C:1096
IOSS_NODISCARD size_t file_node_offset() const
Definition Ioss_Decomposition.h:197
void calculate_element_centroids(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z)
Definition Ioss_Decomposition.C:517
Decomposition & operator=(Decomposition &&)=default
int m_processorCount
Definition Ioss_Decomposition.h:787
void get_local_node_list()
Definition Ioss_Decomposition.C:1314
size_t m_globalNodeCount
Definition Ioss_Decomposition.h:799
std::vector< float > m_weights
Definition Ioss_Decomposition.h:811
std::vector< INT > importElementIndex
Definition Ioss_Decomposition.h:867
int m_spatialDimension
Definition Ioss_Decomposition.h:792
IOSS_NODISCARD size_t global_node_count() const
Definition Ioss_Decomposition.h:188
std::vector< INT > importNodeMap
Definition Ioss_Decomposition.h:883
void get_shared_node_list()
Definition Ioss_Decomposition.C:1522
size_t m_elementCount
Definition Ioss_Decomposition.h:795
Definition Ioss_Decomposition.h:140
IOSS_NODISCARD std::vector< size_t > get_import_offset(const std::vector< int64_t > &blockSubsetIndex, const std::vector< int > &blockComponentCount) const
Definition Ioss_Decomposition.C:223
IOSS_NODISCARD std::vector< size_t > get_ioss_offset(const std::vector< int64_t > &blockSubsetIndex, const std::vector< int > &blockComponentCount) const
Definition Ioss_Decomposition.C:201
const std::vector< BlockDecompositionData > & m_data
Definition Ioss_Decomposition.h:167
ElementBlockBatchOffset()=delete
ElementBlockBatchOffset(const ElementBlockBatchOffset &)=delete
ElementBlockBatchOffset(ElementBlockBatchOffset &&)=delete
ElementBlockBatchOffset(const std::vector< BlockDecompositionData > &data)
Definition Ioss_Decomposition.h:142
Definition Ioss_ParallelUtils.h:32
IOSS_NODISCARD int parallel_size() const
Definition Ioss_ParallelUtils.C:206
static IOSS_NODISCARD constexpr Ioss_MPI_Comm comm_null()
Definition Ioss_ParallelUtils.h:50
void broadcast(T &my_value, int root=0) const
void progress(const std::string &output) const
Definition Ioss_ParallelUtils.C:601
A collection of Ioss::Property objects.
Definition Ioss_PropertyManager.h:36
Definition Ioss_Decomposition.h:92
IOSS_NODISCARD size_t ioss_count() const
Definition Ioss_Decomposition.h:114
IOSS_NODISCARD const std::string & ss_name() const
Definition Ioss_Decomposition.h:106
IOSS_NODISCARD size_t df_count() const
Definition Ioss_Decomposition.h:115
int root_
Definition Ioss_Decomposition.h:127
IOSS_NODISCARD int section() const
Definition Ioss_Decomposition.h:112
SetDecompositionData()=default
IOSS_NODISCARD int zone() const
Definition Ioss_Decomposition.h:111
IOSS_NODISCARD const std::string & name() const
Definition Ioss_Decomposition.h:105
std::vector< size_t > entitylist_map
Definition Ioss_Decomposition.h:118
IOSS_NODISCARD int64_t id() const
Definition Ioss_Decomposition.h:110
~SetDecompositionData()
Definition Ioss_Decomposition.h:98
IOSS_NODISCARD size_t file_count() const
Definition Ioss_Decomposition.h:113
std::vector< bool > hasEntities
Definition Ioss_Decomposition.h:119
SetDecompositionData(SetDecompositionData &&)=default
SetDecompositionData(const SetDecompositionData &)=delete
Ioss_MPI_Comm setComm_
Definition Ioss_Decomposition.h:135
static void generate_index(std::vector< T > &index)
Definition Ioss_Utils.h:177
Definition hopscotch_map.h:82
Definition robin_map.h:90
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40
Ioss::NameList NameList
Definition Ioss_ChangeSetFactory.h:25
IOSS_EXPORT const Ioss::NameList & valid_decomp_methods()
Definition Ioss_Decomposition.C:142
std::vector< int64_t > MapContainer
Definition Ioss_Map.h:29