1 /* 2 This is the main PETSc include file (for C and C++). It is included by all 3 other PETSc include files, so it almost never has to be specifically included. 4 */ 5 #if !defined(__PETSC_H) 6 #define __PETSC_H 7 /* ========================================================================== */ 8 /* 9 This facilitates using C version of PETSc from C++ 10 */ 11 12 #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus) 13 #define PETSC_EXTERN_CXX_BEGIN extern "C" { 14 #define PETSC_EXTERN_CXX_END } 15 #else 16 #define PETSC_EXTERN_CXX_BEGIN 17 #define PETSC_EXTERN_CXX_END 18 #endif 19 /* ========================================================================== */ 20 /* 21 Current PETSc version number and release date 22 */ 23 #include "petscversion.h" 24 25 /* ========================================================================== */ 26 /* 27 petscconf.h is contained in bmake/${PETSC_ARCH}/petscconf.h it is 28 found automatically by the compiler due to the -I${PETSC_DIR}/bmake/${PETSC_ARCH} 29 in the bmake/common_variables definition of PETSC_INCLUDE 30 */ 31 #include "petscconf.h" 32 /* 33 Fixes for configure time choices which impact our interface. Currently only 34 calling conventions and extra compiler checking falls under this category. 35 */ 36 #if !defined(PETSC_PRINTF_FORMAT_CHECK) 37 #define PETSC_PRINTF_FORMAT_CHECK(a,b) 38 #endif 39 #if !defined (PETSC_STDCALL) 40 #define PETSC_STDCALL 41 #endif 42 #if !defined (PETSC_TEMPLATE) 43 #define PETSC_TEMPLATE 44 #endif 45 46 /* ========================================================================== */ 47 48 #include <stdio.h> 49 /* 50 Defines the interface to MPI allowing the use of all MPI functions. 51 */ 52 #include "mpi.h" 53 54 /* 55 All PETSc C functions return this error code, it is the final argument of 56 all Fortran subroutines 57 */ 58 typedef int PetscErrorCode; 59 typedef int PetscCookie; 60 typedef int PetscEvent; 61 typedef int PetscBLASInt; 62 typedef int PetscMPIInt; 63 64 #if defined(PETSC_USE_64BIT_INT) 65 typedef long long PetscInt; 66 #define MPIU_INT MPI_LONG_LONG_INT 67 #undef PETSC_PRINTF_FORMAT_CHECK 68 #define PETSC_PRINTF_FORMAT_CHECK(a,b) 69 #undef PETSC_FPRINTF_FORMAT_CHECK 70 #define PETSC_FPRINTF_FORMAT_CHECK(a,b) 71 #else 72 typedef int PetscInt; 73 #define MPIU_INT MPI_INT 74 #endif 75 76 /* 77 Declare extern C stuff after incuding external header files 78 */ 79 80 PETSC_EXTERN_CXX_BEGIN 81 82 /* 83 EXTERN indicates a PETSc function defined elsewhere 84 */ 85 #if !defined(EXTERN) 86 #define EXTERN extern 87 #endif 88 89 /* 90 Defines some elementary mathematics functions and constants. 91 */ 92 #include "petscmath.h" 93 94 /* 95 Basic PETSc constants 96 */ 97 98 /*E 99 PetscTruth - Logical variable. Actually an integer 100 101 Level: beginner 102 103 E*/ 104 typedef enum { PETSC_FALSE,PETSC_TRUE } PetscTruth; 105 106 /*M 107 PETSC_FALSE - False value of PetscTruth 108 109 Level: beginner 110 111 Note: Zero integer 112 113 .seealso: PetscTruth 114 M*/ 115 116 /*M 117 PETSC_TRUE - True value of PetscTruth 118 119 Level: beginner 120 121 Note: Nonzero integer 122 123 .seealso: PetscTruth 124 M*/ 125 126 /*M 127 PETSC_YES - Alias for PETSC_TRUE 128 129 Level: beginner 130 131 Note: Zero integer 132 133 .seealso: PetscTruth 134 M*/ 135 136 /*M 137 PETSC_NO - Alias for PETSC_FALSE 138 139 Level: beginner 140 141 Note: Nonzero integer 142 143 .seealso: PetscTruth 144 M*/ 145 146 /*M 147 PETSC_NULL - standard way of passing in a null or array or pointer 148 149 Level: beginner 150 151 Notes: accepted by many PETSc functions to not set a parameter and instead use 152 some default 153 154 This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER, 155 PETSC_NULL_DOUBLE_PRECISION etc 156 157 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE 158 159 M*/ 160 #define PETSC_NULL 0 161 162 /*M 163 PETSC_DECIDE - standard way of passing in integer or floating point parameter 164 where you wish PETSc to use the default. 165 166 Level: beginner 167 168 .seealso: PETSC_NULL, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE 169 170 M*/ 171 #define PETSC_DECIDE -1 172 173 /*M 174 PETSC_DEFAULT - standard way of passing in integer or floating point parameter 175 where you wish PETSc to use the default. 176 177 Level: beginner 178 179 .seealso: PETSC_DECIDE, PETSC_NULL, PETSC_IGNORE, PETSC_DETERMINE 180 181 M*/ 182 #define PETSC_DEFAULT -2 183 184 #define PETSC_YES PETSC_TRUE 185 #define PETSC_NO PETSC_FALSE 186 187 /*M 188 PETSC_IGNORE - same as PETSC_NULL, means PETSc will ignore this argument 189 190 Level: beginner 191 192 Notes: accepted by many PETSc functions to not set a parameter and instead use 193 some default 194 195 This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER, 196 PETSC_NULL_DOUBLE_PRECISION etc 197 198 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_NULL, PETSC_DETERMINE 199 200 M*/ 201 #define PETSC_IGNORE PETSC_NULL 202 203 /*M 204 PETSC_DETERMINE - standard way of passing in integer or floating point parameter 205 where you wish PETSc to compute the required value. 206 207 Level: beginner 208 209 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_NULL, VecSetSizes() 210 211 M*/ 212 #define PETSC_DETERMINE PETSC_DECIDE 213 214 /*M 215 PETSC_COMM_WORLD - a duplicate of the MPI_COMM_WORLD communicator which represents 216 all the processs 217 218 Level: beginner 219 220 Notes: PETSC_COMM_WORLD and MPI_COMM_WORLD are equivalent except that passing MPI_COMM_WORLD 221 into PETSc object constructors will result in using more MPI resources since an MPI_Comm_dup() 222 will be done on it internally. We recommend always using PETSC_COMM_WORLD 223 224 .seealso: PETSC_COMM_SELF 225 226 M*/ 227 extern MPI_Comm PETSC_COMM_WORLD; 228 229 /*M 230 PETSC_COMM_SELF - a duplicate of the MPI_COMM_SELF communicator which represents 231 the current process 232 233 Level: beginner 234 235 Notes: PETSC_COMM_SELF and MPI_COMM_SELF are equivalent except that passint MPI_COMM_SELF 236 into PETSc object constructors will result in using more MPI resources since an MPI_Comm_dup() 237 will be done on it internally. We recommend always using PETSC_COMM_SELF 238 239 .seealso: PETSC_COMM_WORLD 240 241 M*/ 242 extern MPI_Comm PETSC_COMM_SELF; 243 244 extern PetscTruth PetscInitializeCalled; 245 EXTERN PetscErrorCode PetscSetCommWorld(MPI_Comm); 246 EXTERN PetscErrorCode PetscSetHelpVersionFunctions(PetscErrorCode (*)(MPI_Comm),PetscErrorCode (*)(MPI_Comm)); 247 EXTERN PetscErrorCode PetscCommDuplicate(MPI_Comm,MPI_Comm*,int*); 248 EXTERN PetscErrorCode PetscCommDestroy(MPI_Comm*); 249 250 /*MC 251 PetscMalloc - Allocates memory 252 253 Input Parameter: 254 . m - number of bytes to allocate 255 256 Output Parameter: 257 . result - memory allocated 258 259 Synopsis: 260 PetscErrorCode PetscMalloc(size_t m,void **result) 261 262 Level: beginner 263 264 Notes: Memory is always allocated at least double aligned 265 266 .seealso: PetscFree(), PetscNew() 267 268 Concepts: memory allocation 269 270 M*/ 271 #define PetscMalloc(a,b) (*PetscTrMalloc)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__,(void**)(b)) 272 /*MC 273 PetscNew - Allocates memory of a particular type 274 275 Input Parameter: 276 . type - structure name of space to be allocated. Memory of size sizeof(type) is allocated 277 278 Output Parameter: 279 . result - memory allocated 280 281 Synopsis: 282 PetscErrorCode PetscNew(struct type,((type *))result) 283 284 Level: beginner 285 286 .seealso: PetscFree(), PetscMalloc() 287 288 Concepts: memory allocation 289 290 M*/ 291 #define PetscNew(A,b) PetscMalloc(sizeof(A),(b)) 292 /*MC 293 PetscFree - Frees memory 294 295 Input Parameter: 296 . memory - memory to free 297 298 Synopsis: 299 PetscErrorCode PetscFree(void *memory) 300 301 Level: beginner 302 303 Notes: Memory must have been obtained with PetscNew() or PetscMalloc() 304 305 .seealso: PetscNew(), PetscMalloc() 306 307 Concepts: memory allocation 308 309 M*/ 310 #define PetscFree(a) ((*PetscTrFree)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__) || ((a = 0),0)) 311 EXTERN PetscErrorCode (*PetscTrMalloc)(size_t,int,const char[],const char[],const char[],void**); 312 EXTERN PetscErrorCode (*PetscTrFree)(void*,int,const char[],const char[],const char[]); 313 EXTERN PetscErrorCode PetscSetMalloc(PetscErrorCode (*)(size_t,int,const char[],const char[],const char[],void**),PetscErrorCode (*)(void*,int,const char[],const char[],const char[])); 314 EXTERN PetscErrorCode PetscClearMalloc(void); 315 316 /* 317 Routines for tracing memory corruption/bleeding with default PETSc 318 memory allocation 319 */ 320 EXTERN PetscErrorCode PetscTrDump(FILE *); 321 EXTERN PetscErrorCode PetscTrSpace(PetscLogDouble *,PetscLogDouble *,PetscLogDouble *); 322 EXTERN PetscErrorCode PetscTrValid(int,const char[],const char[],const char[]); 323 EXTERN PetscErrorCode PetscTrDebug(PetscTruth); 324 EXTERN PetscErrorCode PetscTrLog(void); 325 EXTERN PetscErrorCode PetscTrLogDump(FILE *); 326 EXTERN PetscErrorCode PetscGetResidentSetSize(PetscLogDouble *); 327 328 /* 329 Variable type where we stash PETSc object pointers in Fortran. 330 Assumes that sizeof(long) == sizeof(void*)which is true on 331 all machines that we know. 332 */ 333 #define PetscFortranAddr long 334 335 /*E 336 PetscDataType - Used for handling different basic data types. 337 338 Level: beginner 339 340 .seealso: PetscBinaryRead(), PetscBinaryWrite(), PetscDataTypeToMPIDataType(), 341 PetscDataTypeGetSize(), PetscDataTypeGetName() 342 343 E*/ 344 typedef enum {PETSC_INT = 0,PETSC_DOUBLE = 1,PETSC_COMPLEX = 2, 345 PETSC_LONG =3 ,PETSC_SHORT = 4,PETSC_FLOAT = 5, 346 PETSC_CHAR = 6,PETSC_LOGICAL = 7} PetscDataType; 347 #if defined(PETSC_USE_COMPLEX) 348 #define PETSC_SCALAR PETSC_COMPLEX 349 #else 350 #if defined(PETSC_USE_SINGLE) 351 #define PETSC_SCALAR PETSC_FLOAT 352 #else 353 #define PETSC_SCALAR PETSC_DOUBLE 354 #endif 355 #endif 356 #if defined(PETSC_USE_SINGLE) 357 #define PETSC_REAL PETSC_FLOAT 358 #else 359 #define PETSC_REAL PETSC_DOUBLE 360 #endif 361 #define PETSC_FORTRANADDR PETSC_LONG 362 363 EXTERN PetscErrorCode PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*); 364 EXTERN PetscErrorCode PetscDataTypeGetSize(PetscDataType,int*); 365 EXTERN PetscErrorCode PetscDataTypeGetName(PetscDataType,const char*[]); 366 367 /* 368 Basic memory and string operations. These are usually simple wrappers 369 around the basic Unix system calls, but a few of them have additional 370 functionality and/or error checking. 371 */ 372 EXTERN PetscErrorCode PetscMemcpy(void*,const void *,size_t); 373 EXTERN PetscErrorCode PetscBitMemcpy(void*,int,const void*,int,int,PetscDataType); 374 EXTERN PetscErrorCode PetscMemmove(void*,void *,size_t); 375 EXTERN PetscErrorCode PetscMemzero(void*,size_t); 376 EXTERN PetscErrorCode PetscMemcmp(const void*,const void*,size_t,PetscTruth *); 377 EXTERN PetscErrorCode PetscStrlen(const char[],size_t*); 378 EXTERN PetscErrorCode PetscStrcmp(const char[],const char[],PetscTruth *); 379 EXTERN PetscErrorCode PetscStrgrt(const char[],const char[],PetscTruth *); 380 EXTERN PetscErrorCode PetscStrcasecmp(const char[],const char[],PetscTruth*); 381 EXTERN PetscErrorCode PetscStrncmp(const char[],const char[],size_t,PetscTruth*); 382 EXTERN PetscErrorCode PetscStrcpy(char[],const char[]); 383 EXTERN PetscErrorCode PetscStrcat(char[],const char[]); 384 EXTERN PetscErrorCode PetscStrncat(char[],const char[],size_t); 385 EXTERN PetscErrorCode PetscStrncpy(char[],const char[],size_t); 386 EXTERN PetscErrorCode PetscStrchr(const char[],char,char *[]); 387 EXTERN PetscErrorCode PetscStrtolower(char[]); 388 EXTERN PetscErrorCode PetscStrrchr(const char[],char,char *[]); 389 EXTERN PetscErrorCode PetscStrstr(const char[],const char[],char *[]); 390 EXTERN PetscErrorCode PetscStrallocpy(const char[],char *[]); 391 EXTERN PetscErrorCode PetscStrreplace(MPI_Comm,const char[],char[],size_t); 392 #define PetscStrfree(a) ((a) ? PetscFree(a) : 0) 393 /*S 394 PetscToken - 'Token' used for managing tokenizing strings 395 396 Level: intermediate 397 398 .seealso: PetscTokenCreate(), PetscTokenFind(), PetscTokenDestroy() 399 S*/ 400 typedef struct {char token;char *array;char *current;} PetscToken; 401 402 EXTERN PetscErrorCode PetscTokenCreate(const char[],const char,PetscToken**); 403 EXTERN PetscErrorCode PetscTokenFind(PetscToken*,char *[]); 404 EXTERN PetscErrorCode PetscTokenDestroy(PetscToken*); 405 406 /* 407 These are MPI operations for MPI_Allreduce() etc 408 */ 409 EXTERN MPI_Op PetscMaxSum_Op; 410 #if defined(PETSC_USE_COMPLEX) 411 EXTERN MPI_Op PetscSum_Op; 412 #else 413 #define PetscSum_Op MPI_SUM 414 #endif 415 EXTERN PetscErrorCode PetscMaxSum(MPI_Comm,const PetscInt[],PetscInt*,PetscInt*); 416 417 /*S 418 PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc 419 420 Level: beginner 421 422 Note: This is the base class from which all objects appear. 423 424 .seealso: PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName() 425 S*/ 426 typedef struct _p_PetscObject* PetscObject; 427 428 /*S 429 PetscFList - Linked list of functions, possibly stored in dynamic libraries, accessed 430 by string name 431 432 Level: advanced 433 434 .seealso: PetscFListAdd(), PetscFListDestroy() 435 S*/ 436 typedef struct _PetscFList *PetscFList; 437 438 #include "petscviewer.h" 439 #include "petscoptions.h" 440 441 EXTERN PetscErrorCode PetscShowMemoryUsage(PetscViewer,const char[]); 442 EXTERN PetscErrorCode PetscGetTime(PetscLogDouble*); 443 EXTERN PetscErrorCode PetscGetCPUTime(PetscLogDouble*); 444 EXTERN PetscErrorCode PetscSleep(int); 445 446 /* 447 Initialization of PETSc 448 */ 449 EXTERN PetscErrorCode PetscInitialize(int*,char***,const char[],const char[]); 450 EXTERN PetscErrorCode PetscInitializeNoArguments(void); 451 EXTERN PetscErrorCode PetscInitialized(PetscTruth *); 452 EXTERN PetscErrorCode PetscFinalize(void); 453 EXTERN PetscErrorCode PetscInitializeFortran(void); 454 EXTERN PetscErrorCode PetscGetArgs(int*,char ***); 455 EXTERN PetscErrorCode PetscEnd(void); 456 457 typedef void (**PetscVoidFunction)(void); 458 459 /* 460 PetscTryMethod - Queries an object for a method, if it exists then calls it. 461 These are intended to be used only inside PETSc functions. 462 */ 463 #define PetscTryMethod(obj,A,B,C) \ 464 0;{ PetscErrorCode (*f)B, __ierr; \ 465 __ierr = PetscObjectQueryFunction((PetscObject)obj,#A,(PetscVoidFunction)&f);CHKERRQ(__ierr); \ 466 if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\ 467 } 468 #define PetscUseMethod(obj,A,B,C) \ 469 0;{ PetscErrorCode (*f)B, __ierr; \ 470 __ierr = PetscObjectQueryFunction((PetscObject)obj,A,(PetscVoidFunction)&f);CHKERRQ(__ierr); \ 471 if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\ 472 else {SETERRQ1(1,"Cannot locate function %s in object",A);} \ 473 } 474 /* 475 Functions that can act on any PETSc object. 476 */ 477 EXTERN PetscErrorCode PetscObjectDestroy(PetscObject); 478 EXTERN PetscErrorCode PetscObjectExists(PetscObject,PetscTruth*); 479 EXTERN PetscErrorCode PetscObjectGetComm(PetscObject,MPI_Comm *); 480 EXTERN PetscErrorCode PetscObjectGetCookie(PetscObject,int *); 481 EXTERN PetscErrorCode PetscObjectGetType(PetscObject,int *); 482 EXTERN PetscErrorCode PetscObjectSetName(PetscObject,const char[]); 483 EXTERN PetscErrorCode PetscObjectGetName(PetscObject,char*[]); 484 EXTERN PetscErrorCode PetscObjectReference(PetscObject); 485 EXTERN PetscErrorCode PetscObjectGetReference(PetscObject,int*); 486 EXTERN PetscErrorCode PetscObjectDereference(PetscObject); 487 EXTERN PetscErrorCode PetscObjectGetNewTag(PetscObject,int *); 488 EXTERN PetscErrorCode PetscCommGetNewTag(MPI_Comm,int *); 489 EXTERN PetscErrorCode PetscObjectView(PetscObject,PetscViewer); 490 EXTERN PetscErrorCode PetscObjectCompose(PetscObject,const char[],PetscObject); 491 EXTERN PetscErrorCode PetscObjectQuery(PetscObject,const char[],PetscObject *); 492 EXTERN PetscErrorCode PetscObjectComposeFunction(PetscObject,const char[],const char[],void (*)(void)); 493 494 typedef void (*FCNVOID)(void); /* cast in next macro should never be extern C */ 495 typedef PetscErrorCode (*FCNINTVOID)(void); /* used in casts to make sure they are not extern C */ 496 /*MC 497 PetscObjectComposeFunctionDynamic - Associates a function with a given PETSc object. 498 499 Collective on PetscObject 500 501 Input Parameters: 502 + obj - the PETSc object; this must be cast with a (PetscObject), for example, 503 PetscObjectCompose((PetscObject)mat,...); 504 . name - name associated with the child function 505 . fname - name of the function 506 - ptr - function pointer (or PETSC_NULL if using dynamic libraries) 507 508 Level: advanced 509 510 Synopsis: 511 int PetscObjectComposeFunctionDynamic(PetscObject obj,const char name[],const char fname[],void *ptr) 512 513 Notes: 514 To remove a registered routine, pass in a PETSC_NULL rname and fnc(). 515 516 PetscObjectComposeFunctionDynamic() can be used with any PETSc object (such as 517 Mat, Vec, KSP, SNES, etc.) or any user-provided object. 518 519 The composed function must be wrapped in a EXTERN_C_BEGIN/END for this to 520 work in C++/complex with dynamic link libraries (PETSC_USE_DYNAMIC_LIBRARIES) 521 enabled. 522 523 Concepts: objects^composing functions 524 Concepts: composing functions 525 Concepts: functions^querying 526 Concepts: objects^querying 527 Concepts: querying objects 528 529 .seealso: PetscObjectQueryFunction() 530 M*/ 531 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 532 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,0) 533 #else 534 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,(FCNVOID)(d)) 535 #endif 536 537 EXTERN PetscErrorCode PetscObjectQueryFunction(PetscObject,const char[],void (**)(void)); 538 EXTERN PetscErrorCode PetscObjectSetOptionsPrefix(PetscObject,const char[]); 539 EXTERN PetscErrorCode PetscObjectAppendOptionsPrefix(PetscObject,const char[]); 540 EXTERN PetscErrorCode PetscObjectPrependOptionsPrefix(PetscObject,const char[]); 541 EXTERN PetscErrorCode PetscObjectGetOptionsPrefix(PetscObject,char*[]); 542 EXTERN PetscErrorCode PetscObjectPublish(PetscObject); 543 EXTERN PetscErrorCode PetscObjectChangeTypeName(PetscObject,const char[]); 544 EXTERN PetscErrorCode PetscObjectRegisterDestroy(PetscObject); 545 EXTERN PetscErrorCode PetscObjectRegisterDestroyAll(void); 546 EXTERN PetscErrorCode PetscObjectName(PetscObject); 547 EXTERN PetscErrorCode PetscTypeCompare(PetscObject,const char[],PetscTruth*); 548 549 /* 550 Defines PETSc error handling. 551 */ 552 #include "petscerror.h" 553 554 /*S 555 PetscOList - Linked list of PETSc objects, accessable by string name 556 557 Level: advanced 558 559 .seealso: PetscOListAdd(), PetscOListDestroy(), PetscOListFind() 560 S*/ 561 typedef struct _PetscOList *PetscOList; 562 563 EXTERN PetscErrorCode PetscOListDestroy(PetscOList *); 564 EXTERN PetscErrorCode PetscOListFind(PetscOList,const char[],PetscObject*); 565 EXTERN PetscErrorCode PetscOListReverseFind(PetscOList,PetscObject,char**); 566 EXTERN PetscErrorCode PetscOListAdd(PetscOList *,const char[],PetscObject); 567 EXTERN PetscErrorCode PetscOListDuplicate(PetscOList,PetscOList *); 568 569 /* 570 Dynamic library lists. Lists of names of routines in dynamic 571 link libraries that will be loaded as needed. 572 */ 573 EXTERN PetscErrorCode PetscFListAdd(PetscFList*,const char[],const char[],void (*)(void)); 574 EXTERN PetscErrorCode PetscFListDestroy(PetscFList*); 575 EXTERN PetscErrorCode PetscFListFind(MPI_Comm,PetscFList,const char[],void (**)(void)); 576 EXTERN PetscErrorCode PetscFListPrintTypes(MPI_Comm,FILE*,const char[],const char[],const char[],const char[],PetscFList); 577 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 578 #define PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,0) 579 #else 580 #define PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,(void (*)(void))c) 581 #endif 582 EXTERN PetscErrorCode PetscFListDuplicate(PetscFList,PetscFList *); 583 EXTERN PetscErrorCode PetscFListView(PetscFList,PetscViewer); 584 EXTERN PetscErrorCode PetscFListConcat(const char [],const char [],char []); 585 EXTERN PetscErrorCode PetscFListGet(PetscFList,char ***,int*); 586 587 /*S 588 PetscDLLibraryList - Linked list of dynamics libraries to search for functions 589 590 Level: advanced 591 592 PETSC_USE_DYNAMIC_LIBRARIES must be defined in petscconf.h to use dynamic libraries 593 594 .seealso: PetscDLLibraryOpen() 595 S*/ 596 typedef struct _PetscDLLibraryList *PetscDLLibraryList; 597 extern PetscDLLibraryList DLLibrariesLoaded; 598 EXTERN PetscErrorCode PetscDLLibraryRetrieve(MPI_Comm,const char[],char *,int,PetscTruth *); 599 EXTERN PetscErrorCode PetscDLLibraryOpen(MPI_Comm,const char[],void **); 600 EXTERN PetscErrorCode PetscDLLibrarySym(MPI_Comm,PetscDLLibraryList *,const char[],const char[],void **); 601 EXTERN PetscErrorCode PetscDLLibraryAppend(MPI_Comm,PetscDLLibraryList *,const char[]); 602 EXTERN PetscErrorCode PetscDLLibraryPrepend(MPI_Comm,PetscDLLibraryList *,const char[]); 603 EXTERN PetscErrorCode PetscDLLibraryClose(PetscDLLibraryList); 604 EXTERN PetscErrorCode PetscDLLibraryPrintPath(void); 605 EXTERN PetscErrorCode PetscDLLibraryGetInfo(void*,const char[],const char *[]); 606 607 /* 608 Mechanism for translating PETSc object representations between languages 609 Not currently used. 610 */ 611 typedef enum {PETSC_LANGUAGE_C,PETSC_LANGUAGE_CPP} PetscLanguage; 612 #define PETSC_LANGUAGE_F77 PETSC_LANGUAGE_C 613 EXTERN PetscErrorCode PetscObjectComposeLanguage(PetscObject,PetscLanguage,void *); 614 EXTERN PetscErrorCode PetscObjectQueryLanguage(PetscObject,PetscLanguage,void **); 615 616 /* 617 Useful utility routines 618 */ 619 EXTERN PetscErrorCode PetscSplitOwnership(MPI_Comm,PetscInt*,PetscInt*); 620 EXTERN PetscErrorCode PetscSplitOwnershipBlock(MPI_Comm,PetscInt,PetscInt*,PetscInt*); 621 EXTERN PetscErrorCode PetscSequentialPhaseBegin(MPI_Comm,PetscMPIInt); 622 EXTERN PetscErrorCode PetscSequentialPhaseEnd(MPI_Comm,PetscMPIInt); 623 EXTERN PetscErrorCode PetscBarrier(PetscObject); 624 EXTERN PetscErrorCode PetscMPIDump(FILE*); 625 626 #define PetscNot(a) ((a) ? PETSC_FALSE : PETSC_TRUE) 627 /* 628 Defines basic graphics available from PETSc. 629 */ 630 #include "petscdraw.h" 631 632 /* 633 Defines the base data structures for all PETSc objects 634 */ 635 #include "petschead.h" 636 637 /* 638 Defines PETSc profiling. 639 */ 640 #include "petsclog.h" 641 642 /* 643 For locking, unlocking and destroying AMS memories associated with 644 PETSc objects. Not currently used. 645 */ 646 #define PetscPublishAll(v) 0 647 #define PetscObjectTakeAccess(obj) 0 648 #define PetscObjectGrantAccess(obj) 0 649 #define PetscObjectDepublish(obj) 0 650 651 652 653 /* 654 This code allows one to pass a MPI communicator between 655 C and Fortran. MPI 2.0 defines a standard API for doing this. 656 The code here is provided to allow PETSc to work with MPI 1.1 657 standard MPI libraries. 658 */ 659 EXTERN PetscErrorCode MPICCommToFortranComm(MPI_Comm,int *); 660 EXTERN PetscErrorCode MPIFortranCommToCComm(int,MPI_Comm*); 661 662 /* 663 Simple PETSc parallel IO for ASCII printing 664 */ 665 EXTERN PetscErrorCode PetscFixFilename(const char[],char[]); 666 EXTERN PetscErrorCode PetscFOpen(MPI_Comm,const char[],const char[],FILE**); 667 EXTERN PetscErrorCode PetscFClose(MPI_Comm,FILE*); 668 EXTERN PetscErrorCode PetscFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4); 669 EXTERN PetscErrorCode PetscPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 670 671 /* These are used internally by PETSc ASCII IO routines*/ 672 #include <stdarg.h> 673 EXTERN PetscErrorCode PetscVSNPrintf(char*,size_t,const char*,va_list); 674 EXTERN PetscErrorCode PetscVFPrintf(FILE*,const char*,va_list); 675 676 /*MC 677 PetscErrorPrintf - Prints error messages. 678 679 Not Collective 680 681 Synopsis: 682 PetscErrorCode (*PetscErrorPrintf)(const char format[],...); 683 684 Input Parameters: 685 . format - the usual printf() format string 686 687 Options Database Keys: 688 . -error_output_stderr - cause error messages to be printed to stderr instead of the 689 (default) stdout 690 691 692 Level: developer 693 694 Fortran Note: 695 This routine is not supported in Fortran. 696 697 Concepts: error messages^printing 698 Concepts: printing^error messages 699 700 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscHelpPrintf() 701 M*/ 702 EXTERN PetscErrorCode (*PetscErrorPrintf)(const char[],...); 703 704 /*MC 705 PetscHelpPrintf - Prints help messages. 706 707 Not Collective 708 709 Synopsis: 710 PetscErrorCode (*PetscHelpPrintf)(const char format[],...); 711 712 Input Parameters: 713 . format - the usual printf() format string 714 715 Level: developer 716 717 Fortran Note: 718 This routine is not supported in Fortran. 719 720 Concepts: help messages^printing 721 Concepts: printing^help messages 722 723 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscErrorPrintf() 724 M*/ 725 EXTERN PetscErrorCode (*PetscHelpPrintf)(MPI_Comm,const char[],...); 726 727 EXTERN PetscErrorCode PetscPOpen(MPI_Comm,const char[],const char[],const char[],FILE **); 728 EXTERN PetscErrorCode PetscPClose(MPI_Comm,FILE*); 729 EXTERN PetscErrorCode PetscSynchronizedPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 730 EXTERN PetscErrorCode PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4); 731 EXTERN PetscErrorCode PetscSynchronizedFlush(MPI_Comm); 732 EXTERN PetscErrorCode PetscSynchronizedFGets(MPI_Comm,FILE*,size_t,char[]); 733 EXTERN PetscErrorCode PetscStartMatlab(MPI_Comm,const char[],const char[],FILE**); 734 EXTERN PetscErrorCode PetscStartJava(MPI_Comm,const char[],const char[],FILE**); 735 EXTERN PetscErrorCode PetscGetPetscDir(const char*[]); 736 737 EXTERN PetscErrorCode PetscPopUpSelect(MPI_Comm,char*,char*,int,char**,int*); 738 /*S 739 PetscObjectContainer - Simple PETSc object that contains a pointer to any required data 740 741 Level: advanced 742 743 .seealso: PetscObject, PetscObjectContainerCreate() 744 S*/ 745 typedef struct _p_PetscObjectContainer* PetscObjectContainer; 746 EXTERN PetscErrorCode PetscObjectContainerGetPointer(PetscObjectContainer,void **); 747 EXTERN PetscErrorCode PetscObjectContainerSetPointer(PetscObjectContainer,void *); 748 EXTERN PetscErrorCode PetscObjectContainerDestroy(PetscObjectContainer); 749 EXTERN PetscErrorCode PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *); 750 751 /* 752 For incremental debugging 753 */ 754 extern PetscTruth PetscCompare; 755 EXTERN PetscErrorCode PetscCompareDouble(double); 756 EXTERN PetscErrorCode PetscCompareScalar(PetscScalar); 757 EXTERN PetscErrorCode PetscCompareInt(PetscInt); 758 759 /* 760 For use in debuggers 761 */ 762 extern int PetscGlobalRank,PetscGlobalSize; 763 EXTERN PetscErrorCode PetscIntView(PetscInt,PetscInt[],PetscViewer); 764 EXTERN PetscErrorCode PetscRealView(PetscInt,PetscReal[],PetscViewer); 765 EXTERN PetscErrorCode PetscScalarView(PetscInt,PetscScalar[],PetscViewer); 766 767 /* 768 Allows accessing Matlab Engine 769 */ 770 #include "petscmatlab.h" 771 772 /* 773 C code optimization is often enhanced by telling the compiler 774 that certain pointer arguments to functions are not aliased to 775 to other arguments. This is not yet ANSI C standard so we define 776 the macro "restrict" to indicate that the variable is not aliased 777 to any other argument. 778 */ 779 #if defined(PETSC_HAVE_RESTRICT) && !defined(__cplusplus) 780 #define restrict _Restrict 781 #else 782 #if defined(restrict) 783 #undef restrict 784 #endif 785 #define restrict 786 #endif 787 788 /* 789 Determine if some of the kernel computation routines use 790 Fortran (rather than C) for the numerical calculations. On some machines 791 and compilers (like complex numbers) the Fortran version of the routines 792 is faster than the C/C++ versions. The flag PETSC_USE_FORTRAN_KERNELS 793 would be set in the petscconf.h file 794 */ 795 #if defined(PETSC_USE_FORTRAN_KERNELS) 796 797 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTAIJ) 798 #define PETSC_USE_FORTRAN_KERNEL_MULTAIJ 799 #endif 800 801 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ) 802 #define PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ 803 #endif 804 805 #if !defined(PETSC_USE_FORTRAN_KERNEL_NORM) 806 #define PETSC_USE_FORTRAN_KERNEL_NORM 807 #endif 808 809 #if !defined(PETSC_USE_FORTRAN_KERNEL_MAXPY) 810 #define PETSC_USE_FORTRAN_KERNEL_MAXPY 811 #endif 812 813 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ) 814 #define PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ 815 #endif 816 817 #if !defined(PETSC_USE_FORTRAN_KERNEL_RELAXAIJ) 818 #define PETSC_USE_FORTRAN_KERNEL_RELAXAIJ 819 #endif 820 821 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ) 822 #define PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ 823 #endif 824 825 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ) 826 #define PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ 827 #endif 828 829 #if !defined(PETSC_USE_FORTRAN_KERNEL_MDOT) 830 #define PETSC_USE_FORTRAN_KERNEL_MDOT 831 #endif 832 833 #if !defined(PETSC_USE_FORTRAN_KERNEL_XTIMESY) 834 #define PETSC_USE_FORTRAN_KERNEL_XTIMESY 835 #endif 836 837 #if !defined(PETSC_USE_FORTRAN_KERNEL_AYPX) 838 #define PETSC_USE_FORTRAN_KERNEL_AYPX 839 #endif 840 841 #if !defined(PETSC_USE_FORTRAN_KERNEL_WAXPY) 842 #define PETSC_USE_FORTRAN_KERNEL_WAXPY 843 #endif 844 845 #endif 846 847 /* 848 Macros for indicating code that should be compiled with a C interface, 849 rather than a C++ interface. Any routines that are dynamically loaded 850 (such as the PCCreate_XXX() routines) must be wrapped so that the name 851 mangler does not change the functions symbol name. This just hides the 852 ugly extern "C" {} wrappers. 853 */ 854 #if defined(__cplusplus) 855 #define EXTERN_C_BEGIN extern "C" { 856 #define EXTERN_C_END } 857 #else 858 #define EXTERN_C_BEGIN 859 #define EXTERN_C_END 860 #endif 861 862 /* --------------------------------------------------------------------*/ 863 864 /*M 865 size - integer variable used to contain the number of processors in 866 the relevent MPI_Comm 867 868 Level: beginner 869 870 .seealso: rank, comm 871 M*/ 872 873 /*M 874 rank - integer variable used to contain the number of this processor relative 875 to all in the relevent MPI_Comm 876 877 Level: beginner 878 879 .seealso: size, comm 880 M*/ 881 882 /*M 883 comm - MPI_Comm used in the current routine or object 884 885 Level: beginner 886 887 .seealso: size, rank 888 M*/ 889 890 /*M 891 MPI_Comm - the basic object used by MPI to determine which processes are involved in a 892 communication 893 894 Level: beginner 895 896 Note: This manual page is a place-holder because MPICH does not have a manual page for MPI_Comm 897 898 .seealso: size, rank, comm, PETSC_COMM_WORLD, PETSC_COMM_SELF 899 M*/ 900 901 /*M 902 PetscScalar - PETSc type that represents either a double precision real number or 903 a double precision complex number if the code is compiled with BOPT=g_complex or O_complex 904 905 Level: beginner 906 907 .seealso: PetscReal, PassiveReal, PassiveScalar 908 M*/ 909 910 /*M 911 PetscReal - PETSc type that represents a double precision real number 912 913 Level: beginner 914 915 .seealso: PetscScalar, PassiveReal, PassiveScalar 916 M*/ 917 918 /*M 919 PassiveScalar - PETSc type that represents either a double precision real number or 920 a double precision complex number if the code is compiled with BOPT=g_complex or O_complex 921 922 Level: beginner 923 924 This is the same as a PetscScalar except in code that is automatically differentiated it is 925 treated as a constant (not an indendent or dependent variable) 926 927 .seealso: PetscReal, PassiveReal, PetscScalar 928 M*/ 929 930 /*M 931 PassiveReal - PETSc type that represents a double precision real number 932 933 Level: beginner 934 935 This is the same as a PetscReal except in code that is automatically differentiated it is 936 treated as a constant (not an indendent or dependent variable) 937 938 .seealso: PetscScalar, PetscReal, PassiveScalar 939 M*/ 940 941 /*M 942 MPIU_SCALAR - MPI datatype corresponding to PetscScalar 943 944 Level: beginner 945 946 Note: In MPI calls that require an MPI datatype that matches a PetscScalar or array of PetscScalars 947 pass this value 948 949 .seealso: PetscReal, PassiveReal, PassiveScalar, PetscScalar 950 M*/ 951 952 /* 953 The IBM include files define hz, here we hide it so that it may be used 954 as a regular user variable. 955 */ 956 #if defined(hz) 957 #undef hz 958 #endif 959 960 /* For arrays that contain filenames or paths */ 961 962 963 #if defined(PETSC_HAVE_LIMITS_H) 964 #include <limits.h> 965 #endif 966 #if defined(PETSC_HAVE_SYS_PARAM_H) 967 #include <sys/param.h> 968 #endif 969 970 #if defined(MAXPATHLEN) 971 # define PETSC_MAX_PATH_LEN MAXPATHLEN 972 #elif defined(MAX_PATH) 973 # define PETSC_MAX_PATH_LEN MAX_PATH 974 #elif defined(_MAX_PATH) 975 # define PETSC_MAX_PATH_LEN _MAX_PATH 976 #else 977 # define PETSC_MAX_PATH_LEN 4096 978 #endif 979 980 PETSC_EXTERN_CXX_END 981 #endif 982 983 984