OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
environment.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 VTT Technical Research Centre of Finland Ltd
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
37#ifndef PFC_MPI_ENVIRONMENT_HPP
38#define PFC_MPI_ENVIRONMENT_HPP
39
40#include <mpi.h>
41
42namespace pfc {
43namespace mpi {
44
46public:
47 inline environment();
48 inline ~environment();
49 inline std::string processor_name();
50 inline bool initialized();
51 inline bool finalized();
52};
53
54inline environment::environment() { MPI_Init(NULL, NULL); }
55
56inline environment::~environment() { MPI_Finalize(); }
57
58inline std::string environment::processor_name() {
59 char name[MPI_MAX_PROCESSOR_NAME];
60 int resultlen;
61 MPI_Get_processor_name(name, &resultlen);
62 return std::string(name, resultlen);
63}
64
65inline bool environment::initialized() {
66 int flag;
67 MPI_Initialized(&flag);
68 return (flag != 0);
69}
70
71inline bool environment::finalized() {
72 int flag;
73 MPI_Finalized(&flag);
74 return (flag != 0);
75}
76
77} // namespace mpi
78} // namespace pfc
79
80#endif // PFC_MPI_ENVIRONMENT_HPP
Definition environment.hpp:45
Represents the global simulation domain (the "world").
Definition world.hpp:91