18 {
19
20
23 util::io::print(fmt::format(
"Initialized MPI. MPI size = {}, MPI rank = {}\n", mpiSize, mpiRank));
25
27
28 if (input.cmdOptionExists("-h") or !input.cmdOptionExists("-o")) {
29
32 << ") -o <0 to perform basic test, 1 on uniform mesh and 2 to test on user mesh> -n <grid-size> -p <number-partitions> -m <horizon-integer-factor> -f <mesh-filename>" << std::endl;
33 std::cout << "To perform basic test" << std::endl;
34 std::cout << argv[0] << " -o 0" << std::endl;
35 std::cout << "To test on uniform mesh" << std::endl;
36 std::cout << argv[0] << " -o 1 -p 4 -m 4 -n 10 " << std::endl;
37 std::cout << "To test on user-provided mesh (filename = filepath/meshfile.vtu)" << std::endl;
38 std::cout << argv[0] << " -o 2 -p 4 -m 4 -f filepath/meshfile.vtu" << std::endl;
39 exit(EXIT_FAILURE);
40 }
41
42
43 size_t testOption, nGrid(0), nPart, mHorizon;
44 std::string meshFilename("");
45
46 if (input.cmdOptionExists("-o")) testOption = size_t(std::stoi(input.getCmdOption("-o")));
47 else {
48 std::cerr << "Test requires following arguments -o <option integer> -n <grid-size> -p <number-partition> -m <horizon-integer-factor> -f <mesh-filename>\n";
49 exit(1);
50 }
51
52 if (testOption == 0) {
53 std::cout << "testMeshPartitioning: Simple test of metis graph partitioning\n\n";
55 } else if (testOption == 1 or testOption == 2) {
56
57 if (input.cmdOptionExists("-n"))
58 nGrid = size_t(std::stoi(input.getCmdOption("-n")));
59 else {
60
61 if (testOption == 1) {
62 nGrid = 50;
63 std::cout << "Running test with default grid size = "
64 << nGrid << std::endl;
65 }
66 }
67
68 if (input.cmdOptionExists("-p"))
69 nPart = size_t(std::stoi(input.getCmdOption("-p")));
70 else {
71 nPart = 4;
72 std::cout << "Running test with default number of partitions = "
73 << nPart << std::endl;
74
75 }
76
77 if (input.cmdOptionExists("-m"))
78 mHorizon = size_t(std::stoi(input.getCmdOption("-m")));
79 else {
80 mHorizon = 4;
81 std::cout << "Running test with default integer factor for horizon = "
82 << mHorizon << std::endl;
83 }
84
85 if (input.cmdOptionExists("-f")) meshFilename = input.getCmdOption("-f");
86
87
88 if ((nGrid > 0 and testOption == 2) or
89 (!meshFilename.empty() and testOption == 1)) {
90 std::cerr
91 << "Please specify either using uniform mesh (in-built) or user-defined mesh "
92 "to perform the partitioning test. "
93 "That is, either specify '-o 1 -n <grid-size>' "
94 "or '-o 2 -f <mesh-filename>'.\n";
95 exit(1);
96 }
97
98
99 std::cout
100 << "\n\ntestMeshPartitioning: Test of metis graph partitioning on 2-D mesh with nonlocal interaction\n\n";
102 meshFilename);
103 } else {
104 std::cout << "Invalid option -o argument.\n";
105 }
106
107 return EXIT_SUCCESS;
108}
size_t const MINOR_VERSION
size_t const UPDATE_VERSION
size_t const MAJOR_VERSION
void testGraphPartitioningSimple()
Tests metis partitioning of graph.
void testGraphPartitioning(size_t nPart=4, size_t nGrid=10, size_t mHorizon=3, size_t testOption=0, std::string meshFilename="")
Tests metis partitioning of graph from a 2-D mesh with nonlocal interaction.
std::string printStr(const T &msg, int nt=print_default_tab)
Returns formatted string for output.
void print(const T &msg, int nt=print_default_tab, int printMpiRank=print_default_mpi_rank)
Prints formatted information.
const MpiStatus * getMpiStatus()
Returns pointer to MpiStatus struct.
void initMpi(int argc=0, char *argv[]=nullptr)
Initializes MPI and also creates MpiStatus struct.
int mpiSize()
Get size (number) of processors.
int mpiRank()
get rank (id) of this processor