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 /* 34 Currently cannot check formatting for PETSc print statements because we have our 35 own format %D 36 */ 37 #undef PETSC_PRINTF_FORMAT_CHECK 38 #define PETSC_PRINTF_FORMAT_CHECK(a,b) 39 #undef PETSC_FPRINTF_FORMAT_CHECK 40 #define PETSC_FPRINTF_FORMAT_CHECK(a,b) 41 42 /* 43 Fixes for configure time choices which impact our interface. Currently only 44 calling conventions and extra compiler checking falls under this category. 45 */ 46 #if !defined (PETSC_STDCALL) 47 #define PETSC_STDCALL 48 #endif 49 #if !defined (PETSC_TEMPLATE) 50 #define PETSC_TEMPLATE 51 #endif 52 53 /* ========================================================================== */ 54 55 /* 56 Defines the interface to MPI allowing the use of all MPI functions. 57 */ 58 #include "mpi.h" 59 /* 60 Yuck, we need to put stdio.h AFTER mpi.h for MPICH2 with C++ compiler 61 see the top of mpicxx.h 62 63 The MPI STANDARD HAS TO BE CHANGED to prevent this nonsense. 64 */ 65 #include <stdio.h> 66 67 /* 68 All PETSc C functions return this error code, it is the final argument of 69 all Fortran subroutines 70 */ 71 typedef int PetscErrorCode; 72 typedef int PetscCookie; 73 typedef int PetscEvent; 74 typedef int PetscBLASInt; 75 typedef int PetscMPIInt; 76 77 #if defined(PETSC_USE_64BIT_INT) 78 typedef long long PetscInt; 79 #define MPIU_INT MPI_LONG_LONG_INT 80 #else 81 typedef int PetscInt; 82 #define MPIU_INT MPI_INT 83 #endif 84 85 /* 86 Declare extern C stuff after incuding external header files 87 */ 88 89 PETSC_EXTERN_CXX_BEGIN 90 91 /* 92 EXTERN indicates a PETSc function defined elsewhere 93 */ 94 #if !defined(EXTERN) 95 #define EXTERN extern 96 #endif 97 98 /* 99 Defines some elementary mathematics functions and constants. 100 */ 101 #include "petscmath.h" 102 103 /* 104 Basic PETSc constants 105 */ 106 107 /*E 108 PetscTruth - Logical variable. Actually an integer 109 110 Level: beginner 111 112 E*/ 113 typedef enum { PETSC_FALSE,PETSC_TRUE } PetscTruth; 114 115 /*M 116 PETSC_FALSE - False value of PetscTruth 117 118 Level: beginner 119 120 Note: Zero integer 121 122 .seealso: PetscTruth 123 M*/ 124 125 /*M 126 PETSC_TRUE - True value of PetscTruth 127 128 Level: beginner 129 130 Note: Nonzero integer 131 132 .seealso: PetscTruth 133 M*/ 134 135 /*M 136 PETSC_YES - Alias for PETSC_TRUE 137 138 Level: beginner 139 140 Note: Zero integer 141 142 .seealso: PetscTruth 143 M*/ 144 145 /*M 146 PETSC_NO - Alias for PETSC_FALSE 147 148 Level: beginner 149 150 Note: Nonzero integer 151 152 .seealso: PetscTruth 153 M*/ 154 155 /*M 156 PETSC_NULL - standard way of passing in a null or array or pointer 157 158 Level: beginner 159 160 Notes: accepted by many PETSc functions to not set a parameter and instead use 161 some default 162 163 This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER, 164 PETSC_NULL_DOUBLE_PRECISION etc 165 166 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE 167 168 M*/ 169 #define PETSC_NULL 0 170 171 /*M 172 PETSC_DECIDE - standard way of passing in integer or floating point parameter 173 where you wish PETSc to use the default. 174 175 Level: beginner 176 177 .seealso: PETSC_NULL, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE 178 179 M*/ 180 #define PETSC_DECIDE -1 181 182 /*M 183 PETSC_DEFAULT - standard way of passing in integer or floating point parameter 184 where you wish PETSc to use the default. 185 186 Level: beginner 187 188 .seealso: PETSC_DECIDE, PETSC_NULL, PETSC_IGNORE, PETSC_DETERMINE 189 190 M*/ 191 #define PETSC_DEFAULT -2 192 193 #define PETSC_YES PETSC_TRUE 194 #define PETSC_NO PETSC_FALSE 195 196 /*M 197 PETSC_IGNORE - same as PETSC_NULL, means PETSc will ignore this argument 198 199 Level: beginner 200 201 Notes: accepted by many PETSc functions to not set a parameter and instead use 202 some default 203 204 This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER, 205 PETSC_NULL_DOUBLE_PRECISION etc 206 207 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_NULL, PETSC_DETERMINE 208 209 M*/ 210 #define PETSC_IGNORE PETSC_NULL 211 212 /*M 213 PETSC_DETERMINE - standard way of passing in integer or floating point parameter 214 where you wish PETSc to compute the required value. 215 216 Level: beginner 217 218 .seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_NULL, VecSetSizes() 219 220 M*/ 221 #define PETSC_DETERMINE PETSC_DECIDE 222 223 /*M 224 PETSC_COMM_WORLD - a duplicate of the MPI_COMM_WORLD communicator which represents 225 all the processs 226 227 Level: beginner 228 229 Notes: PETSC_COMM_WORLD and MPI_COMM_WORLD are equivalent except that passing MPI_COMM_WORLD 230 into PETSc object constructors will result in using more MPI resources since an MPI_Comm_dup() 231 will be done on it internally. We recommend always using PETSC_COMM_WORLD 232 233 .seealso: PETSC_COMM_SELF 234 235 M*/ 236 extern MPI_Comm PETSC_COMM_WORLD; 237 238 /*M 239 PETSC_COMM_SELF - a duplicate of the MPI_COMM_SELF communicator which represents 240 the current process 241 242 Level: beginner 243 244 Notes: PETSC_COMM_SELF and MPI_COMM_SELF are equivalent except that passint MPI_COMM_SELF 245 into PETSc object constructors will result in using more MPI resources since an MPI_Comm_dup() 246 will be done on it internally. We recommend always using PETSC_COMM_SELF 247 248 .seealso: PETSC_COMM_WORLD 249 250 M*/ 251 extern MPI_Comm PETSC_COMM_SELF; 252 253 extern PetscTruth PetscInitializeCalled; 254 extern PetscTruth PetscFinalizeCalled; 255 EXTERN PetscErrorCode PetscSetCommWorld(MPI_Comm); 256 EXTERN PetscErrorCode PetscSetHelpVersionFunctions(PetscErrorCode (*)(MPI_Comm),PetscErrorCode (*)(MPI_Comm)); 257 EXTERN PetscErrorCode PetscCommDuplicate(MPI_Comm,MPI_Comm*,int*); 258 EXTERN PetscErrorCode PetscCommDestroy(MPI_Comm*); 259 260 /*MC 261 PetscMalloc - Allocates memory 262 263 Input Parameter: 264 . m - number of bytes to allocate 265 266 Output Parameter: 267 . result - memory allocated 268 269 Synopsis: 270 PetscErrorCode PetscMalloc(size_t m,void **result) 271 272 Level: beginner 273 274 Notes: Memory is always allocated at least double aligned 275 276 If you request memory of zero size it will allocate no space and assign the pointer to 0; PetscFree() will 277 properly handle not freeing the null pointer. 278 279 .seealso: PetscFree(), PetscNew() 280 281 Concepts: memory allocation 282 283 M*/ 284 #define PetscMalloc(a,b) ((a != 0) ? (*PetscTrMalloc)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__,(void**)(b)) : (*(b) = 0,0) ) 285 286 /*MC 287 PetscMalloc2 - Allocates 2 chunks of memory 288 289 Input Parameter: 290 + m1 - number of elements to allocate in 1st chunk (may be zero) 291 . t1 - type of first memory elements 292 . m2 - number of elements to allocate in 2nd chunk (may be zero) 293 - t2 - type of second memory elements 294 295 Output Parameter: 296 + r1 - memory allocated in first chunk 297 - r2 - memory allocated in second chunk 298 299 Synopsis: 300 PetscErrorCode PetscMalloc2(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2) 301 302 Level: developer 303 304 Notes: Memory of first chunk is always allocated at least double aligned 305 306 .seealso: PetscFree(), PetscNew(), PetscMalloc() 307 308 Concepts: memory allocation 309 310 M*/ 311 #if defined(PETSC_USE_DEBUG) 312 #define PetscMalloc2(m1,t1,r1,m2,t2,r2) (PetscMalloc((m1)*sizeof(t1),r1) || PetscMalloc((m2)*sizeof(t2),r2)) 313 #else 314 #define PetscMalloc2(m1,t1,r1,m2,t2,r2) (PetscMalloc((m1)*sizeof(t1)+(m2)*sizeof(t2),r1) || (*(r2) = (t2*)(*(r1)+m1),0)) 315 #endif 316 317 /*MC 318 PetscMalloc3 - Allocates 3 chunks of memory 319 320 Input Parameter: 321 + m1 - number of elements to allocate in 1st chunk (may be zero) 322 . t1 - type of first memory elements 323 . m2 - number of elements to allocate in 2nd chunk (may be zero) 324 . t2 - type of second memory elements 325 . m3 - number of elements to allocate in 3rd chunk (may be zero) 326 - t3 - type of third memory elements 327 328 Output Parameter: 329 + r1 - memory allocated in first chunk 330 . r2 - memory allocated in second chunk 331 - r3 - memory allocated in third chunk 332 333 Synopsis: 334 PetscErrorCode PetscMalloc3(size_t m1,type, t1,void **r1,size_t m2,type t2,void **r2,size_t m3,type t3,void **r3) 335 336 Level: developer 337 338 Notes: Memory of first chunk is always allocated at least double aligned 339 340 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3() 341 342 Concepts: memory allocation 343 344 M*/ 345 #if defined(PETSC_USE_DEBUG) 346 #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)) 347 #else 348 #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)) 349 #endif 350 351 /*MC 352 PetscMalloc4 - Allocates 4 chunks of memory 353 354 Input Parameter: 355 + m1 - number of elements to allocate in 1st chunk (may be zero) 356 . t1 - type of first memory elements 357 . m2 - number of elements to allocate in 2nd chunk (may be zero) 358 . t2 - type of second memory elements 359 . m3 - number of elements to allocate in 3rd chunk (may be zero) 360 . t3 - type of third memory elements 361 . m4 - number of elements to allocate in 4th chunk (may be zero) 362 - t4 - type of fourth memory elements 363 364 Output Parameter: 365 + r1 - memory allocated in first chunk 366 . r2 - memory allocated in second chunk 367 . r3 - memory allocated in third chunk 368 - r4 - memory allocated in fourth chunk 369 370 Synopsis: 371 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) 372 373 Level: developer 374 375 Notes: Memory of first chunk is always allocated at least double aligned 376 377 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4() 378 379 Concepts: memory allocation 380 381 M*/ 382 #if defined(PETSC_USE_DEBUG) 383 #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)) 384 #else 385 #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)) 386 #endif 387 388 /*MC 389 PetscMalloc5 - Allocates 5 chunks of memory 390 391 Input Parameter: 392 + m1 - number of elements to allocate in 1st chunk (may be zero) 393 . t1 - type of first memory elements 394 . m2 - number of elements to allocate in 2nd chunk (may be zero) 395 . t2 - type of second memory elements 396 . m3 - number of elements to allocate in 3rd chunk (may be zero) 397 . t3 - type of third memory elements 398 . m4 - number of elements to allocate in 4th chunk (may be zero) 399 . t4 - type of fourth memory elements 400 . m5 - number of elements to allocate in 5th chunk (may be zero) 401 - t5 - type of fifth memory elements 402 403 Output Parameter: 404 + r1 - memory allocated in first chunk 405 . r2 - memory allocated in second chunk 406 . r3 - memory allocated in third chunk 407 . r4 - memory allocated in fourth chunk 408 - r5 - memory allocated in fifth chunk 409 410 Synopsis: 411 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) 412 413 Level: developer 414 415 Notes: Memory of first chunk is always allocated at least double aligned 416 417 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5() 418 419 Concepts: memory allocation 420 421 M*/ 422 #if defined(PETSC_USE_DEBUG) 423 #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)) 424 #else 425 #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)) 426 #endif 427 428 429 /*MC 430 PetscMalloc6 - Allocates 6 chunks of memory 431 432 Input Parameter: 433 + m1 - number of elements to allocate in 1st chunk (may be zero) 434 . t1 - type of first memory elements 435 . m2 - number of elements to allocate in 2nd chunk (may be zero) 436 . t2 - type of second memory elements 437 . m3 - number of elements to allocate in 3rd chunk (may be zero) 438 . t3 - type of third memory elements 439 . m4 - number of elements to allocate in 4th chunk (may be zero) 440 . t4 - type of fourth memory elements 441 . m5 - number of elements to allocate in 5th chunk (may be zero) 442 . t5 - type of fifth memory elements 443 . m6 - number of elements to allocate in 6th chunk (may be zero) 444 - t6 - type of sixth memory elements 445 446 Output Parameter: 447 + r1 - memory allocated in first chunk 448 . r2 - memory allocated in second chunk 449 . r3 - memory allocated in third chunk 450 . r4 - memory allocated in fourth chunk 451 . r5 - memory allocated in fifth chunk 452 - r6 - memory allocated in sixth chunk 453 454 Synopsis: 455 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) 456 457 Level: developer 458 459 Notes: Memory of first chunk is always allocated at least double aligned 460 461 .seealso: PetscFree(), PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree3(), PetscFree4(), PetscFree5(), PetscFree6() 462 463 Concepts: memory allocation 464 465 M*/ 466 #if defined(PETSC_USE_DEBUG) 467 #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)) 468 #else 469 #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)) 470 #endif 471 472 /*MC 473 PetscNew - Allocates memory of a particular type, Zeros the memory! 474 475 Input Parameter: 476 . type - structure name of space to be allocated. Memory of size sizeof(type) is allocated 477 478 Output Parameter: 479 . result - memory allocated 480 481 Synopsis: 482 PetscErrorCode PetscNew(struct type,((type *))result) 483 484 Level: beginner 485 486 .seealso: PetscFree(), PetscMalloc() 487 488 Concepts: memory allocation 489 490 M*/ 491 #define PetscNew(A,b) (PetscMalloc(sizeof(A),(b)) || PetscMemzero(*(b),sizeof(A))) 492 493 /*MC 494 PetscFree - Frees memory 495 496 Input Parameter: 497 . memory - memory to free 498 499 Synopsis: 500 PetscErrorCode PetscFree(void *memory) 501 502 Level: beginner 503 504 Notes: Memory must have been obtained with PetscNew() or PetscMalloc() 505 506 .seealso: PetscNew(), PetscMalloc() 507 508 Concepts: memory allocation 509 510 M*/ 511 #define PetscFree(a) ((a) ? ((*PetscTrFree)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__) || ((a = 0),0)) : 0) 512 513 /*MC 514 PetscFree2 - Frees 2 chunks of memory obtained with PetscMalloc2() 515 516 Input Parameter: 517 + memory1 - memory to free 518 - memory2 - 2nd memory to free 519 520 521 Synopsis: 522 PetscErrorCode PetscFree2(void *memory1,void *memory2) 523 524 Level: developer 525 526 Notes: Memory must have been obtained with PetscMalloc2() 527 528 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree() 529 530 Concepts: memory allocation 531 532 M*/ 533 #if defined(PETSC_USE_DEBUG) 534 #define PetscFree2(m1,m2) (PetscFree(m2) || PetscFree(m1)) 535 #else 536 #define PetscFree2(m1,m2) (PetscFree(m1)) 537 #endif 538 539 /*MC 540 PetscFree3 - Frees 3 chunks of memory obtained with PetscMalloc3() 541 542 Input Parameter: 543 + memory1 - memory to free 544 . memory2 - 2nd memory to free 545 - memory3 - 3rd memory to free 546 547 548 Synopsis: 549 PetscErrorCode PetscFree3(void *memory1,void *memory2,void *memory3) 550 551 Level: developer 552 553 Notes: Memory must have been obtained with PetscMalloc3() 554 555 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3() 556 557 Concepts: memory allocation 558 559 M*/ 560 #if defined(PETSC_USE_DEBUG) 561 #define PetscFree3(m1,m2,m3) (PetscFree(m3) || PetscFree(m2) || PetscFree(m1)) 562 #else 563 #define PetscFree3(m1,m2,m3) (PetscFree(m1)) 564 #endif 565 566 /*MC 567 PetscFree4 - Frees 4 chunks of memory obtained with PetscMalloc4() 568 569 Input Parameter: 570 + m1 - memory to free 571 . m2 - 2nd memory to free 572 . m3 - 3rd memory to free 573 - m4 - 4th memory to free 574 575 576 Synopsis: 577 PetscErrorCode PetscFree4(void *m1,void *m2,void *m3,void *m4) 578 579 Level: developer 580 581 Notes: Memory must have been obtained with PetscMalloc4() 582 583 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4() 584 585 Concepts: memory allocation 586 587 M*/ 588 #if defined(PETSC_USE_DEBUG) 589 #define PetscFree4(m1,m2,m3,m4) (PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1)) 590 #else 591 #define PetscFree4(m1,m2,m3,m4) (PetscFree(m1)) 592 #endif 593 594 /*MC 595 PetscFree5 - Frees 5 chunks of memory obtained with PetscMalloc5() 596 597 Input Parameter: 598 + m1 - memory to free 599 . m2 - 2nd memory to free 600 . m3 - 3rd memory to free 601 . m4 - 4th memory to free 602 - m5 - 5th memory to free 603 604 605 Synopsis: 606 PetscErrorCode PetscFree5(void *m1,void *m2,void *m3,void *m4,void *m5) 607 608 Level: developer 609 610 Notes: Memory must have been obtained with PetscMalloc5() 611 612 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5() 613 614 Concepts: memory allocation 615 616 M*/ 617 #if defined(PETSC_USE_DEBUG) 618 #define PetscFree5(m1,m2,m3,m4,m5) (PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1)) 619 #else 620 #define PetscFree5(m1,m2,m3,m4,m5) (PetscFree(m1)) 621 #endif 622 623 624 /*MC 625 PetscFree6 - Frees 6 chunks of memory obtained with PetscMalloc6() 626 627 Input Parameter: 628 + m1 - memory to free 629 . m2 - 2nd memory to free 630 . m3 - 3rd memory to free 631 . m4 - 4th memory to free 632 . m5 - 5th memory to free 633 - m6 - 6th memory to free 634 635 636 Synopsis: 637 PetscErrorCode PetscFree6(void *m1,void *m2,void *m3,void *m4,void *m5,void *m6) 638 639 Level: developer 640 641 Notes: Memory must have been obtained with PetscMalloc6() 642 643 .seealso: PetscNew(), PetscMalloc(), PetscMalloc2(), PetscFree(), PetscMalloc3(), PetscMalloc4(), PetscMalloc5(), PetscMalloc6() 644 645 Concepts: memory allocation 646 647 M*/ 648 #if defined(PETSC_USE_DEBUG) 649 #define PetscFree6(m1,m2,m3,m4,m5,m6) (PetscFree(m6) || PetscFree(m5) || PetscFree(m4) || PetscFree(m3) || PetscFree(m2) || PetscFree(m1)) 650 #else 651 #define PetscFree6(m1,m2,m3,m4,m5,m6) (PetscFree(m1)) 652 #endif 653 654 EXTERN PetscErrorCode (*PetscTrMalloc)(size_t,int,const char[],const char[],const char[],void**); 655 EXTERN PetscErrorCode (*PetscTrFree)(void*,int,const char[],const char[],const char[]); 656 EXTERN PetscErrorCode PetscSetMalloc(PetscErrorCode (*)(size_t,int,const char[],const char[],const char[],void**),PetscErrorCode (*)(void*,int,const char[],const char[],const char[])); 657 EXTERN PetscErrorCode PetscClearMalloc(void); 658 659 /* 660 Routines for tracing memory corruption/bleeding with default PETSc 661 memory allocation 662 */ 663 EXTERN PetscErrorCode PetscTrDump(FILE *); 664 EXTERN PetscErrorCode PetscTrSpace(PetscLogDouble *,PetscLogDouble *,PetscLogDouble *); 665 EXTERN PetscErrorCode PetscTrValid(int,const char[],const char[],const char[]); 666 EXTERN PetscErrorCode PetscTrDebug(PetscTruth); 667 EXTERN PetscErrorCode PetscTrLog(void); 668 EXTERN PetscErrorCode PetscTrLogDump(FILE *); 669 EXTERN PetscErrorCode PetscGetResidentSetSize(PetscLogDouble *); 670 671 /* 672 Variable type where we stash PETSc object pointers in Fortran. 673 Assumes that sizeof(long) == sizeof(void*)which is true on 674 all machines that we know. 675 */ 676 #define PetscFortranAddr long 677 678 /*E 679 PetscDataType - Used for handling different basic data types. 680 681 Level: beginner 682 683 .seealso: PetscBinaryRead(), PetscBinaryWrite(), PetscDataTypeToMPIDataType(), 684 PetscDataTypeGetSize(), PetscDataTypeGetName() 685 686 E*/ 687 typedef enum {PETSC_INT = 0,PETSC_DOUBLE = 1,PETSC_COMPLEX = 2, 688 PETSC_LONG = 3 ,PETSC_SHORT = 4,PETSC_FLOAT = 5, 689 PETSC_CHAR = 6,PETSC_LOGICAL = 7} PetscDataType; 690 #if defined(PETSC_USE_COMPLEX) 691 #define PETSC_SCALAR PETSC_COMPLEX 692 #else 693 #if defined(PETSC_USE_SINGLE) 694 #define PETSC_SCALAR PETSC_FLOAT 695 #else 696 #define PETSC_SCALAR PETSC_DOUBLE 697 #endif 698 #endif 699 #if defined(PETSC_USE_SINGLE) 700 #define PETSC_REAL PETSC_FLOAT 701 #else 702 #define PETSC_REAL PETSC_DOUBLE 703 #endif 704 #define PETSC_FORTRANADDR PETSC_LONG 705 706 EXTERN PetscErrorCode PetscDataTypeToMPIDataType(PetscDataType,MPI_Datatype*); 707 EXTERN PetscErrorCode PetscDataTypeGetSize(PetscDataType,PetscInt*); 708 EXTERN PetscErrorCode PetscDataTypeGetName(PetscDataType,const char*[]); 709 710 /* 711 Basic memory and string operations. These are usually simple wrappers 712 around the basic Unix system calls, but a few of them have additional 713 functionality and/or error checking. 714 */ 715 EXTERN PetscErrorCode PetscMemcpy(void*,const void *,size_t); 716 EXTERN PetscErrorCode PetscBitMemcpy(void*,PetscInt,const void*,PetscInt,PetscInt,PetscDataType); 717 EXTERN PetscErrorCode PetscMemmove(void*,void *,size_t); 718 EXTERN PetscErrorCode PetscMemzero(void*,size_t); 719 EXTERN PetscErrorCode PetscMemcmp(const void*,const void*,size_t,PetscTruth *); 720 EXTERN PetscErrorCode PetscStrlen(const char[],size_t*); 721 EXTERN PetscErrorCode PetscStrcmp(const char[],const char[],PetscTruth *); 722 EXTERN PetscErrorCode PetscStrgrt(const char[],const char[],PetscTruth *); 723 EXTERN PetscErrorCode PetscStrcasecmp(const char[],const char[],PetscTruth*); 724 EXTERN PetscErrorCode PetscStrncmp(const char[],const char[],size_t,PetscTruth*); 725 EXTERN PetscErrorCode PetscStrcpy(char[],const char[]); 726 EXTERN PetscErrorCode PetscStrcat(char[],const char[]); 727 EXTERN PetscErrorCode PetscStrncat(char[],const char[],size_t); 728 EXTERN PetscErrorCode PetscStrncpy(char[],const char[],size_t); 729 EXTERN PetscErrorCode PetscStrchr(const char[],char,char *[]); 730 EXTERN PetscErrorCode PetscStrtolower(char[]); 731 EXTERN PetscErrorCode PetscStrrchr(const char[],char,char *[]); 732 EXTERN PetscErrorCode PetscStrstr(const char[],const char[],char *[]); 733 EXTERN PetscErrorCode PetscStrallocpy(const char[],char *[]); 734 EXTERN PetscErrorCode PetscStrreplace(MPI_Comm,const char[],char[],size_t); 735 #define PetscStrfree(a) ((a) ? PetscFree(a) : 0) 736 /*S 737 PetscToken - 'Token' used for managing tokenizing strings 738 739 Level: intermediate 740 741 .seealso: PetscTokenCreate(), PetscTokenFind(), PetscTokenDestroy() 742 S*/ 743 typedef struct {char token;char *array;char *current;} PetscToken; 744 745 EXTERN PetscErrorCode PetscTokenCreate(const char[],const char,PetscToken**); 746 EXTERN PetscErrorCode PetscTokenFind(PetscToken*,char *[]); 747 EXTERN PetscErrorCode PetscTokenDestroy(PetscToken*); 748 749 /* 750 These are MPI operations for MPI_Allreduce() etc 751 */ 752 EXTERN MPI_Op PetscMaxSum_Op; 753 #if defined(PETSC_USE_COMPLEX) 754 EXTERN MPI_Op PetscSum_Op; 755 #else 756 #define PetscSum_Op MPI_SUM 757 #endif 758 EXTERN PetscErrorCode PetscMaxSum(MPI_Comm,const PetscInt[],PetscInt*,PetscInt*); 759 760 /*S 761 PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc 762 763 Level: beginner 764 765 Note: This is the base class from which all objects appear. 766 767 .seealso: PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName() 768 S*/ 769 typedef struct _p_PetscObject* PetscObject; 770 771 /*S 772 PetscFList - Linked list of functions, possibly stored in dynamic libraries, accessed 773 by string name 774 775 Level: advanced 776 777 .seealso: PetscFListAdd(), PetscFListDestroy() 778 S*/ 779 typedef struct _PetscFList *PetscFList; 780 781 #include "petscviewer.h" 782 #include "petscoptions.h" 783 784 EXTERN PetscErrorCode PetscLogInfoAllow(PetscTruth,const char []); 785 EXTERN PetscErrorCode PetscShowMemoryUsage(PetscViewer,const char[]); 786 EXTERN PetscErrorCode PetscGetTime(PetscLogDouble*); 787 EXTERN PetscErrorCode PetscGetCPUTime(PetscLogDouble*); 788 EXTERN PetscErrorCode PetscSleep(int); 789 790 /* 791 Initialization of PETSc 792 */ 793 EXTERN PetscErrorCode PetscInitialize(int*,char***,const char[],const char[]); 794 EXTERN PetscErrorCode PetscInitializeNoArguments(void); 795 EXTERN PetscErrorCode PetscInitialized(PetscTruth *); 796 EXTERN PetscErrorCode PetscFinalized(PetscTruth *); 797 EXTERN PetscErrorCode PetscFinalize(void); 798 EXTERN PetscErrorCode PetscInitializeFortran(void); 799 EXTERN PetscErrorCode PetscGetArgs(int*,char ***); 800 EXTERN PetscErrorCode PetscEnd(void); 801 802 typedef void (**PetscVoidFunction)(void); 803 804 /* 805 PetscTryMethod - Queries an object for a method, if it exists then calls it. 806 These are intended to be used only inside PETSc functions. 807 */ 808 #define PetscTryMethod(obj,A,B,C) \ 809 0;{ PetscErrorCode (*f)B, __ierr; \ 810 __ierr = PetscObjectQueryFunction((PetscObject)obj,#A,(PetscVoidFunction)&f);CHKERRQ(__ierr); \ 811 if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\ 812 } 813 #define PetscUseMethod(obj,A,B,C) \ 814 0;{ PetscErrorCode (*f)B, __ierr; \ 815 __ierr = PetscObjectQueryFunction((PetscObject)obj,A,(PetscVoidFunction)&f);CHKERRQ(__ierr); \ 816 if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\ 817 else {SETERRQ1(PETSC_ERR_SUP,"Cannot locate function %s in object",A);} \ 818 } 819 /* 820 Functions that can act on any PETSc object. 821 */ 822 EXTERN PetscErrorCode PetscObjectDestroy(PetscObject); 823 EXTERN PetscErrorCode PetscObjectExists(PetscObject,PetscTruth*); 824 EXTERN PetscErrorCode PetscObjectGetComm(PetscObject,MPI_Comm *); 825 EXTERN PetscErrorCode PetscObjectGetCookie(PetscObject,int *); 826 EXTERN PetscErrorCode PetscObjectGetType(PetscObject,int *); 827 EXTERN PetscErrorCode PetscObjectSetName(PetscObject,const char[]); 828 EXTERN PetscErrorCode PetscObjectGetName(PetscObject,char*[]); 829 EXTERN PetscErrorCode PetscObjectReference(PetscObject); 830 EXTERN PetscErrorCode PetscObjectGetReference(PetscObject,PetscInt*); 831 EXTERN PetscErrorCode PetscObjectDereference(PetscObject); 832 EXTERN PetscErrorCode PetscObjectGetNewTag(PetscObject,PetscMPIInt *); 833 EXTERN PetscErrorCode PetscCommGetNewTag(MPI_Comm,PetscMPIInt *); 834 EXTERN PetscErrorCode PetscObjectView(PetscObject,PetscViewer); 835 EXTERN PetscErrorCode PetscObjectCompose(PetscObject,const char[],PetscObject); 836 EXTERN PetscErrorCode PetscObjectQuery(PetscObject,const char[],PetscObject *); 837 EXTERN PetscErrorCode PetscObjectComposeFunction(PetscObject,const char[],const char[],void (*)(void)); 838 839 typedef void (*FCNVOID)(void); /* cast in next macro should never be extern C */ 840 typedef PetscErrorCode (*FCNINTVOID)(void); /* used in casts to make sure they are not extern C */ 841 /*MC 842 PetscObjectComposeFunctionDynamic - Associates a function with a given PETSc object. 843 844 Collective on PetscObject 845 846 Input Parameters: 847 + obj - the PETSc object; this must be cast with a (PetscObject), for example, 848 PetscObjectCompose((PetscObject)mat,...); 849 . name - name associated with the child function 850 . fname - name of the function 851 - ptr - function pointer (or PETSC_NULL if using dynamic libraries) 852 853 Level: advanced 854 855 Synopsis: 856 PetscErrorCode PetscObjectComposeFunctionDynamic(PetscObject obj,const char name[],const char fname[],void *ptr) 857 858 Notes: 859 To remove a registered routine, pass in a PETSC_NULL rname and fnc(). 860 861 PetscObjectComposeFunctionDynamic() can be used with any PETSc object (such as 862 Mat, Vec, KSP, SNES, etc.) or any user-provided object. 863 864 The composed function must be wrapped in a EXTERN_C_BEGIN/END for this to 865 work in C++/complex with dynamic link libraries (PETSC_USE_DYNAMIC_LIBRARIES) 866 enabled. 867 868 Concepts: objects^composing functions 869 Concepts: composing functions 870 Concepts: functions^querying 871 Concepts: objects^querying 872 Concepts: querying objects 873 874 .seealso: PetscObjectQueryFunction() 875 M*/ 876 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 877 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,0) 878 #else 879 #define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,(FCNVOID)(d)) 880 #endif 881 882 EXTERN PetscErrorCode PetscObjectQueryFunction(PetscObject,const char[],void (**)(void)); 883 EXTERN PetscErrorCode PetscObjectSetOptionsPrefix(PetscObject,const char[]); 884 EXTERN PetscErrorCode PetscObjectAppendOptionsPrefix(PetscObject,const char[]); 885 EXTERN PetscErrorCode PetscObjectPrependOptionsPrefix(PetscObject,const char[]); 886 EXTERN PetscErrorCode PetscObjectGetOptionsPrefix(PetscObject,char*[]); 887 EXTERN PetscErrorCode PetscObjectPublish(PetscObject); 888 EXTERN PetscErrorCode PetscObjectChangeTypeName(PetscObject,const char[]); 889 EXTERN PetscErrorCode PetscObjectRegisterDestroy(PetscObject); 890 EXTERN PetscErrorCode PetscObjectRegisterDestroyAll(void); 891 EXTERN PetscErrorCode PetscObjectName(PetscObject); 892 EXTERN PetscErrorCode PetscTypeCompare(PetscObject,const char[],PetscTruth*); 893 894 /* 895 Defines PETSc error handling. 896 */ 897 #include "petscerror.h" 898 899 /*S 900 PetscOList - Linked list of PETSc objects, accessable by string name 901 902 Level: advanced 903 904 .seealso: PetscOListAdd(), PetscOListDestroy(), PetscOListFind() 905 S*/ 906 typedef struct _PetscOList *PetscOList; 907 908 EXTERN PetscErrorCode PetscOListDestroy(PetscOList *); 909 EXTERN PetscErrorCode PetscOListFind(PetscOList,const char[],PetscObject*); 910 EXTERN PetscErrorCode PetscOListReverseFind(PetscOList,PetscObject,char**); 911 EXTERN PetscErrorCode PetscOListAdd(PetscOList *,const char[],PetscObject); 912 EXTERN PetscErrorCode PetscOListDuplicate(PetscOList,PetscOList *); 913 914 /* 915 Dynamic library lists. Lists of names of routines in dynamic 916 link libraries that will be loaded as needed. 917 */ 918 EXTERN PetscErrorCode PetscFListAdd(PetscFList*,const char[],const char[],void (*)(void)); 919 EXTERN PetscErrorCode PetscFListDestroy(PetscFList*); 920 EXTERN PetscErrorCode PetscFListFind(MPI_Comm,PetscFList,const char[],void (**)(void)); 921 EXTERN PetscErrorCode PetscFListPrintTypes(MPI_Comm,FILE*,const char[],const char[],const char[],const char[],PetscFList); 922 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 923 #define PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,0) 924 #else 925 #define PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,(void (*)(void))c) 926 #endif 927 EXTERN PetscErrorCode PetscFListDuplicate(PetscFList,PetscFList *); 928 EXTERN PetscErrorCode PetscFListView(PetscFList,PetscViewer); 929 EXTERN PetscErrorCode PetscFListConcat(const char [],const char [],char []); 930 EXTERN PetscErrorCode PetscFListGet(PetscFList,char ***,int*); 931 932 /*S 933 PetscDLLibraryList - Linked list of dynamics libraries to search for functions 934 935 Level: advanced 936 937 PETSC_USE_DYNAMIC_LIBRARIES must be defined in petscconf.h to use dynamic libraries 938 939 .seealso: PetscDLLibraryOpen() 940 S*/ 941 typedef struct _PetscDLLibraryList *PetscDLLibraryList; 942 extern PetscDLLibraryList DLLibrariesLoaded; 943 EXTERN PetscErrorCode PetscDLLibraryRetrieve(MPI_Comm,const char[],char *,int,PetscTruth *); 944 EXTERN PetscErrorCode PetscDLLibraryOpen(MPI_Comm,const char[],void **); 945 EXTERN PetscErrorCode PetscDLLibrarySym(MPI_Comm,PetscDLLibraryList *,const char[],const char[],void **); 946 EXTERN PetscErrorCode PetscDLLibraryAppend(MPI_Comm,PetscDLLibraryList *,const char[]); 947 EXTERN PetscErrorCode PetscDLLibraryPrepend(MPI_Comm,PetscDLLibraryList *,const char[]); 948 EXTERN PetscErrorCode PetscDLLibraryClose(PetscDLLibraryList); 949 EXTERN PetscErrorCode PetscDLLibraryPrintPath(void); 950 EXTERN PetscErrorCode PetscDLLibraryGetInfo(void*,const char[],const char *[]); 951 952 /* 953 Mechanism for translating PETSc object representations between languages 954 Not currently used. 955 */ 956 typedef enum {PETSC_LANGUAGE_C,PETSC_LANGUAGE_CXX} PetscLanguage; 957 #define PETSC_LANGUAGE_F77 PETSC_LANGUAGE_C 958 EXTERN PetscErrorCode PetscObjectComposeLanguage(PetscObject,PetscLanguage,void *); 959 EXTERN PetscErrorCode PetscObjectQueryLanguage(PetscObject,PetscLanguage,void **); 960 961 /* 962 Useful utility routines 963 */ 964 EXTERN PetscErrorCode PetscSplitOwnership(MPI_Comm,PetscInt*,PetscInt*); 965 EXTERN PetscErrorCode PetscSplitOwnershipBlock(MPI_Comm,PetscInt,PetscInt*,PetscInt*); 966 EXTERN PetscErrorCode PetscSequentialPhaseBegin(MPI_Comm,PetscMPIInt); 967 EXTERN PetscErrorCode PetscSequentialPhaseEnd(MPI_Comm,PetscMPIInt); 968 EXTERN PetscErrorCode PetscBarrier(PetscObject); 969 EXTERN PetscErrorCode PetscMPIDump(FILE*); 970 971 #define PetscNot(a) ((a) ? PETSC_FALSE : PETSC_TRUE) 972 /* 973 Defines basic graphics available from PETSc. 974 */ 975 #include "petscdraw.h" 976 977 /* 978 Defines the base data structures for all PETSc objects 979 */ 980 #include "petschead.h" 981 982 /* 983 Defines PETSc profiling. 984 */ 985 #include "petsclog.h" 986 987 /* 988 For locking, unlocking and destroying AMS memories associated with 989 PETSc objects. Not currently used. 990 */ 991 #define PetscPublishAll(v) 0 992 #define PetscObjectTakeAccess(obj) 0 993 #define PetscObjectGrantAccess(obj) 0 994 #define PetscObjectDepublish(obj) 0 995 996 997 998 /* 999 This code allows one to pass a MPI communicator between 1000 C and Fortran. MPI 2.0 defines a standard API for doing this. 1001 The code here is provided to allow PETSc to work with MPI 1.1 1002 standard MPI libraries. 1003 */ 1004 EXTERN PetscErrorCode MPICCommToFortranComm(MPI_Comm,int *); 1005 EXTERN PetscErrorCode MPIFortranCommToCComm(int,MPI_Comm*); 1006 1007 /* 1008 Simple PETSc parallel IO for ASCII printing 1009 */ 1010 EXTERN PetscErrorCode PetscFixFilename(const char[],char[]); 1011 EXTERN PetscErrorCode PetscFOpen(MPI_Comm,const char[],const char[],FILE**); 1012 EXTERN PetscErrorCode PetscFClose(MPI_Comm,FILE*); 1013 EXTERN PetscErrorCode PetscFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4); 1014 EXTERN PetscErrorCode PetscPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 1015 1016 /* These are used internally by PETSc ASCII IO routines*/ 1017 #include <stdarg.h> 1018 EXTERN PetscErrorCode PetscVSNPrintf(char*,size_t,const char*,va_list); 1019 EXTERN PetscErrorCode PetscVFPrintf(FILE*,const char*,va_list); 1020 1021 /*MC 1022 PetscErrorPrintf - Prints error messages. 1023 1024 Not Collective 1025 1026 Synopsis: 1027 PetscErrorCode (*PetscErrorPrintf)(const char format[],...); 1028 1029 Input Parameters: 1030 . format - the usual printf() format string 1031 1032 Options Database Keys: 1033 . -error_output_stderr - cause error messages to be printed to stderr instead of the 1034 (default) stdout 1035 1036 1037 Level: developer 1038 1039 Fortran Note: 1040 This routine is not supported in Fortran. 1041 1042 Concepts: error messages^printing 1043 Concepts: printing^error messages 1044 1045 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscHelpPrintf() 1046 M*/ 1047 EXTERN PetscErrorCode (*PetscErrorPrintf)(const char[],...); 1048 1049 /*MC 1050 PetscHelpPrintf - Prints help messages. 1051 1052 Not Collective 1053 1054 Synopsis: 1055 PetscErrorCode (*PetscHelpPrintf)(const char format[],...); 1056 1057 Input Parameters: 1058 . format - the usual printf() format string 1059 1060 Level: developer 1061 1062 Fortran Note: 1063 This routine is not supported in Fortran. 1064 1065 Concepts: help messages^printing 1066 Concepts: printing^help messages 1067 1068 .seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscErrorPrintf() 1069 M*/ 1070 EXTERN PetscErrorCode (*PetscHelpPrintf)(MPI_Comm,const char[],...); 1071 1072 EXTERN PetscErrorCode PetscPOpen(MPI_Comm,const char[],const char[],const char[],FILE **); 1073 EXTERN PetscErrorCode PetscPClose(MPI_Comm,FILE*); 1074 EXTERN PetscErrorCode PetscSynchronizedPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3); 1075 EXTERN PetscErrorCode PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4); 1076 EXTERN PetscErrorCode PetscSynchronizedFlush(MPI_Comm); 1077 EXTERN PetscErrorCode PetscSynchronizedFGets(MPI_Comm,FILE*,size_t,char[]); 1078 EXTERN PetscErrorCode PetscStartMatlab(MPI_Comm,const char[],const char[],FILE**); 1079 EXTERN PetscErrorCode PetscStartJava(MPI_Comm,const char[],const char[],FILE**); 1080 EXTERN PetscErrorCode PetscGetPetscDir(const char*[]); 1081 1082 EXTERN PetscErrorCode PetscPopUpSelect(MPI_Comm,char*,char*,int,char**,int*); 1083 /*S 1084 PetscObjectContainer - Simple PETSc object that contains a pointer to any required data 1085 1086 Level: advanced 1087 1088 .seealso: PetscObject, PetscObjectContainerCreate() 1089 S*/ 1090 typedef struct _p_PetscObjectContainer* PetscObjectContainer; 1091 EXTERN PetscErrorCode PetscObjectContainerGetPointer(PetscObjectContainer,void **); 1092 EXTERN PetscErrorCode PetscObjectContainerSetPointer(PetscObjectContainer,void *); 1093 EXTERN PetscErrorCode PetscObjectContainerDestroy(PetscObjectContainer); 1094 EXTERN PetscErrorCode PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *); 1095 EXTERN PetscErrorCode PetscObjectContainerSetUserDestroy(PetscObjectContainer, PetscErrorCode (*)(void*)); 1096 1097 /* 1098 For incremental debugging 1099 */ 1100 extern PetscTruth PetscCompare; 1101 EXTERN PetscErrorCode PetscCompareDouble(double); 1102 EXTERN PetscErrorCode PetscCompareScalar(PetscScalar); 1103 EXTERN PetscErrorCode PetscCompareInt(PetscInt); 1104 1105 /* 1106 For use in debuggers 1107 */ 1108 extern int PetscGlobalRank,PetscGlobalSize; 1109 EXTERN PetscErrorCode PetscIntView(PetscInt,PetscInt[],PetscViewer); 1110 EXTERN PetscErrorCode PetscRealView(PetscInt,PetscReal[],PetscViewer); 1111 EXTERN PetscErrorCode PetscScalarView(PetscInt,PetscScalar[],PetscViewer); 1112 1113 /* 1114 Allows accessing Matlab Engine 1115 */ 1116 #include "petscmatlab.h" 1117 1118 /* 1119 C code optimization is often enhanced by telling the compiler 1120 that certain pointer arguments to functions are not aliased to 1121 to other arguments. This is not yet ANSI C standard so we define 1122 the macro "restrict" to indicate that the variable is not aliased 1123 to any other argument. 1124 */ 1125 #if defined(PETSC_HAVE_RESTRICT) && !defined(__cplusplus) 1126 #define restrict _Restrict 1127 #else 1128 #if defined(restrict) 1129 #undef restrict 1130 #endif 1131 #define restrict 1132 #endif 1133 1134 /* 1135 Determine if some of the kernel computation routines use 1136 Fortran (rather than C) for the numerical calculations. On some machines 1137 and compilers (like complex numbers) the Fortran version of the routines 1138 is faster than the C/C++ versions. The flag PETSC_USE_FORTRAN_KERNELS 1139 would be set in the petscconf.h file 1140 */ 1141 #if defined(PETSC_USE_FORTRAN_KERNELS) 1142 1143 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTAIJ) 1144 #define PETSC_USE_FORTRAN_KERNEL_MULTAIJ 1145 #endif 1146 1147 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ) 1148 #define PETSC_USE_FORTRAN_KERNEL_MULTTRANSPOSEAIJ 1149 #endif 1150 1151 #if !defined(PETSC_USE_FORTRAN_KERNEL_NORM) 1152 #define PETSC_USE_FORTRAN_KERNEL_NORM 1153 #endif 1154 1155 #if !defined(PETSC_USE_FORTRAN_KERNEL_MAXPY) 1156 #define PETSC_USE_FORTRAN_KERNEL_MAXPY 1157 #endif 1158 1159 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ) 1160 #define PETSC_USE_FORTRAN_KERNEL_SOLVEAIJ 1161 #endif 1162 1163 #if !defined(PETSC_USE_FORTRAN_KERNEL_RELAXAIJ) 1164 #define PETSC_USE_FORTRAN_KERNEL_RELAXAIJ 1165 #endif 1166 1167 #if !defined(PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ) 1168 #define PETSC_USE_FORTRAN_KERNEL_SOLVEBAIJ 1169 #endif 1170 1171 #if !defined(PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ) 1172 #define PETSC_USE_FORTRAN_KERNEL_MULTADDAIJ 1173 #endif 1174 1175 #if !defined(PETSC_USE_FORTRAN_KERNEL_MDOT) 1176 #define PETSC_USE_FORTRAN_KERNEL_MDOT 1177 #endif 1178 1179 #if !defined(PETSC_USE_FORTRAN_KERNEL_XTIMESY) 1180 #define PETSC_USE_FORTRAN_KERNEL_XTIMESY 1181 #endif 1182 1183 #if !defined(PETSC_USE_FORTRAN_KERNEL_AYPX) 1184 #define PETSC_USE_FORTRAN_KERNEL_AYPX 1185 #endif 1186 1187 #if !defined(PETSC_USE_FORTRAN_KERNEL_WAXPY) 1188 #define PETSC_USE_FORTRAN_KERNEL_WAXPY 1189 #endif 1190 1191 #endif 1192 1193 /* 1194 Macros for indicating code that should be compiled with a C interface, 1195 rather than a C++ interface. Any routines that are dynamically loaded 1196 (such as the PCCreate_XXX() routines) must be wrapped so that the name 1197 mangler does not change the functions symbol name. This just hides the 1198 ugly extern "C" {} wrappers. 1199 */ 1200 #if defined(__cplusplus) 1201 #define EXTERN_C_BEGIN extern "C" { 1202 #define EXTERN_C_END } 1203 #else 1204 #define EXTERN_C_BEGIN 1205 #define EXTERN_C_END 1206 #endif 1207 1208 /* --------------------------------------------------------------------*/ 1209 1210 /*M 1211 size - integer variable used to contain the number of processors in 1212 the relevent MPI_Comm 1213 1214 Level: beginner 1215 1216 .seealso: rank, comm 1217 M*/ 1218 1219 /*M 1220 rank - integer variable used to contain the number of this processor relative 1221 to all in the relevent MPI_Comm 1222 1223 Level: beginner 1224 1225 .seealso: size, comm 1226 M*/ 1227 1228 /*M 1229 comm - MPI_Comm used in the current routine or object 1230 1231 Level: beginner 1232 1233 .seealso: size, rank 1234 M*/ 1235 1236 /*M 1237 MPI_Comm - the basic object used by MPI to determine which processes are involved in a 1238 communication 1239 1240 Level: beginner 1241 1242 Note: This manual page is a place-holder because MPICH does not have a manual page for MPI_Comm 1243 1244 .seealso: size, rank, comm, PETSC_COMM_WORLD, PETSC_COMM_SELF 1245 M*/ 1246 1247 /*M 1248 PetscScalar - PETSc type that represents either a double precision real number or 1249 a double precision complex number if the code is compiled with BOPT=g_complex or O_complex 1250 1251 Level: beginner 1252 1253 .seealso: PetscReal, PassiveReal, PassiveScalar 1254 M*/ 1255 1256 /*M 1257 PetscReal - PETSc type that represents a double precision real number 1258 1259 Level: beginner 1260 1261 .seealso: PetscScalar, PassiveReal, PassiveScalar 1262 M*/ 1263 1264 /*M 1265 PassiveScalar - PETSc type that represents either a double precision real number or 1266 a double precision complex number if the code is compiled with BOPT=g_complex or O_complex 1267 1268 Level: beginner 1269 1270 This is the same as a PetscScalar except in code that is automatically differentiated it is 1271 treated as a constant (not an indendent or dependent variable) 1272 1273 .seealso: PetscReal, PassiveReal, PetscScalar 1274 M*/ 1275 1276 /*M 1277 PassiveReal - PETSc type that represents a double precision real number 1278 1279 Level: beginner 1280 1281 This is the same as a PetscReal except in code that is automatically differentiated it is 1282 treated as a constant (not an indendent or dependent variable) 1283 1284 .seealso: PetscScalar, PetscReal, PassiveScalar 1285 M*/ 1286 1287 /*M 1288 MPIU_SCALAR - MPI datatype corresponding to PetscScalar 1289 1290 Level: beginner 1291 1292 Note: In MPI calls that require an MPI datatype that matches a PetscScalar or array of PetscScalars 1293 pass this value 1294 1295 .seealso: PetscReal, PassiveReal, PassiveScalar, PetscScalar 1296 M*/ 1297 1298 /* 1299 The IBM include files define hz, here we hide it so that it may be used 1300 as a regular user variable. 1301 */ 1302 #if defined(hz) 1303 #undef hz 1304 #endif 1305 1306 /* For arrays that contain filenames or paths */ 1307 1308 1309 #if defined(PETSC_HAVE_LIMITS_H) 1310 #include <limits.h> 1311 #endif 1312 #if defined(PETSC_HAVE_SYS_PARAM_H) 1313 #include <sys/param.h> 1314 #endif 1315 #if defined(PETSC_HAVE_SYS_TYPES_H) 1316 #include <sys/types.h> 1317 #endif 1318 #if defined(MAXPATHLEN) 1319 # define PETSC_MAX_PATH_LEN MAXPATHLEN 1320 #elif defined(MAX_PATH) 1321 # define PETSC_MAX_PATH_LEN MAX_PATH 1322 #elif defined(_MAX_PATH) 1323 # define PETSC_MAX_PATH_LEN _MAX_PATH 1324 #else 1325 # define PETSC_MAX_PATH_LEN 4096 1326 #endif 1327 1328 PETSC_EXTERN_CXX_END 1329 #endif 1330 1331 1332