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 petscconf.h is contained in bmake/${PETSC_ARCH}/petscconf.h it is 10 found automatically by the compiler due to the -I${PETSC_DIR}/bmake/${PETSC_ARCH} 11 in the bmake/common/variables definition of PETSC_INCLUDE 12 */ 13 #include "petscconf.h" 14 15 /* ========================================================================== */ 16 /* 17 This facilitates using C version of PETSc from C++ and 18 C++ version from C. Use --with-c-support --with-clanguage=c++ with config/configure.py for the latter) 19 */ 20 #if defined(PETSC_CLANGUAGE_CXX) && !defined(PETSC_USE_EXTERN_CXX) && !defined(__cplusplus) 21 #error "PETSc configured with --with-clanguage=c++ and NOT --with-c-support - it can be used only with a C++ compiler" 22 #endif 23 24 #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus) 25 #define PETSC_EXTERN_CXX_BEGIN extern "C" { 26 #define PETSC_EXTERN_CXX_END } 27 #else 28 #define PETSC_EXTERN_CXX_BEGIN 29 #define PETSC_EXTERN_CXX_END 30 #endif 31 /* ========================================================================== */ 32 /* 33 Current PETSc version number and release date. Also listed in 34 Web page 35 src/docs/tex/manual/intro.tex, 36 src/docs/tex/manual/manual.tex. 37 src/docs/website/index.html. 38 */ 39 #include "petscversion.h" 40 #define PETSC_AUTHOR_INFO "\ 41 The PETSc Team\n\ 42 petsc-maint@mcs.anl.gov\n\ 43 http://www.mcs.anl.gov/petsc/\n" 44 #if (PETSC_VERSION_RELEASE == 1) 45 #define PetscGetVersion(version,len) (PetscSNPrintf(*(version),len,"Petsc Release Version %d.%d.%d, Patch %d, ", \ 46 PETSC_VERSION_MAJOR,PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR, \ 47 PETSC_VERSION_PATCH),PetscStrcat(*(version),PETSC_VERSION_PATCH_DATE), \ 48 PetscStrcat(*(version)," HG revision: "),PetscStrcat(*(version),PETSC_VERSION_HG),0) 49 #else 50 #define PetscGetVersion(version,len) (PetscSNPrintf(*(version),len,"Petsc Development Version %d.%d.%d, Patch %d, ", \ 51 PETSC_VERSION_MAJOR,PETSC_VERSION_MINOR, PETSC_VERSION_SUBMINOR, \ 52 PETSC_VERSION_PATCH),PetscStrcat(*(version),PETSC_VERSION_PATCH_DATE), \ 53 PetscStrcat(*(version)," HG revision: "),PetscStrcat(*(version),PETSC_VERSION_HG),0) 54 #endif 55 56 /*MC 57 PetscGetVersion - Gets the Petsc Version information in a string. 58 59 Output Parameter: 60 . version - version string 61 62 Input Parameter: 63 . len - length of the string 64 65 Level: developer 66 67 Usage: 68 char version[256]; 69 PetscGetVersion(&version,256); 70 71 Fortran Note: 72 This routine is not supported in Fortran. 73 74 .seealso: PetscGetProgramName() 75 76 M*/ 77 78 /* ========================================================================== */ 79 80 /* 81 Currently cannot check formatting for PETSc print statements because we have our 82 own format %D and %G 83 */ 84 #undef PETSC_PRINTF_FORMAT_CHECK 85 #define PETSC_PRINTF_FORMAT_CHECK(a,b) 86 #undef PETSC_FPRINTF_FORMAT_CHECK 87 #define PETSC_FPRINTF_FORMAT_CHECK(a,b) 88 89 /* 90 Fixes for configure time choices which impact our interface. Currently only 91 calling conventions and extra compiler checking falls under this category. 92 */ 93 #if !defined(PETSC_STDCALL) 94 #define PETSC_STDCALL 95 #endif 96 #if !defined(PETSC_TEMPLATE) 97 #define PETSC_TEMPLATE 98 #endif 99 #if !defined(PETSC_HAVE_DLL_EXPORT) 100 #define PETSC_DLL_EXPORT 101 #define PETSC_DLL_IMPORT 102 #endif 103 #if !defined(PETSC_DLLEXPORT) 104 #define PETSC_DLLEXPORT 105 #endif 106 #if !defined(PETSCVEC_DLLEXPORT) 107 #define PETSCVEC_DLLEXPORT 108 #endif 109 #if !defined(PETSCMAT_DLLEXPORT) 110 #define PETSCMAT_DLLEXPORT 111 #endif 112 #if !defined(PETSCDM_DLLEXPORT) 113 #define PETSCDM_DLLEXPORT 114 #endif 115 #if !defined(PETSCKSP_DLLEXPORT) 116 #define PETSCKSP_DLLEXPORT 117 #endif 118 #if !defined(PETSCSNES_DLLEXPORT) 119 #define PETSCSNES_DLLEXPORT 120 #endif 121 #if !defined(PETSCTS_DLLEXPORT) 122 #define PETSCTS_DLLEXPORT 123 #endif 124 #if !defined(PETSCFORTRAN_DLLEXPORT) 125 #define PETSCFORTRAN_DLLEXPORT 126 #endif 127 /* ========================================================================== */ 128 129 /* 130 Defines the interface to MPI allowing the use of all MPI functions. 131 132 PETSc does not use the C++ binding of MPI at ALL. The following flag 133 makes sure the C++ bindings are not included. The C++ bindings REQUIRE 134 putting mpi.h before ANY C++ include files, we cannot control this 135 with all PETSc users. 136 */ 137 #define MPICH_SKIP_MPICXX 1 138 #include "mpi.h" 139 /* 140 Yuck, we need to put stdio.h AFTER mpi.h for MPICH2 with C++ compiler 141 see the top of mpicxx.h 142 143 The MPI STANDARD HAS TO BE CHANGED to prevent this nonsense. 144 */ 145 #include <stdio.h> 146 147 /*MC 148 PetscErrorCode - datatype used for return error code from all PETSc functions 149 150 Level: beginner 151 152 .seealso: CHKERRQ, SETERRQ 153 M*/ 154 typedef int PetscErrorCode; 155 156 /*MC 157 158 PetscCookie - A unique id used to identify each PETSc object. 159 (internal integer in the data structure used for error 160 checking). These are all defined by an offset from the lowest 161 one, PETSC_SMALLEST_COOKIE. 162 163 Level: advanced 164 165 .seealso: PetscLogClassRegister(), PetscLogEventRegister(), PetscHeaderCreate() 166 M*/ 167 typedef int PetscCookie; 168 169 /*MC 170 PetscEvent - id used to identify PETSc or user events - primarily for logging 171 172 Level: intermediate 173 174 .seealso: PetscLogEventRegister(), PetscLogEventBegin() PetscLogEventEnd() 175 M*/ 176 typedef int PetscEvent; 177 178 /*MC 179 PetscBLASInt - datatype used to represent 'int' parameters to blas functions. 180 181 Level: intermediate 182 M*/ 183 typedef int PetscBLASInt; 184 185 /*MC 186 PetscMPIInt - datatype used to represent 'int' parameters to MPI functions. 187 188 Level: intermediate 189 M*/ 190 typedef int PetscMPIInt; 191 192 /*MC 193 PetscEnum - datatype used to pass enum types within PETSc functions. 194 195 Level: intermediate 196 197 .seealso: PetscOptionsGetEnum(), PetscOptionsEnum(), PetscBagRegisterEnum() 198 M*/ 199 typedef enum { ENUM_DUMMY } PetscEnum; 200 201 /*MC 202 PetscInt - PETSc type that represents integer - used primarily to 203 represent size of objects. Its size can be configured with the option 204 --with-64-bit-indices - to be either 32bit or 64bit [default 32 bit ints] 205 206 Level: intermediate 207 208 .seealso: PetscScalar 209 M*/ 210 #if defined(PETSC_USE_64BIT_INDICES) 211 typedef long long PetscInt; 212 #define MPIU_INT MPI_LONG_LONG_INT 213 #else 214 typedef int PetscInt; 215 #define MPIU_INT MPI_INT 216 #endif 217 218 /* 219 You can use PETSC_STDOUT as a replacement of stdout. You can also change 220 the value of PETSC_STDOUT to redirect all standard output elsewhere 221 */ 222 extern FILE* PETSC_STDOUT; 223 224 /* 225 You can use PETSC_STDERR as a replacement of stderr. You can also change 226 the value of PETSC_STDERR to redirect all standard error elsewhere 227 */ 228 extern FILE* PETSC_STDERR; 229 230 #if !defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus) 231 /*MC 232 PetscPolymorphicSubroutine - allows defining a C++ polymorphic version of 233 a PETSc function that remove certain optional arguments for a simplier user interface 234 235 Not collective 236 237 Synopsis: 238 PetscPolymorphicSubroutine(Functionname,(arguments of C++ function),(arguments of C function)) 239 240 Level: developer 241 242 Example: 243 PetscPolymorphicSubroutine(VecNorm,(Vec x,PetscReal *r),(x,NORM_2,r)) generates the new routine 244 PetscErrorCode VecNorm(Vec x,PetscReal *r) = VecNorm(x,NORM_2,r) 245 246 .seealso: PetscPolymorphicFunction() 247 248 M*/ 249 #define PetscPolymorphicSubroutine(A,B,C) PETSC_STATIC_INLINE PetscErrorCode A B {return A C;} 250 251 /*MC 252 PetscPolymorphicScalar - allows defining a C++ polymorphic version of 253 a PETSc function that replaces a PetscScalar * argument with a PetscScalar argument 254 255 Not collective 256 257 Synopsis: 258 PetscPolymorphicScalar(Functionname,(arguments of C++ function),(arguments of C function)) 259 260 Level: developer 261 262 Example: 263 PetscPolymorphicScalar(VecAXPY,(PetscScalar _val,Vec x,Vec y),(&_Val,x,y)) generates the new routine 264 PetscErrorCode VecAXPY(PetscScalar _val,Vec x,Vec y) = {PetscScalar _Val = _val; return VecAXPY(&_Val,x,y);} 265 266 .seealso: PetscPolymorphicFunction(),PetscPolymorphicSubroutine() 267 268 M*/ 269 #define PetscPolymorphicScalar(A,B,C) PETSC_STATIC_INLINE PetscErrorCode A B {PetscScalar _Val = _val; return A C;} 270 271 /*MC 272 PetscPolymorphicFunction - allows defining a C++ polymorphic version of 273 a PETSc function that remove certain optional arguments for a simplier user interface 274 and returns the computed value (istead of an error code) 275 276 Not collective 277 278 Synopsis: 279 PetscPolymorphicFunction(Functionname,(arguments of C++ function),(arguments of C function),return type,return variable name) 280 281 Level: developer 282 283 Example: 284 PetscPolymorphicFunction(VecNorm,(Vec x,NormType t),(x,t,&r),PetscReal,r) generates the new routine 285 PetscReal VecNorm(Vec x,NormType t) = {PetscReal r; VecNorm(x,t,&r); return r;} 286 287 .seealso: PetscPolymorphicSubroutine() 288 289 M*/ 290 #define PetscPolymorphicFunction(A,B,C,D,E) PETSC_STATIC_INLINE D A B {D E; A C;return E;} 291 292 #else 293 #define PetscPolymorphicSubroutine(A,B,C) 294 #define PetscPolymorphicScalar(A,B,C) 295 #define PetscPolymorphicFunction(A,B,C,D,E) 296 #endif 297 298 /* 299 Extern indicates a PETSc function defined elsewhere 300 */ 301 #if !defined(EXTERN) 302 #define EXTERN extern 303 #endif 304 305 /* 306 Defines some elementary mathematics functions and constants. 307 */ 308 #include "petscmath.h" 309 310 /* 311 Declare extern C stuff after including external header files 312 */ 313 314 PETSC_EXTERN_CXX_BEGIN 315 316 /* 317 Basic PETSc constants 318 */ 319 320 /*E 321 PetscTruth - Logical variable. Actually an integer 322 323 Level: beginner 324 325 E*/ 326 typedef enum { PETSC_FALSE,PETSC_TRUE } PetscTruth; 327 extern const char *PetscTruths[]; 328 329 /*MC 330 PETSC_FALSE - False value of PetscTruth 331 332 Level: beginner 333 334 Note: Zero integer 335 336 .seealso: PetscTruth, PETSC_TRUE 337 M*/ 338 339 /*MC 340 PETSC_TRUE - True value of PetscTruth 341 342 Level: beginner 343 344 Note: Nonzero integer 345 346 .seealso: PetscTruth, PETSC_FALSE 347 M*/ 348 349 /*MC 350 PETSC_YES - Alias for PETSC_TRUE 351 352 Level: beginner 353 354 Note: Zero integer 355 356 .seealso: PetscTruth, PETSC_TRUE, PETSC_FALSE, PETSC_NO 357 M*/ 358 #define PETSC_YES PETSC_TRUE 359 360 /*MC 361 PETSC_NO - Alias for PETSC_FALSE 362 363 Level: beginner 364 365 Note: Nonzero integer 366 367 .seealso: PetscTruth, PETSC_TRUE, PETSC_FALSE, PETSC_YES 368 M*/ 369 #define PETSC_NO PETSC_FALSE 370 371 /*MC 372 PETSC_NULL - standard way of passing in a null or array or pointer 373 374 Level: beginner 375 376 Notes: accepted by many PETSc functions to not set a parameter and instead use 377 some default 378 379 This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER, 380 PETSC_NULL_DOUBLE_PRECISION etc 381 382 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE 383 384 M*/ 385 #define PETSC_NULL 0 386 387 /*MC 388 PETSC_DECIDE - standard way of passing in integer or floating point parameter 389 where you wish PETSc to use the default. 390 391 Level: beginner 392 393 .seealso: PETSC_NULL, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE 394 395 M*/ 396 #define PETSC_DECIDE -1 397 398 /*MC 399 PETSC_DEFAULT - standard way of passing in integer or floating point parameter 400 where you wish PETSc to use the default. 401 402 Level: beginner 403 404 .seealso: PETSC_DECIDE, PETSC_NULL, PETSC_IGNORE, PETSC_DETERMINE 405 406 M*/ 407 #define PETSC_DEFAULT -2 408 409 410 /*MC 411 PETSC_IGNORE - same as PETSC_NULL, means PETSc will ignore this argument 412 413 Level: beginner 414 415 Notes: accepted by many PETSc functions to not set a parameter and instead use 416 some default 417 418 This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER, 419 PETSC_NULL_DOUBLE_PRECISION etc 420 421 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_NULL, PETSC_DETERMINE 422 423 M*/ 424 #define PETSC_IGNORE PETSC_NULL 425 426 /*MC 427 PETSC_DETERMINE - standard way of passing in integer or floating point parameter 428 where you wish PETSc to compute the required value. 429 430 Level: beginner 431 432 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_NULL, VecSetSizes() 433 434 M*/ 435 #define PETSC_DETERMINE PETSC_DECIDE 436 437 /*MC 438 PETSC_COMM_WORLD - the equivalent of the MPI_COMM_WORLD communicator which represents 439 all the processs that PETSc knows about. 440 441 Level: beginner 442 443 Notes: By default PETSC_COMM_WORLD and MPI_COMM_WORLD are identical unless you wish to 444 run PETSc on ONLY a subset of MPI_COMM_WORLD. In that case create your new (smaller) 445 communicator, call it, say comm, and set PETSC_COMM_WORLD = comm BEFORE calling 446 PetscInitialize() 447 448 .seealso: PETSC_COMM_SELF 449 450 M*/ 451 extern MPI_Comm PETSC_COMM_WORLD; 452 453 /*MC 454 PETSC_COMM_SELF - a duplicate of the MPI_COMM_SELF communicator which represents 455 the current process 456 457 Level: beginner 458 459 Notes: PETSC_COMM_SELF and MPI_COMM_SELF are equivalent. 460 461 .seealso: PETSC_COMM_WORLD 462 463 M*/ 464 #define PETSC_COMM_SELF MPI_COMM_SELF 465 466 extern PETSC_DLLEXPORT PetscTruth PetscInitializeCalled; 467 extern PETSC_DLLEXPORT PetscTruth PetscFinalizeCalled; 468 469 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetHelpVersionFunctions(PetscErrorCode (*)(MPI_Comm),PetscErrorCode (*)(MPI_Comm)); 470 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCommDuplicate(MPI_Comm,MPI_Comm*,int*); 471 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCommDestroy(MPI_Comm*); 472 473 /*MC 474 PetscMalloc - Allocates memory 475 476 Input Parameter: 477 . m - number of bytes to allocate 478 479 Output Parameter: 480 . result - memory allocated 481 482 Synopsis: 483 PetscErrorCode PetscMalloc(size_t m,void **result) 484 485 Level: beginner 486 487 Notes: Memory is always allocated at least double aligned 488 489 If you request memory of zero size it will allocate no space and assign the pointer to 0; PetscFree() will 490 properly handle not freeing the null pointer. 491 492 .seealso: PetscFree(), PetscNew() 493 494 Concepts: memory allocation 495 496 M*/ 497 #define PetscMalloc(a,b) ((a != 0) ? (*PetscTrMalloc)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__,(void**)(b)) : (*(b) = 0,0) ) 498 499 /*MC 500 PetscMalloc2 - Allocates 2 chunks of memory 501 502 Input Parameter: 503 + m1 - number of elements to allocate in 1st chunk (may be zero) 504 . t1 - type of first memory elements 505 . m2 - number of elements to allocate in 2nd chunk (may be zero) 506 - t2 - type of second memory elements 507 508 Output Parameter: 509 + r1 - memory allocated in first chunk 510 - r2 - memory allocated in second chunk 511 512 Synopsis: 513 PetscErrorCode PetscMalloc2(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2) 514 515 Level: developer 516 517 Notes: Memory of first chunk is always allocated at least double aligned 518 519 .seealso: PetscFree(), PetscNew(), PetscMalloc() 520 521 Concepts: memory allocation 522 523 M*/ 524 #if defined(PETSC_USE_DEBUG) 525 #define PetscMalloc2(m1,t1,r1,m2,t2,r2) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2)) 526 #else 527 #define PetscMalloc2(m1,t1,r1,m2,t2,r2) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2),r1) || (*(r2) = (t2*)(*(r1)+m1),0)) 528 #endif 529 530 /*MC 531 PetscMalloc3 - Allocates 3 chunks of memory 532 533 Input Parameter: 534 + m1 - number of elements to allocate in 1st chunk (may be zero) 535 . t1 - type of first memory elements 536 . m2 - number of elements to allocate in 2nd chunk (may be zero) 537 . t2 - type of second memory elements 538 . m3 - number of elements to allocate in 3rd chunk (may be zero) 539 - t3 - type of third memory elements 540 541 Output Parameter: 542 + r1 - memory allocated in first chunk 543 . r2 - memory allocated in second chunk 544 - r3 - memory allocated in third chunk 545 546 Synopsis: 547 PetscErrorCode PetscMalloc3(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3) 548 549 Level: developer 550 551 Notes: Memory of first chunk is always allocated at least double aligned 552 553 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3() 554 555 Concepts: memory allocation 556 557 M*/ 558 #if defined(PETSC_USE_DEBUG) 559 #define PetscMalloc3(m1,t1,r1,m2,t2,r2,m3,t3,r3) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3)) 560 #else 561 #define PetscMalloc3(m1,t1,r1,m2,t2,r2,m3,t3,r3) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),0)) 562 #endif 563 564 /*MC 565 PetscMalloc4 - Allocates 4 chunks of memory 566 567 Input Parameter: 568 + m1 - number of elements to allocate in 1st chunk (may be zero) 569 . t1 - type of first memory elements 570 . m2 - number of elements to allocate in 2nd chunk (may be zero) 571 . t2 - type of second memory elements 572 . m3 - number of elements to allocate in 3rd chunk (may be zero) 573 . t3 - type of third memory elements 574 . m4 - number of elements to allocate in 4th chunk (may be zero) 575 - t4 - type of fourth memory elements 576 577 Output Parameter: 578 + r1 - memory allocated in first chunk 579 . r2 - memory allocated in second chunk 580 . r3 - memory allocated in third chunk 581 - r4 - memory allocated in fourth chunk 582 583 Synopsis: 584 PetscErrorCode PetscMalloc4(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3,size_t m4,type t4,void **r4) 585 586 Level: developer 587 588 Notes: Memory of first chunk is always allocated at least double aligned 589 590 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4() 591 592 Concepts: memory allocation 593 594 M*/ 595 #if defined(PETSC_USE_DEBUG) 596 #define PetscMalloc4(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3) || PetscMalloc((m4)*sizeof(t4),r4)) 597 #else 598 #define PetscMalloc4(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),0)) 599 #endif 600 601 /*MC 602 PetscMalloc5 - Allocates 5 chunks of memory 603 604 Input Parameter: 605 + m1 - number of elements to allocate in 1st chunk (may be zero) 606 . t1 - type of first memory elements 607 . m2 - number of elements to allocate in 2nd chunk (may be zero) 608 . t2 - type of second memory elements 609 . m3 - number of elements to allocate in 3rd chunk (may be zero) 610 . t3 - type of third memory elements 611 . m4 - number of elements to allocate in 4th chunk (may be zero) 612 . t4 - type of fourth memory elements 613 . m5 - number of elements to allocate in 5th chunk (may be zero) 614 - t5 - type of fifth memory elements 615 616 Output Parameter: 617 + r1 - memory allocated in first chunk 618 . r2 - memory allocated in second chunk 619 . r3 - memory allocated in third chunk 620 . r4 - memory allocated in fourth chunk 621 - r5 - memory allocated in fifth chunk 622 623 Synopsis: 624 PetscErrorCode PetscMalloc5(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3,size_t m4,type t4,void **r4,size_t m5,type t5,void **r5) 625 626 Level: developer 627 628 Notes: Memory of first chunk is always allocated at least double aligned 629 630 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5() 631 632 Concepts: memory allocation 633 634 M*/ 635 #if defined(PETSC_USE_DEBUG) 636 #define PetscMalloc5(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3) || PetscMalloc((m4)*sizeof(t4),r4) || PetscMalloc((m5)*sizeof(t5),r5)) 637 #else 638 #define PetscMalloc5(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+(m5)*sizeof(t5),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),*(r5) = (t5*)(*(r4)+m4),0)) 639 #endif 640 641 642 /*MC 643 PetscMalloc6 - Allocates 6 chunks of memory 644 645 Input Parameter: 646 + m1 - number of elements to allocate in 1st chunk (may be zero) 647 . t1 - type of first memory elements 648 . m2 - number of elements to allocate in 2nd chunk (may be zero) 649 . t2 - type of second memory elements 650 . m3 - number of elements to allocate in 3rd chunk (may be zero) 651 . t3 - type of third memory elements 652 . m4 - number of elements to allocate in 4th chunk (may be zero) 653 . t4 - type of fourth memory elements 654 . m5 - number of elements to allocate in 5th chunk (may be zero) 655 . t5 - type of fifth memory elements 656 . m6 - number of elements to allocate in 6th chunk (may be zero) 657 - t6 - type of sixth memory elements 658 659 Output Parameter: 660 + r1 - memory allocated in first chunk 661 . r2 - memory allocated in second chunk 662 . r3 - memory allocated in third chunk 663 . r4 - memory allocated in fourth chunk 664 . r5 - memory allocated in fifth chunk 665 - r6 - memory allocated in sixth chunk 666 667 Synopsis: 668 PetscErrorCode PetscMalloc6(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3,size_t m4,type t4,void **r4,size_t m5,type t5,void **r5,size_t m6,type t6,void **r6) 669 670 Level: developer 671 672 Notes: Memory of first chunk is always allocated at least double aligned 673 674 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5(), PetscFree6() 675 676 Concepts: memory allocation 677 678 M*/ 679 #if defined(PETSC_USE_DEBUG) 680 #define PetscMalloc6(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3) || PetscMalloc((m4)*sizeof(t4),r4) || PetscMalloc((m5)*sizeof(t5),r5) || PetscMalloc((m6)*sizeof(t6),r6)) 681 #else 682 #define PetscMalloc6(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+(m5)*sizeof(t5)+(m6)*sizeof(t6),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),*(r5) = (t5*)(*(r4)+m4),*(r6) = (t6*)(*(r5)+m5),0)) 683 #endif 684 685 /*MC 686 PetscMalloc7 - Allocates 7 chunks of memory 687 688 Input Parameter: 689 + m1 - number of elements to allocate in 1st chunk (may be zero) 690 . t1 - type of first memory elements 691 . m2 - number of elements to allocate in 2nd chunk (may be zero) 692 . t2 - type of second memory elements 693 . m3 - number of elements to allocate in 3rd chunk (may be zero) 694 . t3 - type of third memory elements 695 . m4 - number of elements to allocate in 4th chunk (may be zero) 696 . t4 - type of fourth memory elements 697 . m5 - number of elements to allocate in 5th chunk (may be zero) 698 . t5 - type of fifth memory elements 699 . m6 - number of elements to allocate in 6th chunk (may be zero) 700 . t6 - type of sixth memory elements 701 . m7 - number of elements to allocate in 7th chunk (may be zero) 702 - t7 - type of sixth memory elements 703 704 Output Parameter: 705 + r1 - memory allocated in first chunk 706 . r2 - memory allocated in second chunk 707 . r3 - memory allocated in third chunk 708 . r4 - memory allocated in fourth chunk 709 . r5 - memory allocated in fifth chunk 710 . r6 - memory allocated in sixth chunk 711 - r7 - memory allocated in sixth chunk 712 713 Synopsis: 714 PetscErrorCode PetscMalloc7(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3,size_t m4,type t4,void **r4,size_t m5,type t5,void **r5,size_t m6,type t6,void **r6,size_t m7,type t7,void **r7) 715 716 Level: developer 717 718 Notes: Memory of first chunk is always allocated at least double aligned 719 720 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5(), PetscFree6(), PetscFree7() 721 722 Concepts: memory allocation 723 724 M*/ 725 #if defined(PETSC_USE_DEBUG) 726 #define PetscMalloc7(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6,m7,t7,r7) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2) || PetscMalloc((m3)*sizeof(t3),r3) || PetscMalloc((m4)*sizeof(t4),r4) || PetscMalloc((m5)*sizeof(t5),r5) || PetscMalloc((m6)*sizeof(t6),r6) || PetscMalloc((m7)*sizeof(t7),r7)) 727 #else 728 #define PetscMalloc7(m1,t1,r1,m2,t2,r2,m3,t3,r3,m4,t4,r4,m5,t5,r5,m6,t6,r6,m7,t7,r7) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2)+(m3)*sizeof(t3)+(m4)*sizeof(t4)+(m5)*sizeof(t5)+(m6)*sizeof(t6)+(m7)*sizeof(t7),r1) || (*(r2) = (t2*)(*(r1)+m1),*(r3) = (t3*)(*(r2)+m2),*(r4) = (t4*)(*(r3)+m3),*(r5) = (t5*)(*(r4)+m4),*(r6) = (t6*)(*(r5)+m5),*(r7) = (t7*)(*(r6)+m6),0)) 729 #endif 730 731 /*MC 732 PetscNew - Allocates memory of a particular type, zeros the memory! 733 734 Input Parameter: 735 . type - structure name of space to be allocated. Memory of size sizeof(type) is allocated 736 737 Output Parameter: 738 . result - memory allocated 739 740 Synopsis: 741 PetscErrorCode PetscNew(struct type,((type *))result) 742 743 Level: beginner 744 745 .seealso: PetscFree(), PetscMalloc() 746 747 Concepts: memory allocation 748 749 M*/ 750 #define PetscNew(A,b) (PetscMalloc(sizeof(A),(b)) || PetscMemzero(*(b),sizeof(A))) 751 752 /*MC 753 PetscFree - Frees memory 754 755 Input Parameter: 756 . memory - memory to free (the pointer is ALWAYS set to 0 upon sucess) 757 758 Synopsis: 759 PetscErrorCode PetscFree(void *memory) 760 761 Level: beginner 762 763 Notes: Memory must have been obtained with PetscNew() or PetscMalloc() 764 765 .seealso: PetscNew(), PetscMalloc(), PetscFreeVoid() 766 767 Concepts: memory allocation 768 769 M*/ 770 #define PetscFree(a) ((a) ? ((*PetscTrFree)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__) || ((a = 0),0)) : 0) 771 772 /*MC 773 PetscFreeVoid - Frees memory 774 775 Input Parameter: 776 . memory - memory to free 777 778 Synopsis: 779 void PetscFreeVoid(void *memory) 780 781 Level: beginner 782 783 Notes: This is different from PetscFree() in that no error code is returned 784 785 .seealso: PetscFree(), PetscNew(), PetscMalloc() 786 787 Concepts: memory allocation 788 789 M*/ 790 #define PetscFreeVoid(a) ((*PetscTrFree)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__),(a) = 0) 791 792 793 /*MC 794 PetscFree2 - Frees 2 chunks of memory obtained with PetscMalloc2() 795 796 Input Parameter: 797 + memory1 - memory to free 798 - memory2 - 2nd memory to free 799 800 801 Synopsis: 802 PetscErrorCode PetscFree2(void *memory1,void *memory2) 803 804 Level: developer 805 806 Notes: Memory must have been obtained with PetscMalloc2() 807 808 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree() 809 810 Concepts: memory allocation 811 812 M*/ 813 #if defined(PETSC_USE_DEBUG) 814 #define PetscFree2(m1,m2) (PetscFree(m2) || PetscFree(m1)) 815 #else 816 #define PetscFree2(m1,m2) (PetscFree(m1)) 817 #endif 818 819 /*MC 820 PetscFree3 - Frees 3 chunks of memory obtained with PetscMalloc3() 821 822 Input Parameter: 823 + memory1 - memory to free 824 . memory2 - 2nd memory to free 825 - memory3 - 3rd memory to free 826 827 828 Synopsis: 829 PetscErrorCode PetscFree3(void *memory1,void *memory2,void *memory3) 830 831 Level: developer 832 833 Notes: Memory must have been obtained with PetscMalloc3() 834 835 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3() 836 837 Concepts: memory allocation 838 839 M*/ 840 #if defined(PETSC_USE_DEBUG) 841 #define PetscFree3(m1,m2,m3) (PetscFree(m3) || PetscFree(m2) || PetscFree(m1)) 842 #else 843 #define PetscFree3(m1,m2,m3) (PetscFree(m1)) 844 #endif 845 846 /*MC 847 PetscFree4 - Frees 4 chunks of memory obtained with PetscMalloc4() 848 849 Input Parameter: 850 + m1 - memory to free 851 . m2 - 2nd memory to free 852 . m3 - 3rd memory to free 853 - m4 - 4th memory to free 854 855 856 Synopsis: 857 PetscErrorCode PetscFree4(void *m1,void *m2,void *m3,void *m4) 858 859 Level: developer 860 861 Notes: Memory must have been obtained with PetscMalloc4() 862 863 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4() 864 865 Concepts: memory allocation 866 867 M*/ 868 #if defined(PETSC_USE_DEBUG) 869 #define PetscFree4(m1,m2,m3,m4) (PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1)) 870 #else 871 #define PetscFree4(m1,m2,m3,m4) (PetscFree(m1)) 872 #endif 873 874 /*MC 875 PetscFree5 - Frees 5 chunks of memory obtained with PetscMalloc5() 876 877 Input Parameter: 878 + m1 - memory to free 879 . m2 - 2nd memory to free 880 . m3 - 3rd memory to free 881 . m4 - 4th memory to free 882 - m5 - 5th memory to free 883 884 885 Synopsis: 886 PetscErrorCode PetscFree5(void *m1,void *m2,void *m3,void *m4,void *m5) 887 888 Level: developer 889 890 Notes: Memory must have been obtained with PetscMalloc5() 891 892 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5() 893 894 Concepts: memory allocation 895 896 M*/ 897 #if defined(PETSC_USE_DEBUG) 898 #define PetscFree5(m1,m2,m3,m4,m5) (PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1)) 899 #else 900 #define PetscFree5(m1,m2,m3,m4,m5) (PetscFree(m1)) 901 #endif 902 903 904 /*MC 905 PetscFree6 - Frees 6 chunks of memory obtained with PetscMalloc6() 906 907 Input Parameter: 908 + m1 - memory to free 909 . m2 - 2nd memory to free 910 . m3 - 3rd memory to free 911 . m4 - 4th memory to free 912 . m5 - 5th memory to free 913 - m6 - 6th memory to free 914 915 916 Synopsis: 917 PetscErrorCode PetscFree6(void *m1,void *m2,void *m3,void *m4,void *m5,void *m6) 918 919 Level: developer 920 921 Notes: Memory must have been obtained with PetscMalloc6() 922 923 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5(), PetscMalloc6() 924 925 Concepts: memory allocation 926 927 M*/ 928 #if defined(PETSC_USE_DEBUG) 929 #define PetscFree6(m1,m2,m3,m4,m5,m6) (PetscFree(m6) || PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1)) 930 #else 931 #define PetscFree6(m1,m2,m3,m4,m5,m6) (PetscFree(m1)) 932 #endif 933 934 /*MC 935 PetscFree7 - Frees 7 chunks of memory obtained with PetscMalloc7() 936 937 Input Parameter: 938 + m1 - memory to free 939 . m2 - 2nd memory to free 940 . m3 - 3rd memory to free 941 . m4 - 4th memory to free 942 . m5 - 5th memory to free 943 . m6 - 6th memory to free 944 - m7 - 7th memory to free 945 946 947 Synopsis: 948 PetscErrorCode PetscFree7(void *m1,void *m2,void *m3,void *m4,void *m5,void *m6,void *m7) 949 950 Level: developer 951 952 Notes: Memory must have been obtained with PetscMalloc7() 953 954 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5(), PetscMalloc6(), 955 PetscMalloc7() 956 957 Concepts: memory allocation 958 959 M*/ 960 #if defined(PETSC_USE_DEBUG) 961 #define PetscFree7(m1,m2,m3,m4,m5,m6,m7) (PetscFree(m7) || PetscFree(m6) || PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1)) 962 #else 963 #define PetscFree7(m1,m2,m3,m4,m5,m6,m7) (PetscFree(m1)) 964 #endif 965 966 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscTrMalloc)(size_t,int,const char[],const char[],const char[],void**); 967 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscTrFree)(void*,int,const char[],const char[],const char[]); 968 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetMalloc(PetscErrorCode (*)(size_t,int,const char[],const char[],const char[],void**),PetscErrorCode (*)(void*,int,const char[],const char[],const char[])); 969 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscClearMalloc(void); 970 971 /* 972 Routines for tracing memory corruption/bleeding with default PETSc 973 memory allocation 974 */ 975 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMallocDump(FILE *); 976 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMallocDumpLog(FILE *); 977 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMallocGetCurrentUsage(PetscLogDouble *); 978 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMallocGetMaximumUsage(PetscLogDouble *); 979 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMallocDebug(PetscTruth); 980 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMallocValidate(int,const char[],const char[],const char[]); 981 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMallocSetDumpLog(void); 982 983 984 /* 985 Variable type where we stash PETSc object pointers in Fortran. 986 On most machines size(pointer) == sizeof(long) - except windows 987 where its sizeof(long long) 988 */ 989 990 #if (PETSC_SIZEOF_VOID_P) == (PETSC_SIZEOF_LONG) 991 #define PetscFortranAddr long 992 #elif (PETSC_SIZEOF_VOID_P) == (PETSC_SIZEOF_LONG_LONG) 993 #define PetscFortranAddr long long 994 #else 995 #error "Unknown size for PetscFortranAddr! Send us a bugreport at petsc-maint@mcs.anl.gov" 996 #endif 997 998 /*E 999 PetscDataType - Used for handling different basic data types. 1000 1001 Level: beginner 1002 1003 .seealso: PetscBinaryRead(), PetscBinaryWrite(), PetscDataTypeToMPIDataType(), 1004 PetscDataTypeGetSize() 1005 1006 E*/ 1007 typedef enum {PETSC_INT = 0,PETSC_DOUBLE = 1,PETSC_COMPLEX = 2, PETSC_LONG = 3 ,PETSC_SHORT = 4,PETSC_FLOAT = 5, 1008 PETSC_CHAR = 6,PETSC_LOGICAL = 7,PETSC_ENUM = 8,PETSC_TRUTH=9, PETSC_LONG_DOUBLE = 10} PetscDataType; 1009 extern const char *PetscDataTypes[]; 1010 1011 #if defined(PETSC_USE_COMPLEX) 1012 #define PETSC_SCALAR PETSC_COMPLEX 1013 #else 1014 #if defined(PETSC_USE_SINGLE) 1015 #define PETSC_SCALAR PETSC_FLOAT 1016 #elif defined(PETSC_USE_LONG_DOUBLE) 1017 #define PETSC_SCALAR PETSC_LONG_DOUBLE 1018 #elif defined(PETSC_USE_INT) 1019 #define PETSC_SCALAR PETSC_INT 1020 #else 1021 #define PETSC_SCALAR PETSC_DOUBLE 1022 #endif 1023 #endif 1024 #if defined(PETSC_USE_SINGLE) 1025 #define PETSC_REAL PETSC_FLOAT 1026 #elif defined(PETSC_USE_LONG_DOUBLE) 1027 #define PETSC_REAL PETSC_LONG_DOUBLE 1028 #elif defined(PETSC_USE_INT) 1029 #define PETSC_REAL PETSC_INT 1030 #else 1031 #define PETSC_REAL PETSC_DOUBLE 1032 #endif 1033 #define PETSC_FORTRANADDR PETSC_LONG 1034 1035 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*); 1036 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDataTypeGetSize(PetscDataType,PetscInt*); 1037 1038 /* 1039 Basic memory and string operations. These are usually simple wrappers 1040 around the basic Unix system calls, but a few of them have additional 1041 functionality and/or error checking. 1042 */ 1043 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemcpy(void*,const void *,size_t); 1044 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBitMemcpy(void*,PetscInt,const void*,PetscInt,PetscInt,PetscDataType); 1045 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemmove(void*,void *,size_t); 1046 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemzero(void*,size_t); 1047 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemcmp(const void*,const void*,size_t,PetscTruth *); 1048 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrlen(const char[],size_t*); 1049 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrcmp(const char[],const char[],PetscTruth *); 1050 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrgrt(const char[],const char[],PetscTruth *); 1051 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrcasecmp(const char[],const char[],PetscTruth*); 1052 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrncmp(const char[],const char[],size_t,PetscTruth*); 1053 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrcpy(char[],const char[]); 1054 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrcat(char[],const char[]); 1055 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrncat(char[],const char[],size_t); 1056 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrncpy(char[],const char[],size_t); 1057 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrchr(const char[],char,char *[]); 1058 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrtolower(char[]); 1059 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrrchr(const char[],char,char *[]); 1060 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrstr(const char[],const char[],char *[]); 1061 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrrstr(const char[],const char[],char *[]); 1062 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrallocpy(const char[],char *[]); 1063 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStrreplace(MPI_Comm,const char[],char[],size_t); 1064 #define PetscStrfree(a) ((a) ? PetscFree(a) : 0) 1065 1066 /*S 1067 PetscToken - 'Token' used for managing tokenizing strings 1068 1069 Level: intermediate 1070 1071 .seealso: PetscTokenCreate(), PetscTokenFind(), PetscTokenDestroy() 1072 S*/ 1073 typedef struct {char token;char *array;char *current;} PetscToken; 1074 1075 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTokenCreate(const char[],const char,PetscToken**); 1076 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTokenFind(PetscToken*,char *[]); 1077 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTokenDestroy(PetscToken*); 1078 1079 /* 1080 These are MPI operations for MPI_Allreduce() etc 1081 */ 1082 EXTERN PETSC_DLLEXPORT MPI_Op PetscMaxSum_Op; 1083 #if defined(PETSC_USE_COMPLEX) 1084 EXTERN PETSC_DLLEXPORT MPI_Op PetscSum_Op; 1085 #else 1086 #define PetscSum_Op MPI_SUM 1087 #endif 1088 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMaxSum(MPI_Comm,const PetscInt[],PetscInt*,PetscInt*); 1089 1090 /*S 1091 PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc 1092 1093 Level: beginner 1094 1095 Note: This is the base class from which all objects appear. 1096 1097 .seealso: PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName() 1098 S*/ 1099 typedef struct _p_PetscObject* PetscObject; 1100 1101 /*S 1102 PetscFList - Linked list of functions, possibly stored in dynamic libraries, accessed 1103 by string name 1104 1105 Level: advanced 1106 1107 .seealso: PetscFListAdd(), PetscFListDestroy() 1108 S*/ 1109 typedef struct _n_PetscFList *PetscFList; 1110 1111 /*E 1112 PetscFileMode - Access mode for a file. 1113 1114 Level: beginner 1115 1116 FILE_MODE_READ - open a file at its beginning for reading 1117 1118 FILE_MODE_WRITE - open a file at its beginning for writing (will create if the file does not exist) 1119 1120 FILE_MODE_APPEND - open a file at end for writing 1121 1122 FILE_MODE_UPDATE - open a file for updating, meaning for reading and writing 1123 1124 FILE_MODE_APPEND_UPDATE - open a file for updating, meaning for reading and writing, at the end 1125 1126 .seealso: PetscViewerFileSetMode() 1127 E*/ 1128 typedef enum {FILE_MODE_READ, FILE_MODE_WRITE, FILE_MODE_APPEND, FILE_MODE_UPDATE, FILE_MODE_APPEND_UPDATE} PetscFileMode; 1129 1130 #include "petscviewer.h" 1131 #include "petscoptions.h" 1132 1133 #define PETSC_SMALLEST_COOKIE 1211211 1134 extern PETSC_DLLEXPORT PetscCookie PETSC_LARGEST_COOKIE; 1135 extern PETSC_DLLEXPORT PetscCookie PETSC_OBJECT_COOKIE; 1136 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCookieRegister(PetscCookie *); 1137 1138 /* 1139 Routines that get memory usage information from the OS 1140 */ 1141 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemoryGetCurrentUsage(PetscLogDouble *); 1142 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemoryGetMaximumUsage(PetscLogDouble *); 1143 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemorySetGetMaximumUsage(void); 1144 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMemoryShowUsage(PetscViewer,const char[]); 1145 1146 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInfoAllow(PetscTruth,const char []); 1147 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetTime(PetscLogDouble*); 1148 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetCPUTime(PetscLogDouble*); 1149 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSleep(int); 1150 1151 /* 1152 Initialization of PETSc 1153 */ 1154 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInitialize(int*,char***,const char[],const char[]); 1155 PetscPolymorphicSubroutine(PetscInitialize,(int *argc,char ***args),(argc,args,PETSC_NULL,PETSC_NULL)) 1156 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInitializeNoArguments(void); 1157 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInitialized(PetscTruth *); 1158 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFinalized(PetscTruth *); 1159 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFinalize(void); 1160 EXTERN PetscErrorCode PetscInitializeFortran(void); 1161 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetArgs(int*,char ***); 1162 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetArguments(char ***args); 1163 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFreeArguments(char **args); 1164 1165 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscEnd(void); 1166 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscInitializePackage(const char[]); 1167 1168 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPMerge(PetscMPIInt); 1169 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPSpawn(PetscMPIInt); 1170 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPFinalize(void); 1171 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPRun(MPI_Comm,PetscErrorCode (*)(MPI_Comm,void *),void*); 1172 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPFree(MPI_Comm,void*); 1173 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOpenMPNew(MPI_Comm,PetscInt,void**); 1174 1175 /* 1176 These are so that in extern C code we can caste function pointers to non-extern C 1177 function pointers. Since the regular C++ code expects its function pointers to be 1178 C++. 1179 */ 1180 typedef void (**PetscVoidStarFunction)(void); 1181 typedef void (*PetscVoidFunction)(void); 1182 typedef PetscErrorCode (*PetscErrorCodeFunction)(void); 1183 1184 /* 1185 PetscTryMethod - Queries an object for a method, if it exists then calls it. 1186 These are intended to be used only inside PETSc functions. 1187 */ 1188 #define PetscTryMethod(obj,A,B,C) \ 1189 0;{ PetscErrorCode (*f)B, __ierr; \ 1190 __ierr = PetscObjectQueryFunction((PetscObject)obj,#A,(PetscVoidStarFunction)&f);CHKERRQ(__ierr); \ 1191 if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\ 1192 } 1193 #define PetscUseMethod(obj,A,B,C) \ 1194 0;{ PetscErrorCode (*f)B, __ierr; \ 1195 __ierr = PetscObjectQueryFunction((PetscObject)obj,A,(PetscVoidStarFunction)&f);CHKERRQ(__ierr); \ 1196 if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\ 1197 else {SETERRQ1(PETSC_ERR_SUP,"Cannot locate function %s in object",A);} \ 1198 } 1199 /* 1200 Functions that can act on any PETSc object. 1201 */ 1202 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectCreate(MPI_Comm,PetscObject*); 1203 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectCreateGeneric(MPI_Comm, PetscCookie, const char [], PetscObject *); 1204 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectDestroy(PetscObject); 1205 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectExists(PetscObject,PetscTruth*); 1206 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetComm(PetscObject,MPI_Comm *); 1207 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetCookie(PetscObject,PetscCookie *); 1208 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetType(PetscObject,const char []); 1209 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetType(PetscObject,const char *[]); 1210 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetName(PetscObject,const char[]); 1211 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetName(PetscObject,const char*[]); 1212 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectReference(PetscObject); 1213 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetReference(PetscObject,PetscInt*); 1214 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectDereference(PetscObject); 1215 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetNewTag(PetscObject,PetscMPIInt *); 1216 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectView(PetscObject,PetscViewer); 1217 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectCompose(PetscObject,const char[],PetscObject); 1218 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectQuery(PetscObject,const char[],PetscObject *); 1219 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectComposeFunction(PetscObject,const char[],const char[],void (*)(void)); 1220 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetFromOptions(PetscObject); 1221 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetUp(PetscObject); 1222 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscCommGetNewTag(MPI_Comm,PetscMPIInt *); 1223 1224 /*MC 1225 PetscObjectComposeFunctionDynamic - Associates a function with a given PETSc object. 1226 1227 Collective on PetscObject 1228 1229 Input Parameters: 1230 + obj - the PETSc object; this must be cast with a (PetscObject), for example, 1231 PetscObjectCompose((PetscObject)mat,...); 1232 . name - name associated with the child function 1233 . fname - name of the function 1234 - ptr - function pointer (or PETSC_NULL if using dynamic libraries) 1235 1236 Level: advanced 1237 1238 Synopsis: 1239 PetscErrorCode PetscObjectComposeFunctionDynamic(PetscObject obj,const char name[],const char fname[],void *ptr) 1240 1241 Notes: 1242 To remove a registered routine, pass in a PETSC_NULL rname and fnc(). 1243 1244 PetscObjectComposeFunctionDynamic() can be used with any PETSc object (such as 1245 Mat, Vec, KSP, SNES, etc.) or any user-provided object. 1246 1247 The composed function must be wrapped in a EXTERN_C_BEGIN/END for this to 1248 work in C++/complex with dynamic link libraries (config/configure.py options --with-shared --with-dynamic) 1249 enabled. 1250 1251 Concepts: objects^composing functions 1252 Concepts: composing functions 1253 Concepts: functions^querying 1254 Concepts: objects^querying 1255 Concepts: querying objects 1256 1257 .seealso: PetscObjectQueryFunction() 1258 M*/ 1259 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1260 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,0) 1261 #else 1262 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,(PetscVoidFunction)(d)) 1263 #endif 1264 1265 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectQueryFunction(PetscObject,const char[],void (**)(void)); 1266 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectSetOptionsPrefix(PetscObject,const char[]); 1267 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectAppendOptionsPrefix(PetscObject,const char[]); 1268 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectPrependOptionsPrefix(PetscObject,const char[]); 1269 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectGetOptionsPrefix(PetscObject,const char*[]); 1270 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectPublish(PetscObject); 1271 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectChangeTypeName(PetscObject,const char[]); 1272 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectRegisterDestroy(PetscObject); 1273 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectRegisterDestroyAll(void); 1274 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectName(PetscObject); 1275 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTypeCompare(PetscObject,const char[],PetscTruth*); 1276 1277 /* 1278 Defines PETSc error handling. 1279 */ 1280 #include "petscerror.h" 1281 1282 /*S 1283 PetscOList - Linked list of PETSc objects, accessable by string name 1284 1285 Level: advanced 1286 1287 .seealso: PetscOListAdd(), PetscOListDestroy(), PetscOListFind() 1288 S*/ 1289 typedef struct _n_PetscOList *PetscOList; 1290 1291 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListDestroy(PetscOList); 1292 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListFind(PetscOList,const char[],PetscObject*); 1293 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListReverseFind(PetscOList,PetscObject,char**); 1294 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListAdd(PetscOList *,const char[],PetscObject); 1295 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOListDuplicate(PetscOList,PetscOList *); 1296 1297 /* 1298 Dynamic library lists. Lists of names of routines in dynamic 1299 link libraries that will be loaded as needed. 1300 */ 1301 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListAdd(PetscFList*,const char[],const char[],void (*)(void)); 1302 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListDestroy(PetscFList*); 1303 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListFind(PetscFList,MPI_Comm,const char[],void (**)(void)); 1304 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListPrintTypes(PetscFList,MPI_Comm,FILE*,const char[],const char[],const char[],const char[]); 1305 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1306 #define PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,0) 1307 #else 1308 #define PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,(void (*)(void))c) 1309 #endif 1310 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListDuplicate(PetscFList,PetscFList *); 1311 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListView(PetscFList,PetscViewer); 1312 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListConcat(const char [],const char [],char []); 1313 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFListGet(PetscFList,char ***,int*); 1314 1315 /*S 1316 PetscDLLibrary - Linked list of dynamics libraries to search for functions 1317 1318 Level: advanced 1319 1320 --with-shared --with-dynamic must be used with config/configure.py to use dynamic libraries 1321 1322 .seealso: PetscDLLibraryOpen() 1323 S*/ 1324 typedef struct _n_PetscDLLibrary *PetscDLLibrary; 1325 extern PetscDLLibrary DLLibrariesLoaded; 1326 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryRetrieve(MPI_Comm,const char[],char *,int,PetscTruth *); 1327 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryOpen(MPI_Comm,const char[],void **); 1328 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibrarySym(MPI_Comm,PetscDLLibrary *,const char[],const char[],void **); 1329 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryAppend(MPI_Comm,PetscDLLibrary *,const char[]); 1330 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryPrepend(MPI_Comm,PetscDLLibrary *,const char[]); 1331 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryClose(PetscDLLibrary); 1332 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryPrintPath(void); 1333 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryGetInfo(void*,const char[],const char *[]); 1334 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDLLibraryCCAAppend(MPI_Comm,PetscDLLibrary *,const char[]); 1335 1336 /* 1337 Useful utility routines 1338 */ 1339 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSplitOwnership(MPI_Comm,PetscInt*,PetscInt*); 1340 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSplitOwnershipBlock(MPI_Comm,PetscInt,PetscInt*,PetscInt*); 1341 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSequentialPhaseBegin(MPI_Comm,PetscMPIInt); 1342 PetscPolymorphicSubroutine(PetscSequentialPhaseBegin,(MPI_Comm comm),(comm,1)) 1343 PetscPolymorphicSubroutine(PetscSequentialPhaseBegin,(void),(PETSC_COMM_WORLD,1)) 1344 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSequentialPhaseEnd(MPI_Comm,PetscMPIInt); 1345 PetscPolymorphicSubroutine(PetscSequentialPhaseEnd,(MPI_Comm comm),(comm,1)) 1346 PetscPolymorphicSubroutine(PetscSequentialPhaseEnd,(void),(PETSC_COMM_WORLD,1)) 1347 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBarrier(PetscObject); 1348 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscMPIDump(FILE*); 1349 1350 #define PetscNot(a) ((a) ? PETSC_FALSE : PETSC_TRUE) 1351 /* 1352 Defines basic graphics available from PETSc. 1353 */ 1354 #include "petscdraw.h" 1355 1356 /* 1357 Defines the base data structures for all PETSc objects 1358 */ 1359 #include "private/petscimpl.h" 1360 /* 1361 Defines PETSc profiling. 1362 */ 1363 #include "petsclog.h" 1364 1365 /* 1366 For locking, unlocking and destroying AMS memories associated with 1367 PETSc objects. Not currently used. 1368 */ 1369 #define PetscPublishAll(v) 0 1370 #define PetscObjectTakeAccess(obj) 0 1371 #define PetscObjectGrantAccess(obj) 0 1372 #define PetscObjectDepublish(obj) 0 1373 1374 1375 1376 /* 1377 This code allows one to pass a MPI communicator between 1378 C and Fortran. MPI 2.0 defines a standard API for doing this. 1379 The code here is provided to allow PETSc to work with MPI 1.1 1380 standard MPI libraries. 1381 */ 1382 EXTERN PetscErrorCode MPICCommToFortranComm(MPI_Comm,int *); 1383 EXTERN PetscErrorCode MPIFortranCommToCComm(int,MPI_Comm*); 1384 1385 /* 1386 Simple PETSc parallel IO for ASCII printing 1387 */ 1388 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFixFilename(const char[],char[]); 1389 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFOpen(MPI_Comm,const char[],const char[],FILE**); 1390 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFClose(MPI_Comm,FILE*); 1391 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4); 1392 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 1393 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSNPrintf(char*,size_t,const char [],...); 1394 1395 /* These are used internally by PETSc ASCII IO routines*/ 1396 #include <stdarg.h> 1397 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscVSNPrintf(char*,size_t,const char[],va_list); 1398 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscVFPrintf(FILE*,const char[],va_list); 1399 1400 /*MC 1401 PetscErrorPrintf - Prints error messages. 1402 1403 Not Collective 1404 1405 Synopsis: 1406 PetscErrorCode (*PetscErrorPrintf)(const char format[],...); 1407 1408 Input Parameters: 1409 . format - the usual printf() format string 1410 1411 Options Database Keys: 1412 + -error_output_stderr - cause error messages to be printed to stderr instead of the 1413 (default) stdout 1414 - -error_output_none to turn off all printing of error messages (does not change the way the 1415 error is handled.) 1416 1417 Notes: Use 1418 PetscErrorPrintf = PetscErrorPrintfNone; to turn off all printing of error messages (does not change the way the 1419 error is handled.) and 1420 PetscErrorPrintf = PetscErrorPrintfDefault; to turn it back on 1421 1422 1423 1424 1425 Level: developer 1426 1427 Fortran Note: 1428 This routine is not supported in Fortran. 1429 1430 Concepts: error messages^printing 1431 Concepts: printing^error messages 1432 1433 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscHelpPrintf() 1434 M*/ 1435 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscErrorPrintf)(const char[],...); 1436 1437 /*MC 1438 PetscHelpPrintf - Prints help messages. 1439 1440 Not Collective 1441 1442 Synopsis: 1443 PetscErrorCode (*PetscHelpPrintf)(const char format[],...); 1444 1445 Input Parameters: 1446 . format - the usual printf() format string 1447 1448 Level: developer 1449 1450 Fortran Note: 1451 This routine is not supported in Fortran. 1452 1453 Concepts: help messages^printing 1454 Concepts: printing^help messages 1455 1456 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscErrorPrintf() 1457 M*/ 1458 EXTERN PETSC_DLLEXPORT PetscErrorCode (*PetscHelpPrintf)(MPI_Comm,const char[],...); 1459 1460 EXTERN PetscErrorCode PetscErrorPrintfDefault(const char [],...); 1461 EXTERN PetscErrorCode PetscErrorPrintfNone(const char [],...); 1462 EXTERN PetscErrorCode PetscHelpPrintfDefault(MPI_Comm,const char [],...); 1463 1464 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPOpen(MPI_Comm,const char[],const char[],const char[],FILE **); 1465 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPClose(MPI_Comm,FILE*); 1466 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 1467 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4); 1468 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedFlush(MPI_Comm); 1469 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedFGets(MPI_Comm,FILE*,size_t,char[]); 1470 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStartMatlab(MPI_Comm,const char[],const char[],FILE**); 1471 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStartJava(MPI_Comm,const char[],const char[],FILE**); 1472 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetPetscDir(const char*[]); 1473 1474 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPopUpSelect(MPI_Comm,char*,char*,int,char**,int*); 1475 1476 /*S 1477 PetscContainer - Simple PETSc object that contains a pointer to any required data 1478 1479 Level: advanced 1480 1481 .seealso: PetscObject, PetscContainerCreate() 1482 S*/ 1483 extern PetscCookie PETSC_DLLEXPORT PETSC_CONTAINER_COOKIE; 1484 typedef struct _p_PetscContainer* PetscContainer; 1485 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerGetPointer(PetscContainer,void **); 1486 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerSetPointer(PetscContainer,void *); 1487 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerDestroy(PetscContainer); 1488 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerCreate(MPI_Comm,PetscContainer *); 1489 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscContainerSetUserDestroy(PetscContainer, PetscErrorCode (*)(void*)); 1490 1491 /* 1492 For use in debuggers 1493 */ 1494 extern PETSC_DLLEXPORT PetscMPIInt PetscGlobalRank; 1495 extern PETSC_DLLEXPORT PetscMPIInt PetscGlobalSize; 1496 1497 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscIntView(PetscInt,PetscInt[],PetscViewer); 1498 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRealView(PetscInt,PetscReal[],PetscViewer); 1499 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscScalarView(PetscInt,PetscScalar[],PetscViewer); 1500 1501 /* 1502 Allows accessing Matlab Engine 1503 */ 1504 #include "petscmatlab.h" 1505 1506 /* 1507 Determine if some of the kernel computation routines use 1508 Fortran (rather than C) for the numerical calculations. On some machines 1509 and compilers (like complex numbers) the Fortran version of the routines 1510 is faster than the C/C++ versions. The flag --with-fortran-kernels 1511 should be used with config/configure.py to turn these on. 1512 */ 1513 #if defined(PETSC_USE_FORTRAN_KERNELS) 1514 1515 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTCRL) 1516 #define PETSC_USE_FORTRAN_KERNEL_MULTCRL 1517 #endif 1518 1519 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTCSRPERM) 1520 #define PETSC_USE_FORTRAN_KERNEL_MULTCSRPERM 1521 #endif 1522 1523 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTAIJ) 1524 #define PETSC_USE_FORTRAN_KERNEL_MULTAIJ 1525 #endif 1526 1527 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ) 1528 #define PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ 1529 #endif 1530 1531 #if !defined(PETSC_USE_FORTRAN_KERNEL_NORM) 1532 #define PETSC_USE_FORTRAN_KERNEL_NORM 1533 #endif 1534 1535 #if !defined(PETSC_USE_FORTRAN_KERNEL_MAXPY) 1536 #define PETSC_USE_FORTRAN_KERNEL_MAXPY 1537 #endif 1538 1539 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ) 1540 #define PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ 1541 #endif 1542 1543 #if !defined(PETSC_USE_FORTRAN_KERNEL_RELAXAIJ) 1544 #define PETSC_USE_FORTRAN_KERNEL_RELAXAIJ 1545 #endif 1546 1547 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ) 1548 #define PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ 1549 #endif 1550 1551 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ) 1552 #define PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ 1553 #endif 1554 1555 #if !defined(PETSC_USE_FORTRAN_KERNEL_MDOT) 1556 #define PETSC_USE_FORTRAN_KERNEL_MDOT 1557 #endif 1558 1559 #if !defined(PETSC_USE_FORTRAN_KERNEL_XTIMESY) 1560 #define PETSC_USE_FORTRAN_KERNEL_XTIMESY 1561 #endif 1562 1563 #if !defined(PETSC_USE_FORTRAN_KERNEL_AYPX) 1564 #define PETSC_USE_FORTRAN_KERNEL_AYPX 1565 #endif 1566 1567 #if !defined(PETSC_USE_FORTRAN_KERNEL_WAXPY) 1568 #define PETSC_USE_FORTRAN_KERNEL_WAXPY 1569 #endif 1570 1571 #endif 1572 1573 /* 1574 Macros for indicating code that should be compiled with a C interface, 1575 rather than a C++ interface. Any routines that are dynamically loaded 1576 (such as the PCCreate_XXX() routines) must be wrapped so that the name 1577 mangler does not change the functions symbol name. This just hides the 1578 ugly extern "C" {} wrappers. 1579 */ 1580 #if defined(__cplusplus) 1581 #define EXTERN_C_BEGIN extern "C" { 1582 #define EXTERN_C_END } 1583 #else 1584 #define EXTERN_C_BEGIN 1585 #define EXTERN_C_END 1586 #endif 1587 1588 /* --------------------------------------------------------------------*/ 1589 1590 /*MC 1591 size - integer variable used to contain the number of processors in 1592 the relevent MPI_Comm 1593 1594 Level: beginner 1595 1596 .seealso: rank, comm 1597 M*/ 1598 1599 /*MC 1600 rank - integer variable used to contain the number of this processor relative 1601 to all in the relevent MPI_Comm 1602 1603 Level: beginner 1604 1605 .seealso: size, comm 1606 M*/ 1607 1608 /*MC 1609 comm - MPI_Comm used in the current routine or object 1610 1611 Level: beginner 1612 1613 .seealso: size, rank 1614 M*/ 1615 1616 /*MC 1617 MPI_Comm - the basic object used by MPI to determine which processes are involved in a 1618 communication 1619 1620 Level: beginner 1621 1622 Note: This manual page is a place-holder because MPICH does not have a manual page for MPI_Comm 1623 1624 .seealso: size, rank, comm, PETSC_COMM_WORLD, PETSC_COMM_SELF 1625 M*/ 1626 1627 /*MC 1628 PetscScalar - PETSc type that represents either a double precision real number, a double precision 1629 complex number, a single precision real number, a long double or an int - if the code is configured 1630 with --with-scalar-type=real,complex --with-precision=single,double,longdouble,int,matsingle 1631 1632 1633 Level: beginner 1634 1635 .seealso: PetscReal, PassiveReal, PassiveScalar 1636 M*/ 1637 1638 /*MC 1639 PetscReal - PETSc type that represents a real number version of PetscScalar 1640 1641 Level: beginner 1642 1643 .seealso: PetscScalar, PassiveReal, PassiveScalar 1644 M*/ 1645 1646 /*MC 1647 PassiveScalar - PETSc type that represents a PetscScalar 1648 Level: beginner 1649 1650 This is the same as a PetscScalar except in code that is automatically differentiated it is 1651 treated as a constant (not an indendent or dependent variable) 1652 1653 .seealso: PetscReal, PassiveReal, PetscScalar 1654 M*/ 1655 1656 /*MC 1657 PassiveReal - PETSc type that represents a PetscReal 1658 1659 Level: beginner 1660 1661 This is the same as a PetscReal except in code that is automatically differentiated it is 1662 treated as a constant (not an indendent or dependent variable) 1663 1664 .seealso: PetscScalar, PetscReal, PassiveScalar 1665 M*/ 1666 1667 /*MC 1668 MPIU_SCALAR - MPI datatype corresponding to PetscScalar 1669 1670 Level: beginner 1671 1672 Note: In MPI calls that require an MPI datatype that matches a PetscScalar or array of PetscScalars 1673 pass this value 1674 1675 .seealso: PetscReal, PassiveReal, PassiveScalar, PetscScalar 1676 M*/ 1677 1678 /* 1679 The IBM include files define hz, here we hide it so that it may be used 1680 as a regular user variable. 1681 */ 1682 #if defined(hz) 1683 #undef hz 1684 #endif 1685 1686 /* For arrays that contain filenames or paths */ 1687 1688 1689 #if defined(PETSC_HAVE_LIMITS_H) 1690 #include <limits.h> 1691 #endif 1692 #if defined(PETSC_HAVE_SYS_PARAM_H) 1693 #include <sys/param.h> 1694 #endif 1695 #if defined(PETSC_HAVE_SYS_TYPES_H) 1696 #include <sys/types.h> 1697 #endif 1698 #if defined(MAXPATHLEN) 1699 # define PETSC_MAX_PATH_LEN MAXPATHLEN 1700 #elif defined(MAX_PATH) 1701 # define PETSC_MAX_PATH_LEN MAX_PATH 1702 #elif defined(_MAX_PATH) 1703 # define PETSC_MAX_PATH_LEN _MAX_PATH 1704 #else 1705 # define PETSC_MAX_PATH_LEN 4096 1706 #endif 1707 1708 PETSC_EXTERN_CXX_END 1709 #endif 1710 1711 1712