147d993e7Ssuyashtn /* Portions of this code are under: 247d993e7Ssuyashtn Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 347d993e7Ssuyashtn */ 447d993e7Ssuyashtn 56524c165SJacob Faibussowitsch #ifndef PETSCSYSTYPES_H 626bd1501SBarry Smith #define PETSCSYSTYPES_H 7df4397b0SStefano Zampini 8df4397b0SStefano Zampini #include <petscconf.h> 9e1bf4ed2SJacob Faibussowitsch #include <petscconf_poison.h> 10df4397b0SStefano Zampini #include <petscfix.h> 113ba16761SJacob Faibussowitsch #include <petscmacros.h> // PETSC_NODISCARD, PETSC_CPP_VERSION 123edda6a2SJed Brown #include <stddef.h> 13df4397b0SStefano Zampini 14ac09b921SBarry Smith /* SUBMANSEC = Sys */ 15ac09b921SBarry Smith 163ba16761SJacob Faibussowitsch #include <limits.h> // INT_MIN, INT_MAX 173ba16761SJacob Faibussowitsch 183ba16761SJacob Faibussowitsch #if defined(__clang__) || (PETSC_CPP_VERSION >= 17) 193ba16761SJacob Faibussowitsch // clang allows both [[nodiscard]] and __attribute__((warn_unused_result)) on type 203ba16761SJacob Faibussowitsch // definitions. GCC, however, does not, so check that we are using C++17 [[nodiscard]] 213ba16761SJacob Faibussowitsch // instead of __attribute__((warn_unused_result)) 223ba16761SJacob Faibussowitsch #define PETSC_ERROR_CODE_NODISCARD PETSC_NODISCARD 233ba16761SJacob Faibussowitsch #else 243ba16761SJacob Faibussowitsch #define PETSC_ERROR_CODE_NODISCARD 253ba16761SJacob Faibussowitsch #endif 263ba16761SJacob Faibussowitsch 278a7d4faaSJacob Faibussowitsch #ifdef PETSC_CLANG_STATIC_ANALYZER 288a7d4faaSJacob Faibussowitsch #undef PETSC_USE_STRICT_PETSCERRORCODE 298a7d4faaSJacob Faibussowitsch #endif 308a7d4faaSJacob Faibussowitsch 313ba16761SJacob Faibussowitsch #ifdef PETSC_USE_STRICT_PETSCERRORCODE 323ba16761SJacob Faibussowitsch #define PETSC_ERROR_CODE_TYPEDEF typedef 333ba16761SJacob Faibussowitsch #define PETSC_ERROR_CODE_ENUM_NAME PetscErrorCode 343ba16761SJacob Faibussowitsch #else 353ba16761SJacob Faibussowitsch #define PETSC_ERROR_CODE_TYPEDEF 363ba16761SJacob Faibussowitsch #define PETSC_ERROR_CODE_ENUM_NAME 373ba16761SJacob Faibussowitsch #endif 383ba16761SJacob Faibussowitsch 393ba16761SJacob Faibussowitsch /*E 403ba16761SJacob Faibussowitsch PetscErrorCode - Datatype used to return PETSc error codes. 41df4397b0SStefano Zampini 42df4397b0SStefano Zampini Level: beginner 43df4397b0SStefano Zampini 443ba16761SJacob Faibussowitsch Notes: 453ba16761SJacob Faibussowitsch Virtually all PETSc functions return an error code. It is the callers responsibility to check 463ba16761SJacob Faibussowitsch the value of the returned error code after each PETSc call to determine if any errors 473ba16761SJacob Faibussowitsch occurred. A set of convenience macros (e.g. `PetscCall()`, `PetscCallVoid()`) are provided 483ba16761SJacob Faibussowitsch for this purpose. Failing to properly check for errors is not supported, as errors may leave 493ba16761SJacob Faibussowitsch PETSc in an undetermined state. 503ba16761SJacob Faibussowitsch 513ba16761SJacob Faibussowitsch One can retrieve the error string corresponding to a particular error code using 523ba16761SJacob Faibussowitsch `PetscErrorMessage()`. 533ba16761SJacob Faibussowitsch 543ba16761SJacob Faibussowitsch The user can also configure PETSc with the `--with-strict-petscerrorcode` option to enable 553ba16761SJacob Faibussowitsch compiler warnings when the returned error codes are not captured and checked. Users are 563ba16761SJacob Faibussowitsch *heavily* encouraged to opt-in to this option, as it will become enabled by default in a 573ba16761SJacob Faibussowitsch future release. 583ba16761SJacob Faibussowitsch 593ba16761SJacob Faibussowitsch Developer Notes: 603ba16761SJacob Faibussowitsch 613ba16761SJacob Faibussowitsch These are the generic error codes. These error codes are used in many different places in the 623ba16761SJacob Faibussowitsch PETSc source code. The C-string versions are at defined in `PetscErrorStrings[]` in 6316a05f60SBarry Smith `src/sys/error/err.c`, while the Fortran versions are defined in 643ba16761SJacob Faibussowitsch `src/sys/f90-mod/petscerror.h`. Any changes here must also be made in both locations. 653ba16761SJacob Faibussowitsch 663ba16761SJacob Faibussowitsch .seealso: `PetscErrorMessage()`, `PetscCall()`, `SETERRQ()` 673ba16761SJacob Faibussowitsch E*/ 683ba16761SJacob Faibussowitsch PETSC_ERROR_CODE_TYPEDEF enum PETSC_ERROR_CODE_NODISCARD { 693ba16761SJacob Faibussowitsch PETSC_SUCCESS = 0, 703ba16761SJacob Faibussowitsch PETSC_ERR_BOOLEAN_MACRO_FAILURE = 1, /* do not use */ 713ba16761SJacob Faibussowitsch 723ba16761SJacob Faibussowitsch PETSC_ERR_MIN_VALUE = 54, /* should always be one less then the smallest value */ 733ba16761SJacob Faibussowitsch 743ba16761SJacob Faibussowitsch PETSC_ERR_MEM = 55, /* unable to allocate requested memory */ 753ba16761SJacob Faibussowitsch PETSC_ERR_SUP = 56, /* no support for requested operation */ 763ba16761SJacob Faibussowitsch PETSC_ERR_SUP_SYS = 57, /* no support for requested operation on this computer system */ 773ba16761SJacob Faibussowitsch PETSC_ERR_ORDER = 58, /* operation done in wrong order */ 783ba16761SJacob Faibussowitsch PETSC_ERR_SIG = 59, /* signal received */ 793ba16761SJacob Faibussowitsch PETSC_ERR_FP = 72, /* floating point exception */ 803ba16761SJacob Faibussowitsch PETSC_ERR_COR = 74, /* corrupted PETSc object */ 813ba16761SJacob Faibussowitsch PETSC_ERR_LIB = 76, /* error in library called by PETSc */ 823ba16761SJacob Faibussowitsch PETSC_ERR_PLIB = 77, /* PETSc library generated inconsistent data */ 833ba16761SJacob Faibussowitsch PETSC_ERR_MEMC = 78, /* memory corruption */ 843ba16761SJacob Faibussowitsch PETSC_ERR_CONV_FAILED = 82, /* iterative method (KSP or SNES) failed */ 853ba16761SJacob Faibussowitsch PETSC_ERR_USER = 83, /* user has not provided needed function */ 863ba16761SJacob Faibussowitsch PETSC_ERR_SYS = 88, /* error in system call */ 873ba16761SJacob Faibussowitsch PETSC_ERR_POINTER = 70, /* pointer does not point to valid address */ 883ba16761SJacob Faibussowitsch PETSC_ERR_MPI_LIB_INCOMP = 87, /* MPI library at runtime is not compatible with MPI user compiled with */ 893ba16761SJacob Faibussowitsch 903ba16761SJacob Faibussowitsch PETSC_ERR_ARG_SIZ = 60, /* nonconforming object sizes used in operation */ 913ba16761SJacob Faibussowitsch PETSC_ERR_ARG_IDN = 61, /* two arguments not allowed to be the same */ 923ba16761SJacob Faibussowitsch PETSC_ERR_ARG_WRONG = 62, /* wrong argument (but object probably ok) */ 933ba16761SJacob Faibussowitsch PETSC_ERR_ARG_CORRUPT = 64, /* null or corrupted PETSc object as argument */ 943ba16761SJacob Faibussowitsch PETSC_ERR_ARG_OUTOFRANGE = 63, /* input argument, out of range */ 953ba16761SJacob Faibussowitsch PETSC_ERR_ARG_BADPTR = 68, /* invalid pointer argument */ 963ba16761SJacob Faibussowitsch PETSC_ERR_ARG_NOTSAMETYPE = 69, /* two args must be same object type */ 973ba16761SJacob Faibussowitsch PETSC_ERR_ARG_NOTSAMECOMM = 80, /* two args must be same communicators */ 983ba16761SJacob Faibussowitsch PETSC_ERR_ARG_WRONGSTATE = 73, /* object in argument is in wrong state, e.g. unassembled mat */ 993ba16761SJacob Faibussowitsch PETSC_ERR_ARG_TYPENOTSET = 89, /* the type of the object has not yet been set */ 1003ba16761SJacob Faibussowitsch PETSC_ERR_ARG_INCOMP = 75, /* two arguments are incompatible */ 1013ba16761SJacob Faibussowitsch PETSC_ERR_ARG_NULL = 85, /* argument is null that should not be */ 1023ba16761SJacob Faibussowitsch PETSC_ERR_ARG_UNKNOWN_TYPE = 86, /* type name doesn't match any registered type */ 1033ba16761SJacob Faibussowitsch 1043ba16761SJacob Faibussowitsch PETSC_ERR_FILE_OPEN = 65, /* unable to open file */ 1053ba16761SJacob Faibussowitsch PETSC_ERR_FILE_READ = 66, /* unable to read from file */ 1063ba16761SJacob Faibussowitsch PETSC_ERR_FILE_WRITE = 67, /* unable to write to file */ 1073ba16761SJacob Faibussowitsch PETSC_ERR_FILE_UNEXPECTED = 79, /* unexpected data in file */ 1083ba16761SJacob Faibussowitsch 1093ba16761SJacob Faibussowitsch PETSC_ERR_MAT_LU_ZRPVT = 71, /* detected a zero pivot during LU factorization */ 1103ba16761SJacob Faibussowitsch PETSC_ERR_MAT_CH_ZRPVT = 81, /* detected a zero pivot during Cholesky factorization */ 1113ba16761SJacob Faibussowitsch 1123ba16761SJacob Faibussowitsch PETSC_ERR_INT_OVERFLOW = 84, 1133ba16761SJacob Faibussowitsch PETSC_ERR_FLOP_COUNT = 90, 1143ba16761SJacob Faibussowitsch PETSC_ERR_NOT_CONVERGED = 91, /* solver did not converge */ 1153ba16761SJacob Faibussowitsch PETSC_ERR_MISSING_FACTOR = 92, /* MatGetFactor() failed */ 1163ba16761SJacob Faibussowitsch PETSC_ERR_OPT_OVERWRITE = 93, /* attempted to over write options which should not be changed */ 1173ba16761SJacob Faibussowitsch PETSC_ERR_WRONG_MPI_SIZE = 94, /* example/application run with number of MPI ranks it does not support */ 1183ba16761SJacob Faibussowitsch PETSC_ERR_USER_INPUT = 95, /* missing or incorrect user input */ 1193ba16761SJacob Faibussowitsch PETSC_ERR_GPU_RESOURCE = 96, /* unable to load a GPU resource, for example cuBLAS */ 1203ba16761SJacob Faibussowitsch PETSC_ERR_GPU = 97, /* An error from a GPU call, this may be due to lack of resources on the GPU or a true error in the call */ 1213ba16761SJacob Faibussowitsch PETSC_ERR_MPI = 98, /* general MPI error */ 1223ba16761SJacob Faibussowitsch PETSC_ERR_RETURN = 99, /* PetscError() incorrectly returned an error code of 0 */ 1233ba16761SJacob Faibussowitsch PETSC_ERR_MAX_VALUE = 100, /* this is always the one more than the largest error code */ 1243ba16761SJacob Faibussowitsch 1253ba16761SJacob Faibussowitsch /* 1263ba16761SJacob Faibussowitsch do not use, exist purely to make the enum bounds equal that of a regular int (so conversion 1273ba16761SJacob Faibussowitsch to int in main() is not undefined behavior) 1283ba16761SJacob Faibussowitsch */ 1293ba16761SJacob Faibussowitsch PETSC_ERR_MIN_SIGNED_BOUND_DO_NOT_USE = INT_MIN, 1303ba16761SJacob Faibussowitsch PETSC_ERR_MAX_SIGNED_BOUND_DO_NOT_USE = INT_MAX 1313ba16761SJacob Faibussowitsch } PETSC_ERROR_CODE_ENUM_NAME; 1323ba16761SJacob Faibussowitsch 1333ba16761SJacob Faibussowitsch #ifndef PETSC_USE_STRICT_PETSCERRORCODE 134df4397b0SStefano Zampini typedef int PetscErrorCode; 135df4397b0SStefano Zampini 1363ba16761SJacob Faibussowitsch /* 1373ba16761SJacob Faibussowitsch Needed so that C++ lambdas can deduce the return type as PetscErrorCode from 1383ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS). Otherwise we get 1393ba16761SJacob Faibussowitsch 1403ba16761SJacob Faibussowitsch error: return type '(unnamed enum at include/petscsystypes.h:50:1)' must match previous 1413ba16761SJacob Faibussowitsch return type 'int' when lambda expression has unspecified explicit return type 1423ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS); 1433ba16761SJacob Faibussowitsch ^ 1443ba16761SJacob Faibussowitsch */ 1453ba16761SJacob Faibussowitsch #define PETSC_SUCCESS ((PetscErrorCode)0) 1463ba16761SJacob Faibussowitsch #endif 1473ba16761SJacob Faibussowitsch 1483ba16761SJacob Faibussowitsch #undef PETSC_ERROR_CODE_NODISCARD 1493ba16761SJacob Faibussowitsch #undef PETSC_ERROR_CODE_TYPEDEF 1503ba16761SJacob Faibussowitsch #undef PETSC_ERROR_CODE_ENUM_NAME 1513ba16761SJacob Faibussowitsch 152df4397b0SStefano Zampini /*MC 153df4397b0SStefano Zampini PetscClassId - A unique id used to identify each PETSc class. 154df4397b0SStefano Zampini 15516a05f60SBarry Smith Level: developer 15616a05f60SBarry Smith 15716a05f60SBarry Smith Note: 15887497f52SBarry Smith Use `PetscClassIdRegister()` to obtain a new value for a new class being created. Usually 159df4397b0SStefano Zampini XXXInitializePackage() calls it for each class it defines. 160df4397b0SStefano Zampini 16116a05f60SBarry Smith Developer Note: 162667f096bSBarry Smith Internal integer stored in the `_p_PetscObject` data structure. These are all computed by an offset from the lowest one, `PETSC_SMALLEST_CLASSID`. 163df4397b0SStefano Zampini 164db781477SPatrick Sanan .seealso: `PetscClassIdRegister()`, `PetscLogEventRegister()`, `PetscHeaderCreate()` 165df4397b0SStefano Zampini M*/ 166df4397b0SStefano Zampini typedef int PetscClassId; 167df4397b0SStefano Zampini 168df4397b0SStefano Zampini /*MC 169df4397b0SStefano Zampini PetscMPIInt - datatype used to represent 'int' parameters to MPI functions. 170df4397b0SStefano Zampini 171df4397b0SStefano Zampini Level: intermediate 172df4397b0SStefano Zampini 173df4397b0SStefano Zampini Notes: 17416a05f60SBarry Smith 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 17587497f52SBarry Smith standard C/Fortran integers are 32 bit then this is NOT the same as `PetscInt`; it remains 32 bit. 176df4397b0SStefano Zampini 17787497f52SBarry Smith `PetscMPIIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscMPIInt`, if not it 17887497f52SBarry Smith generates a `PETSC_ERR_ARG_OUTOFRANGE` error. 179df4397b0SStefano Zampini 180db781477SPatrick Sanan .seealso: `PetscBLASInt`, `PetscInt`, `PetscMPIIntCast()` 181df4397b0SStefano Zampini M*/ 182df4397b0SStefano Zampini typedef int PetscMPIInt; 183df4397b0SStefano Zampini 184bf491261SJacob Faibussowitsch /* Limit MPI to 32-bits */ 185bf491261SJacob Faibussowitsch enum { 186bf491261SJacob Faibussowitsch PETSC_MPI_INT_MIN = INT_MIN, 187bf491261SJacob Faibussowitsch PETSC_MPI_INT_MAX = INT_MAX 188bf491261SJacob Faibussowitsch }; 189bf491261SJacob Faibussowitsch 190df4397b0SStefano Zampini /*MC 19116a05f60SBarry Smith PetscSizeT - datatype used to represent sizes in memory (like `size_t`) 1923edda6a2SJed Brown 1933edda6a2SJed Brown Level: intermediate 1943edda6a2SJed Brown 1953edda6a2SJed Brown Notes: 19616a05f60SBarry Smith This is equivalent to `size_t`, but defined for consistency with Fortran, which lacks a native equivalent of `size_t`. 1973edda6a2SJed Brown 198db781477SPatrick Sanan .seealso: `PetscInt`, `PetscInt64`, `PetscCount` 1993edda6a2SJed Brown M*/ 2003edda6a2SJed Brown typedef size_t PetscSizeT; 2013edda6a2SJed Brown 2023edda6a2SJed Brown /*MC 20382a78a4eSJed Brown PetscCount - signed datatype used to represent counts 20482a78a4eSJed Brown 20582a78a4eSJed Brown Level: intermediate 20682a78a4eSJed Brown 20782a78a4eSJed Brown Notes: 20816a05f60SBarry Smith This is equivalent to `ptrdiff_t`, but defined for consistency with Fortran, which lacks a native equivalent of `ptrdiff_t`. 20982a78a4eSJed Brown 21087497f52SBarry Smith Use `PetscCount_FMT` to format with `PetscPrintf()`, `printf()`, and related functions. 21182a78a4eSJed Brown 212db781477SPatrick Sanan .seealso: `PetscInt`, `PetscInt64`, `PetscSizeT` 21382a78a4eSJed Brown M*/ 21482a78a4eSJed Brown typedef ptrdiff_t PetscCount; 21563a3b9bcSJacob Faibussowitsch #define PetscCount_FMT "td" 21682a78a4eSJed Brown 21782a78a4eSJed Brown /*MC 218df4397b0SStefano Zampini PetscEnum - datatype used to pass enum types within PETSc functions. 219df4397b0SStefano Zampini 220df4397b0SStefano Zampini Level: intermediate 221df4397b0SStefano Zampini 222db781477SPatrick Sanan .seealso: `PetscOptionsGetEnum()`, `PetscOptionsEnum()`, `PetscBagRegisterEnum()` 223df4397b0SStefano Zampini M*/ 2249371c9d4SSatish Balay typedef enum { 2259371c9d4SSatish Balay ENUM_DUMMY 2269371c9d4SSatish Balay } PetscEnum; 227df4397b0SStefano Zampini 228df4397b0SStefano Zampini typedef short PetscShort; 229df4397b0SStefano Zampini typedef char PetscChar; 230df4397b0SStefano Zampini typedef float PetscFloat; 231df4397b0SStefano Zampini 232df4397b0SStefano Zampini /*MC 233df4397b0SStefano Zampini PetscInt - PETSc type that represents an integer, used primarily to 23416a05f60SBarry Smith 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. 235df4397b0SStefano Zampini 236667f096bSBarry Smith Level: beginner 237667f096bSBarry Smith 238df4397b0SStefano Zampini Notes: 23916a05f60SBarry Smith 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`. 240df4397b0SStefano Zampini 24116a05f60SBarry Smith .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PetscIntCast()` 242df4397b0SStefano Zampini M*/ 243df4397b0SStefano Zampini 244df4397b0SStefano Zampini #if defined(PETSC_HAVE_STDINT_H) 245df4397b0SStefano Zampini #include <stdint.h> 246df4397b0SStefano Zampini #endif 247df4397b0SStefano Zampini #if defined(PETSC_HAVE_INTTYPES_H) 248df4397b0SStefano Zampini #if !defined(__STDC_FORMAT_MACROS) 249df4397b0SStefano Zampini #define __STDC_FORMAT_MACROS /* required for using PRId64 from c++ */ 250df4397b0SStefano Zampini #endif 251df4397b0SStefano Zampini #include <inttypes.h> 252df4397b0SStefano Zampini #if !defined(PRId64) 253df4397b0SStefano Zampini #define PRId64 "ld" 254df4397b0SStefano Zampini #endif 255df4397b0SStefano Zampini #endif 256df4397b0SStefano Zampini 257df4397b0SStefano Zampini #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 */ 258df4397b0SStefano Zampini typedef int64_t PetscInt64; 259bf491261SJacob Faibussowitsch 260bf491261SJacob Faibussowitsch #define PETSC_INT64_MIN INT64_MIN 261bf491261SJacob Faibussowitsch #define PETSC_INT64_MAX INT64_MAX 262bf491261SJacob Faibussowitsch 263df4397b0SStefano Zampini #elif (PETSC_SIZEOF_LONG_LONG == 8) 264df4397b0SStefano Zampini typedef long long PetscInt64; 265bf491261SJacob Faibussowitsch 266bf491261SJacob Faibussowitsch #define PETSC_INT64_MIN LLONG_MIN 267bf491261SJacob Faibussowitsch #define PETSC_INT64_MAX LLONG_MAX 268bf491261SJacob Faibussowitsch 269df4397b0SStefano Zampini #elif defined(PETSC_HAVE___INT64) 270df4397b0SStefano Zampini typedef __int64 PetscInt64; 271bf491261SJacob Faibussowitsch 272bf491261SJacob Faibussowitsch #define PETSC_INT64_MIN INT64_MIN 273bf491261SJacob Faibussowitsch #define PETSC_INT64_MAX INT64_MAX 274bf491261SJacob Faibussowitsch 275df4397b0SStefano Zampini #else 276df4397b0SStefano Zampini #error "cannot determine PetscInt64 type" 277df4397b0SStefano Zampini #endif 278df4397b0SStefano Zampini 279df4397b0SStefano Zampini #if defined(PETSC_USE_64BIT_INDICES) 280df4397b0SStefano Zampini typedef PetscInt64 PetscInt; 281bf491261SJacob Faibussowitsch 282bf491261SJacob Faibussowitsch #define PETSC_INT_MIN PETSC_INT64_MIN 283bf491261SJacob Faibussowitsch #define PETSC_INT_MAX PETSC_INT64_MAX 284bf491261SJacob Faibussowitsch #define PetscInt_FMT PetscInt64_FMT 285df4397b0SStefano Zampini #else 286df4397b0SStefano Zampini typedef int PetscInt; 287bf491261SJacob Faibussowitsch 288bf491261SJacob Faibussowitsch enum { 289bf491261SJacob Faibussowitsch PETSC_INT_MIN = INT_MIN, 290bf491261SJacob Faibussowitsch PETSC_INT_MAX = INT_MAX 291bf491261SJacob Faibussowitsch }; 292bf491261SJacob Faibussowitsch 293bf491261SJacob Faibussowitsch #define PetscInt_FMT "d" 294df4397b0SStefano Zampini #endif 295df4397b0SStefano Zampini 296bf491261SJacob Faibussowitsch #define PETSC_MIN_INT PETSC_INT_MIN 297bf491261SJacob Faibussowitsch #define PETSC_MAX_INT PETSC_INT_MAX 298bf491261SJacob Faibussowitsch #define PETSC_MAX_UINT16 65535 299bf491261SJacob Faibussowitsch 300c93fae50SJacob Faibussowitsch #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 */ 301c93fae50SJacob Faibussowitsch #define MPIU_INT64 MPI_INT64_T 302c93fae50SJacob Faibussowitsch #define PetscInt64_FMT PRId64 303c93fae50SJacob Faibussowitsch #elif (PETSC_SIZEOF_LONG_LONG == 8) 304c93fae50SJacob Faibussowitsch #define MPIU_INT64 MPI_LONG_LONG_INT 305c93fae50SJacob Faibussowitsch #define PetscInt64_FMT "lld" 306c93fae50SJacob Faibussowitsch #elif defined(PETSC_HAVE___INT64) 307c93fae50SJacob Faibussowitsch #define MPIU_INT64 MPI_INT64_T 308c93fae50SJacob Faibussowitsch #define PetscInt64_FMT "ld" 309c93fae50SJacob Faibussowitsch #else 310c93fae50SJacob Faibussowitsch #error "cannot determine PetscInt64 type" 311c93fae50SJacob Faibussowitsch #endif 312c93fae50SJacob Faibussowitsch 313df4397b0SStefano Zampini /*MC 314df4397b0SStefano Zampini PetscBLASInt - datatype used to represent 'int' parameters to BLAS/LAPACK functions. 315df4397b0SStefano Zampini 316667f096bSBarry Smith Level: intermediate 317667f096bSBarry Smith 318df4397b0SStefano Zampini Notes: 31916a05f60SBarry Smith Usually this is the same as `PetscInt`, but if PETSc was built with `--with-64-bit-indices` but 32087497f52SBarry Smith standard C/Fortran integers are 32 bit then this may not be the same as `PetscInt`, 32187497f52SBarry Smith except on some BLAS/LAPACK implementations that support 64 bit integers see the notes below. 322df4397b0SStefano Zampini 32387497f52SBarry Smith `PetscErrorCode` `PetscBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscBLASInt`, if not it 32487497f52SBarry Smith generates a `PETSC_ERR_ARG_OUTOFRANGE` error 325df4397b0SStefano Zampini 326df4397b0SStefano Zampini Installation Notes: 32716a05f60SBarry Smith ./configure automatically determines the size of the integers used by BLAS/LAPACK except when `--with-batch` is used 32816a05f60SBarry Smith 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-indices` 329cdc6ee08SBarry Smith 330cdc6ee08SBarry Smith MATLAB ships with BLAS and LAPACK that use 64 bit integers, for example if you run ./configure with, the option 33116a05f60SBarry Smith `--with-blaslapack-lib`=[/Applications/MATLAB_R2010b.app/bin/maci64/libmwblas.dylib,/Applications/MATLAB_R2010b.app/bin/maci64/libmwlapack.dylib] 332df4397b0SStefano Zampini 33316a05f60SBarry Smith 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 33416a05f60SBarry Smith against the 64 bit version, otherwise it uses the 32 bit version 335df4397b0SStefano Zampini 33616a05f60SBarry Smith 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 337df4397b0SStefano Zampini 338df4397b0SStefano Zampini External packages such as hypre, ML, SuperLU etc do not provide any support for passing 64 bit integers to BLAS/LAPACK so cannot 339cdc6ee08SBarry Smith 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 340cdc6ee08SBarry Smith these external libraries while using 64 bit integer BLAS/LAPACK. 341df4397b0SStefano Zampini 342db781477SPatrick Sanan .seealso: `PetscMPIInt`, `PetscInt`, `PetscBLASIntCast()` 343df4397b0SStefano Zampini M*/ 344df4397b0SStefano Zampini #if defined(PETSC_HAVE_64BIT_BLAS_INDICES) 345df4397b0SStefano Zampini typedef PetscInt64 PetscBLASInt; 346bf491261SJacob Faibussowitsch 347bf491261SJacob Faibussowitsch #define PETSC_BLAS_INT_MIN PETSC_INT64_MIN 348bf491261SJacob Faibussowitsch #define PETSC_BLAS_INT_MAX PETSC_INT64_MAX 349bf491261SJacob Faibussowitsch #define PetscBLASInt_FMT PetscInt64_FMT 350df4397b0SStefano Zampini #else 351df4397b0SStefano Zampini typedef int PetscBLASInt; 352bf491261SJacob Faibussowitsch 353bf491261SJacob Faibussowitsch enum { 354bf491261SJacob Faibussowitsch PETSC_BLAS_INT_MIN = INT_MIN, 355bf491261SJacob Faibussowitsch PETSC_BLAS_INT_MAX = INT_MAX 356bf491261SJacob Faibussowitsch }; 357bf491261SJacob Faibussowitsch 358bf491261SJacob Faibussowitsch #define PetscBLASInt_FMT "d" 359df4397b0SStefano Zampini #endif 360df4397b0SStefano Zampini 361eee0c0a6SToby Isaac /*MC 362eee0c0a6SToby Isaac PetscCuBLASInt - datatype used to represent 'int' parameters to cuBLAS/cuSOLVER functions. 363eee0c0a6SToby Isaac 364667f096bSBarry Smith Level: intermediate 365667f096bSBarry Smith 366eee0c0a6SToby Isaac Notes: 367667f096bSBarry Smith As of this writing `PetscCuBLASInt` is always the system `int`. 368eee0c0a6SToby Isaac 36987497f52SBarry Smith `PetscErrorCode` `PetscCuBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscCuBLASInt`, if not it 37087497f52SBarry Smith generates a `PETSC_ERR_ARG_OUTOFRANGE` error 371eee0c0a6SToby Isaac 372db781477SPatrick Sanan .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscInt`, `PetscCuBLASIntCast()` 373eee0c0a6SToby Isaac M*/ 374eee0c0a6SToby Isaac typedef int PetscCuBLASInt; 375eee0c0a6SToby Isaac 376bf491261SJacob Faibussowitsch enum { 377bf491261SJacob Faibussowitsch PETSC_CUBLAS_INT_MIN = INT_MIN, 378bf491261SJacob Faibussowitsch PETSC_CUBLAS_INT_MAX = INT_MAX 379bf491261SJacob Faibussowitsch }; 380bf491261SJacob Faibussowitsch 38147d993e7Ssuyashtn /*MC 38247d993e7Ssuyashtn PetscHipBLASInt - datatype used to represent 'int' parameters to hipBLAS/hipSOLVER functions. 38347d993e7Ssuyashtn 38447d993e7Ssuyashtn Level: intermediate 38547d993e7Ssuyashtn 386667f096bSBarry Smith Notes: 387667f096bSBarry Smith As of this writing `PetscHipBLASInt` is always the system `int`. 38847d993e7Ssuyashtn 389667f096bSBarry Smith `PetscErrorCode` `PetscHipBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscHipBLASInt`, if not it 390667f096bSBarry Smith generates a `PETSC_ERR_ARG_OUTOFRANGE` error 391667f096bSBarry Smith 392667f096bSBarry Smith .seealso: PetscBLASInt, PetscMPIInt, PetscInt, PetscHipBLASIntCast() 39347d993e7Ssuyashtn M*/ 39447d993e7Ssuyashtn typedef int PetscHipBLASInt; 39547d993e7Ssuyashtn 396bf491261SJacob Faibussowitsch enum { 397bf491261SJacob Faibussowitsch PETSC_HIPBLAS_INT_MIN = INT_MIN, 398bf491261SJacob Faibussowitsch PETSC_HIPBLAS_INT_MAX = INT_MAX 399bf491261SJacob Faibussowitsch }; 400bf491261SJacob Faibussowitsch 401df4397b0SStefano Zampini /*E 402b94d7dedSBarry Smith PetscBool - Logical variable. Actually an enum in C and a logical in Fortran. 403df4397b0SStefano Zampini 404df4397b0SStefano Zampini Level: beginner 405df4397b0SStefano Zampini 406df4397b0SStefano Zampini Developer Note: 40787497f52SBarry Smith 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 408df4397b0SStefano Zampini boolean values. It is not easy to have a simple macro that that will work properly in all circumstances with all three mechanisms. 409df4397b0SStefano Zampini 410b94d7dedSBarry Smith .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PetscBool3` 411df4397b0SStefano Zampini E*/ 4129371c9d4SSatish Balay typedef enum { 4139371c9d4SSatish Balay PETSC_FALSE, 4149371c9d4SSatish Balay PETSC_TRUE 4159371c9d4SSatish Balay } PetscBool; 4163b590011SJacob Faibussowitsch PETSC_EXTERN const char *const PetscBools[]; 417df4397b0SStefano Zampini 418b94d7dedSBarry Smith /*E 419b94d7dedSBarry Smith PetscBool3 - Ternary logical variable. Actually an enum in C and a 4 byte integer in Fortran. 420b94d7dedSBarry Smith 421b94d7dedSBarry Smith Level: beginner 422b94d7dedSBarry Smith 42387497f52SBarry Smith Note: 424b94d7dedSBarry Smith Should not be used with the if (flg) or if (!flg) syntax. 425b94d7dedSBarry Smith 42690dd7910SPierre Jolivet .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PETSC_BOOL3_TRUE`, `PETSC_BOOL3_FALSE`, `PETSC_BOOL3_UNKNOWN` 427b94d7dedSBarry Smith E*/ 4289371c9d4SSatish Balay typedef enum { 4299371c9d4SSatish Balay PETSC_BOOL3_FALSE, 4309371c9d4SSatish Balay PETSC_BOOL3_TRUE, 4319371c9d4SSatish Balay PETSC_BOOL3_UNKNOWN = -1 4329371c9d4SSatish Balay } PetscBool3; 433b94d7dedSBarry Smith 434b94d7dedSBarry Smith #define PetscBool3ToBool(a) ((a) == PETSC_BOOL3_TRUE ? PETSC_TRUE : PETSC_FALSE) 435b94d7dedSBarry Smith #define PetscBoolToBool3(a) ((a) == PETSC_TRUE ? PETSC_BOOL3_TRUE : PETSC_BOOL3_FALSE) 436b94d7dedSBarry Smith 437df4397b0SStefano Zampini /*MC 43887497f52SBarry Smith PetscReal - PETSc type that represents a real number version of `PetscScalar` 439df4397b0SStefano Zampini 440667f096bSBarry Smith Level: beginner 441667f096bSBarry Smith 442df4397b0SStefano Zampini Notes: 44387497f52SBarry Smith For MPI calls that require datatypes, use `MPIU_REAL` as the datatype for `PetscReal` and `MPIU_SUM`, `MPIU_MAX`, etc. for operations. 44487497f52SBarry Smith They will automatically work correctly regardless of the size of `PetscReal`. 445df4397b0SStefano Zampini 44687497f52SBarry Smith See `PetscScalar` for details on how to ./configure the size of `PetscReal`. 447df4397b0SStefano Zampini 448db781477SPatrick Sanan .seealso: `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT` 449df4397b0SStefano Zampini M*/ 450df4397b0SStefano Zampini 451df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) 452df4397b0SStefano Zampini typedef float PetscReal; 453df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE) 454df4397b0SStefano Zampini typedef double PetscReal; 455df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 456df4397b0SStefano Zampini #if defined(__cplusplus) 457df4397b0SStefano Zampini extern "C" { 458df4397b0SStefano Zampini #endif 459df4397b0SStefano Zampini #include <quadmath.h> 460df4397b0SStefano Zampini #if defined(__cplusplus) 461df4397b0SStefano Zampini } 462df4397b0SStefano Zampini #endif 463df4397b0SStefano Zampini typedef __float128 PetscReal; 464df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FP16) 465df4397b0SStefano Zampini typedef __fp16 PetscReal; 466df4397b0SStefano Zampini #endif /* PETSC_USE_REAL_* */ 467df4397b0SStefano Zampini 468df4397b0SStefano Zampini /*MC 46987497f52SBarry Smith PetscComplex - PETSc type that represents a complex number with precision matching that of `PetscReal`. 470df4397b0SStefano Zampini 471df4397b0SStefano Zampini Synopsis: 472df4397b0SStefano Zampini #include <petscsys.h> 473df4397b0SStefano Zampini PetscComplex number = 1. + 2.*PETSC_i; 474df4397b0SStefano Zampini 475667f096bSBarry Smith Level: beginner 476667f096bSBarry Smith 477df4397b0SStefano Zampini Notes: 47887497f52SBarry Smith For MPI calls that require datatypes, use `MPIU_COMPLEX` as the datatype for `PetscComplex` and `MPIU_SUM` etc for operations. 47987497f52SBarry Smith They will automatically work correctly regardless of the size of `PetscComplex`. 480df4397b0SStefano Zampini 48116a05f60SBarry Smith See `PetscScalar` for details on how to ./configure the size of `PetscReal` 482df4397b0SStefano Zampini 483df4397b0SStefano Zampini Complex numbers are automatically available if PETSc was able to find a working complex implementation 484df4397b0SStefano Zampini 48516a05f60SBarry Smith PETSc has a 'fix' for complex numbers to support expressions such as `std::complex<PetscReal>` + `PetscInt`, which are not supported by the standard 48616a05f60SBarry Smith C++ library, but are convenient for petsc users. If the C++ compiler is able to compile code in `petsccxxcomplexfix.h` (This is checked by 48716a05f60SBarry Smith configure), we include `petsccxxcomplexfix.h` to provide this convenience. 488a966371cSJunchao Zhang 48987497f52SBarry Smith 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` 490a966371cSJunchao Zhang at the beginning of the C++ file to skip the fix. 491a966371cSJunchao Zhang 492db781477SPatrick Sanan .seealso: `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PETSC_i` 493df4397b0SStefano Zampini M*/ 494df4397b0SStefano Zampini #if !defined(PETSC_SKIP_COMPLEX) 4957a19d461SSatish Balay #if defined(PETSC_CLANGUAGE_CXX) 4967a19d461SSatish Balay #if !defined(PETSC_USE_REAL___FP16) && !defined(PETSC_USE_REAL___FLOAT128) 4977a19d461SSatish Balay #if defined(__cplusplus) && defined(PETSC_HAVE_CXX_COMPLEX) /* enable complex for library code */ 498df4397b0SStefano Zampini #define PETSC_HAVE_COMPLEX 1 499d5b43468SJose E. Roman #elif !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on library code complex support */ 5007a19d461SSatish Balay #define PETSC_HAVE_COMPLEX 1 5017a19d461SSatish Balay #endif 502450fc7c9SSatish Balay #elif defined(PETSC_USE_REAL___FLOAT128) && defined(PETSC_HAVE_C99_COMPLEX) 503450fc7c9SSatish Balay #define PETSC_HAVE_COMPLEX 1 5047a19d461SSatish Balay #endif 5057a19d461SSatish Balay #else /* !PETSC_CLANGUAGE_CXX */ 5067a19d461SSatish Balay #if !defined(PETSC_USE_REAL___FP16) 5077a19d461SSatish Balay #if !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) /* enable complex for library code */ 5087a19d461SSatish Balay #define PETSC_HAVE_COMPLEX 1 509d5b43468SJose E. Roman #elif defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on library code complex support */ 5107a19d461SSatish Balay #define PETSC_HAVE_COMPLEX 1 5117a19d461SSatish Balay #endif 5127a19d461SSatish Balay #endif 5137a19d461SSatish Balay #endif /* PETSC_CLANGUAGE_CXX */ 5147a19d461SSatish Balay #endif /* !PETSC_SKIP_COMPLEX */ 5157a19d461SSatish Balay 5167a19d461SSatish Balay #if defined(PETSC_HAVE_COMPLEX) 5177a19d461SSatish Balay #if defined(__cplusplus) /* C++ complex support */ 51811d22bbfSJunchao Zhang /* Locate a C++ complex template library */ 51911d22bbfSJunchao Zhang #if defined(PETSC_DESIRE_KOKKOS_COMPLEX) /* Defined in petscvec_kokkos.hpp for *.kokkos.cxx files */ 52011d22bbfSJunchao Zhang #define petsccomplexlib Kokkos 52111d22bbfSJunchao Zhang #include <Kokkos_Complex.hpp> 522022afdc5SJed Brown #elif defined(__CUDACC__) || defined(__HIPCC__) 523df4397b0SStefano Zampini #define petsccomplexlib thrust 524df4397b0SStefano Zampini #include <thrust/complex.h> 525450fc7c9SSatish Balay #elif defined(PETSC_USE_REAL___FLOAT128) 526450fc7c9SSatish Balay #include <complex.h> 527df4397b0SStefano Zampini #else 528df4397b0SStefano Zampini #define petsccomplexlib std 529df4397b0SStefano Zampini #include <complex> 530df4397b0SStefano Zampini #endif 53111d22bbfSJunchao Zhang 53211d22bbfSJunchao Zhang /* Define PetscComplex based on the precision */ 533df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) 534df4397b0SStefano Zampini typedef petsccomplexlib::complex<float> PetscComplex; 535df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE) 536df4397b0SStefano Zampini typedef petsccomplexlib::complex<double> PetscComplex; 537df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 538450fc7c9SSatish Balay typedef __complex128 PetscComplex; 53911d22bbfSJunchao Zhang #endif 54011d22bbfSJunchao Zhang 541a966371cSJunchao Zhang /* Include a PETSc C++ complex 'fix'. Check PetscComplex manual page for details */ 542a966371cSJunchao Zhang #if defined(PETSC_HAVE_CXX_COMPLEX_FIX) && !defined(PETSC_SKIP_CXX_COMPLEX_FIX) 54339829747SLisandro Dalcin #include <petsccxxcomplexfix.h> 54411d22bbfSJunchao Zhang #endif 5457a19d461SSatish Balay #else /* c99 complex support */ 546df4397b0SStefano Zampini #include <complex.h> 547df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) || defined(PETSC_USE_REAL___FP16) 548df4397b0SStefano Zampini typedef float _Complex PetscComplex; 549df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE) 550df4397b0SStefano Zampini typedef double _Complex PetscComplex; 551df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 552df4397b0SStefano Zampini typedef __complex128 PetscComplex; 553df4397b0SStefano Zampini #endif /* PETSC_USE_REAL_* */ 5547a19d461SSatish Balay #endif /* !__cplusplus */ 5557a19d461SSatish Balay #endif /* PETSC_HAVE_COMPLEX */ 556df4397b0SStefano Zampini 557df4397b0SStefano Zampini /*MC 558df4397b0SStefano Zampini PetscScalar - PETSc type that represents either a double precision real number, a double precision 559df4397b0SStefano Zampini complex number, a single precision real number, a __float128 real or complex or a __fp16 real - if the code is configured 56016a05f60SBarry Smith with `--with-scalar-type`=real,complex `--with-precision`=single,double,__float128,__fp16 561df4397b0SStefano Zampini 562df4397b0SStefano Zampini Level: beginner 563df4397b0SStefano Zampini 56416a05f60SBarry Smith Note: 56516a05f60SBarry Smith 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`. 56616a05f60SBarry Smith 567db781477SPatrick Sanan .seealso: `PetscReal`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PetscRealPart()`, `PetscImaginaryPart()` 568df4397b0SStefano Zampini M*/ 569df4397b0SStefano Zampini 5707a19d461SSatish Balay #if defined(PETSC_USE_COMPLEX) && defined(PETSC_HAVE_COMPLEX) 571df4397b0SStefano Zampini typedef PetscComplex PetscScalar; 572df4397b0SStefano Zampini #else /* PETSC_USE_COMPLEX */ 573df4397b0SStefano Zampini typedef PetscReal PetscScalar; 574df4397b0SStefano Zampini #endif /* PETSC_USE_COMPLEX */ 575df4397b0SStefano Zampini 576df4397b0SStefano Zampini /*E 57787497f52SBarry Smith PetscCopyMode - Determines how an array or `PetscObject` passed to certain functions is copied or retained by the aggregate `PetscObject` 578df4397b0SStefano Zampini 579df4397b0SStefano Zampini Level: beginner 580df4397b0SStefano Zampini 581667f096bSBarry Smith Values for array input: 582667f096bSBarry Smith + `PETSC_COPY_VALUES` - the array values are copied into new space, the user is free to reuse or delete the passed in array 583667f096bSBarry Smith . `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 58416a05f60SBarry Smith delete the array. The array MUST have been obtained with `PetscMalloc()`. Hence this mode cannot be used in Fortran. 585667f096bSBarry Smith - `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 586667f096bSBarry Smith the array but the user must delete the array after the object is destroyed. 5875d80c0bfSVaclav Hapla 588667f096bSBarry Smith Values for PetscObject: 589667f096bSBarry Smith + `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. 590667f096bSBarry Smith . `PETSC_OWN_POINTER` - the input `PetscObject` is referenced by pointer (with reference count), thus should not be modified by the user. 591667f096bSBarry Smith increases its reference count). 592667f096bSBarry Smith - `PETSC_USE_POINTER` - invalid for `PetscObject` inputs. 593*bdedc06fSMatthew G. Knepley 594*bdedc06fSMatthew G. Knepley .seealso: `PetcsInsertMode` 595df4397b0SStefano Zampini E*/ 5969371c9d4SSatish Balay typedef enum { 5979371c9d4SSatish Balay PETSC_COPY_VALUES, 5989371c9d4SSatish Balay PETSC_OWN_POINTER, 5999371c9d4SSatish Balay PETSC_USE_POINTER 6009371c9d4SSatish Balay } PetscCopyMode; 6013b590011SJacob Faibussowitsch PETSC_EXTERN const char *const PetscCopyModes[]; 602df4397b0SStefano Zampini 603df4397b0SStefano Zampini /*MC 60487497f52SBarry Smith PETSC_FALSE - False value of `PetscBool` 605df4397b0SStefano Zampini 606df4397b0SStefano Zampini Level: beginner 607df4397b0SStefano Zampini 608df4397b0SStefano Zampini Note: 609df4397b0SStefano Zampini Zero integer 610df4397b0SStefano Zampini 61187497f52SBarry Smith .seealso: `PetscBool`, `PetscBool3`, `PETSC_TRUE` 612df4397b0SStefano Zampini M*/ 613df4397b0SStefano Zampini 614df4397b0SStefano Zampini /*MC 61587497f52SBarry Smith PETSC_TRUE - True value of `PetscBool` 616df4397b0SStefano Zampini 617df4397b0SStefano Zampini Level: beginner 618df4397b0SStefano Zampini 619df4397b0SStefano Zampini Note: 620df4397b0SStefano Zampini Nonzero integer 621df4397b0SStefano Zampini 62287497f52SBarry Smith .seealso: `PetscBool`, `PetscBool3`, `PETSC_FALSE` 623df4397b0SStefano Zampini M*/ 624df4397b0SStefano Zampini 625df4397b0SStefano Zampini /*MC 626df4397b0SStefano Zampini PetscLogDouble - Used for logging times 627df4397b0SStefano Zampini 6286b3bf505SPatrick Sanan Level: developer 6296b3bf505SPatrick Sanan 630667f096bSBarry Smith Note: 631667f096bSBarry Smith Contains double precision numbers that are not used in the numerical computations, but rather in logging, timing etc. 632667f096bSBarry Smith 633*bdedc06fSMatthew G. Knepley .seealso: `PetscBool`, `PetscDataType` 634df4397b0SStefano Zampini M*/ 635df4397b0SStefano Zampini typedef double PetscLogDouble; 636df4397b0SStefano Zampini 637df4397b0SStefano Zampini /*E 638df4397b0SStefano Zampini PetscDataType - Used for handling different basic data types. 639df4397b0SStefano Zampini 640df4397b0SStefano Zampini Level: beginner 641df4397b0SStefano Zampini 642df4397b0SStefano Zampini Notes: 64387497f52SBarry Smith Use of this should be avoided if one can directly use `MPI_Datatype` instead. 644df4397b0SStefano Zampini 64587497f52SBarry Smith `PETSC_INT` is the datatype for a `PetscInt`, regardless of whether it is 4 or 8 bytes. 64687497f52SBarry Smith `PETSC_REAL`, `PETSC_COMPLEX` and `PETSC_SCALAR` are the datatypes for `PetscReal`, `PetscComplex` and `PetscScalar`, regardless of their sizes. 647277f51e8SBarry Smith 64887497f52SBarry Smith Developer Notes: 649df4397b0SStefano Zampini It would be nice if we could always just use MPI Datatypes, why can we not? 650df4397b0SStefano Zampini 65187497f52SBarry Smith If you change any values in `PetscDatatype` make sure you update their usage in 652fa131761SBarry Smith share/petsc/matlab/PetscBagRead.m and share/petsc/matlab/@PetscOpenSocket/read/write.m 65391e29162SBarry Smith 654667f096bSBarry Smith TODO: 655667f096bSBarry Smith Add PETSC_INT32 and remove use of improper `PETSC_ENUM` 656277f51e8SBarry Smith 657db781477SPatrick Sanan .seealso: `PetscBinaryRead()`, `PetscBinaryWrite()`, `PetscDataTypeToMPIDataType()`, 658db781477SPatrick Sanan `PetscDataTypeGetSize()` 659df4397b0SStefano Zampini E*/ 6609371c9d4SSatish Balay typedef enum { 6619371c9d4SSatish Balay PETSC_DATATYPE_UNKNOWN = 0, 6629371c9d4SSatish Balay PETSC_DOUBLE = 1, 6639371c9d4SSatish Balay PETSC_COMPLEX = 2, 6649371c9d4SSatish Balay PETSC_LONG = 3, 6659371c9d4SSatish Balay PETSC_SHORT = 4, 6669371c9d4SSatish Balay PETSC_FLOAT = 5, 6679371c9d4SSatish Balay PETSC_CHAR = 6, 6689371c9d4SSatish Balay PETSC_BIT_LOGICAL = 7, 6699371c9d4SSatish Balay PETSC_ENUM = 8, 6709371c9d4SSatish Balay PETSC_BOOL = 9, 6719371c9d4SSatish Balay PETSC___FLOAT128 = 10, 6729371c9d4SSatish Balay PETSC_OBJECT = 11, 6739371c9d4SSatish Balay PETSC_FUNCTION = 12, 6749371c9d4SSatish Balay PETSC_STRING = 13, 6759371c9d4SSatish Balay PETSC___FP16 = 14, 6769371c9d4SSatish Balay PETSC_STRUCT = 15, 6779371c9d4SSatish Balay PETSC_INT = 16, 67862e5d2d2SJDBetteridge PETSC_INT64 = 17, 67962e5d2d2SJDBetteridge PETSC_COUNT = 18 6809371c9d4SSatish Balay } PetscDataType; 6813b590011SJacob Faibussowitsch PETSC_EXTERN const char *const PetscDataTypes[]; 682df4397b0SStefano Zampini 683df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) 684df4397b0SStefano Zampini #define PETSC_REAL PETSC_FLOAT 6855117d392SLisandro Dalcin #elif defined(PETSC_USE_REAL_DOUBLE) 6865117d392SLisandro Dalcin #define PETSC_REAL PETSC_DOUBLE 687df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 688df4397b0SStefano Zampini #define PETSC_REAL PETSC___FLOAT128 689df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FP16) 690df4397b0SStefano Zampini #define PETSC_REAL PETSC___FP16 691df4397b0SStefano Zampini #else 692df4397b0SStefano Zampini #define PETSC_REAL PETSC_DOUBLE 693df4397b0SStefano Zampini #endif 6945117d392SLisandro Dalcin 6955117d392SLisandro Dalcin #if defined(PETSC_USE_COMPLEX) 6965117d392SLisandro Dalcin #define PETSC_SCALAR PETSC_COMPLEX 6975117d392SLisandro Dalcin #else 6985117d392SLisandro Dalcin #define PETSC_SCALAR PETSC_REAL 6995117d392SLisandro Dalcin #endif 7005117d392SLisandro Dalcin 701df4397b0SStefano Zampini #define PETSC_FORTRANADDR PETSC_LONG 702df4397b0SStefano Zampini 703df4397b0SStefano Zampini /*S 704df4397b0SStefano Zampini PetscToken - 'Token' used for managing tokenizing strings 705df4397b0SStefano Zampini 706df4397b0SStefano Zampini Level: intermediate 707df4397b0SStefano Zampini 708db781477SPatrick Sanan .seealso: `PetscTokenCreate()`, `PetscTokenFind()`, `PetscTokenDestroy()` 709df4397b0SStefano Zampini S*/ 710df4397b0SStefano Zampini typedef struct _p_PetscToken *PetscToken; 711df4397b0SStefano Zampini 712df4397b0SStefano Zampini /*S 71387497f52SBarry Smith PetscObject - any PETSc object, `PetscViewer`, `Mat`, `Vec`, `KSP` etc 714df4397b0SStefano Zampini 715df4397b0SStefano Zampini Level: beginner 716df4397b0SStefano Zampini 71787497f52SBarry Smith Notes: 718df4397b0SStefano Zampini This is the base class from which all PETSc objects are derived from. 719df4397b0SStefano Zampini 72087497f52SBarry Smith In certain situations one can cast an object, for example a `Vec`, to a `PetscObject` with (`PetscObject`)vec 72187497f52SBarry Smith 722db781477SPatrick Sanan .seealso: `PetscObjectDestroy()`, `PetscObjectView()`, `PetscObjectGetName()`, `PetscObjectSetName()`, `PetscObjectReference()`, `PetscObjectDereference()` 723df4397b0SStefano Zampini S*/ 724df4397b0SStefano Zampini typedef struct _p_PetscObject *PetscObject; 725df4397b0SStefano Zampini 726df4397b0SStefano Zampini /*MC 72787497f52SBarry Smith PetscObjectId - unique integer Id for a `PetscObject` 728df4397b0SStefano Zampini 729df4397b0SStefano Zampini Level: developer 730df4397b0SStefano Zampini 73187497f52SBarry Smith Note: 73287497f52SBarry Smith 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 73387497f52SBarry Smith if the objects are the same. Never compare two object pointer values. 734df4397b0SStefano Zampini 735db781477SPatrick Sanan .seealso: `PetscObjectState`, `PetscObjectGetId()` 736df4397b0SStefano Zampini M*/ 737df4397b0SStefano Zampini typedef PetscInt64 PetscObjectId; 738df4397b0SStefano Zampini 739df4397b0SStefano Zampini /*MC 74087497f52SBarry Smith PetscObjectState - integer state for a `PetscObject` 741df4397b0SStefano Zampini 742df4397b0SStefano Zampini Level: developer 743df4397b0SStefano Zampini 744df4397b0SStefano Zampini Notes: 745df4397b0SStefano Zampini Object state is always-increasing and (for objects that track state) can be used to determine if an object has 746df4397b0SStefano Zampini changed since the last time you interacted with it. It is 64-bit so that it will not overflow for a very long time. 747df4397b0SStefano Zampini 748db781477SPatrick Sanan .seealso: `PetscObjectId`, `PetscObjectStateGet()`, `PetscObjectStateIncrease()`, `PetscObjectStateSet()` 749df4397b0SStefano Zampini M*/ 750df4397b0SStefano Zampini typedef PetscInt64 PetscObjectState; 751df4397b0SStefano Zampini 752df4397b0SStefano Zampini /*S 753df4397b0SStefano Zampini PetscFunctionList - Linked list of functions, possibly stored in dynamic libraries, accessed 754df4397b0SStefano Zampini by string name 755df4397b0SStefano Zampini 756df4397b0SStefano Zampini Level: advanced 757df4397b0SStefano Zampini 758db781477SPatrick Sanan .seealso: `PetscFunctionListAdd()`, `PetscFunctionListDestroy()` 759df4397b0SStefano Zampini S*/ 760df4397b0SStefano Zampini typedef struct _n_PetscFunctionList *PetscFunctionList; 761df4397b0SStefano Zampini 762df4397b0SStefano Zampini /*E 763df4397b0SStefano Zampini PetscFileMode - Access mode for a file. 764df4397b0SStefano Zampini 765667f096bSBarry Smith Values: 766667f096bSBarry Smith + `FILE_MODE_UNDEFINED` - initial invalid value 767667f096bSBarry Smith . `FILE_MODE_READ` - open a file at its beginning for reading 768667f096bSBarry Smith . `FILE_MODE_WRITE` - open a file at its beginning for writing (will create if the file does not exist) 769667f096bSBarry Smith . `FILE_MODE_APPEND` - open a file at end for writing 770667f096bSBarry Smith . `FILE_MODE_UPDATE` - open a file for updating, meaning for reading and writing 771667f096bSBarry Smith - `FILE_MODE_APPEND_UPDATE` - open a file for updating, meaning for reading and writing, at the end 772df4397b0SStefano Zampini 77316a05f60SBarry Smith Level: beginner 77416a05f60SBarry Smith 775db781477SPatrick Sanan .seealso: `PetscViewerFileSetMode()` 776df4397b0SStefano Zampini E*/ 7779371c9d4SSatish Balay typedef enum { 7789371c9d4SSatish Balay FILE_MODE_UNDEFINED = -1, 7799371c9d4SSatish Balay FILE_MODE_READ = 0, 7809371c9d4SSatish Balay FILE_MODE_WRITE, 7819371c9d4SSatish Balay FILE_MODE_APPEND, 7829371c9d4SSatish Balay FILE_MODE_UPDATE, 7839371c9d4SSatish Balay FILE_MODE_APPEND_UPDATE 7849371c9d4SSatish Balay } PetscFileMode; 7853b590011SJacob Faibussowitsch PETSC_EXTERN const char *const PetscFileModes[]; 786df4397b0SStefano Zampini 787df4397b0SStefano Zampini typedef void *PetscDLHandle; 7889371c9d4SSatish Balay typedef enum { 7899371c9d4SSatish Balay PETSC_DL_DECIDE = 0, 7909371c9d4SSatish Balay PETSC_DL_NOW = 1, 7919371c9d4SSatish Balay PETSC_DL_LOCAL = 2 7929371c9d4SSatish Balay } PetscDLMode; 793df4397b0SStefano Zampini 794df4397b0SStefano Zampini /*S 7957243573dSPierre Jolivet PetscObjectList - Linked list of PETSc objects, each accessible by string name 796df4397b0SStefano Zampini 797df4397b0SStefano Zampini Level: developer 798df4397b0SStefano Zampini 79987497f52SBarry Smith Note: 80087497f52SBarry Smith Used by `PetscObjectCompose()` and `PetscObjectQuery()` 801df4397b0SStefano Zampini 802db781477SPatrick Sanan .seealso: `PetscObjectListAdd()`, `PetscObjectListDestroy()`, `PetscObjectListFind()`, `PetscObjectCompose()`, `PetscObjectQuery()`, `PetscFunctionList` 803df4397b0SStefano Zampini S*/ 804df4397b0SStefano Zampini typedef struct _n_PetscObjectList *PetscObjectList; 805df4397b0SStefano Zampini 806df4397b0SStefano Zampini /*S 807667f096bSBarry Smith PetscDLLibrary - Linked list of dynamic libraries to search for functions 808df4397b0SStefano Zampini 80916a05f60SBarry Smith Level: developer 810df4397b0SStefano Zampini 811db781477SPatrick Sanan .seealso: `PetscDLLibraryOpen()` 812df4397b0SStefano Zampini S*/ 813df4397b0SStefano Zampini typedef struct _n_PetscDLLibrary *PetscDLLibrary; 814df4397b0SStefano Zampini 815df4397b0SStefano Zampini /*S 816df4397b0SStefano Zampini PetscContainer - Simple PETSc object that contains a pointer to any required data 817df4397b0SStefano Zampini 818df4397b0SStefano Zampini Level: advanced 819df4397b0SStefano Zampini 82087497f52SBarry Smith Note: 82187497f52SBarry Smith This is useful to attach arbitrary data to a `PetscObject` with `PetscObjectCompose()` and `PetscObjectQuery()` 82287497f52SBarry Smith 82387497f52SBarry Smith .seealso: `PetscObject`, `PetscContainerCreate()`, `PetscObjectCompose()`, `PetscObjectQuery()` 824df4397b0SStefano Zampini S*/ 825df4397b0SStefano Zampini typedef struct _p_PetscContainer *PetscContainer; 826df4397b0SStefano Zampini 827df4397b0SStefano Zampini /*S 828df4397b0SStefano Zampini PetscRandom - Abstract PETSc object that manages generating random numbers 829df4397b0SStefano Zampini 830df4397b0SStefano Zampini Level: intermediate 831df4397b0SStefano Zampini 832db781477SPatrick Sanan .seealso: `PetscRandomCreate()`, `PetscRandomGetValue()`, `PetscRandomType` 833df4397b0SStefano Zampini S*/ 834df4397b0SStefano Zampini typedef struct _p_PetscRandom *PetscRandom; 835df4397b0SStefano Zampini 836df4397b0SStefano Zampini /* 837df4397b0SStefano Zampini In binary files variables are stored using the following lengths, 838df4397b0SStefano Zampini regardless of how they are stored in memory on any one particular 839df4397b0SStefano Zampini machine. Use these rather then sizeof() in computing sizes for 840df4397b0SStefano Zampini PetscBinarySeek(). 841df4397b0SStefano Zampini */ 842df4397b0SStefano Zampini #define PETSC_BINARY_INT_SIZE (32 / 8) 843df4397b0SStefano Zampini #define PETSC_BINARY_FLOAT_SIZE (32 / 8) 844df4397b0SStefano Zampini #define PETSC_BINARY_CHAR_SIZE (8 / 8) 845df4397b0SStefano Zampini #define PETSC_BINARY_SHORT_SIZE (16 / 8) 846df4397b0SStefano Zampini #define PETSC_BINARY_DOUBLE_SIZE (64 / 8) 847df4397b0SStefano Zampini #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar) 848df4397b0SStefano Zampini 849df4397b0SStefano Zampini /*E 85087497f52SBarry Smith PetscBinarySeekType - argument to `PetscBinarySeek()` 851df4397b0SStefano Zampini 85216a05f60SBarry Smith Values: 85316a05f60SBarry Smith + `PETSC_BINARY_SEEK_SET` - offset is an absolute location in the file 85416a05f60SBarry Smith . `PETSC_BINARY_SEEK_CUR` - offset is an offset from the current location of the file pointer 85516a05f60SBarry Smith - `PETSC_BINARY_SEEK_END` - offset is an offset from the end of the file 85616a05f60SBarry Smith 857df4397b0SStefano Zampini Level: advanced 858df4397b0SStefano Zampini 859db781477SPatrick Sanan .seealso: `PetscBinarySeek()`, `PetscBinarySynchronizedSeek()` 860df4397b0SStefano Zampini E*/ 8619371c9d4SSatish Balay typedef enum { 8629371c9d4SSatish Balay PETSC_BINARY_SEEK_SET = 0, 8639371c9d4SSatish Balay PETSC_BINARY_SEEK_CUR = 1, 8649371c9d4SSatish Balay PETSC_BINARY_SEEK_END = 2 8659371c9d4SSatish Balay } PetscBinarySeekType; 866df4397b0SStefano Zampini 867df4397b0SStefano Zampini /*E 86816a05f60SBarry Smith PetscBuildTwoSidedType - algorithm for setting up two-sided communication for use with `PetscSF` 869df4397b0SStefano Zampini 870667f096bSBarry Smith Values: 871667f096bSBarry Smith + `PETSC_BUILDTWOSIDED_ALLREDUCE` - classical algorithm using an `MPI_Allreduce()` with 872667f096bSBarry Smith a buffer of length equal to the communicator size. Not memory-scalable due to 87316a05f60SBarry Smith the large reduction size. Requires only an MPI-1 implementation. 874667f096bSBarry Smith . `PETSC_BUILDTWOSIDED_IBARRIER` - nonblocking algorithm based on `MPI_Issend()` and `MPI_Ibarrier()`. 87516a05f60SBarry Smith Proved communication-optimal in Hoefler, Siebert, and Lumsdaine (2010). Requires an MPI-3 implementation. 876667f096bSBarry Smith - `PETSC_BUILDTWOSIDED_REDSCATTER` - similar to above, but use more optimized function 87716a05f60SBarry Smith that only communicates the part of the reduction that is necessary. Requires an MPI-2 implementation. 878df4397b0SStefano Zampini 879df4397b0SStefano Zampini Level: developer 880df4397b0SStefano Zampini 881db781477SPatrick Sanan .seealso: `PetscCommBuildTwoSided()`, `PetscCommBuildTwoSidedSetType()`, `PetscCommBuildTwoSidedGetType()` 882df4397b0SStefano Zampini E*/ 883df4397b0SStefano Zampini typedef enum { 884df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_NOTSET = -1, 885df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_ALLREDUCE = 0, 886df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_IBARRIER = 1, 887df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_REDSCATTER = 2 888df4397b0SStefano Zampini /* Updates here must be accompanied by updates in finclude/petscsys.h and the string array in mpits.c */ 889df4397b0SStefano Zampini } PetscBuildTwoSidedType; 8903b590011SJacob Faibussowitsch PETSC_EXTERN const char *const PetscBuildTwoSidedTypes[]; 891df4397b0SStefano Zampini 892aa2d33c1SMatthew G. Knepley /* NOTE: If you change this, you must also change the values in src/vec/f90-mod/petscvec.h */ 893df4397b0SStefano Zampini /*E 894667f096bSBarry Smith InsertMode - How the entries are combined with the current values in the vectors or matrices 895df4397b0SStefano Zampini 896667f096bSBarry Smith Values: 897667f096bSBarry Smith + `NOT_SET_VALUES` - do not actually use the values 898667f096bSBarry Smith . `INSERT_VALUES` - replace the current values with the provided values, unless the index is marked as constrained by the `PetscSection` 899667f096bSBarry Smith . `ADD_VALUES` - add the values to the current values, unless the index is marked as constrained by the `PetscSection` 900667f096bSBarry Smith . `MAX_VALUES` - use the maximum of each current value and provided value 901667f096bSBarry Smith . `MIN_VALUES` - use the minimum of each current value and provided value 902667f096bSBarry Smith . `INSERT_ALL_VALUES` - insert, even if indices that are not marked as constrained by the `PetscSection` 903667f096bSBarry Smith . `ADD_ALL_VALUES` - add, even if indices that are not marked as constrained by the `PetscSection` 904667f096bSBarry Smith . `INSERT_BC_VALUES` - insert, but ignore indices that are not marked as constrained by the `PetscSection` 905667f096bSBarry Smith - `ADD_BC_VALUES` - add, but ignore indices that are not marked as constrained by the `PetscSection` 906667f096bSBarry Smith 90716a05f60SBarry Smith Level: beginner 90816a05f60SBarry Smith 909667f096bSBarry Smith Note: 910667f096bSBarry Smith The `PetscSection` that determines the effects of the `InsertMode` values can be obtained by the `Vec` object with `VecGetDM()` 911667f096bSBarry Smith and `DMGetLocalSection()`. 912667f096bSBarry Smith 913667f096bSBarry Smith Not all options are supported for all operations or PETSc object types. 914667f096bSBarry Smith 915db781477SPatrick Sanan .seealso: `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, 916db781477SPatrick Sanan `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, 917db781477SPatrick Sanan `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()` 918df4397b0SStefano Zampini E*/ 9199371c9d4SSatish Balay typedef enum { 9209371c9d4SSatish Balay NOT_SET_VALUES, 9219371c9d4SSatish Balay INSERT_VALUES, 9229371c9d4SSatish Balay ADD_VALUES, 9239371c9d4SSatish Balay MAX_VALUES, 9249371c9d4SSatish Balay MIN_VALUES, 9259371c9d4SSatish Balay INSERT_ALL_VALUES, 9269371c9d4SSatish Balay ADD_ALL_VALUES, 9279371c9d4SSatish Balay INSERT_BC_VALUES, 9289371c9d4SSatish Balay ADD_BC_VALUES 9299371c9d4SSatish Balay } InsertMode; 930df4397b0SStefano Zampini 931df4397b0SStefano Zampini /*MC 932df4397b0SStefano Zampini INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value 933df4397b0SStefano Zampini 934df4397b0SStefano Zampini Level: beginner 935df4397b0SStefano Zampini 936db781477SPatrick Sanan .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, 937db781477SPatrick Sanan `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `ADD_VALUES`, 938db781477SPatrick Sanan `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES` 939df4397b0SStefano Zampini M*/ 940df4397b0SStefano Zampini 941df4397b0SStefano Zampini /*MC 942df4397b0SStefano Zampini ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the 943df4397b0SStefano Zampini value into that location 944df4397b0SStefano Zampini 945df4397b0SStefano Zampini Level: beginner 946df4397b0SStefano Zampini 947db781477SPatrick Sanan .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, 948db781477SPatrick Sanan `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `INSERT_VALUES`, 949db781477SPatrick Sanan `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES` 950df4397b0SStefano Zampini M*/ 951df4397b0SStefano Zampini 952df4397b0SStefano Zampini /*MC 953df4397b0SStefano Zampini MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location 954df4397b0SStefano Zampini 955df4397b0SStefano Zampini Level: beginner 956df4397b0SStefano Zampini 957db781477SPatrick Sanan .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES` 958df4397b0SStefano Zampini M*/ 959df4397b0SStefano Zampini 960421aa1e7SJunchao Zhang /*MC 961421aa1e7SJunchao Zhang MIN_VALUES - Puts the minimal of the scattered/gathered value and the current value into each location 962421aa1e7SJunchao Zhang 963421aa1e7SJunchao Zhang Level: beginner 964421aa1e7SJunchao Zhang 965db781477SPatrick Sanan .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES` 966421aa1e7SJunchao Zhang M*/ 967421aa1e7SJunchao Zhang 968df4397b0SStefano Zampini /*S 969df4397b0SStefano Zampini PetscSubcomm - A decomposition of an MPI communicator into subcommunicators 970df4397b0SStefano Zampini 971667f096bSBarry Smith Values: 972667f096bSBarry Smith + `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 973667f096bSBarry Smith . `PETSC_SUBCOMM_CONTIGUOUS` - each new communicator contains a set of process with contiguous ranks in the original MPI communicator 974667f096bSBarry Smith - `PETSC_SUBCOMM_INTERLACED` - each new communictor contains a set of processes equally far apart in rank from the others in that new communicator 975667f096bSBarry Smith 976df4397b0SStefano Zampini Sample Usage: 97787497f52SBarry Smith .vb 97816a05f60SBarry Smith PetscSubcommCreate() 97916a05f60SBarry Smith PetscSubcommSetNumber() 98016a05f60SBarry Smith PetscSubcommSetType(PETSC_SUBCOMM_INTERLACED); 98116a05f60SBarry Smith ccomm = PetscSubcommChild() 98216a05f60SBarry Smith PetscSubcommDestroy() 98387497f52SBarry Smith .ve 984df4397b0SStefano Zampini 985667f096bSBarry Smith Example: 986667f096bSBarry Smith Consider a communicator with six processes split into 3 subcommunicators. 987667f096bSBarry Smith .vb 98816a05f60SBarry Smith 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 98916a05f60SBarry Smith PETSC_SUBCOMM_INTERLACED - the first communicator contains rank 0,3, the second 1,4 and the third 2,5 990667f096bSBarry Smith .ve 991667f096bSBarry Smith 992df4397b0SStefano Zampini Level: advanced 993df4397b0SStefano Zampini 99416a05f60SBarry Smith Note: 99516a05f60SBarry Smith After a call to `PetscSubcommSetType()`, `PetscSubcommSetTypeGeneral()`, or `PetscSubcommSetFromOptions()` one may call 99616a05f60SBarry Smith .vb 99716a05f60SBarry Smith PetscSubcommChild() returns the associated subcommunicator on this process 99816a05f60SBarry Smith PetscSubcommContiguousParent() returns a parent communitor but with all child of the same subcommunicator having contiguous rank 99916a05f60SBarry Smith .ve 100016a05f60SBarry Smith 100187497f52SBarry Smith Developer Note: 100287497f52SBarry Smith This is used in objects such as `PCREDUNDANT` to manage the subcommunicators on which the redundant computations 1003df4397b0SStefano Zampini are performed. 1004df4397b0SStefano Zampini 1005db781477SPatrick Sanan .seealso: `PetscSubcommCreate()`, `PetscSubcommSetNumber()`, `PetscSubcommSetType()`, `PetscSubcommView()`, `PetscSubcommSetFromOptions()` 1006df4397b0SStefano Zampini S*/ 1007df4397b0SStefano Zampini typedef struct _n_PetscSubcomm *PetscSubcomm; 10089371c9d4SSatish Balay typedef enum { 10099371c9d4SSatish Balay PETSC_SUBCOMM_GENERAL = 0, 10109371c9d4SSatish Balay PETSC_SUBCOMM_CONTIGUOUS = 1, 10119371c9d4SSatish Balay PETSC_SUBCOMM_INTERLACED = 2 10129371c9d4SSatish Balay } PetscSubcommType; 10133b590011SJacob Faibussowitsch PETSC_EXTERN const char *const PetscSubcommTypes[]; 1014df4397b0SStefano Zampini 1015df4397b0SStefano Zampini /*S 1016df4397b0SStefano Zampini PetscHeap - A simple class for managing heaps 1017df4397b0SStefano Zampini 1018df4397b0SStefano Zampini Level: intermediate 1019df4397b0SStefano Zampini 1020db781477SPatrick Sanan .seealso: `PetscHeapCreate()`, `PetscHeapAdd()`, `PetscHeapPop()`, `PetscHeapPeek()`, `PetscHeapStash()`, `PetscHeapUnstash()`, `PetscHeapView()`, `PetscHeapDestroy()` 1021df4397b0SStefano Zampini S*/ 1022df4397b0SStefano Zampini typedef struct _PetscHeap *PetscHeap; 1023df4397b0SStefano Zampini 1024df4397b0SStefano Zampini typedef struct _n_PetscShmComm *PetscShmComm; 1025df4397b0SStefano Zampini typedef struct _n_PetscOmpCtrl *PetscOmpCtrl; 1026df4397b0SStefano Zampini 1027df4397b0SStefano Zampini /*S 1028df4397b0SStefano Zampini PetscSegBuffer - a segmented extendable buffer 1029df4397b0SStefano Zampini 1030df4397b0SStefano Zampini Level: developer 1031df4397b0SStefano Zampini 1032db781477SPatrick Sanan .seealso: `PetscSegBufferCreate()`, `PetscSegBufferGet()`, `PetscSegBufferExtract()`, `PetscSegBufferDestroy()` 1033df4397b0SStefano Zampini S*/ 1034df4397b0SStefano Zampini typedef struct _n_PetscSegBuffer *PetscSegBuffer; 1035df4397b0SStefano Zampini 1036df4397b0SStefano Zampini typedef struct _n_PetscOptionsHelpPrinted *PetscOptionsHelpPrinted; 1037df4397b0SStefano Zampini #endif 1038