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