PolyDiM
C++ library for POLYtopal DIscretization Methods
Loading...
Searching...
No Matches
MpiParallelEnvironment.hpp
Go to the documentation of this file.
1// _LICENSE_HEADER_
2//
3// Copyright (C) 2019 - 2025.
4// Terms register on the GPL-3.0 license.
5//
6// This file can be redistributed and/or modified under the license terms.
7//
8// See top level LICENSE file for more details.
9//
10// This file can be used citing references in CITATION.cff file.
11
12#ifndef __GEDIM_MPIPARALLELENVIRONMENT_H
13#define __GEDIM_MPIPARALLELENVIRONMENT_H
14
15#include "IMpiProcess.hpp"
16#include <memory>
17
18namespace Gedim
19{
23{
24 protected:
25 static std::shared_ptr<IMpiProcess> _process;
26
27 public:
28 static const IMpiProcess &Process()
29 {
30 return *_process;
31 }
32
36 template <typename ProcessType> static void Initialize(int argc, char **argv)
37 {
38#if USE_MPI == 1
39 MPI::Init(argc, argv);
40#endif
41
42 unsigned int rank = 0;
43 unsigned int numberProcesses = 1;
44
45#if USE_MPI == 1
46 MPI_Comm_rank(MPI_COMM_WORLD, (int *)&rank);
48#endif // USE_MPI
49
50 _process.reset(new ProcessType(rank, numberProcesses, true));
51 }
52
54 static void Finalize()
55 {
56#if USE_MPI == 1
57 MPI::Finalize();
58#endif
59 }
60};
61} // namespace Gedim
62
63#endif // __GEDIM_MPIPARALLELENVIRONMENT_H
Eigen column vector.
Definition Eigen_Array.hpp:23
Interface used to implement the MPI process.
Definition IMpiProcess.hpp:20
Interface used to implement the Mpi Parallel Environment.
Definition MpiParallelEnvironment.hpp:23
static void Initialize(int argc, char **argv)
Definition MpiParallelEnvironment.hpp:36
static const IMpiProcess & Process()
Definition MpiParallelEnvironment.hpp:28
static std::shared_ptr< IMpiProcess > _process
Definition MpiParallelEnvironment.hpp:25
static void Finalize()
Finalize the MPI Environment.
Definition MpiParallelEnvironment.hpp:54
Definition Eigen_Array.cpp:22