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