VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
MetisPartitioner.cpp
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
33//=======================================================================================
34#if defined VF_METIS
35
36#include "MetisPartitioner.h"
37
39{
41 options[METIS_OPTION_NUMBERING] = 0;
42 vsize = NULL;
43 tpwgts = NULL;
44 ubvec = NULL;
45
46 // options[METIS_OPTION_OBJTYPE] = METIS_OBJTYPE_CUT;
48
49 // options[METIS_OPTION_CTYPE] = METIS_CTYPE_SHEM;
50 // options[METIS_OPTION_IPTYPE] = METIS_IPTYPE_GROW;
51}
54void MetisPartitioner::setMetisOptions(int option, idx_t value) { options[option] = value; }
57{
58 int rc {0};
59 idx_t nvtxs = (idx_t)xadj.size() - 1; // number of nodes
60 idx_t ncon = (idx_t)vwgt.size() / nvtxs; // number Of node constraints;
61 part.resize(nvtxs);
64
65 switch (ptype) {
67 if (nofParts < 1)
68 UB_THROW(UbException(UB_EXARGS, "invalid nofParts<1"));
69 else if (nofParts == 1) {
70 part.resize(nvtxs, 0);
71 return 0;
72 }
73 // else if( nofParts > 8 ) UBLOG(logWARNING, "MetisPartitioner::Recursive: !!!Warning!!! best for
74 // nofParts<=8 --> Kway is maybe a better option");
75
77 &nofPartsMetis, tpwgts, ubvec, options, &edgecutCount, &part[0]);
78 break;
80 if (nofParts < 1)
81 UB_THROW(UbException(UB_EXARGS, "invalid nofParts<1"));
82 else if (nofParts == 1) {
83 part.resize(nvtxs, 0);
84 return 0;
85 }
86 // else if( nofParts < 9 ) UBLOG(logWARNING, "MetisPartitioner::Kway: !!!Warning!!! best for nofParts>8
87 // --> Recursive is maybe a better option");
88
90 tpwgts, ubvec, options, &edgecutCount, &part[0]);
91 break;
92 }
93
94 switch (rc) {
96 throw UbException(UB_EXARGS, "METIS: input error");
97 break;
99 throw UbException(UB_EXARGS, "METIS: it could not allocate the required memory");
100 break;
101 case METIS_ERROR:
102 throw UbException(UB_EXARGS, "METIS: error");
103 break;
104 }
105
106 return edgecutCount;
107}
108#endif
109
std::vector< idx_t > adjncy
std::vector< idx_t > adjwgt
std::vector< idx_t > part
std::vector< idx_t > xadj
std::vector< idx_t > vwgt
std::shared_ptr< T > SPtr
int partition(int nofParts, PartType ptype)
void setMetisOptions(int option, idx_t value)
#define UB_THROW(e)
Definition UbException.h:78
#define UB_EXARGS
Definition UbException.h:73