CppNoddy  0.92
Loading...
Searching...
No Matches
PetscSession.h
Go to the documentation of this file.
1
2#if defined(PETSC_D) || defined(PETSC_Z)
3
4#ifndef PETSCSESSION_H
5#define PETSCSESSION_H
6
7#include <string.h>
8#include "petsc.h"
9
10namespace CppNoddy {
11
12
13 /* This initialises PETSc and then finalizes everything on destruction.
14 Instantiate this object first, then it will only finalize on
15 exit of main() */
16 class PetscSession {
17
18 private:
19 /// Constructor is private -- there is only 1 instance
20 PetscSession() {
21 };
22
23 public:
24
25 static PetscSession* getInstance(int argc, char *argv[]) {
26 static PetscSession instance;
27 PetscInitialize(&argc,&argv,(char*)0,(char*)0);
28#if defined(DEBUG)
29 PetscPrintf(PETSC_COMM_WORLD, "[DEBUG] Starting a PETSc session using command line options.\n");
30#endif
31 return &instance;
32 }
33
34 ~PetscSession() {
35#if defined(DEBUG)
36 PetscSynchronizedPrintf(PETSC_COMM_WORLD, "[DEBUG] Exiting the PETSc session.\n");
37#endif
38 PetscFinalize();
39 }
40
41
42
43 };
44
45} // end CppNoddy namespace
46
47#endif // include guard
48
49#endif // check for PETSC_D and PETSC_Z
50
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...

© 2012

R.E. Hewitt