DOLFIN
DOLFIN C++ interface
SubSystemsManager.h
1// Copyright (C) 2008-2017 Garth N. Wells
2//
3// This file is part of DOLFIN.
4//
5// DOLFIN is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// DOLFIN is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17
18#ifndef __SUB_SYSTEMS_MANAGER_H
19#define __SUB_SYSTEMS_MANAGER_H
20
21#include <string>
22
23#ifdef HAS_PETSC
24#include <petsc.h>
25#endif
26
27namespace dolfin
28{
29
32
34 {
35 public:
36
41
42 // Copy constructor
43 SubSystemsManager(const SubSystemsManager&) = delete;
44
46 static void init_mpi();
47
49 static int init_mpi(int argc, char* argv[], int required_thread_level);
50
52 static void init_petsc();
53
57 static void init_petsc(int argc, char* argv[]);
58
61 static void finalize();
62
65 static bool responsible_mpi();
66
69 static bool responsible_petsc();
70
73 static bool mpi_initialized();
74
77 static bool mpi_finalized();
78
79#ifdef HAS_PETSC
83 static PetscErrorCode PetscDolfinErrorHandler(
84 MPI_Comm comm, int line, const char *fun, const char *file,
85 PetscErrorCode n, PetscErrorType p, const char *mess, void *ctx);
86#endif
87
89 std::string petsc_err_msg;
90
91 private:
92
93 // Constructor (private)
95
96 // Destructor
98
99 // Finalize MPI
100 static void finalize_mpi();
101
102 // Finalize PETSc
103 static void finalize_petsc();
104
105 // State variables
106 bool petsc_initialized;
107 bool control_mpi;
108
109 };
110
111}
112
113#endif
Definition: SubSystemsManager.h:34
static void init_mpi()
Initialise MPI.
Definition: SubSystemsManager.cpp:63
static bool responsible_petsc()
Definition: SubSystemsManager.cpp:203
static PetscErrorCode PetscDolfinErrorHandler(MPI_Comm comm, int line, const char *fun, const char *file, PetscErrorCode n, PetscErrorType p, const char *mess, void *ctx)
Definition: SubSystemsManager.cpp:289
static bool mpi_initialized()
Definition: SubSystemsManager.cpp:260
static bool responsible_mpi()
Definition: SubSystemsManager.cpp:198
static void finalize()
Definition: SubSystemsManager.cpp:191
static void init_petsc()
Initialize PETSc without command-line arguments.
Definition: SubSystemsManager.cpp:125
static bool mpi_finalized()
Definition: SubSystemsManager.cpp:276
static SubSystemsManager & singleton()
Definition: SubSystemsManager.cpp:46
std::string petsc_err_msg
Last recorded PETSc error message.
Definition: SubSystemsManager.h:89
Definition: adapt.h:30