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

© 2012

R.E. Hewitt