xref: /petsc/include/petsc.h (revision 11ca99fd20cfeb10dd1e85d109c38fb94c6872ef)
1 /* $Id: petsc.h,v 1.169 1997/08/29 20:31:26 bsmith Exp bsmith $ */
2 /*
3    This is the main PETSc include file (for C and C++).  It is included by
4    all other PETSc include files so almost never has to be specifically included.
5 */
6 #if !defined(__PETSC_PACKAGE)
7 #define __PETSC_PACKAGE
8 
9 /*
10    Current PETSc Version
11 */
12 #define PETSC_VERSION_NUMBER "PETSc Version 2.0.19, Released August 13, 1997."
13 
14 #define PETSC_VERSION_MAJOR    2
15 #define PETSC_VERSION_MINOR    0
16 #define PETSC_VERSION_SUBMINOR 19
17 #define PETSC_VERSION_DATE     "August 13, 1997"
18 
19 /* Before anything else, include the PETSc configuration file.  This
20    contains various definitions that handle portability issues and the
21    presence of important features.  For backward compatibility while
22    developing, this configuration is itself conditionally included.
23  */
24 #ifdef HAVE_PETSCCONF_H
25 #include "petscconf.h"
26 #endif
27 
28 #include <stdio.h>
29 /*
30     Defines the interface to MPI allowing the use of all MPI functions.
31 */
32 #include "mpi.h"
33 
34 /*
35     Defines some elementary mathematics functions and constants.
36 */
37 #include "petscmath.h"
38 
39 extern MPI_Comm PETSC_COMM_WORLD;
40 extern MPI_Comm PETSC_COMM_SELF;
41 extern int      PetscInitializedCalled;
42 extern int      PetscSetCommWorld(MPI_Comm);
43 
44 /*
45     Defines the malloc employed by PETSc. Users may employ these routines as well.
46 */
47 extern void *(*PetscTrMalloc)(unsigned int,int,char*,char*,char*);
48 extern int  (*PetscTrFree)(void *,int,char*,char*,char*);
49 extern int  PetscSetMalloc(void *(*)(unsigned int,int,char*,char*,char*),
50                            int (*)(void *,int,char*,char*,char*));
51 #define PetscMalloc(a)       (*PetscTrMalloc)(a,__LINE__,__FUNC__,__FILE__,__SDIR__)
52 #define PetscNew(A)          (A*) PetscMalloc(sizeof(A))
53 #define PetscFree(a)         (*PetscTrFree)(a,__LINE__,__FUNC__,__FILE__,__SDIR__)
54 
55 extern int   PetscTrDump(FILE *);
56 extern int   PetscTrSpace( PLogDouble *, PLogDouble *,PLogDouble *);
57 extern int   PetscTrValid(int,char *,char *,char *);
58 extern int   PetscTrDebugLevel(int);
59 extern int   PetscTrLog();
60 extern int   PetscTrLogDump(FILE *);
61 extern int   PetscGetResidentSetSize(PLogDouble *);
62 
63 /*
64     Basic memory and string operations
65 */
66 extern void  PetscMemcpy(void *,void *,int);
67 extern void  PetscMemmove(void *,void *,int);
68 extern void  PetscMemzero(void *,int);
69 extern int   PetscMemcmp(void*, void*, int);
70 extern int   PetscStrlen(char *);
71 extern int   PetscStrcmp(char *,char *);
72 extern int   PetscStrcasecmp(char *,char *);
73 extern int   PetscStrncmp(char *,char *,int );
74 extern void  PetscStrcpy(char *,char *);
75 extern void  PetscStrcat(char *,char *);
76 extern void  PetscStrncat(char *,char *,int);
77 extern void  PetscStrncpy(char *,char *,int);
78 extern char* PetscStrchr(char *,char);
79 extern char* PetscStrrchr(char *,char);
80 extern char* PetscStrstr(char*,char*);
81 extern char* PetscStrtok(char*,char*);
82 extern char* PetscStrrtok(char*,char*);
83 
84 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth;
85 #define PETSC_NULL            0
86 #define PETSC_DECIDE         -1
87 #define PETSC_DEFAULT        -2
88 
89 /*
90     Each PETSc object class has it's own cookie (internal integer in the
91   data structure used for error checking). These are all defined by an offset
92   from the lowest one, PETSC_COOKIE. If you increase these you must
93   increase the field sizes in petsc/src/plog/src/plog.c
94 */
95 #define PETSC_COOKIE                    1211211
96 #define LARGEST_PETSC_COOKIE_PREDEFINED PETSC_COOKIE + 30
97 #define LARGEST_PETSC_COOKIE_ALLOWED    PETSC_COOKIE + 50
98 extern int LARGEST_PETSC_COOKIE;
99 
100 #include "viewer.h"
101 #include "options.h"
102 
103 /*
104     Defines basic graphics available from PETSc.
105 */
106 #include "draw.h"
107 
108 extern PLogDouble PetscGetTime();
109 extern PLogDouble PetscGetCPUTime();
110 extern void       PetscSleep(int);
111 
112 extern int    PetscInitialize(int*,char***,char*,char*);
113 extern int    PetscFinalize();
114 extern void   PetscInitializeFortran();
115 
116 /*
117     Functions that can act on any PETSc object.
118 */
119 typedef struct _p_PetscObject* PetscObject;
120 extern int PetscObjectDestroy(PetscObject);
121 extern int PetscObjectExists(PetscObject,int*);
122 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm);
123 extern int PetscObjectGetCookie(PetscObject,int *cookie);
124 extern int PetscObjectGetChild(PetscObject,void **child);
125 extern int PetscObjectGetType(PetscObject,int *type);
126 extern int PetscObjectSetName(PetscObject,char*);
127 extern int PetscObjectGetName(PetscObject,char**);
128 extern int PetscObjectInherit(PetscObject,void *, int (*)(void *,void **),int (*)(void*));
129 extern int PetscObjectReference(PetscObject);
130 extern int PetscObjectGetNewTag(PetscObject,int *);
131 extern int PetscObjectRestoreNewTag(PetscObject,int *);
132 extern int PetscObjectView(PetscObject,Viewer);
133 
134 /*
135     Defines PETSc error handling.
136 */
137 #include "petscerror.h"
138 #include "petschead.h"
139 
140 /*
141      Defines PETSc profiling.
142 */
143 #include "petsclog.h"
144 
145 extern int  PetscSequentialPhaseBegin(MPI_Comm,int);
146 extern int  PetscSequentialPhaseEnd(MPI_Comm,int);
147 
148 /*M
149     PetscBarrier - Blocks until this routine is executed by all
150                    processors owning the object A.
151 
152    Input Parameters:
153 .  A - PETSc object  ( Mat, Vec, IS, SNES etc...)
154 
155    Synopsis:
156    void PetscBarrier(PetscObject obj)
157 
158   Notes:
159   This routine calls MPI_Barrier with the communicator
160   of the PETSc Object "A".
161 
162 .keywords: barrier, petscobject
163 M*/
164 
165 #define PetscBarrier(A) \
166   { \
167     PetscValidHeader(A); \
168     PLogEventBegin(Petsc_Barrier,A,0,0,0); \
169     MPI_Barrier(((PetscObject)A)->comm); \
170     PLogEventEnd(Petsc_Barrier,A,0,0,0); \
171   }
172 
173 extern int PetscMPIDump(FILE *);
174 
175 /*
176       This code allows one to pass a PETSc object in C
177   to a Fortran routine, where (like all PETSc objects in
178   Fortran) it is treated as an integer.
179 */
180 extern int  PetscCObjectToFortranObject(void *,int *);
181 extern int  PetscFortranObjectToCObject(int,void *);
182 extern int  MPICCommToFortranComm(MPI_Comm,int *);
183 extern int  MPIFortranCommToCComm(int,MPI_Comm*);
184 
185 extern FILE *PetscFOpen(MPI_Comm,char *,char *);
186 extern int  PetscFClose(MPI_Comm,FILE*);
187 extern int  PetscFPrintf(MPI_Comm,FILE*,char *,...);
188 extern int  PetscPrintf(MPI_Comm,char *,...);
189 
190 extern int  PetscSynchronizedPrintf(MPI_Comm,char *,...);
191 extern int  PetscSynchronizedFPrintf(MPI_Comm,FILE*,char *,...);
192 extern int  PetscSynchronizedFlush(MPI_Comm);
193 
194 /*
195    For incremental debugging
196 */
197 extern int PetscCompare;
198 extern int PetscCompareDouble(double);
199 extern int PetscCompareScalar(Scalar);
200 extern int PetscCompareInt(int);
201 
202 /*
203    For use in debuggers
204 */
205 extern int PetscGlobalRank,PetscGlobalSize;
206 extern int PetscIntView(int,int*,Viewer);
207 extern int PetscDoubleView(int,double *,Viewer);
208 
209 #endif
210