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