126bd1501SBarry Smith #if !defined(PETSCSYSTYPES_H) 226bd1501SBarry Smith #define PETSCSYSTYPES_H 3df4397b0SStefano Zampini 4df4397b0SStefano Zampini #include <petscconf.h> 5e1bf4ed2SJacob Faibussowitsch #include <petscconf_poison.h> 6df4397b0SStefano Zampini #include <petscfix.h> 73edda6a2SJed Brown #include <stddef.h> 8df4397b0SStefano Zampini 9*ac09b921SBarry Smith /* SUBMANSEC = Sys */ 10*ac09b921SBarry Smith 11df4397b0SStefano Zampini /*MC 12df4397b0SStefano Zampini PetscErrorCode - datatype used for return error code from almost all PETSc functions 13df4397b0SStefano Zampini 14df4397b0SStefano Zampini Level: beginner 15df4397b0SStefano Zampini 16db781477SPatrick Sanan .seealso: `PetscCall()`, `SETERRQ()` 17df4397b0SStefano Zampini M*/ 18df4397b0SStefano Zampini typedef int PetscErrorCode; 19df4397b0SStefano Zampini 20df4397b0SStefano Zampini /*MC 21df4397b0SStefano Zampini 22df4397b0SStefano Zampini PetscClassId - A unique id used to identify each PETSc class. 23df4397b0SStefano Zampini 24df4397b0SStefano Zampini Notes: 25df4397b0SStefano Zampini Use PetscClassIdRegister() to obtain a new value for a new class being created. Usually 26df4397b0SStefano Zampini XXXInitializePackage() calls it for each class it defines. 27df4397b0SStefano Zampini 28df4397b0SStefano Zampini Developer Notes: 29df4397b0SStefano Zampini Internal integer stored in the _p_PetscObject data structure. 30df4397b0SStefano Zampini These are all computed by an offset from the lowest one, PETSC_SMALLEST_CLASSID. 31df4397b0SStefano Zampini 32df4397b0SStefano Zampini Level: developer 33df4397b0SStefano Zampini 34db781477SPatrick Sanan .seealso: `PetscClassIdRegister()`, `PetscLogEventRegister()`, `PetscHeaderCreate()` 35df4397b0SStefano Zampini M*/ 36df4397b0SStefano Zampini typedef int PetscClassId; 37df4397b0SStefano Zampini 38df4397b0SStefano Zampini /*MC 39df4397b0SStefano Zampini PetscMPIInt - datatype used to represent 'int' parameters to MPI functions. 40df4397b0SStefano Zampini 41df4397b0SStefano Zampini Level: intermediate 42df4397b0SStefano Zampini 43df4397b0SStefano Zampini Notes: 44df4397b0SStefano Zampini usually this is the same as PetscInt, but if PETSc was built with --with-64-bit-indices but 45df4397b0SStefano Zampini standard C/Fortran integers are 32 bit then this is NOT the same as PetscInt; it remains 32 bit. 46df4397b0SStefano Zampini 47df4397b0SStefano Zampini PetscMPIIntCast(a,&b) checks if the given PetscInt a will fit in a PetscMPIInt, if not it 48df4397b0SStefano Zampini generates a PETSC_ERR_ARG_OUTOFRANGE error. 49df4397b0SStefano Zampini 50db781477SPatrick Sanan .seealso: `PetscBLASInt`, `PetscInt`, `PetscMPIIntCast()` 51df4397b0SStefano Zampini 52df4397b0SStefano Zampini M*/ 53df4397b0SStefano Zampini typedef int PetscMPIInt; 54df4397b0SStefano Zampini 55df4397b0SStefano Zampini /*MC 563edda6a2SJed Brown PetscSizeT - datatype used to represent sizes in memory (like size_t) 573edda6a2SJed Brown 583edda6a2SJed Brown Level: intermediate 593edda6a2SJed Brown 603edda6a2SJed Brown Notes: 613edda6a2SJed Brown This is equivalent to size_t, but defined for consistency with Fortran, which lacks a native equivalent of size_t. 623edda6a2SJed Brown 63db781477SPatrick Sanan .seealso: `PetscInt`, `PetscInt64`, `PetscCount` 643edda6a2SJed Brown 653edda6a2SJed Brown M*/ 663edda6a2SJed Brown typedef size_t PetscSizeT; 673edda6a2SJed Brown 683edda6a2SJed Brown /*MC 6982a78a4eSJed Brown PetscCount - signed datatype used to represent counts 7082a78a4eSJed Brown 7182a78a4eSJed Brown Level: intermediate 7282a78a4eSJed Brown 7382a78a4eSJed Brown Notes: 7482a78a4eSJed Brown This is equivalent to ptrdiff_t, but defined for consistency with Fortran, which lacks a native equivalent of ptrdiff_t. 7582a78a4eSJed Brown 7682a78a4eSJed Brown Use PetscCount_FMT to format with PetscPrintf(), printf(), and related functions. 7782a78a4eSJed Brown 78db781477SPatrick Sanan .seealso: `PetscInt`, `PetscInt64`, `PetscSizeT` 7982a78a4eSJed Brown 8082a78a4eSJed Brown M*/ 8182a78a4eSJed Brown typedef ptrdiff_t PetscCount; 8263a3b9bcSJacob Faibussowitsch #define PetscCount_FMT "td" 8382a78a4eSJed Brown 8482a78a4eSJed Brown /*MC 85df4397b0SStefano Zampini PetscEnum - datatype used to pass enum types within PETSc functions. 86df4397b0SStefano Zampini 87df4397b0SStefano Zampini Level: intermediate 88df4397b0SStefano Zampini 89db781477SPatrick Sanan .seealso: `PetscOptionsGetEnum()`, `PetscOptionsEnum()`, `PetscBagRegisterEnum()` 90df4397b0SStefano Zampini M*/ 91df4397b0SStefano Zampini typedef enum { ENUM_DUMMY } PetscEnum; 92df4397b0SStefano Zampini 93df4397b0SStefano Zampini typedef short PetscShort; 94df4397b0SStefano Zampini typedef char PetscChar; 95df4397b0SStefano Zampini typedef float PetscFloat; 96df4397b0SStefano Zampini 97df4397b0SStefano Zampini /*MC 98df4397b0SStefano Zampini PetscInt - PETSc type that represents an integer, used primarily to 99df4397b0SStefano Zampini 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. 100df4397b0SStefano Zampini 101df4397b0SStefano Zampini Notes: 102df4397b0SStefano Zampini 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. 103df4397b0SStefano Zampini 104df4397b0SStefano Zampini Level: beginner 105df4397b0SStefano Zampini 106db781477SPatrick Sanan .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT` 107df4397b0SStefano Zampini M*/ 108df4397b0SStefano Zampini 109df4397b0SStefano Zampini #if defined(PETSC_HAVE_STDINT_H) 110df4397b0SStefano Zampini # include <stdint.h> 111df4397b0SStefano Zampini #endif 112df4397b0SStefano Zampini #if defined (PETSC_HAVE_INTTYPES_H) 113df4397b0SStefano Zampini # if !defined(__STDC_FORMAT_MACROS) 114df4397b0SStefano Zampini # define __STDC_FORMAT_MACROS /* required for using PRId64 from c++ */ 115df4397b0SStefano Zampini # endif 116df4397b0SStefano Zampini # include <inttypes.h> 117df4397b0SStefano Zampini # if !defined(PRId64) 118df4397b0SStefano Zampini # define PRId64 "ld" 119df4397b0SStefano Zampini # endif 120df4397b0SStefano Zampini #endif 121df4397b0SStefano Zampini 122df4397b0SStefano 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 */ 123df4397b0SStefano Zampini typedef int64_t PetscInt64; 124df4397b0SStefano Zampini #elif (PETSC_SIZEOF_LONG_LONG == 8) 125df4397b0SStefano Zampini typedef long long PetscInt64; 126df4397b0SStefano Zampini #elif defined(PETSC_HAVE___INT64) 127df4397b0SStefano Zampini typedef __int64 PetscInt64; 128df4397b0SStefano Zampini #else 129df4397b0SStefano Zampini # error "cannot determine PetscInt64 type" 130df4397b0SStefano Zampini #endif 131df4397b0SStefano Zampini 132df4397b0SStefano Zampini #if defined(PETSC_USE_64BIT_INDICES) 133df4397b0SStefano Zampini typedef PetscInt64 PetscInt; 134df4397b0SStefano Zampini #else 135df4397b0SStefano Zampini typedef int PetscInt; 136df4397b0SStefano Zampini #endif 137df4397b0SStefano Zampini 138c93fae50SJacob 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 */ 139c93fae50SJacob Faibussowitsch # define MPIU_INT64 MPI_INT64_T 140c93fae50SJacob Faibussowitsch # define PetscInt64_FMT PRId64 141c93fae50SJacob Faibussowitsch #elif (PETSC_SIZEOF_LONG_LONG == 8) 142c93fae50SJacob Faibussowitsch # define MPIU_INT64 MPI_LONG_LONG_INT 143c93fae50SJacob Faibussowitsch # define PetscInt64_FMT "lld" 144c93fae50SJacob Faibussowitsch #elif defined(PETSC_HAVE___INT64) 145c93fae50SJacob Faibussowitsch # define MPIU_INT64 MPI_INT64_T 146c93fae50SJacob Faibussowitsch # define PetscInt64_FMT "ld" 147c93fae50SJacob Faibussowitsch #else 148c93fae50SJacob Faibussowitsch # error "cannot determine PetscInt64 type" 149c93fae50SJacob Faibussowitsch #endif 150c93fae50SJacob Faibussowitsch 151df4397b0SStefano Zampini /*MC 152df4397b0SStefano Zampini PetscBLASInt - datatype used to represent 'int' parameters to BLAS/LAPACK functions. 153df4397b0SStefano Zampini 154df4397b0SStefano Zampini Notes: 155df4397b0SStefano Zampini Usually this is the same as PetscInt, but if PETSc was built with --with-64-bit-indices but 156df4397b0SStefano Zampini standard C/Fortran integers are 32 bit then this is NOT the same as PetscInt it remains 32 bit 157cdc6ee08SBarry Smith (except on very rare BLAS/LAPACK implementations that support 64 bit integers see the notes below). 158df4397b0SStefano Zampini 159df4397b0SStefano Zampini PetscErrorCode PetscBLASIntCast(a,&b) checks if the given PetscInt a will fit in a PetscBLASInt, if not it 160df4397b0SStefano Zampini generates a PETSC_ERR_ARG_OUTOFRANGE error 161df4397b0SStefano Zampini 162df4397b0SStefano Zampini Installation Notes: 163cdc6ee08SBarry Smith ./configure automatically determines the size of the integers used by BLAS/LAPACK except when --with-batch is used 164cdc6ee08SBarry 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-indice 165cdc6ee08SBarry Smith 166cdc6ee08SBarry Smith MATLAB ships with BLAS and LAPACK that use 64 bit integers, for example if you run ./configure with, the option 167df4397b0SStefano Zampini --with-blaslapack-lib=[/Applications/MATLAB_R2010b.app/bin/maci64/libmwblas.dylib,/Applications/MATLAB_R2010b.app/bin/maci64/libmwlapack.dylib] 168df4397b0SStefano Zampini 169cdc6ee08SBarry 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 170cdc6ee08SBarry Smith against the 64 bit version, otherwise it use the 32 bit version 171df4397b0SStefano Zampini 172cdc6ee08SBarry 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 173df4397b0SStefano Zampini 174df4397b0SStefano Zampini External packages such as hypre, ML, SuperLU etc do not provide any support for passing 64 bit integers to BLAS/LAPACK so cannot 175cdc6ee08SBarry 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 176cdc6ee08SBarry Smith these external libraries while using 64 bit integer BLAS/LAPACK. 177df4397b0SStefano Zampini 178df4397b0SStefano Zampini Level: intermediate 179df4397b0SStefano Zampini 180db781477SPatrick Sanan .seealso: `PetscMPIInt`, `PetscInt`, `PetscBLASIntCast()` 181df4397b0SStefano Zampini 182df4397b0SStefano Zampini M*/ 183df4397b0SStefano Zampini #if defined(PETSC_HAVE_64BIT_BLAS_INDICES) 184c93fae50SJacob Faibussowitsch # define PetscBLASInt_FMT PetscInt64_FMT 185df4397b0SStefano Zampini typedef PetscInt64 PetscBLASInt; 186df4397b0SStefano Zampini #else 187c93fae50SJacob Faibussowitsch # define PetscBLASInt_FMT "d" 188df4397b0SStefano Zampini typedef int PetscBLASInt; 189df4397b0SStefano Zampini #endif 190df4397b0SStefano Zampini 191eee0c0a6SToby Isaac /*MC 192eee0c0a6SToby Isaac PetscCuBLASInt - datatype used to represent 'int' parameters to cuBLAS/cuSOLVER functions. 193eee0c0a6SToby Isaac 194eee0c0a6SToby Isaac Notes: 195eee0c0a6SToby Isaac As of this writing PetscCuBLASInt is always the system `int`. 196eee0c0a6SToby Isaac 197eee0c0a6SToby Isaac PetscErrorCode PetscCuBLASIntCast(a,&b) checks if the given PetscInt a will fit in a PetscCuBLASInt, if not it 198eee0c0a6SToby Isaac generates a PETSC_ERR_ARG_OUTOFRANGE error 199eee0c0a6SToby Isaac 200eee0c0a6SToby Isaac Level: intermediate 201eee0c0a6SToby Isaac 202db781477SPatrick Sanan .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscInt`, `PetscCuBLASIntCast()` 203eee0c0a6SToby Isaac 204eee0c0a6SToby Isaac M*/ 205eee0c0a6SToby Isaac typedef int PetscCuBLASInt; 206eee0c0a6SToby Isaac 207df4397b0SStefano Zampini /*E 208df4397b0SStefano Zampini PetscBool - Logical variable. Actually an int in C and a logical in Fortran. 209df4397b0SStefano Zampini 210df4397b0SStefano Zampini Level: beginner 211df4397b0SStefano Zampini 212df4397b0SStefano Zampini Developer Note: 213df4397b0SStefano Zampini 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 214df4397b0SStefano Zampini boolean values. It is not easy to have a simple macro that that will work properly in all circumstances with all three mechanisms. 215df4397b0SStefano Zampini 216db781477SPatrick Sanan .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()` 217df4397b0SStefano Zampini E*/ 218df4397b0SStefano Zampini typedef enum { PETSC_FALSE,PETSC_TRUE } PetscBool; 219df4397b0SStefano Zampini 220df4397b0SStefano Zampini /*MC 221df4397b0SStefano Zampini PetscReal - PETSc type that represents a real number version of PetscScalar 222df4397b0SStefano Zampini 223df4397b0SStefano Zampini Notes: 224df4397b0SStefano Zampini For MPI calls that require datatypes, use MPIU_REAL as the datatype for PetscScalar and MPIU_SUM, MPIU_MAX, etc. for operations. 225df4397b0SStefano Zampini They will automatically work correctly regardless of the size of PetscReal. 226df4397b0SStefano Zampini 227df4397b0SStefano Zampini See PetscScalar for details on how to ./configure the size of PetscReal. 228df4397b0SStefano Zampini 229df4397b0SStefano Zampini Level: beginner 230df4397b0SStefano Zampini 231db781477SPatrick Sanan .seealso: `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT` 232df4397b0SStefano Zampini M*/ 233df4397b0SStefano Zampini 234df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) 235df4397b0SStefano Zampini typedef float PetscReal; 236df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE) 237df4397b0SStefano Zampini typedef double PetscReal; 238df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 239df4397b0SStefano Zampini # if defined(__cplusplus) 240df4397b0SStefano Zampini extern "C" { 241df4397b0SStefano Zampini # endif 242df4397b0SStefano Zampini # include <quadmath.h> 243df4397b0SStefano Zampini # if defined(__cplusplus) 244df4397b0SStefano Zampini } 245df4397b0SStefano Zampini # endif 246df4397b0SStefano Zampini typedef __float128 PetscReal; 247df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FP16) 248df4397b0SStefano Zampini typedef __fp16 PetscReal; 249df4397b0SStefano Zampini #endif /* PETSC_USE_REAL_* */ 250df4397b0SStefano Zampini 251df4397b0SStefano Zampini /*MC 252df4397b0SStefano Zampini PetscComplex - PETSc type that represents a complex number with precision matching that of PetscReal. 253df4397b0SStefano Zampini 254df4397b0SStefano Zampini Synopsis: 255df4397b0SStefano Zampini #include <petscsys.h> 256df4397b0SStefano Zampini PetscComplex number = 1. + 2.*PETSC_i; 257df4397b0SStefano Zampini 258df4397b0SStefano Zampini Notes: 259df4397b0SStefano Zampini For MPI calls that require datatypes, use MPIU_COMPLEX as the datatype for PetscComplex and MPIU_SUM etc for operations. 260df4397b0SStefano Zampini They will automatically work correctly regardless of the size of PetscComplex. 261df4397b0SStefano Zampini 262df4397b0SStefano Zampini See PetscScalar for details on how to ./configure the size of PetscReal 263df4397b0SStefano Zampini 264df4397b0SStefano Zampini Complex numbers are automatically available if PETSc was able to find a working complex implementation 265df4397b0SStefano Zampini 266a966371cSJunchao Zhang Petsc has a 'fix' for complex numbers to support expressions such as std::complex<PetscReal> + PetscInt, which are not supported by the standard 267a966371cSJunchao Zhang C++ library, but are convenient for petsc users. If the C++ compiler is able to compile code in petsccxxcomplexfix.h (This is checked by 268a966371cSJunchao Zhang configure), we include petsccxxcomplexfix.h to provide this convenience. 269a966371cSJunchao Zhang 270a966371cSJunchao Zhang 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 271a966371cSJunchao Zhang at the beginning of the C++ file to skip the fix. 272a966371cSJunchao Zhang 273df4397b0SStefano Zampini Level: beginner 274df4397b0SStefano Zampini 275db781477SPatrick Sanan .seealso: `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PETSC_i` 276df4397b0SStefano Zampini M*/ 277df4397b0SStefano Zampini #if !defined(PETSC_SKIP_COMPLEX) 2787a19d461SSatish Balay # if defined(PETSC_CLANGUAGE_CXX) 2797a19d461SSatish Balay # if !defined(PETSC_USE_REAL___FP16) && !defined(PETSC_USE_REAL___FLOAT128) 2807a19d461SSatish Balay # if defined(__cplusplus) && defined(PETSC_HAVE_CXX_COMPLEX) /* enable complex for library code */ 281df4397b0SStefano Zampini # define PETSC_HAVE_COMPLEX 1 2827a19d461SSatish Balay # elif !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on libary code complex support */ 2837a19d461SSatish Balay # define PETSC_HAVE_COMPLEX 1 2847a19d461SSatish Balay # endif 285450fc7c9SSatish Balay # elif defined(PETSC_USE_REAL___FLOAT128) && defined(PETSC_HAVE_C99_COMPLEX) 286450fc7c9SSatish Balay # define PETSC_HAVE_COMPLEX 1 2877a19d461SSatish Balay # endif 2887a19d461SSatish Balay # else /* !PETSC_CLANGUAGE_CXX */ 2897a19d461SSatish Balay # if !defined(PETSC_USE_REAL___FP16) 2907a19d461SSatish Balay # if !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) /* enable complex for library code */ 2917a19d461SSatish Balay # define PETSC_HAVE_COMPLEX 1 2927a19d461SSatish Balay # elif defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on libary code complex support */ 2937a19d461SSatish Balay # define PETSC_HAVE_COMPLEX 1 2947a19d461SSatish Balay # endif 2957a19d461SSatish Balay # endif 2967a19d461SSatish Balay # endif /* PETSC_CLANGUAGE_CXX */ 2977a19d461SSatish Balay #endif /* !PETSC_SKIP_COMPLEX */ 2987a19d461SSatish Balay 2997a19d461SSatish Balay #if defined(PETSC_HAVE_COMPLEX) 3007a19d461SSatish Balay #if defined(__cplusplus) /* C++ complex support */ 30111d22bbfSJunchao Zhang /* Locate a C++ complex template library */ 30211d22bbfSJunchao Zhang #if defined(PETSC_DESIRE_KOKKOS_COMPLEX) /* Defined in petscvec_kokkos.hpp for *.kokkos.cxx files */ 30311d22bbfSJunchao Zhang #define petsccomplexlib Kokkos 30411d22bbfSJunchao Zhang #include <Kokkos_Complex.hpp> 305022afdc5SJed Brown #elif defined(__CUDACC__) || defined(__HIPCC__) 306df4397b0SStefano Zampini #define petsccomplexlib thrust 307df4397b0SStefano Zampini #include <thrust/complex.h> 308450fc7c9SSatish Balay #elif defined(PETSC_USE_REAL___FLOAT128) 309450fc7c9SSatish Balay #include <complex.h> 310df4397b0SStefano Zampini #else 311df4397b0SStefano Zampini #define petsccomplexlib std 312df4397b0SStefano Zampini #include <complex> 313df4397b0SStefano Zampini #endif 31411d22bbfSJunchao Zhang 31511d22bbfSJunchao Zhang /* Define PetscComplex based on the precision */ 316df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) 317df4397b0SStefano Zampini typedef petsccomplexlib::complex<float> PetscComplex; 318df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE) 319df4397b0SStefano Zampini typedef petsccomplexlib::complex<double> PetscComplex; 320df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 321450fc7c9SSatish Balay typedef __complex128 PetscComplex; 32211d22bbfSJunchao Zhang #endif 32311d22bbfSJunchao Zhang 324a966371cSJunchao Zhang /* Include a PETSc C++ complex 'fix'. Check PetscComplex manual page for details */ 325a966371cSJunchao Zhang #if defined(PETSC_HAVE_CXX_COMPLEX_FIX) && !defined(PETSC_SKIP_CXX_COMPLEX_FIX) 32639829747SLisandro Dalcin #include <petsccxxcomplexfix.h> 32711d22bbfSJunchao Zhang #endif 3287a19d461SSatish Balay #else /* c99 complex support */ 329df4397b0SStefano Zampini #include <complex.h> 330df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) || defined(PETSC_USE_REAL___FP16) 331df4397b0SStefano Zampini typedef float _Complex PetscComplex; 332df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE) 333df4397b0SStefano Zampini typedef double _Complex PetscComplex; 334df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 335df4397b0SStefano Zampini typedef __complex128 PetscComplex; 336df4397b0SStefano Zampini #endif /* PETSC_USE_REAL_* */ 3377a19d461SSatish Balay #endif /* !__cplusplus */ 3387a19d461SSatish Balay #endif /* PETSC_HAVE_COMPLEX */ 339df4397b0SStefano Zampini 340df4397b0SStefano Zampini /*MC 341df4397b0SStefano Zampini PetscScalar - PETSc type that represents either a double precision real number, a double precision 342df4397b0SStefano Zampini complex number, a single precision real number, a __float128 real or complex or a __fp16 real - if the code is configured 343df4397b0SStefano Zampini with --with-scalar-type=real,complex --with-precision=single,double,__float128,__fp16 344df4397b0SStefano Zampini 345df4397b0SStefano Zampini Notes: 346df4397b0SStefano Zampini For MPI calls that require datatypes, use MPIU_SCALAR as the datatype for PetscScalar and MPIU_SUM, MPIU_MAX etc for operations. They will automatically work correctly regardless of the size of PetscScalar. 347df4397b0SStefano Zampini 348df4397b0SStefano Zampini Level: beginner 349df4397b0SStefano Zampini 350db781477SPatrick Sanan .seealso: `PetscReal`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PetscRealPart()`, `PetscImaginaryPart()` 351df4397b0SStefano Zampini M*/ 352df4397b0SStefano Zampini 3537a19d461SSatish Balay #if defined(PETSC_USE_COMPLEX) && defined(PETSC_HAVE_COMPLEX) 354df4397b0SStefano Zampini typedef PetscComplex PetscScalar; 355df4397b0SStefano Zampini #else /* PETSC_USE_COMPLEX */ 356df4397b0SStefano Zampini typedef PetscReal PetscScalar; 357df4397b0SStefano Zampini #endif /* PETSC_USE_COMPLEX */ 358df4397b0SStefano Zampini 359df4397b0SStefano Zampini /*E 3605d80c0bfSVaclav Hapla PetscCopyMode - Determines how an array or PetscObject passed to certain functions is copied or retained by the aggregate PetscObject 361df4397b0SStefano Zampini 362df4397b0SStefano Zampini Level: beginner 363df4397b0SStefano Zampini 3645d80c0bfSVaclav Hapla For the array input: 365df4397b0SStefano Zampini $ PETSC_COPY_VALUES - the array values are copied into new space, the user is free to reuse or delete the passed in array 366df4397b0SStefano Zampini $ 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 367df4397b0SStefano Zampini $ delete the array. The array MUST have been obtained with PetscMalloc(). Hence this mode cannot be used in Fortran. 368df4397b0SStefano Zampini $ 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 3695d80c0bfSVaclav Hapla $ the array but the user must delete the array after the object is destroyed. 3705d80c0bfSVaclav Hapla 3715d80c0bfSVaclav Hapla For the PetscObject input: 3725d80c0bfSVaclav Hapla $ 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. 3735d80c0bfSVaclav Hapla $ 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.) 3745d80c0bfSVaclav Hapla For either case above, the input PetscObject should be destroyed by the user when no longer needed (the aggregate object increases its reference count). 3755d80c0bfSVaclav Hapla $ PETSC_USE_POINTER - invalid for PetscObject inputs. 376df4397b0SStefano Zampini 377df4397b0SStefano Zampini E*/ 378df4397b0SStefano Zampini typedef enum {PETSC_COPY_VALUES, PETSC_OWN_POINTER, PETSC_USE_POINTER} PetscCopyMode; 379df4397b0SStefano Zampini 380df4397b0SStefano Zampini /*MC 381df4397b0SStefano Zampini PETSC_FALSE - False value of PetscBool 382df4397b0SStefano Zampini 383df4397b0SStefano Zampini Level: beginner 384df4397b0SStefano Zampini 385df4397b0SStefano Zampini Note: 386df4397b0SStefano Zampini Zero integer 387df4397b0SStefano Zampini 388db781477SPatrick Sanan .seealso: `PetscBool`, `PETSC_TRUE` 389df4397b0SStefano Zampini M*/ 390df4397b0SStefano Zampini 391df4397b0SStefano Zampini /*MC 392df4397b0SStefano Zampini PETSC_TRUE - True value of PetscBool 393df4397b0SStefano Zampini 394df4397b0SStefano Zampini Level: beginner 395df4397b0SStefano Zampini 396df4397b0SStefano Zampini Note: 397df4397b0SStefano Zampini Nonzero integer 398df4397b0SStefano Zampini 399db781477SPatrick Sanan .seealso: `PetscBool`, `PETSC_FALSE` 400df4397b0SStefano Zampini M*/ 401df4397b0SStefano Zampini 402df4397b0SStefano Zampini /*MC 403df4397b0SStefano Zampini PetscLogDouble - Used for logging times 404df4397b0SStefano Zampini 405df4397b0SStefano Zampini Notes: 406df4397b0SStefano Zampini Contains double precision numbers that are not used in the numerical computations, but rather in logging, timing etc. 407df4397b0SStefano Zampini 4086b3bf505SPatrick Sanan Level: developer 4096b3bf505SPatrick Sanan 410df4397b0SStefano Zampini M*/ 411df4397b0SStefano Zampini typedef double PetscLogDouble; 412df4397b0SStefano Zampini 413df4397b0SStefano Zampini /*E 414df4397b0SStefano Zampini PetscDataType - Used for handling different basic data types. 415df4397b0SStefano Zampini 416df4397b0SStefano Zampini Level: beginner 417df4397b0SStefano Zampini 418df4397b0SStefano Zampini Notes: 419df4397b0SStefano Zampini Use of this should be avoided if one can directly use MPI_Datatype instead. 420df4397b0SStefano Zampini 421277f51e8SBarry Smith PETSC_INT is the datatype for a PetscInt, regardless of whether it is 4 or 8 bytes. 422277f51e8SBarry Smith PETSC_REAL, PETSC_COMPLEX and PETSC_SCALAR are the datatypes for PetscReal, PetscComplex and PetscScalar, regardless of their sizes. 423277f51e8SBarry Smith 424df4397b0SStefano Zampini Developer comment: 425df4397b0SStefano Zampini It would be nice if we could always just use MPI Datatypes, why can we not? 426df4397b0SStefano Zampini 42791e29162SBarry Smith If you change any values in PetscDatatype make sure you update their usage in 428fa131761SBarry Smith share/petsc/matlab/PetscBagRead.m and share/petsc/matlab/@PetscOpenSocket/read/write.m 42991e29162SBarry Smith 430277f51e8SBarry Smith TODO: Add PETSC_INT32 and remove use of improper PETSC_ENUM 431277f51e8SBarry Smith 432db781477SPatrick Sanan .seealso: `PetscBinaryRead()`, `PetscBinaryWrite()`, `PetscDataTypeToMPIDataType()`, 433db781477SPatrick Sanan `PetscDataTypeGetSize()` 434df4397b0SStefano Zampini 435df4397b0SStefano Zampini E*/ 4362ebc710fSVaclav Hapla typedef enum {PETSC_DATATYPE_UNKNOWN = 0, 4372ebc710fSVaclav Hapla PETSC_DOUBLE = 1, PETSC_COMPLEX = 2, PETSC_LONG = 3, PETSC_SHORT = 4, PETSC_FLOAT = 5, 43849de050aSVaclav Hapla PETSC_CHAR = 6, PETSC_BIT_LOGICAL = 7, PETSC_ENUM = 8, PETSC_BOOL = 9, PETSC___FLOAT128 = 10, 439ea127267SVaclav Hapla PETSC_OBJECT = 11, PETSC_FUNCTION = 12, PETSC_STRING = 13, PETSC___FP16 = 14, PETSC_STRUCT = 15, 4409e3e4c22SLisandro Dalcin PETSC_INT = 16, PETSC_INT64 = 17} PetscDataType; 441df4397b0SStefano Zampini 442df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE) 443df4397b0SStefano Zampini # define PETSC_REAL PETSC_FLOAT 4445117d392SLisandro Dalcin #elif defined(PETSC_USE_REAL_DOUBLE) 4455117d392SLisandro Dalcin # define PETSC_REAL PETSC_DOUBLE 446df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128) 447df4397b0SStefano Zampini # define PETSC_REAL PETSC___FLOAT128 448df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FP16) 449df4397b0SStefano Zampini # define PETSC_REAL PETSC___FP16 450df4397b0SStefano Zampini #else 451df4397b0SStefano Zampini # define PETSC_REAL PETSC_DOUBLE 452df4397b0SStefano Zampini #endif 4535117d392SLisandro Dalcin 4545117d392SLisandro Dalcin #if defined(PETSC_USE_COMPLEX) 4555117d392SLisandro Dalcin # define PETSC_SCALAR PETSC_COMPLEX 4565117d392SLisandro Dalcin #else 4575117d392SLisandro Dalcin # define PETSC_SCALAR PETSC_REAL 4585117d392SLisandro Dalcin #endif 4595117d392SLisandro Dalcin 460df4397b0SStefano Zampini #define PETSC_FORTRANADDR PETSC_LONG 461df4397b0SStefano Zampini 462df4397b0SStefano Zampini /*S 463df4397b0SStefano Zampini PetscToken - 'Token' used for managing tokenizing strings 464df4397b0SStefano Zampini 465df4397b0SStefano Zampini Level: intermediate 466df4397b0SStefano Zampini 467db781477SPatrick Sanan .seealso: `PetscTokenCreate()`, `PetscTokenFind()`, `PetscTokenDestroy()` 468df4397b0SStefano Zampini S*/ 469df4397b0SStefano Zampini typedef struct _p_PetscToken* PetscToken; 470df4397b0SStefano Zampini 471df4397b0SStefano Zampini /*S 472df4397b0SStefano Zampini PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc 473df4397b0SStefano Zampini 474df4397b0SStefano Zampini Level: beginner 475df4397b0SStefano Zampini 476df4397b0SStefano Zampini Note: 477df4397b0SStefano Zampini This is the base class from which all PETSc objects are derived from. 478df4397b0SStefano Zampini 479db781477SPatrick Sanan .seealso: `PetscObjectDestroy()`, `PetscObjectView()`, `PetscObjectGetName()`, `PetscObjectSetName()`, `PetscObjectReference()`, `PetscObjectDereference()` 480df4397b0SStefano Zampini S*/ 481df4397b0SStefano Zampini typedef struct _p_PetscObject* PetscObject; 482df4397b0SStefano Zampini 483df4397b0SStefano Zampini /*MC 484df4397b0SStefano Zampini PetscObjectId - unique integer Id for a PetscObject 485df4397b0SStefano Zampini 486df4397b0SStefano Zampini Level: developer 487df4397b0SStefano Zampini 488df4397b0SStefano Zampini Notes: 489df4397b0SStefano Zampini Unlike pointer values, object ids are never reused. 490df4397b0SStefano Zampini 491db781477SPatrick Sanan .seealso: `PetscObjectState`, `PetscObjectGetId()` 492df4397b0SStefano Zampini M*/ 493df4397b0SStefano Zampini typedef PetscInt64 PetscObjectId; 494df4397b0SStefano Zampini 495df4397b0SStefano Zampini /*MC 496df4397b0SStefano Zampini PetscObjectState - integer state for a PetscObject 497df4397b0SStefano Zampini 498df4397b0SStefano Zampini Level: developer 499df4397b0SStefano Zampini 500df4397b0SStefano Zampini Notes: 501df4397b0SStefano Zampini Object state is always-increasing and (for objects that track state) can be used to determine if an object has 502df4397b0SStefano 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. 503df4397b0SStefano Zampini 504db781477SPatrick Sanan .seealso: `PetscObjectId`, `PetscObjectStateGet()`, `PetscObjectStateIncrease()`, `PetscObjectStateSet()` 505df4397b0SStefano Zampini M*/ 506df4397b0SStefano Zampini typedef PetscInt64 PetscObjectState; 507df4397b0SStefano Zampini 508df4397b0SStefano Zampini /*S 509df4397b0SStefano Zampini PetscFunctionList - Linked list of functions, possibly stored in dynamic libraries, accessed 510df4397b0SStefano Zampini by string name 511df4397b0SStefano Zampini 512df4397b0SStefano Zampini Level: advanced 513df4397b0SStefano Zampini 514db781477SPatrick Sanan .seealso: `PetscFunctionListAdd()`, `PetscFunctionListDestroy()` 515df4397b0SStefano Zampini S*/ 516df4397b0SStefano Zampini typedef struct _n_PetscFunctionList *PetscFunctionList; 517df4397b0SStefano Zampini 518df4397b0SStefano Zampini /*E 519df4397b0SStefano Zampini PetscFileMode - Access mode for a file. 520df4397b0SStefano Zampini 521df4397b0SStefano Zampini Level: beginner 522df4397b0SStefano Zampini 5237e4fd573SVaclav Hapla $ FILE_MODE_UNDEFINED - initial invalid value 524df4397b0SStefano Zampini $ FILE_MODE_READ - open a file at its beginning for reading 525df4397b0SStefano Zampini $ FILE_MODE_WRITE - open a file at its beginning for writing (will create if the file does not exist) 526df4397b0SStefano Zampini $ FILE_MODE_APPEND - open a file at end for writing 527df4397b0SStefano Zampini $ FILE_MODE_UPDATE - open a file for updating, meaning for reading and writing 528df4397b0SStefano Zampini $ FILE_MODE_APPEND_UPDATE - open a file for updating, meaning for reading and writing, at the end 529df4397b0SStefano Zampini 530db781477SPatrick Sanan .seealso: `PetscViewerFileSetMode()` 531df4397b0SStefano Zampini E*/ 5327e4fd573SVaclav Hapla typedef enum {FILE_MODE_UNDEFINED=-1, FILE_MODE_READ=0, FILE_MODE_WRITE, FILE_MODE_APPEND, FILE_MODE_UPDATE, FILE_MODE_APPEND_UPDATE} PetscFileMode; 533df4397b0SStefano Zampini 534df4397b0SStefano Zampini typedef void* PetscDLHandle; 535df4397b0SStefano Zampini typedef enum {PETSC_DL_DECIDE=0,PETSC_DL_NOW=1,PETSC_DL_LOCAL=2} PetscDLMode; 536df4397b0SStefano Zampini 537df4397b0SStefano Zampini /*S 5387243573dSPierre Jolivet PetscObjectList - Linked list of PETSc objects, each accessible by string name 539df4397b0SStefano Zampini 540df4397b0SStefano Zampini Level: developer 541df4397b0SStefano Zampini 542df4397b0SStefano Zampini Notes: 543df4397b0SStefano Zampini Used by PetscObjectCompose() and PetscObjectQuery() 544df4397b0SStefano Zampini 545db781477SPatrick Sanan .seealso: `PetscObjectListAdd()`, `PetscObjectListDestroy()`, `PetscObjectListFind()`, `PetscObjectCompose()`, `PetscObjectQuery()`, `PetscFunctionList` 546df4397b0SStefano Zampini S*/ 547df4397b0SStefano Zampini typedef struct _n_PetscObjectList *PetscObjectList; 548df4397b0SStefano Zampini 549df4397b0SStefano Zampini /*S 550df4397b0SStefano Zampini PetscDLLibrary - Linked list of dynamics libraries to search for functions 551df4397b0SStefano Zampini 552df4397b0SStefano Zampini Level: advanced 553df4397b0SStefano Zampini 554db781477SPatrick Sanan .seealso: `PetscDLLibraryOpen()` 555df4397b0SStefano Zampini S*/ 556df4397b0SStefano Zampini typedef struct _n_PetscDLLibrary *PetscDLLibrary; 557df4397b0SStefano Zampini 558df4397b0SStefano Zampini /*S 559df4397b0SStefano Zampini PetscContainer - Simple PETSc object that contains a pointer to any required data 560df4397b0SStefano Zampini 561df4397b0SStefano Zampini Level: advanced 562df4397b0SStefano Zampini 563db781477SPatrick Sanan .seealso: `PetscObject`, `PetscContainerCreate()` 564df4397b0SStefano Zampini S*/ 565df4397b0SStefano Zampini typedef struct _p_PetscContainer* PetscContainer; 566df4397b0SStefano Zampini 567df4397b0SStefano Zampini /*S 568df4397b0SStefano Zampini PetscRandom - Abstract PETSc object that manages generating random numbers 569df4397b0SStefano Zampini 570df4397b0SStefano Zampini Level: intermediate 571df4397b0SStefano Zampini 572db781477SPatrick Sanan .seealso: `PetscRandomCreate()`, `PetscRandomGetValue()`, `PetscRandomType` 573df4397b0SStefano Zampini S*/ 574df4397b0SStefano Zampini typedef struct _p_PetscRandom* PetscRandom; 575df4397b0SStefano Zampini 576df4397b0SStefano Zampini /* 577df4397b0SStefano Zampini In binary files variables are stored using the following lengths, 578df4397b0SStefano Zampini regardless of how they are stored in memory on any one particular 579df4397b0SStefano Zampini machine. Use these rather then sizeof() in computing sizes for 580df4397b0SStefano Zampini PetscBinarySeek(). 581df4397b0SStefano Zampini */ 582df4397b0SStefano Zampini #define PETSC_BINARY_INT_SIZE (32/8) 583df4397b0SStefano Zampini #define PETSC_BINARY_FLOAT_SIZE (32/8) 584df4397b0SStefano Zampini #define PETSC_BINARY_CHAR_SIZE (8/8) 585df4397b0SStefano Zampini #define PETSC_BINARY_SHORT_SIZE (16/8) 586df4397b0SStefano Zampini #define PETSC_BINARY_DOUBLE_SIZE (64/8) 587df4397b0SStefano Zampini #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar) 588df4397b0SStefano Zampini 589df4397b0SStefano Zampini /*E 590df4397b0SStefano Zampini PetscBinarySeekType - argument to PetscBinarySeek() 591df4397b0SStefano Zampini 592df4397b0SStefano Zampini Level: advanced 593df4397b0SStefano Zampini 594db781477SPatrick Sanan .seealso: `PetscBinarySeek()`, `PetscBinarySynchronizedSeek()` 595df4397b0SStefano Zampini E*/ 596df4397b0SStefano Zampini typedef enum {PETSC_BINARY_SEEK_SET = 0,PETSC_BINARY_SEEK_CUR = 1,PETSC_BINARY_SEEK_END = 2} PetscBinarySeekType; 597df4397b0SStefano Zampini 598df4397b0SStefano Zampini /*E 599df4397b0SStefano Zampini PetscBuildTwoSidedType - algorithm for setting up two-sided communication 600df4397b0SStefano Zampini 601df4397b0SStefano Zampini $ PETSC_BUILDTWOSIDED_ALLREDUCE - classical algorithm using an MPI_Allreduce with 602df4397b0SStefano Zampini $ a buffer of length equal to the communicator size. Not memory-scalable due to 603df4397b0SStefano Zampini $ the large reduction size. Requires only MPI-1. 604df4397b0SStefano Zampini $ PETSC_BUILDTWOSIDED_IBARRIER - nonblocking algorithm based on MPI_Issend and MPI_Ibarrier. 605df4397b0SStefano Zampini $ Proved communication-optimal in Hoefler, Siebert, and Lumsdaine (2010). Requires MPI-3. 606df4397b0SStefano Zampini $ PETSC_BUILDTWOSIDED_REDSCATTER - similar to above, but use more optimized function 607df4397b0SStefano Zampini $ that only communicates the part of the reduction that is necessary. Requires MPI-2. 608df4397b0SStefano Zampini 609df4397b0SStefano Zampini Level: developer 610df4397b0SStefano Zampini 611db781477SPatrick Sanan .seealso: `PetscCommBuildTwoSided()`, `PetscCommBuildTwoSidedSetType()`, `PetscCommBuildTwoSidedGetType()` 612df4397b0SStefano Zampini E*/ 613df4397b0SStefano Zampini typedef enum { 614df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_NOTSET = -1, 615df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_ALLREDUCE = 0, 616df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_IBARRIER = 1, 617df4397b0SStefano Zampini PETSC_BUILDTWOSIDED_REDSCATTER = 2 618df4397b0SStefano Zampini /* Updates here must be accompanied by updates in finclude/petscsys.h and the string array in mpits.c */ 619df4397b0SStefano Zampini } PetscBuildTwoSidedType; 620df4397b0SStefano Zampini 621aa2d33c1SMatthew G. Knepley /* NOTE: If you change this, you must also change the values in src/vec/f90-mod/petscvec.h */ 622df4397b0SStefano Zampini /*E 623df4397b0SStefano Zampini InsertMode - Whether entries are inserted or added into vectors or matrices 624df4397b0SStefano Zampini 625df4397b0SStefano Zampini Level: beginner 626df4397b0SStefano Zampini 627db781477SPatrick Sanan .seealso: `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, 628db781477SPatrick Sanan `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, 629db781477SPatrick Sanan `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()` 630df4397b0SStefano Zampini E*/ 6310c91829fSJunchao Zhang 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; 632df4397b0SStefano Zampini 633df4397b0SStefano Zampini /*MC 634df4397b0SStefano Zampini INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value 635df4397b0SStefano Zampini 636df4397b0SStefano Zampini Level: beginner 637df4397b0SStefano Zampini 638db781477SPatrick Sanan .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, 639db781477SPatrick Sanan `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `ADD_VALUES`, 640db781477SPatrick Sanan `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES` 641df4397b0SStefano Zampini 642df4397b0SStefano Zampini M*/ 643df4397b0SStefano Zampini 644df4397b0SStefano Zampini /*MC 645df4397b0SStefano Zampini ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the 646df4397b0SStefano Zampini value into that location 647df4397b0SStefano Zampini 648df4397b0SStefano Zampini Level: beginner 649df4397b0SStefano Zampini 650db781477SPatrick Sanan .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`, 651db781477SPatrick Sanan `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `INSERT_VALUES`, 652db781477SPatrick Sanan `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES` 653df4397b0SStefano Zampini 654df4397b0SStefano Zampini M*/ 655df4397b0SStefano Zampini 656df4397b0SStefano Zampini /*MC 657df4397b0SStefano Zampini MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location 658df4397b0SStefano Zampini 659df4397b0SStefano Zampini Level: beginner 660df4397b0SStefano Zampini 661db781477SPatrick Sanan .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES` 662df4397b0SStefano Zampini 663df4397b0SStefano Zampini M*/ 664df4397b0SStefano Zampini 665421aa1e7SJunchao Zhang /*MC 666421aa1e7SJunchao Zhang MIN_VALUES - Puts the minimal of the scattered/gathered value and the current value into each location 667421aa1e7SJunchao Zhang 668421aa1e7SJunchao Zhang Level: beginner 669421aa1e7SJunchao Zhang 670db781477SPatrick Sanan .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES` 671421aa1e7SJunchao Zhang 672421aa1e7SJunchao Zhang M*/ 673421aa1e7SJunchao Zhang 674df4397b0SStefano Zampini /*S 675df4397b0SStefano Zampini PetscSubcomm - A decomposition of an MPI communicator into subcommunicators 676df4397b0SStefano Zampini 677df4397b0SStefano Zampini Notes: 678df4397b0SStefano Zampini After a call to PetscSubcommSetType(), PetscSubcommSetTypeGeneral(), or PetscSubcommSetFromOptions() one may call 679df4397b0SStefano Zampini $ PetscSubcommChild() returns the associated subcommunicator on this process 680df4397b0SStefano Zampini $ PetscSubcommContiguousParent() returns a parent communitor but with all child of the same subcommunicator having contiguous rank 681df4397b0SStefano Zampini 682df4397b0SStefano Zampini Sample Usage: 683df4397b0SStefano Zampini PetscSubcommCreate() 684df4397b0SStefano Zampini PetscSubcommSetNumber() 685df4397b0SStefano Zampini PetscSubcommSetType(PETSC_SUBCOMM_INTERLACED); 686df4397b0SStefano Zampini ccomm = PetscSubcommChild() 687df4397b0SStefano Zampini PetscSubcommDestroy() 688df4397b0SStefano Zampini 689df4397b0SStefano Zampini Level: advanced 690df4397b0SStefano Zampini 691df4397b0SStefano Zampini Notes: 692df4397b0SStefano Zampini $ 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 693df4397b0SStefano Zampini $ PETSC_SUBCOMM_CONTIGUOUS - each new communicator contains a set of process with contiguous ranks in the original MPI communicator 694df4397b0SStefano Zampini $ PETSC_SUBCOMM_INTERLACED - each new communictor contains a set of processes equally far apart in rank from the others in that new communicator 695df4397b0SStefano Zampini 696df4397b0SStefano Zampini Example: Consider a communicator with six processes split into 3 subcommunicators. 697df4397b0SStefano Zampini $ 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 698df4397b0SStefano Zampini $ PETSC_SUBCOMM_INTERLACED - the first communicator contains rank 0,3, the second 1,4 and the third 2,5 699df4397b0SStefano Zampini 700df4397b0SStefano Zampini Developer Notes: 701df4397b0SStefano Zampini This is used in objects such as PCREDUNDANT to manage the subcommunicators on which the redundant computations 702df4397b0SStefano Zampini are performed. 703df4397b0SStefano Zampini 704db781477SPatrick Sanan .seealso: `PetscSubcommCreate()`, `PetscSubcommSetNumber()`, `PetscSubcommSetType()`, `PetscSubcommView()`, `PetscSubcommSetFromOptions()` 705df4397b0SStefano Zampini 706df4397b0SStefano Zampini S*/ 707df4397b0SStefano Zampini typedef struct _n_PetscSubcomm* PetscSubcomm; 708df4397b0SStefano Zampini typedef enum {PETSC_SUBCOMM_GENERAL=0,PETSC_SUBCOMM_CONTIGUOUS=1,PETSC_SUBCOMM_INTERLACED=2} PetscSubcommType; 709df4397b0SStefano Zampini 710df4397b0SStefano Zampini /*S 711df4397b0SStefano Zampini PetscHeap - A simple class for managing heaps 712df4397b0SStefano Zampini 713df4397b0SStefano Zampini Level: intermediate 714df4397b0SStefano Zampini 715db781477SPatrick Sanan .seealso: `PetscHeapCreate()`, `PetscHeapAdd()`, `PetscHeapPop()`, `PetscHeapPeek()`, `PetscHeapStash()`, `PetscHeapUnstash()`, `PetscHeapView()`, `PetscHeapDestroy()` 716df4397b0SStefano Zampini S*/ 717df4397b0SStefano Zampini typedef struct _PetscHeap *PetscHeap; 718df4397b0SStefano Zampini 719df4397b0SStefano Zampini typedef struct _n_PetscShmComm* PetscShmComm; 720df4397b0SStefano Zampini typedef struct _n_PetscOmpCtrl* PetscOmpCtrl; 721df4397b0SStefano Zampini 722df4397b0SStefano Zampini /*S 723df4397b0SStefano Zampini PetscSegBuffer - a segmented extendable buffer 724df4397b0SStefano Zampini 725df4397b0SStefano Zampini Level: developer 726df4397b0SStefano Zampini 727db781477SPatrick Sanan .seealso: `PetscSegBufferCreate()`, `PetscSegBufferGet()`, `PetscSegBufferExtract()`, `PetscSegBufferDestroy()` 728df4397b0SStefano Zampini S*/ 729df4397b0SStefano Zampini typedef struct _n_PetscSegBuffer *PetscSegBuffer; 730df4397b0SStefano Zampini 731df4397b0SStefano Zampini typedef struct _n_PetscOptionsHelpPrinted *PetscOptionsHelpPrinted; 732df4397b0SStefano Zampini #endif 733