1 #if !defined(PETSCSYSTYPES_H) 2 #define PETSCSYSTYPES_H 3 4 #include <petscconf.h> 5 #include <petscconf_poison.h> 6 #include <petscfix.h> 7 #include <stddef.h> 8 9 /* SUBMANSEC = Sys */ 10 11 /*MC 12 PetscErrorCode - datatype used for return error code from almost all PETSc functions 13 14 Level: beginner 15 16 .seealso: `PetscCall()`, `SETERRQ()` 17 M*/ 18 typedef int PetscErrorCode; 19 20 /*MC 21 22 PetscClassId - A unique id used to identify each PETSc class. 23 24 Notes: 25 Use `PetscClassIdRegister()` to obtain a new value for a new class being created. Usually 26 XXXInitializePackage() calls it for each class it defines. 27 28 Developer Notes: 29 Internal integer stored in the `_p_PetscObject` data structure. 30 These are all computed by an offset from the lowest one, `PETSC_SMALLEST_CLASSID`. 31 32 Level: developer 33 34 .seealso: `PetscClassIdRegister()`, `PetscLogEventRegister()`, `PetscHeaderCreate()` 35 M*/ 36 typedef int PetscClassId; 37 38 /*MC 39 PetscMPIInt - datatype used to represent 'int' parameters to MPI functions. 40 41 Level: intermediate 42 43 Notes: 44 This is always a 32 bit integer, sometimes it is the same as `PetscInt`, but if PETSc was built with --with-64-bit-indices but 45 standard C/Fortran integers are 32 bit then this is NOT the same as `PetscInt`; it remains 32 bit. 46 47 `PetscMPIIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscMPIInt`, if not it 48 generates a `PETSC_ERR_ARG_OUTOFRANGE` error. 49 50 .seealso: `PetscBLASInt`, `PetscInt`, `PetscMPIIntCast()` 51 52 M*/ 53 typedef int PetscMPIInt; 54 55 /*MC 56 PetscSizeT - datatype used to represent sizes in memory (like size_t) 57 58 Level: intermediate 59 60 Notes: 61 This is equivalent to size_t, but defined for consistency with Fortran, which lacks a native equivalent of size_t. 62 63 .seealso: `PetscInt`, `PetscInt64`, `PetscCount` 64 65 M*/ 66 typedef size_t PetscSizeT; 67 68 /*MC 69 PetscCount - signed datatype used to represent counts 70 71 Level: intermediate 72 73 Notes: 74 This is equivalent to ptrdiff_t, but defined for consistency with Fortran, which lacks a native equivalent of ptrdiff_t. 75 76 Use `PetscCount_FMT` to format with `PetscPrintf()`, `printf()`, and related functions. 77 78 .seealso: `PetscInt`, `PetscInt64`, `PetscSizeT` 79 80 M*/ 81 typedef ptrdiff_t PetscCount; 82 #define PetscCount_FMT "td" 83 84 /*MC 85 PetscEnum - datatype used to pass enum types within PETSc functions. 86 87 Level: intermediate 88 89 .seealso: `PetscOptionsGetEnum()`, `PetscOptionsEnum()`, `PetscBagRegisterEnum()` 90 M*/ 91 typedef enum { ENUM_DUMMY } PetscEnum; 92 93 typedef short PetscShort; 94 typedef char PetscChar; 95 typedef float PetscFloat; 96 97 /*MC 98 PetscInt - PETSc type that represents an integer, used primarily to 99 represent size of arrays and indexing into arrays. Its size can be configured with the option --with-64-bit-indices to be either 32-bit (default) or 64-bit. 100 101 Notes: 102 For MPI calls that require datatypes, use `MPIU_INT` as the datatype for `PetscInt`. It will automatically work correctly regardless of the size of PetscInt. 103 104 Level: beginner 105 106 .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT` 107 M*/ 108 109 #if defined(PETSC_HAVE_STDINT_H) 110 # include <stdint.h> 111 #endif 112 #if defined (PETSC_HAVE_INTTYPES_H) 113 # if !defined(__STDC_FORMAT_MACROS) 114 # define __STDC_FORMAT_MACROS /* required for using PRId64 from c++ */ 115 # endif 116 # include <inttypes.h> 117 # if !defined(PRId64) 118 # define PRId64 "ld" 119 # endif 120 #endif 121 122 #if defined(PETSC_HAVE_STDINT_H) && defined(PETSC_HAVE_INTTYPES_H) && defined(PETSC_HAVE_MPI_INT64_T) /* MPI_INT64_T is not guaranteed to be a macro */ 123 typedef int64_t PetscInt64; 124 #elif (PETSC_SIZEOF_LONG_LONG == 8) 125 typedef long long PetscInt64; 126 #elif defined(PETSC_HAVE___INT64) 127 typedef __int64 PetscInt64; 128 #else 129 # error "cannot determine PetscInt64 type" 130 #endif 131 132 #if defined(PETSC_USE_64BIT_INDICES) 133 typedef PetscInt64 PetscInt; 134 #else 135 typedef int PetscInt; 136 #endif 137 138 #if defined(PETSC_HAVE_STDINT_H) && defined(PETSC_HAVE_INTTYPES_H) && defined(PETSC_HAVE_MPI_INT64_T) /* MPI_INT64_T is not guaranteed to be a macro */ 139 # define MPIU_INT64 MPI_INT64_T 140 # define PetscInt64_FMT PRId64 141 #elif (PETSC_SIZEOF_LONG_LONG == 8) 142 # define MPIU_INT64 MPI_LONG_LONG_INT 143 # define PetscInt64_FMT "lld" 144 #elif defined(PETSC_HAVE___INT64) 145 # define MPIU_INT64 MPI_INT64_T 146 # define PetscInt64_FMT "ld" 147 #else 148 # error "cannot determine PetscInt64 type" 149 #endif 150 151 /*MC 152 PetscBLASInt - datatype used to represent 'int' parameters to BLAS/LAPACK functions. 153 154 Notes: 155 Usually this is the same as `PetscIn`t, but if PETSc was built with --with-64-bit-indices but 156 standard C/Fortran integers are 32 bit then this may not be the same as `PetscInt`, 157 except on some BLAS/LAPACK implementations that support 64 bit integers see the notes below. 158 159 `PetscErrorCode` `PetscBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscBLASInt`, if not it 160 generates a `PETSC_ERR_ARG_OUTOFRANGE` error 161 162 Installation Notes: 163 ./configure automatically determines the size of the integers used by BLAS/LAPACK except when --with-batch is used 164 in that situation one must know (by some other means) if the integers used by BLAS/LAPACK are 64 bit and if so pass the flag --known-64-bit-blas-indice 165 166 MATLAB ships with BLAS and LAPACK that use 64 bit integers, for example if you run ./configure with, the option 167 --with-blaslapack-lib=[/Applications/MATLAB_R2010b.app/bin/maci64/libmwblas.dylib,/Applications/MATLAB_R2010b.app/bin/maci64/libmwlapack.dylib] 168 169 MKL ships with both 32 and 64 bit integer versions of the BLAS and LAPACK. If you pass the flag -with-64-bit-blas-indices PETSc will link 170 against the 64 bit version, otherwise it use the 32 bit version 171 172 OpenBLAS can be built to use 64 bit integers. The ./configure options --download-openblas -with-64-bit-blas-indices will build a 64 bit integer version 173 174 External packages such as hypre, ML, SuperLU etc do not provide any support for passing 64 bit integers to BLAS/LAPACK so cannot 175 be used with PETSc when PETSc links against 64 bit integer BLAS/LAPACK. ./configure will generate an error if you attempt to link PETSc against any of 176 these external libraries while using 64 bit integer BLAS/LAPACK. 177 178 Level: intermediate 179 180 .seealso: `PetscMPIInt`, `PetscInt`, `PetscBLASIntCast()` 181 182 M*/ 183 #if defined(PETSC_HAVE_64BIT_BLAS_INDICES) 184 # define PetscBLASInt_FMT PetscInt64_FMT 185 typedef PetscInt64 PetscBLASInt; 186 #else 187 # define PetscBLASInt_FMT "d" 188 typedef int PetscBLASInt; 189 #endif 190 191 /*MC 192 PetscCuBLASInt - datatype used to represent 'int' parameters to cuBLAS/cuSOLVER functions. 193 194 Notes: 195 As of this writing PetscCuBLASInt is always the system `int`. 196 197 `PetscErrorCode` `PetscCuBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscCuBLASInt`, if not it 198 generates a `PETSC_ERR_ARG_OUTOFRANGE` error 199 200 Level: intermediate 201 202 .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscInt`, `PetscCuBLASIntCast()` 203 204 M*/ 205 typedef int PetscCuBLASInt; 206 207 /*E 208 PetscBool - Logical variable. Actually an enum in C and a logical in Fortran. 209 210 Level: beginner 211 212 Developer Note: 213 Why have `PetscBool`, why not use bool in C? The problem is that K and R C, C99 and C++ all have different mechanisms for 214 boolean values. It is not easy to have a simple macro that that will work properly in all circumstances with all three mechanisms. 215 216 .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PetscBool3` 217 E*/ 218 typedef enum { PETSC_FALSE,PETSC_TRUE } PetscBool; 219 220 /*E 221 PetscBool3 - Ternary logical variable. Actually an enum in C and a 4 byte integer in Fortran. 222 223 Level: beginner 224 225 Note: 226 Should not be used with the if (flg) or if (!flg) syntax. 227 228 .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PETSC_BOOL3_TRUE`, `PETSC_BOOL3_FALSE`, `PETSC_BOOL3_UKNOWN` 229 E*/ 230 typedef enum { PETSC_BOOL3_FALSE,PETSC_BOOL3_TRUE, PETSC_BOOL3_UNKNOWN = -1 } PetscBool3; 231 232 #define PetscBool3ToBool(a) ((a) == PETSC_BOOL3_TRUE ? PETSC_TRUE : PETSC_FALSE) 233 #define PetscBoolToBool3(a) ((a) == PETSC_TRUE ? PETSC_BOOL3_TRUE : PETSC_BOOL3_FALSE) 234 235 /*MC 236 PetscReal - PETSc type that represents a real number version of `PetscScalar` 237 238 Notes: 239 For MPI calls that require datatypes, use `MPIU_REAL` as the datatype for `PetscReal` and `MPIU_SUM`, `MPIU_MAX`, etc. for operations. 240 They will automatically work correctly regardless of the size of `PetscReal`. 241 242 See `PetscScalar` for details on how to ./configure the size of `PetscReal`. 243 244 Level: beginner 245 246 .seealso: `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT` 247 M*/ 248 249 #if defined(PETSC_USE_REAL_SINGLE) 250 typedef float PetscReal; 251 #elif defined(PETSC_USE_REAL_DOUBLE) 252 typedef double PetscReal; 253 #elif defined(PETSC_USE_REAL___FLOAT128) 254 # if defined(__cplusplus) 255 extern "C" { 256 # endif 257 # include <quadmath.h> 258 # if defined(__cplusplus) 259 } 260 # endif 261 typedef __float128 PetscReal; 262 #elif defined(PETSC_USE_REAL___FP16) 263 typedef __fp16 PetscReal; 264 #endif /* PETSC_USE_REAL_* */ 265 266 /*MC 267 PetscComplex - PETSc type that represents a complex number with precision matching that of `PetscReal`. 268 269 Synopsis: 270 #include <petscsys.h> 271 PetscComplex number = 1. + 2.*PETSC_i; 272 273 Notes: 274 For MPI calls that require datatypes, use `MPIU_COMPLEX` as the datatype for `PetscComplex` and `MPIU_SUM` etc for operations. 275 They will automatically work correctly regardless of the size of `PetscComplex`. 276 277 See PetscScalar for details on how to ./configure the size of `PetscReal` 278 279 Complex numbers are automatically available if PETSc was able to find a working complex implementation 280 281 Petsc has a 'fix' for complex numbers to support expressions such as std::complex<PetscReal> + `PetscInt`, which are not supported by the standard 282 C++ library, but are convenient for petsc users. If the C++ compiler is able to compile code in petsccxxcomplexfix.h (This is checked by 283 configure), we include petsccxxcomplexfix.h to provide this convenience. 284 285 If the fix causes conflicts, or one really does not want this fix for a particular C++ file, one can define `PETSC_SKIP_CXX_COMPLEX_FIX` 286 at the beginning of the C++ file to skip the fix. 287 288 Level: beginner 289 290 .seealso: `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PETSC_i` 291 M*/ 292 #if !defined(PETSC_SKIP_COMPLEX) 293 # if defined(PETSC_CLANGUAGE_CXX) 294 # if !defined(PETSC_USE_REAL___FP16) && !defined(PETSC_USE_REAL___FLOAT128) 295 # if defined(__cplusplus) && defined(PETSC_HAVE_CXX_COMPLEX) /* enable complex for library code */ 296 # define PETSC_HAVE_COMPLEX 1 297 # elif !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on libary code complex support */ 298 # define PETSC_HAVE_COMPLEX 1 299 # endif 300 # elif defined(PETSC_USE_REAL___FLOAT128) && defined(PETSC_HAVE_C99_COMPLEX) 301 # define PETSC_HAVE_COMPLEX 1 302 # endif 303 # else /* !PETSC_CLANGUAGE_CXX */ 304 # if !defined(PETSC_USE_REAL___FP16) 305 # if !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) /* enable complex for library code */ 306 # define PETSC_HAVE_COMPLEX 1 307 # elif defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on libary code complex support */ 308 # define PETSC_HAVE_COMPLEX 1 309 # endif 310 # endif 311 # endif /* PETSC_CLANGUAGE_CXX */ 312 #endif /* !PETSC_SKIP_COMPLEX */ 313 314 #if defined(PETSC_HAVE_COMPLEX) 315 #if defined(__cplusplus) /* C++ complex support */ 316 /* Locate a C++ complex template library */ 317 #if defined(PETSC_DESIRE_KOKKOS_COMPLEX) /* Defined in petscvec_kokkos.hpp for *.kokkos.cxx files */ 318 #define petsccomplexlib Kokkos 319 #include <Kokkos_Complex.hpp> 320 #elif defined(__CUDACC__) || defined(__HIPCC__) 321 #define petsccomplexlib thrust 322 #include <thrust/complex.h> 323 #elif defined(PETSC_USE_REAL___FLOAT128) 324 #include <complex.h> 325 #else 326 #define petsccomplexlib std 327 #include <complex> 328 #endif 329 330 /* Define PetscComplex based on the precision */ 331 #if defined(PETSC_USE_REAL_SINGLE) 332 typedef petsccomplexlib::complex<float> PetscComplex; 333 #elif defined(PETSC_USE_REAL_DOUBLE) 334 typedef petsccomplexlib::complex<double> PetscComplex; 335 #elif defined(PETSC_USE_REAL___FLOAT128) 336 typedef __complex128 PetscComplex; 337 #endif 338 339 /* Include a PETSc C++ complex 'fix'. Check PetscComplex manual page for details */ 340 #if defined(PETSC_HAVE_CXX_COMPLEX_FIX) && !defined(PETSC_SKIP_CXX_COMPLEX_FIX) 341 #include <petsccxxcomplexfix.h> 342 #endif 343 #else /* c99 complex support */ 344 #include <complex.h> 345 #if defined(PETSC_USE_REAL_SINGLE) || defined(PETSC_USE_REAL___FP16) 346 typedef float _Complex PetscComplex; 347 #elif defined(PETSC_USE_REAL_DOUBLE) 348 typedef double _Complex PetscComplex; 349 #elif defined(PETSC_USE_REAL___FLOAT128) 350 typedef __complex128 PetscComplex; 351 #endif /* PETSC_USE_REAL_* */ 352 #endif /* !__cplusplus */ 353 #endif /* PETSC_HAVE_COMPLEX */ 354 355 /*MC 356 PetscScalar - PETSc type that represents either a double precision real number, a double precision 357 complex number, a single precision real number, a __float128 real or complex or a __fp16 real - if the code is configured 358 with --with-scalar-type=real,complex --with-precision=single,double,__float128,__fp16 359 360 Notes: 361 For MPI calls that require datatypes, use `MPIU_SCALAR` as the datatype for `PetscScalar` and `MPIU_SUM`, etc for operations. They will automatically work correctly regardless of the size of `PetscScalar`. 362 363 Level: beginner 364 365 .seealso: `PetscReal`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PetscRealPart()`, `PetscImaginaryPart()` 366 M*/ 367 368 #if defined(PETSC_USE_COMPLEX) && defined(PETSC_HAVE_COMPLEX) 369 typedef PetscComplex PetscScalar; 370 #else /* PETSC_USE_COMPLEX */ 371 typedef PetscReal PetscScalar; 372 #endif /* PETSC_USE_COMPLEX */ 373 374 /*E 375 PetscCopyMode - Determines how an array or `PetscObject` passed to certain functions is copied or retained by the aggregate `PetscObject` 376 377 Level: beginner 378 379 For the array input: 380 $ `PETSC_COPY_VALUES` - the array values are copied into new space, the user is free to reuse or delete the passed in array 381 $ `PETSC_OWN_POINTER` - the array values are NOT copied, the object takes ownership of the array and will free it later, the user cannot change or 382 $ delete the array. The array MUST have been obtained with PetscMalloc(). Hence this mode cannot be used in Fortran. 383 $ `PETSC_USE_POINTER` - the array values are NOT copied, the object uses the array but does NOT take ownership of the array. The user cannot use 384 $ the array but the user must delete the array after the object is destroyed. 385 386 For the PetscObject input: 387 $ `PETSC_COPY_VALUES` - the input `PetscObject` is cloned into the aggregate `PetscObject`; the user is free to reuse/modify the input `PetscObject` without side effects. 388 $ `PETSC_OWN_POINTER` - the input `PetscObject` is referenced by pointer (with reference count), thus should not be modified by the user. (Modification may cause errors or unintended side-effects in this or a future version of PETSc.) 389 For either case above, the input `PetscObject` should be destroyed by the user when no longer needed (the aggregate object increases its reference count). 390 $ `PETSC_USE_POINTER` - invalid for `PetscObject` inputs. 391 392 E*/ 393 typedef enum {PETSC_COPY_VALUES, PETSC_OWN_POINTER, PETSC_USE_POINTER} PetscCopyMode; 394 395 /*MC 396 PETSC_FALSE - False value of `PetscBool` 397 398 Level: beginner 399 400 Note: 401 Zero integer 402 403 .seealso: `PetscBool`, `PetscBool3`, `PETSC_TRUE` 404 M*/ 405 406 /*MC 407 PETSC_TRUE - True value of `PetscBool` 408 409 Level: beginner 410 411 Note: 412 Nonzero integer 413 414 .seealso: `PetscBool`, `PetscBool3`, `PETSC_FALSE` 415 M*/ 416 417 /*MC 418 PetscLogDouble - Used for logging times 419 420 Notes: 421 Contains double precision numbers that are not used in the numerical computations, but rather in logging, timing etc. 422 423 Level: developer 424 425 M*/ 426 typedef double PetscLogDouble; 427 428 /*E 429 PetscDataType - Used for handling different basic data types. 430 431 Level: beginner 432 433 Notes: 434 Use of this should be avoided if one can directly use `MPI_Datatype` instead. 435 436 `PETSC_INT` is the datatype for a `PetscInt`, regardless of whether it is 4 or 8 bytes. 437 `PETSC_REAL`, `PETSC_COMPLEX` and `PETSC_SCALAR` are the datatypes for `PetscReal`, `PetscComplex` and `PetscScalar`, regardless of their sizes. 438 439 Developer Notes: 440 It would be nice if we could always just use MPI Datatypes, why can we not? 441 442 If you change any values in `PetscDatatype` make sure you update their usage in 443 share/petsc/matlab/PetscBagRead.m and share/petsc/matlab/@PetscOpenSocket/read/write.m 444 445 TODO: Add PETSC_INT32 and remove use of improper PETSC_ENUM 446 447 .seealso: `PetscBinaryRead()`, `PetscBinaryWrite()`, `PetscDataTypeToMPIDataType()`, 448 `PetscDataTypeGetSize()` 449 450 E*/ 451 typedef enum {PETSC_DATATYPE_UNKNOWN = 0, 452 PETSC_DOUBLE = 1, PETSC_COMPLEX = 2, PETSC_LONG = 3, PETSC_SHORT = 4, PETSC_FLOAT = 5, 453 PETSC_CHAR = 6, PETSC_BIT_LOGICAL = 7, PETSC_ENUM = 8, PETSC_BOOL = 9, PETSC___FLOAT128 = 10, 454 PETSC_OBJECT = 11, PETSC_FUNCTION = 12, PETSC_STRING = 13, PETSC___FP16 = 14, PETSC_STRUCT = 15, 455 PETSC_INT = 16, PETSC_INT64 = 17} PetscDataType; 456 457 #if defined(PETSC_USE_REAL_SINGLE) 458 # define PETSC_REAL PETSC_FLOAT 459 #elif defined(PETSC_USE_REAL_DOUBLE) 460 # define PETSC_REAL PETSC_DOUBLE 461 #elif defined(PETSC_USE_REAL___FLOAT128) 462 # define PETSC_REAL PETSC___FLOAT128 463 #elif defined(PETSC_USE_REAL___FP16) 464 # define PETSC_REAL PETSC___FP16 465 #else 466 # define PETSC_REAL PETSC_DOUBLE 467 #endif 468 469 #if defined(PETSC_USE_COMPLEX) 470 # define PETSC_SCALAR PETSC_COMPLEX 471 #else 472 # define PETSC_SCALAR PETSC_REAL 473 #endif 474 475 #define PETSC_FORTRANADDR PETSC_LONG 476 477 /*S 478 PetscToken - 'Token' used for managing tokenizing strings 479 480 Level: intermediate 481 482 .seealso: `PetscTokenCreate()`, `PetscTokenFind()`, `PetscTokenDestroy()` 483 S*/ 484 typedef struct _p_PetscToken* PetscToken; 485 486 /*S 487 PetscObject - any PETSc object, `PetscViewer`, `Mat`, `Vec`, `KSP` etc 488 489 Level: beginner 490 491 Notes: 492 This is the base class from which all PETSc objects are derived from. 493 494 In certain situations one can cast an object, for example a `Vec`, to a `PetscObject` with (`PetscObject`)vec 495 496 .seealso: `PetscObjectDestroy()`, `PetscObjectView()`, `PetscObjectGetName()`, `PetscObjectSetName()`, `PetscObjectReference()`, `PetscObjectDereference()` 497 S*/ 498 typedef struct _p_PetscObject* PetscObject; 499 500 /*MC 501 PetscObjectId - unique integer Id for a `PetscObject` 502 503 Level: developer 504 505 Note: 506 Unlike pointer values, object ids are never reused so one may save a `PetscObjectId` and compare it to one obtained later from a `PetscObject` to determine 507 if the objects are the same. Never compare two object pointer values. 508 509 .seealso: `PetscObjectState`, `PetscObjectGetId()` 510 M*/ 511 typedef PetscInt64 PetscObjectId; 512 513 /*MC 514 PetscObjectState - integer state for a `PetscObject` 515 516 Level: developer 517 518 Notes: 519 Object state is always-increasing and (for objects that track state) can be used to determine if an object has 520 changed since the last time you interacted with it. It is 64-bit so that it will not overflow for a very long time. 521 522 .seealso: `PetscObjectId`, `PetscObjectStateGet()`, `PetscObjectStateIncrease()`, `PetscObjectStateSet()` 523 M*/ 524 typedef PetscInt64 PetscObjectState; 525 526 /*S 527 PetscFunctionList - Linked list of functions, possibly stored in dynamic libraries, accessed 528 by string name 529 530 Level: advanced 531 532 .seealso: `PetscFunctionListAdd()`, `PetscFunctionListDestroy()` 533 S*/ 534 typedef struct _n_PetscFunctionList *PetscFunctionList; 535 536 /*E 537 PetscFileMode - Access mode for a file. 538 539 Level: beginner 540 541 $ `FILE_MODE_UNDEFINED` - initial invalid value 542 $ `FILE_MODE_READ` - open a file at its beginning for reading 543 $ `FILE_MODE_WRITE` - open a file at its beginning for writing (will create if the file does not exist) 544 $ `FILE_MODE_APPEND` - open a file at end for writing 545 $ `FILE_MODE_UPDATE` - open a file for updating, meaning for reading and writing 546 $ `FILE_MODE_APPEND_UPDATE` - open a file for updating, meaning for reading and writing, at the end 547 548 .seealso: `PetscViewerFileSetMode()` 549 E*/ 550 typedef enum {FILE_MODE_UNDEFINED=-1, FILE_MODE_READ=0, FILE_MODE_WRITE, FILE_MODE_APPEND, FILE_MODE_UPDATE, FILE_MODE_APPEND_UPDATE} PetscFileMode; 551 552 typedef void* PetscDLHandle; 553 typedef enum {PETSC_DL_DECIDE=0,PETSC_DL_NOW=1,PETSC_DL_LOCAL=2} PetscDLMode; 554 555 /*S 556 PetscObjectList - Linked list of PETSc objects, each accessible by string name 557 558 Level: developer 559 560 Note: 561 Used by `PetscObjectCompose()` and `PetscObjectQuery()` 562 563 .seealso: `PetscObjectListAdd()`, `PetscObjectListDestroy()`, `PetscObjectListFind()`, `PetscObjectCompose()`, `PetscObjectQuery()`, `PetscFunctionList` 564 S*/ 565 typedef struct _n_PetscObjectList *PetscObjectList; 566 567 /*S 568 PetscDLLibrary - Linked list of dynamics libraries to search for functions 569 570 Level: advanced 571 572 .seealso: `PetscDLLibraryOpen()` 573 S*/ 574 typedef struct _n_PetscDLLibrary *PetscDLLibrary; 575 576 /*S 577 PetscContainer - Simple PETSc object that contains a pointer to any required data 578 579 Level: advanced 580 581 Note: 582 This is useful to attach arbitrary data to a `PetscObject` with `PetscObjectCompose()` and `PetscObjectQuery()` 583 584 .seealso: `PetscObject`, `PetscContainerCreate()`, `PetscObjectCompose()`, `PetscObjectQuery()` 585 S*/ 586 typedef struct _p_PetscContainer* PetscContainer; 587 588 /*S 589 PetscRandom - Abstract PETSc object that manages generating random numbers 590 591 Level: intermediate 592 593 .seealso: `PetscRandomCreate()`, `PetscRandomGetValue()`, `PetscRandomType` 594 S*/ 595 typedef struct _p_PetscRandom* PetscRandom; 596 597 /* 598 In binary files variables are stored using the following lengths, 599 regardless of how they are stored in memory on any one particular 600 machine. Use these rather then sizeof() in computing sizes for 601 PetscBinarySeek(). 602 */ 603 #define PETSC_BINARY_INT_SIZE (32/8) 604 #define PETSC_BINARY_FLOAT_SIZE (32/8) 605 #define PETSC_BINARY_CHAR_SIZE (8/8) 606 #define PETSC_BINARY_SHORT_SIZE (16/8) 607 #define PETSC_BINARY_DOUBLE_SIZE (64/8) 608 #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar) 609 610 /*E 611 PetscBinarySeekType - argument to `PetscBinarySeek()` 612 613 Level: advanced 614 615 .seealso: `PetscBinarySeek()`, `PetscBinarySynchronizedSeek()` 616 E*/ 617 typedef enum {PETSC_BINARY_SEEK_SET = 0,PETSC_BINARY_SEEK_CUR = 1,PETSC_BINARY_SEEK_END = 2} PetscBinarySeekType; 618 619 /*E 620 PetscBuildTwoSidedType - algorithm for setting up two-sided communication 621 622 $ `PETSC_BUILDTWOSIDED_ALLREDUCE` - classical algorithm using an MPI_Allreduce with 623 $ a buffer of length equal to the communicator size. Not memory-scalable due to 624 $ the large reduction size. Requires only MPI-1. 625 $ `PETSC_BUILDTWOSIDED_IBARRIER` - nonblocking algorithm based on MPI_Issend and MPI_Ibarrier. 626 $ Proved communication-optimal in Hoefler, Siebert, and Lumsdaine (2010). Requires MPI-3. 627 $ `PETSC_BUILDTWOSIDED_REDSCATTER` - similar to above, but use more optimized function 628 $ that only communicates the part of the reduction that is necessary. Requires MPI-2. 629 630 Level: developer 631 632 .seealso: `PetscCommBuildTwoSided()`, `PetscCommBuildTwoSidedSetType()`, `PetscCommBuildTwoSidedGetType()` 633 E*/ 634 typedef enum { 635 PETSC_BUILDTWOSIDED_NOTSET = -1, 636 PETSC_BUILDTWOSIDED_ALLREDUCE = 0, 637 PETSC_BUILDTWOSIDED_IBARRIER = 1, 638 PETSC_BUILDTWOSIDED_REDSCATTER = 2 639 /* Updates here must be accompanied by updates in finclude/petscsys.h and the string array in mpits.c */ 640 } PetscBuildTwoSidedType; 641 642 /* NOTE: If you change this, you must also change the values in src/vec/f90-mod/petscvec.h */ 643 /*E 644 InsertMode - Whether entries are inserted or added into vectors or matrices 645 646 Level: beginner 647 648 .seealso: `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, 649 `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, 650 `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()` 651 E*/ 652 typedef enum {NOT_SET_VALUES, INSERT_VALUES, ADD_VALUES, MAX_VALUES, MIN_VALUES, INSERT_ALL_VALUES, ADD_ALL_VALUES, INSERT_BC_VALUES, ADD_BC_VALUES} InsertMode; 653 654 /*MC 655 INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value 656 657 Level: beginner 658 659 .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, 660 `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `ADD_VALUES`, 661 `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES` 662 663 M*/ 664 665 /*MC 666 ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the 667 value into that location 668 669 Level: beginner 670 671 .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, 672 `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `INSERT_VALUES`, 673 `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES` 674 675 M*/ 676 677 /*MC 678 MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location 679 680 Level: beginner 681 682 .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES` 683 684 M*/ 685 686 /*MC 687 MIN_VALUES - Puts the minimal of the scattered/gathered value and the current value into each location 688 689 Level: beginner 690 691 .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES` 692 693 M*/ 694 695 /*S 696 PetscSubcomm - A decomposition of an MPI communicator into subcommunicators 697 698 Notes: 699 After a call to `PetscSubcommSetType()`, `PetscSubcommSetTypeGeneral()`, or `PetscSubcommSetFromOptions()` one may call 700 $ `PetscSubcommChild()` returns the associated subcommunicator on this process 701 $ `PetscSubcommContiguousParent()` returns a parent communitor but with all child of the same subcommunicator having contiguous rank 702 703 Sample Usage: 704 .vb 705 `PetscSubcommCreate()` 706 `PetscSubcommSetNumber()` 707 `PetscSubcommSetType`(`PETSC_SUBCOMM_INTERLACED`); 708 ccomm = `PetscSubcommChild()` 709 `PetscSubcommDestroy()` 710 .ve 711 712 Level: advanced 713 714 Notes: 715 $ `PETSC_SUBCOMM_GENERAL` - similar to `MPI_Comm_split()` each process sets the new communicator (color) they will belong to and the order within that communicator 716 $ `PETSC_SUBCOMM_CONTIGUOUS` - each new communicator contains a set of process with contiguous ranks in the original MPI communicator 717 $ `PETSC_SUBCOMM_INTERLACED` - each new communictor contains a set of processes equally far apart in rank from the others in that new communicator 718 719 Example: Consider a communicator with six processes split into 3 subcommunicators. 720 $ `PETSC_SUBCOMM_CONTIGUOUS` - the first communicator contains rank 0,1 the second rank 2,3 and the third rank 4,5 in the original ordering of the original communicator 721 $ `PETSC_SUBCOMM_INTERLACED` - the first communicator contains rank 0,3, the second 1,4 and the third 2,5 722 723 Developer Note: 724 This is used in objects such as `PCREDUNDANT` to manage the subcommunicators on which the redundant computations 725 are performed. 726 727 .seealso: `PetscSubcommCreate()`, `PetscSubcommSetNumber()`, `PetscSubcommSetType()`, `PetscSubcommView()`, `PetscSubcommSetFromOptions()` 728 729 S*/ 730 typedef struct _n_PetscSubcomm* PetscSubcomm; 731 typedef enum {PETSC_SUBCOMM_GENERAL=0,PETSC_SUBCOMM_CONTIGUOUS=1,PETSC_SUBCOMM_INTERLACED=2} PetscSubcommType; 732 733 /*S 734 PetscHeap - A simple class for managing heaps 735 736 Level: intermediate 737 738 .seealso: `PetscHeapCreate()`, `PetscHeapAdd()`, `PetscHeapPop()`, `PetscHeapPeek()`, `PetscHeapStash()`, `PetscHeapUnstash()`, `PetscHeapView()`, `PetscHeapDestroy()` 739 S*/ 740 typedef struct _PetscHeap *PetscHeap; 741 742 typedef struct _n_PetscShmComm* PetscShmComm; 743 typedef struct _n_PetscOmpCtrl* PetscOmpCtrl; 744 745 /*S 746 PetscSegBuffer - a segmented extendable buffer 747 748 Level: developer 749 750 .seealso: `PetscSegBufferCreate()`, `PetscSegBufferGet()`, `PetscSegBufferExtract()`, `PetscSegBufferDestroy()` 751 S*/ 752 typedef struct _n_PetscSegBuffer *PetscSegBuffer; 753 754 typedef struct _n_PetscOptionsHelpPrinted *PetscOptionsHelpPrinted; 755 #endif 756