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