MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
structuredpartition.h
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#ifndef FVSOLVERSTRUCTPARTITION_H
8#define FVSOLVERSTRUCTPARTITION_H
9
10#include "INCLUDE/maiatypes.h"
11#include "MEMORY/scratch.h"
12
13class ParallelIoHdf5;
14
15class treeNode {
16 public:
22 treeNode** childs = nullptr;
23};
24
25template <MInt nDim>
27 public:
29 size = std::make_unique<MInt[]>(nDim);
30 offset = std::make_unique<MInt[]>(nDim);
31 };
33
36 MInt cpu = -1;
37 std::unique_ptr<MInt[]> size{};
38 std::unique_ptr<MInt[]> offset{};
41};
42
58template <MInt nDim>
60 public:
61 StructuredDecomposition(const MInt, const MString, MPI_Comm, const MInt);
62 StructuredDecomposition(const MInt, ParallelIoHdf5* pio, MPI_Comm, const MInt);
64 void decompose();
66 MInt getBlockIdFromPartition(const MInt domainId_) { return m_partitionInfo[domainId_]->blockId; };
67 MInt getPartitionOffset(const MInt domainId_, const MInt dim) { return m_partitionInfo[domainId_]->offset[dim]; };
68 MInt getPartitionSize(const MInt domainId_, const MInt dim) { return m_partitionInfo[domainId_]->size[dim]; };
69 MInt getBlockOffset(const MInt domainId_, const MInt dim) { return m_blockInfo[domainId_]->offset[dim]; };
70 MInt getBlockSize(const MInt domainId_, const MInt dim) { return m_blockInfo[domainId_]->size[dim]; };
71
72 private:
74 void initializeChilds(treeNode*& treePointer);
75 void setPartitionInfoHelper(treeNode*&, const MInt, const MInt (&)[nDim], MInt&, MInt (&)[nDim], MInt (&)[nDim],
76 MInt (&)[nDim]);
78 void traverseForInsertionNode(treeNode*& treePointer, const MInt, const MInt (&)[nDim], treeNode*&);
79 void destroyChilds(treeNode*& treePointer);
80 MInt sumLeaves(treeNode*& treePointer);
81 void insertChildAtNode(treeNode*&, const MInt, const MInt (&)[nDim]);
82 void addLeaf(treeNode**& treeRoot, MIntScratchSpace& level2dimension);
83 MInt noDomains() const { return m_noDomains; }
84
86 const MPI_Comm m_mpiComm;
90
91 std::vector<std::unique_ptr<PartitionInfo<nDim>>> m_blockInfo{};
92 std::vector<std::unique_ptr<PartitionInfo<nDim>>> m_partitionInfo{};
93};
94
95#endif
std::unique_ptr< MInt[]> offset
std::unique_ptr< MInt[]> size
This class is a ScratchSpace.
Definition: scratch.h:758
Class for the decomposition (partition) of structured grids.
MBool readFromFile()
Read a precomputed partition info from an external file.
MInt sumLeaves(treeNode *&treePointer)
Compute the number of leaves of a tree nodes.
MInt getPartitionSize(const MInt domainId_, const MInt dim)
void addLeaf(treeNode **&treeRoot, MIntScratchSpace &level2dimension)
Add a leaf into the tree.
void decompose()
Decompose the grid into partitions for the set number of domains.
std::vector< std::unique_ptr< PartitionInfo< nDim > > > m_blockInfo
MInt getBlockIdFromPartition(const MInt domainId_)
MInt getBlockOffset(const MInt domainId_, const MInt dim)
void destroyChilds(treeNode *&treePointer)
Recursively destroy all childs of a tree node.
MInt getBlockSize(const MInt domainId_, const MInt dim)
void setPartitionInfo(treeNode **&, MIntScratchSpace &)
Computes partition information from given BCT.
MInt getPartitionOffset(const MInt domainId_, const MInt dim)
void insertChildAtNode(treeNode *&, const MInt, const MInt(&)[nDim])
Inserts new child node below given tree node.
void traverseForInsertionNode(treeNode *&treePointer, const MInt, const MInt(&)[nDim], treeNode *&)
Recursively traverses the given tree to find the next insertion position.
void initializeChilds(treeNode *&treePointer)
Initializes the childs of the given tree node.
std::vector< std::unique_ptr< PartitionInfo< nDim > > > m_partitionInfo
void setPartitionInfoHelper(treeNode *&, const MInt, const MInt(&)[nDim], MInt &, MInt(&)[nDim], MInt(&)[nDim], MInt(&)[nDim])
Helper function for setPartionInfo.
treeNode ** childs
int32_t MInt
Definition: maiatypes.h:62
std::basic_string< char > MString
Definition: maiatypes.h:55
double MFloat
Definition: maiatypes.h:52
int64_t MLong
Definition: maiatypes.h:64
bool MBool
Definition: maiatypes.h:58