xref: /petsc/include/petsc.h (revision 5c605e6c6d09ff9c3f80e824bd98f9596e5f2e23)
1 /* $Id: petsc.h,v 1.220 1998/06/01 16:09:30 curfman Exp bsmith $ */
2 /*
3    This is the main PETSc include file (for C and C++).  It is included by all
4    other PETSc include files, so it almost never has to be specifically included.
5 */
6 #if !defined(__PETSC_H)
7 #define __PETSC_H
8 
9 /* ========================================================================== */
10 /*
11    Current PETSc version number and release date, also listed in
12     docs/changes.html
13     docs/tex/manual/manual.tex and
14     docs/tex/manual/manual_tex.tex.
15 */
16 #define PETSC_VERSION_NUMBER "PETSc Version 2.0.22, Released April 28, 1998."
17 
18 #define PETSC_VERSION_MAJOR    2
19 #define PETSC_VERSION_MINOR    0
20 #define PETSC_VERSION_SUBMINOR 22
21 #define PETSC_VERSION_DATE     "April 29, 1998"
22 #define PETSC_AUTHOR_INFO      "The PETSc Team:\
23  Satish Balay, Bill Gropp, Lois Curfman McInnes, Barry Smith\n\
24  Bug reports, questions: petsc-maint@mcs.anl.gov\n\
25  Web page: http://www.mcs.anl.gov/petsc/\n"
26 
27 /* ========================================================================== */
28 /*
29    The PETSc configuration file.  Contains various definitions that
30    handle portability issues and the presence of machine features.
31 
32    petscconf.h is contained in bmake/${PETSC_ARCH}/petscconf.h
33 */
34 #include "petscconf.h"
35 
36 /* ========================================================================== */
37 
38 #include <stdio.h>
39 /*
40     Defines the interface to MPI allowing the use of all MPI functions.
41 */
42 #include "mpi.h"
43 
44 /*
45     Defines some elementary mathematics functions and constants.
46 */
47 #include "petscmath.h"
48 
49 /*
50     Variable type where we stash PETSc object pointers in Fortran.
51     Assumes that sizeof(long) == sizeof(void *) which is true on
52     all machines that we know.
53 */
54 #define PetscFortranAddr   long
55 
56 extern MPI_Comm PETSC_COMM_WORLD;
57 extern MPI_Comm PETSC_COMM_SELF;
58 extern int      PetscInitializedCalled;
59 extern int      PetscSetCommWorld(MPI_Comm);
60 
61 /*
62     Defines the malloc employed by PETSc. Users may use these routines as well.
63 */
64 #define PetscMalloc(a)       (*PetscTrMalloc)(a,__LINE__,__FUNC__,__FILE__,__SDIR__)
65 #define PetscNew(A)          (A*) PetscMalloc(sizeof(A))
66 #define PetscFree(a)         (*PetscTrFree)(a,__LINE__,__FUNC__,__FILE__,__SDIR__)
67 extern void *(*PetscTrMalloc)(unsigned int,int,char*,char*,char*);
68 extern int  (*PetscTrFree)(void *,int,char*,char*,char*);
69 extern int  PetscSetMalloc(void *(*)(unsigned int,int,char*,char*,char*),
70                            int (*)(void *,int,char*,char*,char*));
71 extern int  PetscClearMalloc(void);
72 
73 extern int   PetscTrDump(FILE *);
74 extern int   PetscTrSpace( PLogDouble *, PLogDouble *,PLogDouble *);
75 extern int   PetscTrValid(int,char *,char *,char *);
76 extern int   PetscTrDebugLevel(int);
77 extern int   PetscTrLog(void);
78 extern int   PetscTrLogDump(FILE *);
79 extern int   PetscGetResidentSetSize(PLogDouble *);
80 
81 #include "src/inline/bitarray.h"
82 
83 typedef enum {PETSC_INT = 0, PETSC_DOUBLE = 1, PETSC_SHORT = 2, PETSC_FLOAT = 3,
84               PETSC_COMPLEX = 4, PETSC_CHAR = 5, PETSC_LOGICAL = 6} PetscDataType;
85 #if defined(USE_PETSC_COMPLEX)
86 #define PETSC_SCALAR PETSC_COMPLEX
87 #else
88 #define PETSC_SCALAR PETSC_DOUBLE
89 #endif
90 
91 typedef enum {PETSC_INT_SIZE = sizeof(int), PETSC_DOUBLE_SIZE = sizeof(double),
92               PETSC_SCALAR_SIZE = sizeof(Scalar), PETSC_COMPLEX_SIZE = sizeof(double),
93               PETSC_CHAR_SIZE = sizeof(char), PETSC_LOGICAL_SIZE = 1} PetscDataTypeSize;
94 extern int PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*);
95 extern int PetscDataTypeGetSize(PetscDataType,int*);
96 extern int PetscDataTypeGetName(PetscDataType,char**);
97 
98 /*
99     Basic memory and string operations
100 */
101 extern int   PetscMemcpy(void *,void *,int);
102 extern int   PetscBitMemcpy(void*,int,void*,int,int,PetscDataType);
103 extern int   PetscMemmove(void *,void *,int);
104 extern int   PetscMemzero(void *,int);
105 extern int   PetscMemcmp(void*, void*, int);
106 extern int   PetscStrlen(char *);
107 extern int   PetscStrcmp(char *,char *);
108 extern int   PetscStrcasecmp(char *,char *);
109 extern int   PetscStrncmp(char *,char *,int );
110 extern int   PetscStrcpy(char *,char *);
111 extern int   PetscStrcat(char *,char *);
112 extern int   PetscStrncat(char *,char *,int);
113 extern int   PetscStrncpy(char *,char *,int);
114 extern char* PetscStrchr(char *,char);
115 extern char* PetscStrrchr(char *,char);
116 extern char* PetscStrstr(char*,char*);
117 extern char* PetscStrtok(char*,char*);
118 extern char* PetscStrrtok(char*,char*);
119 
120 /*
121        Basic PETSc constants
122 */
123 typedef enum { PETSC_FALSE, PETSC_TRUE } PetscTruth;
124 #define PETSC_NULL            0
125 #define PETSC_DECIDE         -1
126 #define PETSC_DETERMINE      PETSC_DECIDE
127 #define PETSC_DEFAULT        -2
128 
129 /*
130     Each PETSc object class has it's own cookie (internal integer in the
131   data structure used for error checking). These are all defined by an offset
132   from the lowest one, PETSC_COOKIE. If you increase these you must
133   increase the field sizes in petsc/src/plog/src/plog.c
134 */
135 #define PETSC_COOKIE                    1211211
136 #define LARGEST_PETSC_COOKIE_PREDEFINED PETSC_COOKIE + 30
137 #define LARGEST_PETSC_COOKIE_ALLOWED    PETSC_COOKIE + 50
138 extern int LARGEST_PETSC_COOKIE;
139 
140 #include "viewer.h"
141 #include "options.h"
142 
143 /*
144     Defines basic graphics available from PETSc.
145 */
146 #include "draw.h"
147 
148 extern int PetscGetTime(PLogDouble*);
149 extern int PetscGetCPUTime(PLogDouble*);
150 extern int PetscSleep(int);
151 
152 /*
153     Initialization of PETSc or its micro-kernel ALICE
154 */
155 extern int  AliceInitialize(int*,char***,char*,char*);
156 extern int  AliceInitializeNoArguments(void);
157 extern int  AliceFinalize(void);
158 extern void AliceInitializeFortran(void);
159 
160 extern int  PetscInitialize(int*,char***,char*,char*);
161 extern int  PetscInitializeNoArguments(void);
162 extern int  PetscFinalize(void);
163 extern void PetscInitializeFortran(void);
164 
165 /*
166     Functions that can act on any PETSc object.
167 */
168 typedef struct _p_PetscObject* PetscObject;
169 extern int PetscObjectDestroy(PetscObject);
170 extern int PetscObjectExists(PetscObject,int*);
171 extern int PetscObjectGetComm(PetscObject,MPI_Comm *comm);
172 extern int PetscObjectGetCookie(PetscObject,int *cookie);
173 extern int PetscObjectGetType(PetscObject,int *type);
174 extern int PetscObjectSetName(PetscObject,char*);
175 extern int PetscObjectGetName(PetscObject,char**);
176 extern int PetscObjectReference(PetscObject);
177 extern int PetscObjectGetReference(PetscObject,int*);
178 extern int PetscObjectDereference(PetscObject);
179 extern int PetscObjectGetNewTag(PetscObject,int *);
180 extern int PetscObjectRestoreNewTag(PetscObject,int *);
181 extern int PetscObjectView(PetscObject,Viewer);
182 extern int PetscObjectCompose(PetscObject,char *,PetscObject);
183 extern int PetscObjectQuery(PetscObject,char *,PetscObject *);
184 extern int PetscObjectComposeFunction_Private(PetscObject,char *,char *,void *);
185 #if defined(USE_DYNAMIC_LIBRARIES)
186 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,0)
187 #else
188 #define PetscObjectComposeFunction(a,b,c,d) PetscObjectComposeFunction_Private(a,b,c,d)
189 #endif
190 extern int PetscObjectQueryFunction(PetscObject,char *,void **);
191 
192 /*
193     Defines PETSc error handling.
194 */
195 #include "petscerror.h"
196 
197 /*
198     Mechanism for managing lists of objects attached (composed) with
199    a PETSc object.
200 */
201 typedef struct _OList *OList;
202 extern int OListDestroy(OList *);
203 extern int OListFind(OList,char *,PetscObject*);
204 extern int OListAdd(OList *,char *,PetscObject);
205 extern int OListRemove(OList *,char *);
206 extern int OListDuplicate(OList,OList *);
207 
208 /*
209     Dynamic library lists. Lists of names of routines in dynamic
210   link libraries that will be loaded as needed.
211 */
212 typedef struct _DLList *DLList;
213 extern int    DLRegister_Private(DLList*,char*,char*,int (*)(void *));
214 extern int    DLRegisterCreate(DLList *);
215 extern int    DLRegisterDestroy(DLList);
216 extern int    DLRegisterFind(MPI_Comm,DLList,char*,int (**)(void*));
217 extern int    DLRegisterPrintTypes(MPI_Comm,FILE*,char*,char *,DLList);
218 #if defined(USE_DYNAMIC_LIBRARIES)
219 #define       DLRegister(a,b,p,c) DLRegister_Private(a,b,p,0)
220 #else
221 #define       DLRegister(a,b,p,c) DLRegister_Private(a,b,p,(int (*)(void *))c)
222 #endif
223 
224 typedef struct _DLLibraryList *DLLibraryList;
225 extern DLLibraryList DLLibrariesLoaded;
226 extern int DLLibraryOpen(MPI_Comm,char *,void **);
227 extern int DLLibrarySym(MPI_Comm,DLLibraryList *,char*,char *, void **);
228 extern int DLLibraryAppend(MPI_Comm,DLLibraryList *,char *);
229 extern int DLLibraryPrepend(MPI_Comm,DLLibraryList *,char *);
230 extern int DLLibraryClose(DLLibraryList);
231 
232 /*
233     Mechanism for translating PETSc object representations between languages
234 */
235 typedef enum {PETSC_LANGUAGE_C,PETSC_LANGUAGE_CPP} PetscLanguage;
236 #define PETSC_LANGUAGE_F77 PETSC_LANGUAGE_C
237 extern int PetscObjectComposeLanguage(PetscObject,PetscLanguage,void *);
238 extern int PetscObjectQueryLanguage(PetscObject,PetscLanguage,void **);
239 
240 #include "petschead.h"
241 
242 /*
243      Defines PETSc profiling.
244 */
245 #include "petsclog.h"
246 
247 extern int  PetscSequentialPhaseBegin(MPI_Comm,int);
248 extern int  PetscSequentialPhaseEnd(MPI_Comm,int);
249 extern int  PetscBarrier(PetscObject);
250 extern int  PetscMPIDump(FILE *);
251 
252 /*
253       This code allows one to pass a MPI communicator between
254     C and Fortran. MPI 2.0 defines a standard API for doing this.
255     The code here is provided to allow PETSc to work with MPI 1.1
256     standard MPI libraries.
257 */
258 extern int  MPICCommToFortranComm(MPI_Comm,int *);
259 extern int  MPIFortranCommToCComm(int,MPI_Comm*);
260 
261 /*
262       Simple PETSc parallel IO for ASCII printing
263 */
264 extern int  PetscFixFilename(char*);
265 extern FILE *PetscFOpen(MPI_Comm,char *,char *);
266 extern int  PetscFClose(MPI_Comm,FILE*);
267 extern int  PetscFPrintf(MPI_Comm,FILE*,char *,...);
268 extern int  PetscPrintf(MPI_Comm,char *,...);
269 extern int  (*PetscErrorPrintf)(char *,...);
270 extern int  (*PetscHelpPrintf)(MPI_Comm,char *,...);
271 
272 extern int  PetscSynchronizedPrintf(MPI_Comm,char *,...);
273 extern int  PetscSynchronizedFPrintf(MPI_Comm,FILE*,char *,...);
274 extern int  PetscSynchronizedFlush(MPI_Comm);
275 
276 
277 /*
278     Simple PETSc object that contains a pointer to any required data
279 */
280 typedef struct _p_PetscObjectContainer*  PetscObjectContainer;
281 extern int PetscObjectContainerGetPointer(PetscObjectContainer,void **);
282 extern int PetscObjectContainerSetPointer(PetscObjectContainer,void *);
283 extern int PetscObjectContainerDestroy(PetscObjectContainer);
284 extern int PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *);
285 
286 
287 /*
288     C code optimization is often enhanced by telling the compiler
289   that certain pointer arguments to functions are not aliased to
290   to other arguments. This is not yet ANSI C standard so we define
291   the macro "restrict" to indicate that the variable is not aliased
292   to any other argument.
293 */
294 #if defined(HAVE_RESTRICT) && !defined(__cplusplus)
295 #define restrict _Restrict
296 #else
297 #define restrict
298 #endif
299 
300 /*
301    For incremental debugging
302 */
303 extern int PetscCompare;
304 extern int PetscCompareDouble(double);
305 extern int PetscCompareScalar(Scalar);
306 extern int PetscCompareInt(int);
307 
308 /*
309    For use in debuggers
310 */
311 extern int PetscGlobalRank,PetscGlobalSize;
312 extern int PetscIntView(int,int*,Viewer);
313 extern int PetscDoubleView(int,double *,Viewer);
314 
315 #endif
316