Overture  Version 25
PETScSolver.h
Go to the documentation of this file.
1 #ifndef PETSC_SOLVER
2 
3 // **************************************************************************
4 // *********** PETScSolver: Oges interface to parallel PETsc ****************
5 // *********** PARALLEL VERSION ****************
6 // **************************************************************************
7 
8 // extern "C"
9 // {
10 #include "petscksp.h"
11 // }
12 
13 #include "Overture.h"
14 #include "ParallelUtility.h"
15 #include "EquationSolver.h"
16 
17 //extern "C"
18 //{
19 //#include "petscksp.h"
20 //}
21 
23 {
24 public:
25 
27 {
32 };
33 
34 
35 PETScSolver(Oges & oges_);
36 virtual ~PETScSolver();
37 
39 
40 
41 int destroy();
42 
44 
45 // Return the current memory usage in Mb:
47 
48 inline int getGlobalIndex( int n, int *iv, int grid, int p ) const;
49 int getGlobalIndex( int n, int *iv, int grid, realArray & ug ) const;
50 
52 
54 
55 virtual int printStatistics( FILE *file = stdout ) const; // output any relevant statistics
56 
58 
59 int buildSolver();
60 
62 
63 
64 // assign values to rhs for the the extra equations
65 virtual int setExtraEquationValues( realCompositeGridFunction & f, real *value );
66 
67 // return solution values from the extra equations
68 virtual int getExtraEquationValues( const realCompositeGridFunction & u, real *value );
69 
70 // evaluate the dot product of an extra equation times u
71 virtual int evaluateExtraEquation( const realCompositeGridFunction & u, real & value, int extraEquation=0 );
72 
73 virtual int evaluateExtraEquation( const realCompositeGridFunction & u, real & value,
74  real & sumOfExtraEquationCoefficients, int extraEquation=0 );
75 
76 virtual real sizeOf( FILE *file=NULL ); // return number of bytes allocated
77 
78 int setPetscParameters();
80 
81 int initializePETSc();
82 int finalizePETSc();
83 
84 
85 static int debug;
86 static int instancesOfPETSc; // keeps count of how many different applications use PETSc
87 
88  Vec x,b; /* approx solution, RHS */
89  Mat A; /* linear system matrix */
90  KSP ksp; /* linear solver context */
91  PC pc; // Preconditioner ctx
92  MatNullSpace nsp; // for singular problems
93  Vec *nullVector;
94 
95 // PetscRandom rctx; /* random number generator context */
96 // PetscReal norm; /* norm of solution error */
97  PetscInt i,j,I,J,Istart,Iend;
98  PetscErrorCode ierr;
99  PetscTruth flg;
100  PetscScalar v;
101 
102  bool turnOnPETScMemoryTracing; // have PETSc keep track of allocated memory.
103 
107 int *pnab,*pnoffset;
109 realCompositeGridFunction *pCoeff; // pointer to coefficients
110 realCompositeGridFunction *diagonalScale; // for scaling the equations
111 
113 
116 
119 
120 };
121 
122 
123 #endif