xref: /petsc/include/petsc.h (revision 0713fee8a27481b0deeccc792613f84c28abcf5e)
1 /* $Id: petsc.h,v 1.221 1998/06/09 20:53:40 bsmith 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 extern int PetscObjectSetOptionsPrefix(PetscObject,char*);
192 extern int PetscObjectAppendOptionsPrefix(PetscObject,char*);
193 extern int PetscObjectGetOptionsPrefix(PetscObject,char**);
194 
195 /*
196     Defines PETSc error handling.
197 */
198 #include "petscerror.h"
199 
200 /*
201     Mechanism for managing lists of objects attached (composed) with
202    a PETSc object.
203 */
204 typedef struct _OList *OList;
205 extern int OListDestroy(OList *);
206 extern int OListFind(OList,char *,PetscObject*);
207 extern int OListAdd(OList *,char *,PetscObject);
208 extern int OListRemove(OList *,char *);
209 extern int OListDuplicate(OList,OList *);
210 
211 /*
212     Dynamic library lists. Lists of names of routines in dynamic
213   link libraries that will be loaded as needed.
214 */
215 typedef struct _DLList *DLList;
216 extern int    DLRegister_Private(DLList*,char*,char*,int (*)(void *));
217 extern int    DLRegisterCreate(DLList *);
218 extern int    DLRegisterDestroy(DLList);
219 extern int    DLRegisterFind(MPI_Comm,DLList,char*,int (**)(void*));
220 extern int    DLRegisterPrintTypes(MPI_Comm,FILE*,char*,char *,DLList);
221 #if defined(USE_DYNAMIC_LIBRARIES)
222 #define       DLRegister(a,b,p,c) DLRegister_Private(a,b,p,0)
223 #else
224 #define       DLRegister(a,b,p,c) DLRegister_Private(a,b,p,(int (*)(void *))c)
225 #endif
226 
227 typedef struct _DLLibraryList *DLLibraryList;
228 extern DLLibraryList DLLibrariesLoaded;
229 extern int DLLibraryOpen(MPI_Comm,char *,void **);
230 extern int DLLibrarySym(MPI_Comm,DLLibraryList *,char*,char *, void **);
231 extern int DLLibraryAppend(MPI_Comm,DLLibraryList *,char *);
232 extern int DLLibraryPrepend(MPI_Comm,DLLibraryList *,char *);
233 extern int DLLibraryClose(DLLibraryList);
234 extern int DLLibraryPrintPath();
235 
236 /*
237     Mechanism for translating PETSc object representations between languages
238 */
239 typedef enum {PETSC_LANGUAGE_C,PETSC_LANGUAGE_CPP} PetscLanguage;
240 #define PETSC_LANGUAGE_F77 PETSC_LANGUAGE_C
241 extern int PetscObjectComposeLanguage(PetscObject,PetscLanguage,void *);
242 extern int PetscObjectQueryLanguage(PetscObject,PetscLanguage,void **);
243 
244 #include "petschead.h"
245 
246 /*
247      Defines PETSc profiling.
248 */
249 #include "petsclog.h"
250 
251 extern int  PetscSequentialPhaseBegin(MPI_Comm,int);
252 extern int  PetscSequentialPhaseEnd(MPI_Comm,int);
253 extern int  PetscBarrier(PetscObject);
254 extern int  PetscMPIDump(FILE *);
255 
256 /*
257       This code allows one to pass a MPI communicator between
258     C and Fortran. MPI 2.0 defines a standard API for doing this.
259     The code here is provided to allow PETSc to work with MPI 1.1
260     standard MPI libraries.
261 */
262 extern int  MPICCommToFortranComm(MPI_Comm,int *);
263 extern int  MPIFortranCommToCComm(int,MPI_Comm*);
264 
265 /*
266       Simple PETSc parallel IO for ASCII printing
267 */
268 extern int  PetscFixFilename(char*);
269 extern FILE *PetscFOpen(MPI_Comm,char *,char *);
270 extern int  PetscFClose(MPI_Comm,FILE*);
271 extern int  PetscFPrintf(MPI_Comm,FILE*,char *,...);
272 extern int  PetscPrintf(MPI_Comm,char *,...);
273 extern int  (*PetscErrorPrintf)(char *,...);
274 extern int  (*PetscHelpPrintf)(MPI_Comm,char *,...);
275 
276 extern int  PetscSynchronizedPrintf(MPI_Comm,char *,...);
277 extern int  PetscSynchronizedFPrintf(MPI_Comm,FILE*,char *,...);
278 extern int  PetscSynchronizedFlush(MPI_Comm);
279 
280 
281 /*
282     Simple PETSc object that contains a pointer to any required data
283 */
284 typedef struct _p_PetscObjectContainer*  PetscObjectContainer;
285 extern int PetscObjectContainerGetPointer(PetscObjectContainer,void **);
286 extern int PetscObjectContainerSetPointer(PetscObjectContainer,void *);
287 extern int PetscObjectContainerDestroy(PetscObjectContainer);
288 extern int PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *);
289 
290 
291 /*
292     C code optimization is often enhanced by telling the compiler
293   that certain pointer arguments to functions are not aliased to
294   to other arguments. This is not yet ANSI C standard so we define
295   the macro "restrict" to indicate that the variable is not aliased
296   to any other argument.
297 */
298 #if defined(HAVE_RESTRICT) && !defined(__cplusplus)
299 #define restrict _Restrict
300 #else
301 #define restrict
302 #endif
303 
304 /*
305    For incremental debugging
306 */
307 extern int PetscCompare;
308 extern int PetscCompareDouble(double);
309 extern int PetscCompareScalar(Scalar);
310 extern int PetscCompareInt(int);
311 
312 /*
313    For use in debuggers
314 */
315 extern int PetscGlobalRank,PetscGlobalSize;
316 extern int PetscIntView(int,int*,Viewer);
317 extern int PetscDoubleView(int,double *,Viewer);
318 
319 #endif
320