Overture
Version 25
Main Page
Namespaces
Classes
Files
File List
File Members
Overture.v25.d
include
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
22
class
PETScSolver
:
public
EquationSolver
23
{
24
public
:
25
26
enum
SingularProblemEnum
27
{
28
notSingular
=0,
29
specifyConstantNullVector
,
30
specifyNullVector
,
31
addExtraEquation
32
};
33
34
35
PETScSolver
(
Oges
& oges_);
36
virtual
~PETScSolver
();
37
38
virtual
int
solve
(
realCompositeGridFunction
& u,
realCompositeGridFunction
& f );
39
40
41
int
destroy
();
42
43
int
buildGlobalIndexing
(
CompositeGrid
& cg,
realCompositeGridFunction
& uu );
44
45
// Return the current memory usage in Mb:
46
static
real
getCurrentMemoryUsage
();
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
51
real
getMaximumResidual
();
52
53
int
buildMatrix
(
realCompositeGridFunction
& coeff,
realCompositeGridFunction
& u );
54
55
virtual
int
printStatistics
( FILE *file = stdout )
const
;
// output any relevant statistics
56
57
int
setProblemIsSingular
(
SingularProblemEnum
singularOption=
specifyConstantNullVector
);
58
59
int
buildSolver
();
60
61
int
fillInterpolationCoefficients
(
realCompositeGridFunction
& uu);
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
();
79
int
setPetscRunTimeParameters
();
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
104
real
relativeTol
;
105
int
numberOfProcessors
;
106
int
numberOfGridPoints
,
numberOfGridPointsThisProcessor
,
numberOfUnknowns
,
numberOfUnknownsThisProcessor
;
107
int
*
pnab
,*
pnoffset
;
108
int
numberOfComponents
;
109
realCompositeGridFunction
*
pCoeff
;
// pointer to coefficients
110
realCompositeGridFunction
*
diagonalScale
;
// for scaling the equations
111
112
SingularProblemEnum
problemIsSingular
;
113
114
bool
initialized
;
115
bool
reInitialize
;
116
117
bool
useDiagonalScaling
;
118
bool
adjustPeriodicCoefficients
;
119
120
};
121
122
123
#endif
Generated on Fri Jan 4 2013 10:17:57 for Overture by
1.8.3