xref: /petsc/include/petscsystypes.h (revision 62e5d2d2208a68fdbd23dac44110783534664de8)
16524c165SJacob Faibussowitsch #ifndef 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 
9ac09b921SBarry Smith /* SUBMANSEC = Sys */
10ac09b921SBarry 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:
2587497f52SBarry Smith     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:
2987497f52SBarry Smith     Internal integer stored in the `_p_PetscObject` data structure.
3087497f52SBarry Smith          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:
4487497f52SBarry 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
4587497f52SBarry Smith            standard C/Fortran integers are 32 bit then this is NOT the same as `PetscInt`; it remains 32 bit.
46df4397b0SStefano Zampini 
4787497f52SBarry Smith     `PetscMPIIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscMPIInt`, if not it
4887497f52SBarry Smith       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 
7687497f52SBarry Smith     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*/
919371c9d4SSatish Balay typedef enum {
929371c9d4SSatish Balay   ENUM_DUMMY
939371c9d4SSatish Balay } PetscEnum;
94df4397b0SStefano Zampini 
95df4397b0SStefano Zampini typedef short PetscShort;
96df4397b0SStefano Zampini typedef char  PetscChar;
97df4397b0SStefano Zampini typedef float PetscFloat;
98df4397b0SStefano Zampini 
99df4397b0SStefano Zampini /*MC
100df4397b0SStefano Zampini   PetscInt - PETSc type that represents an integer, used primarily to
101df4397b0SStefano 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.
102df4397b0SStefano Zampini 
103df4397b0SStefano Zampini   Notes:
10487497f52SBarry 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.
105df4397b0SStefano Zampini 
106df4397b0SStefano Zampini   Level: beginner
107df4397b0SStefano Zampini 
108db781477SPatrick Sanan .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`
109df4397b0SStefano Zampini M*/
110df4397b0SStefano Zampini 
111df4397b0SStefano Zampini #if defined(PETSC_HAVE_STDINT_H)
112df4397b0SStefano Zampini   #include <stdint.h>
113df4397b0SStefano Zampini #endif
114df4397b0SStefano Zampini #if defined(PETSC_HAVE_INTTYPES_H)
115df4397b0SStefano Zampini   #if !defined(__STDC_FORMAT_MACROS)
116df4397b0SStefano Zampini     #define __STDC_FORMAT_MACROS /* required for using PRId64 from c++ */
117df4397b0SStefano Zampini   #endif
118df4397b0SStefano Zampini   #include <inttypes.h>
119df4397b0SStefano Zampini   #if !defined(PRId64)
120df4397b0SStefano Zampini     #define PRId64 "ld"
121df4397b0SStefano Zampini   #endif
122df4397b0SStefano Zampini #endif
123df4397b0SStefano Zampini 
124df4397b0SStefano 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 */
125df4397b0SStefano Zampini typedef int64_t PetscInt64;
126df4397b0SStefano Zampini #elif (PETSC_SIZEOF_LONG_LONG == 8)
127df4397b0SStefano Zampini typedef long long PetscInt64;
128df4397b0SStefano Zampini #elif defined(PETSC_HAVE___INT64)
129df4397b0SStefano Zampini typedef __int64 PetscInt64;
130df4397b0SStefano Zampini #else
131df4397b0SStefano Zampini   #error "cannot determine PetscInt64 type"
132df4397b0SStefano Zampini #endif
133df4397b0SStefano Zampini 
134df4397b0SStefano Zampini #if defined(PETSC_USE_64BIT_INDICES)
135df4397b0SStefano Zampini typedef PetscInt64 PetscInt;
136df4397b0SStefano Zampini #else
137df4397b0SStefano Zampini typedef int       PetscInt;
138df4397b0SStefano Zampini #endif
139df4397b0SStefano Zampini 
140c93fae50SJacob 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 */
141c93fae50SJacob Faibussowitsch   #define MPIU_INT64     MPI_INT64_T
142c93fae50SJacob Faibussowitsch   #define PetscInt64_FMT PRId64
143c93fae50SJacob Faibussowitsch #elif (PETSC_SIZEOF_LONG_LONG == 8)
144c93fae50SJacob Faibussowitsch   #define MPIU_INT64     MPI_LONG_LONG_INT
145c93fae50SJacob Faibussowitsch   #define PetscInt64_FMT "lld"
146c93fae50SJacob Faibussowitsch #elif defined(PETSC_HAVE___INT64)
147c93fae50SJacob Faibussowitsch   #define MPIU_INT64     MPI_INT64_T
148c93fae50SJacob Faibussowitsch   #define PetscInt64_FMT "ld"
149c93fae50SJacob Faibussowitsch #else
150c93fae50SJacob Faibussowitsch   #error "cannot determine PetscInt64 type"
151c93fae50SJacob Faibussowitsch #endif
152c93fae50SJacob Faibussowitsch 
153df4397b0SStefano Zampini /*MC
154df4397b0SStefano Zampini    PetscBLASInt - datatype used to represent 'int' parameters to BLAS/LAPACK functions.
155df4397b0SStefano Zampini 
156df4397b0SStefano Zampini    Notes:
15787497f52SBarry Smith     Usually this is the same as `PetscIn`t, but if PETSc was built with --with-64-bit-indices but
15887497f52SBarry Smith            standard C/Fortran integers are 32 bit then this may not be the same as `PetscInt`,
15987497f52SBarry Smith            except on some BLAS/LAPACK implementations that support 64 bit integers see the notes below.
160df4397b0SStefano Zampini 
16187497f52SBarry Smith     `PetscErrorCode` `PetscBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscBLASInt`, if not it
16287497f52SBarry Smith       generates a `PETSC_ERR_ARG_OUTOFRANGE` error
163df4397b0SStefano Zampini 
164df4397b0SStefano Zampini    Installation Notes:
165cdc6ee08SBarry Smith     ./configure automatically determines the size of the integers used by BLAS/LAPACK except when --with-batch is used
166cdc6ee08SBarry 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
167cdc6ee08SBarry Smith 
168cdc6ee08SBarry Smith     MATLAB ships with BLAS and LAPACK that use 64 bit integers, for example if you run ./configure with, the option
169df4397b0SStefano Zampini      --with-blaslapack-lib=[/Applications/MATLAB_R2010b.app/bin/maci64/libmwblas.dylib,/Applications/MATLAB_R2010b.app/bin/maci64/libmwlapack.dylib]
170df4397b0SStefano Zampini 
171cdc6ee08SBarry 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
172cdc6ee08SBarry Smith     against the 64 bit version, otherwise it use the 32 bit version
173df4397b0SStefano Zampini 
174cdc6ee08SBarry 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
175df4397b0SStefano Zampini 
176df4397b0SStefano Zampini     External packages such as hypre, ML, SuperLU etc do not provide any support for passing 64 bit integers to BLAS/LAPACK so cannot
177cdc6ee08SBarry 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
178cdc6ee08SBarry Smith     these external libraries while using 64 bit integer BLAS/LAPACK.
179df4397b0SStefano Zampini 
180df4397b0SStefano Zampini    Level: intermediate
181df4397b0SStefano Zampini 
182db781477SPatrick Sanan .seealso: `PetscMPIInt`, `PetscInt`, `PetscBLASIntCast()`
183df4397b0SStefano Zampini 
184df4397b0SStefano Zampini M*/
185df4397b0SStefano Zampini #if defined(PETSC_HAVE_64BIT_BLAS_INDICES)
186c93fae50SJacob Faibussowitsch   #define PetscBLASInt_FMT PetscInt64_FMT
187df4397b0SStefano Zampini typedef PetscInt64 PetscBLASInt;
188df4397b0SStefano Zampini #else
189c93fae50SJacob Faibussowitsch   #define PetscBLASInt_FMT "d"
190df4397b0SStefano Zampini typedef int       PetscBLASInt;
191df4397b0SStefano Zampini #endif
192df4397b0SStefano Zampini 
193eee0c0a6SToby Isaac /*MC
194eee0c0a6SToby Isaac    PetscCuBLASInt - datatype used to represent 'int' parameters to cuBLAS/cuSOLVER functions.
195eee0c0a6SToby Isaac 
196eee0c0a6SToby Isaac    Notes:
197eee0c0a6SToby Isaac     As of this writing PetscCuBLASInt is always the system `int`.
198eee0c0a6SToby Isaac 
19987497f52SBarry Smith     `PetscErrorCode` `PetscCuBLASIntCast`(a,&b) checks if the given `PetscInt` a will fit in a `PetscCuBLASInt`, if not it
20087497f52SBarry Smith       generates a `PETSC_ERR_ARG_OUTOFRANGE` error
201eee0c0a6SToby Isaac 
202eee0c0a6SToby Isaac    Level: intermediate
203eee0c0a6SToby Isaac 
204db781477SPatrick Sanan .seealso: `PetscBLASInt`, `PetscMPIInt`, `PetscInt`, `PetscCuBLASIntCast()`
205eee0c0a6SToby Isaac 
206eee0c0a6SToby Isaac M*/
207eee0c0a6SToby Isaac typedef int PetscCuBLASInt;
208eee0c0a6SToby Isaac 
209df4397b0SStefano Zampini /*E
210b94d7dedSBarry Smith     PetscBool  - Logical variable. Actually an enum in C and a logical in Fortran.
211df4397b0SStefano Zampini 
212df4397b0SStefano Zampini    Level: beginner
213df4397b0SStefano Zampini 
214df4397b0SStefano Zampini    Developer Note:
21587497f52SBarry 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
216df4397b0SStefano Zampini       boolean values. It is not easy to have a simple macro that that will work properly in all circumstances with all three mechanisms.
217df4397b0SStefano Zampini 
218b94d7dedSBarry Smith .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PetscBool3`
219df4397b0SStefano Zampini E*/
2209371c9d4SSatish Balay typedef enum {
2219371c9d4SSatish Balay   PETSC_FALSE,
2229371c9d4SSatish Balay   PETSC_TRUE
2239371c9d4SSatish Balay } PetscBool;
224df4397b0SStefano Zampini 
225b94d7dedSBarry Smith /*E
226b94d7dedSBarry Smith     PetscBool3  - Ternary logical variable. Actually an enum in C and a 4 byte integer in Fortran.
227b94d7dedSBarry Smith 
228b94d7dedSBarry Smith    Level: beginner
229b94d7dedSBarry Smith 
23087497f52SBarry Smith    Note:
231b94d7dedSBarry Smith    Should not be used with the if (flg) or if (!flg) syntax.
232b94d7dedSBarry Smith 
233b94d7dedSBarry Smith .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PETSC_BOOL3_TRUE`, `PETSC_BOOL3_FALSE`, `PETSC_BOOL3_UKNOWN`
234b94d7dedSBarry Smith E*/
2359371c9d4SSatish Balay typedef enum {
2369371c9d4SSatish Balay   PETSC_BOOL3_FALSE,
2379371c9d4SSatish Balay   PETSC_BOOL3_TRUE,
2389371c9d4SSatish Balay   PETSC_BOOL3_UNKNOWN = -1
2399371c9d4SSatish Balay } PetscBool3;
240b94d7dedSBarry Smith 
241b94d7dedSBarry Smith #define PetscBool3ToBool(a) ((a) == PETSC_BOOL3_TRUE ? PETSC_TRUE : PETSC_FALSE)
242b94d7dedSBarry Smith #define PetscBoolToBool3(a) ((a) == PETSC_TRUE ? PETSC_BOOL3_TRUE : PETSC_BOOL3_FALSE)
243b94d7dedSBarry Smith 
244df4397b0SStefano Zampini /*MC
24587497f52SBarry Smith    PetscReal - PETSc type that represents a real number version of `PetscScalar`
246df4397b0SStefano Zampini 
247df4397b0SStefano Zampini    Notes:
24887497f52SBarry Smith    For MPI calls that require datatypes, use `MPIU_REAL` as the datatype for `PetscReal` and `MPIU_SUM`, `MPIU_MAX`, etc. for operations.
24987497f52SBarry Smith           They will automatically work correctly regardless of the size of `PetscReal`.
250df4397b0SStefano Zampini 
25187497f52SBarry Smith           See `PetscScalar` for details on how to ./configure the size of `PetscReal`.
252df4397b0SStefano Zampini 
253df4397b0SStefano Zampini    Level: beginner
254df4397b0SStefano Zampini 
255db781477SPatrick Sanan .seealso: `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`
256df4397b0SStefano Zampini M*/
257df4397b0SStefano Zampini 
258df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE)
259df4397b0SStefano Zampini typedef float PetscReal;
260df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL_DOUBLE)
261df4397b0SStefano Zampini typedef double    PetscReal;
262df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128)
263df4397b0SStefano Zampini   #if defined(__cplusplus)
264df4397b0SStefano Zampini extern "C" {
265df4397b0SStefano Zampini   #endif
266df4397b0SStefano Zampini   #include <quadmath.h>
267df4397b0SStefano Zampini   #if defined(__cplusplus)
268df4397b0SStefano Zampini }
269df4397b0SStefano Zampini   #endif
270df4397b0SStefano Zampini typedef __float128 PetscReal;
271df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FP16)
272df4397b0SStefano Zampini typedef __fp16 PetscReal;
273df4397b0SStefano Zampini #endif /* PETSC_USE_REAL_* */
274df4397b0SStefano Zampini 
275df4397b0SStefano Zampini /*MC
27687497f52SBarry Smith    PetscComplex - PETSc type that represents a complex number with precision matching that of `PetscReal`.
277df4397b0SStefano Zampini 
278df4397b0SStefano Zampini    Synopsis:
279df4397b0SStefano Zampini    #include <petscsys.h>
280df4397b0SStefano Zampini    PetscComplex number = 1. + 2.*PETSC_i;
281df4397b0SStefano Zampini 
282df4397b0SStefano Zampini    Notes:
28387497f52SBarry Smith    For MPI calls that require datatypes, use `MPIU_COMPLEX` as the datatype for `PetscComplex` and `MPIU_SUM` etc for operations.
28487497f52SBarry Smith           They will automatically work correctly regardless of the size of `PetscComplex`.
285df4397b0SStefano Zampini 
28687497f52SBarry Smith           See PetscScalar for details on how to ./configure the size of `PetscReal`
287df4397b0SStefano Zampini 
288df4397b0SStefano Zampini           Complex numbers are automatically available if PETSc was able to find a working complex implementation
289df4397b0SStefano Zampini 
29087497f52SBarry Smith     Petsc has a 'fix' for complex numbers to support expressions such as std::complex<PetscReal> + `PetscInt`, which are not supported by the standard
291a966371cSJunchao 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
292a966371cSJunchao Zhang     configure), we include petsccxxcomplexfix.h to provide this convenience.
293a966371cSJunchao Zhang 
29487497f52SBarry 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`
295a966371cSJunchao Zhang     at the beginning of the C++ file to skip the fix.
296a966371cSJunchao Zhang 
297df4397b0SStefano Zampini    Level: beginner
298df4397b0SStefano Zampini 
299db781477SPatrick Sanan .seealso: `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PETSC_i`
300df4397b0SStefano Zampini M*/
301df4397b0SStefano Zampini #if !defined(PETSC_SKIP_COMPLEX)
3027a19d461SSatish Balay   #if defined(PETSC_CLANGUAGE_CXX)
3037a19d461SSatish Balay     #if !defined(PETSC_USE_REAL___FP16) && !defined(PETSC_USE_REAL___FLOAT128)
3047a19d461SSatish Balay       #if defined(__cplusplus) && defined(PETSC_HAVE_CXX_COMPLEX) /* enable complex for library code */
305df4397b0SStefano Zampini         #define PETSC_HAVE_COMPLEX 1
3067a19d461SSatish Balay       #elif !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on libary code complex support */
3077a19d461SSatish Balay         #define PETSC_HAVE_COMPLEX 1
3087a19d461SSatish Balay       #endif
309450fc7c9SSatish Balay     #elif defined(PETSC_USE_REAL___FLOAT128) && defined(PETSC_HAVE_C99_COMPLEX)
310450fc7c9SSatish Balay       #define PETSC_HAVE_COMPLEX 1
3117a19d461SSatish Balay     #endif
3127a19d461SSatish Balay   #else /* !PETSC_CLANGUAGE_CXX */
3137a19d461SSatish Balay     #if !defined(PETSC_USE_REAL___FP16)
3147a19d461SSatish Balay       #if !defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) /* enable complex for library code */
3157a19d461SSatish Balay         #define PETSC_HAVE_COMPLEX 1
3167a19d461SSatish Balay       #elif defined(__cplusplus) && defined(PETSC_HAVE_C99_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) /* User code only - conditional on libary code complex support */
3177a19d461SSatish Balay         #define PETSC_HAVE_COMPLEX 1
3187a19d461SSatish Balay       #endif
3197a19d461SSatish Balay     #endif
3207a19d461SSatish Balay   #endif /* PETSC_CLANGUAGE_CXX */
3217a19d461SSatish Balay #endif   /* !PETSC_SKIP_COMPLEX */
3227a19d461SSatish Balay 
3237a19d461SSatish Balay #if defined(PETSC_HAVE_COMPLEX)
3247a19d461SSatish Balay   #if defined(__cplusplus) /* C++ complex support */
32511d22bbfSJunchao Zhang     /* Locate a C++ complex template library */
32611d22bbfSJunchao Zhang     #if defined(PETSC_DESIRE_KOKKOS_COMPLEX) /* Defined in petscvec_kokkos.hpp for *.kokkos.cxx files */
32711d22bbfSJunchao Zhang       #define petsccomplexlib Kokkos
32811d22bbfSJunchao Zhang       #include <Kokkos_Complex.hpp>
329022afdc5SJed Brown     #elif defined(__CUDACC__) || defined(__HIPCC__)
330df4397b0SStefano Zampini       #define petsccomplexlib thrust
331df4397b0SStefano Zampini       #include <thrust/complex.h>
332450fc7c9SSatish Balay     #elif defined(PETSC_USE_REAL___FLOAT128)
333450fc7c9SSatish Balay       #include <complex.h>
334df4397b0SStefano Zampini     #else
335df4397b0SStefano Zampini       #define petsccomplexlib std
336df4397b0SStefano Zampini       #include <complex>
337df4397b0SStefano Zampini     #endif
33811d22bbfSJunchao Zhang 
33911d22bbfSJunchao Zhang     /* Define PetscComplex based on the precision */
340df4397b0SStefano Zampini     #if defined(PETSC_USE_REAL_SINGLE)
341df4397b0SStefano Zampini typedef petsccomplexlib::complex<float> PetscComplex;
342df4397b0SStefano Zampini     #elif defined(PETSC_USE_REAL_DOUBLE)
343df4397b0SStefano Zampini typedef petsccomplexlib::complex<double> PetscComplex;
344df4397b0SStefano Zampini     #elif defined(PETSC_USE_REAL___FLOAT128)
345450fc7c9SSatish Balay typedef __complex128 PetscComplex;
34611d22bbfSJunchao Zhang     #endif
34711d22bbfSJunchao Zhang 
348a966371cSJunchao Zhang     /* Include a PETSc C++ complex 'fix'. Check PetscComplex manual page for details */
349a966371cSJunchao Zhang     #if defined(PETSC_HAVE_CXX_COMPLEX_FIX) && !defined(PETSC_SKIP_CXX_COMPLEX_FIX)
35039829747SLisandro Dalcin       #include <petsccxxcomplexfix.h>
35111d22bbfSJunchao Zhang     #endif
3527a19d461SSatish Balay   #else /* c99 complex support */
353df4397b0SStefano Zampini     #include <complex.h>
354df4397b0SStefano Zampini     #if defined(PETSC_USE_REAL_SINGLE) || defined(PETSC_USE_REAL___FP16)
355df4397b0SStefano Zampini typedef float _Complex PetscComplex;
356df4397b0SStefano Zampini     #elif defined(PETSC_USE_REAL_DOUBLE)
357df4397b0SStefano Zampini typedef double _Complex PetscComplex;
358df4397b0SStefano Zampini     #elif defined(PETSC_USE_REAL___FLOAT128)
359df4397b0SStefano Zampini typedef __complex128 PetscComplex;
360df4397b0SStefano Zampini     #endif /* PETSC_USE_REAL_* */
3617a19d461SSatish Balay   #endif   /* !__cplusplus */
3627a19d461SSatish Balay #endif     /* PETSC_HAVE_COMPLEX */
363df4397b0SStefano Zampini 
364df4397b0SStefano Zampini /*MC
365df4397b0SStefano Zampini    PetscScalar - PETSc type that represents either a double precision real number, a double precision
366df4397b0SStefano Zampini        complex number, a single precision real number, a __float128 real or complex or a __fp16 real - if the code is configured
367df4397b0SStefano Zampini        with --with-scalar-type=real,complex --with-precision=single,double,__float128,__fp16
368df4397b0SStefano Zampini 
369df4397b0SStefano Zampini    Notes:
37087497f52SBarry 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`.
371df4397b0SStefano Zampini 
372df4397b0SStefano Zampini    Level: beginner
373df4397b0SStefano Zampini 
374db781477SPatrick Sanan .seealso: `PetscReal`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PetscRealPart()`, `PetscImaginaryPart()`
375df4397b0SStefano Zampini M*/
376df4397b0SStefano Zampini 
3777a19d461SSatish Balay #if defined(PETSC_USE_COMPLEX) && defined(PETSC_HAVE_COMPLEX)
378df4397b0SStefano Zampini typedef PetscComplex PetscScalar;
379df4397b0SStefano Zampini #else  /* PETSC_USE_COMPLEX */
380df4397b0SStefano Zampini typedef PetscReal PetscScalar;
381df4397b0SStefano Zampini #endif /* PETSC_USE_COMPLEX */
382df4397b0SStefano Zampini 
383df4397b0SStefano Zampini /*E
38487497f52SBarry Smith     PetscCopyMode  - Determines how an array or `PetscObject` passed to certain functions is copied or retained by the aggregate `PetscObject`
385df4397b0SStefano Zampini 
386df4397b0SStefano Zampini    Level: beginner
387df4397b0SStefano Zampini 
3885d80c0bfSVaclav Hapla    For the array input:
38987497f52SBarry Smith $   `PETSC_COPY_VALUES` - the array values are copied into new space, the user is free to reuse or delete the passed in array
39087497f52SBarry 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
391df4397b0SStefano Zampini $                       delete the array. The array MUST have been obtained with PetscMalloc(). Hence this mode cannot be used in Fortran.
39287497f52SBarry 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
3935d80c0bfSVaclav Hapla $                       the array but the user must delete the array after the object is destroyed.
3945d80c0bfSVaclav Hapla 
3955d80c0bfSVaclav Hapla    For the PetscObject input:
39687497f52SBarry 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.
39787497f52SBarry Smith $   `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.)
39887497f52SBarry Smith    For either case above, the input `PetscObject` should be destroyed by the user when no longer needed (the aggregate object increases its reference count).
39987497f52SBarry Smith $   `PETSC_USE_POINTER` - invalid for `PetscObject` inputs.
400df4397b0SStefano Zampini 
401df4397b0SStefano Zampini E*/
4029371c9d4SSatish Balay typedef enum {
4039371c9d4SSatish Balay   PETSC_COPY_VALUES,
4049371c9d4SSatish Balay   PETSC_OWN_POINTER,
4059371c9d4SSatish Balay   PETSC_USE_POINTER
4069371c9d4SSatish Balay } PetscCopyMode;
407df4397b0SStefano Zampini 
408df4397b0SStefano Zampini /*MC
40987497f52SBarry Smith     PETSC_FALSE - False value of `PetscBool`
410df4397b0SStefano Zampini 
411df4397b0SStefano Zampini     Level: beginner
412df4397b0SStefano Zampini 
413df4397b0SStefano Zampini     Note:
414df4397b0SStefano Zampini     Zero integer
415df4397b0SStefano Zampini 
41687497f52SBarry Smith .seealso: `PetscBool`, `PetscBool3`, `PETSC_TRUE`
417df4397b0SStefano Zampini M*/
418df4397b0SStefano Zampini 
419df4397b0SStefano Zampini /*MC
42087497f52SBarry Smith     PETSC_TRUE - True value of `PetscBool`
421df4397b0SStefano Zampini 
422df4397b0SStefano Zampini     Level: beginner
423df4397b0SStefano Zampini 
424df4397b0SStefano Zampini     Note:
425df4397b0SStefano Zampini     Nonzero integer
426df4397b0SStefano Zampini 
42787497f52SBarry Smith .seealso: `PetscBool`, `PetscBool3`, `PETSC_FALSE`
428df4397b0SStefano Zampini M*/
429df4397b0SStefano Zampini 
430df4397b0SStefano Zampini /*MC
431df4397b0SStefano Zampini     PetscLogDouble - Used for logging times
432df4397b0SStefano Zampini 
433df4397b0SStefano Zampini   Notes:
434df4397b0SStefano Zampini   Contains double precision numbers that are not used in the numerical computations, but rather in logging, timing etc.
435df4397b0SStefano Zampini 
4366b3bf505SPatrick Sanan   Level: developer
4376b3bf505SPatrick Sanan 
438df4397b0SStefano Zampini M*/
439df4397b0SStefano Zampini typedef double PetscLogDouble;
440df4397b0SStefano Zampini 
441df4397b0SStefano Zampini /*E
442df4397b0SStefano Zampini     PetscDataType - Used for handling different basic data types.
443df4397b0SStefano Zampini 
444df4397b0SStefano Zampini    Level: beginner
445df4397b0SStefano Zampini 
446df4397b0SStefano Zampini    Notes:
44787497f52SBarry Smith    Use of this should be avoided if one can directly use `MPI_Datatype` instead.
448df4397b0SStefano Zampini 
44987497f52SBarry Smith    `PETSC_INT` is the datatype for a `PetscInt`, regardless of whether it is 4 or 8 bytes.
45087497f52SBarry Smith    `PETSC_REAL`, `PETSC_COMPLEX` and `PETSC_SCALAR` are the datatypes for `PetscReal`, `PetscComplex` and `PetscScalar`, regardless of their sizes.
451277f51e8SBarry Smith 
45287497f52SBarry Smith    Developer Notes:
453df4397b0SStefano Zampini    It would be nice if we could always just use MPI Datatypes, why can we not?
454df4397b0SStefano Zampini 
45587497f52SBarry Smith    If you change any values in `PetscDatatype` make sure you update their usage in
456fa131761SBarry Smith    share/petsc/matlab/PetscBagRead.m and share/petsc/matlab/@PetscOpenSocket/read/write.m
45791e29162SBarry Smith 
458277f51e8SBarry Smith    TODO: Add PETSC_INT32 and remove use of improper PETSC_ENUM
459277f51e8SBarry Smith 
460db781477SPatrick Sanan .seealso: `PetscBinaryRead()`, `PetscBinaryWrite()`, `PetscDataTypeToMPIDataType()`,
461db781477SPatrick Sanan           `PetscDataTypeGetSize()`
462df4397b0SStefano Zampini 
463df4397b0SStefano Zampini E*/
4649371c9d4SSatish Balay typedef enum {
4659371c9d4SSatish Balay   PETSC_DATATYPE_UNKNOWN = 0,
4669371c9d4SSatish Balay   PETSC_DOUBLE           = 1,
4679371c9d4SSatish Balay   PETSC_COMPLEX          = 2,
4689371c9d4SSatish Balay   PETSC_LONG             = 3,
4699371c9d4SSatish Balay   PETSC_SHORT            = 4,
4709371c9d4SSatish Balay   PETSC_FLOAT            = 5,
4719371c9d4SSatish Balay   PETSC_CHAR             = 6,
4729371c9d4SSatish Balay   PETSC_BIT_LOGICAL      = 7,
4739371c9d4SSatish Balay   PETSC_ENUM             = 8,
4749371c9d4SSatish Balay   PETSC_BOOL             = 9,
4759371c9d4SSatish Balay   PETSC___FLOAT128       = 10,
4769371c9d4SSatish Balay   PETSC_OBJECT           = 11,
4779371c9d4SSatish Balay   PETSC_FUNCTION         = 12,
4789371c9d4SSatish Balay   PETSC_STRING           = 13,
4799371c9d4SSatish Balay   PETSC___FP16           = 14,
4809371c9d4SSatish Balay   PETSC_STRUCT           = 15,
4819371c9d4SSatish Balay   PETSC_INT              = 16,
482*62e5d2d2SJDBetteridge   PETSC_INT64            = 17,
483*62e5d2d2SJDBetteridge   PETSC_COUNT            = 18
4849371c9d4SSatish Balay } PetscDataType;
485df4397b0SStefano Zampini 
486df4397b0SStefano Zampini #if defined(PETSC_USE_REAL_SINGLE)
487df4397b0SStefano Zampini   #define PETSC_REAL PETSC_FLOAT
4885117d392SLisandro Dalcin #elif defined(PETSC_USE_REAL_DOUBLE)
4895117d392SLisandro Dalcin   #define PETSC_REAL PETSC_DOUBLE
490df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FLOAT128)
491df4397b0SStefano Zampini   #define PETSC_REAL PETSC___FLOAT128
492df4397b0SStefano Zampini #elif defined(PETSC_USE_REAL___FP16)
493df4397b0SStefano Zampini   #define PETSC_REAL PETSC___FP16
494df4397b0SStefano Zampini #else
495df4397b0SStefano Zampini   #define PETSC_REAL PETSC_DOUBLE
496df4397b0SStefano Zampini #endif
4975117d392SLisandro Dalcin 
4985117d392SLisandro Dalcin #if defined(PETSC_USE_COMPLEX)
4995117d392SLisandro Dalcin   #define PETSC_SCALAR PETSC_COMPLEX
5005117d392SLisandro Dalcin #else
5015117d392SLisandro Dalcin   #define PETSC_SCALAR PETSC_REAL
5025117d392SLisandro Dalcin #endif
5035117d392SLisandro Dalcin 
504df4397b0SStefano Zampini #define PETSC_FORTRANADDR PETSC_LONG
505df4397b0SStefano Zampini 
506df4397b0SStefano Zampini /*S
507df4397b0SStefano Zampini     PetscToken - 'Token' used for managing tokenizing strings
508df4397b0SStefano Zampini 
509df4397b0SStefano Zampini   Level: intermediate
510df4397b0SStefano Zampini 
511db781477SPatrick Sanan .seealso: `PetscTokenCreate()`, `PetscTokenFind()`, `PetscTokenDestroy()`
512df4397b0SStefano Zampini S*/
513df4397b0SStefano Zampini typedef struct _p_PetscToken *PetscToken;
514df4397b0SStefano Zampini 
515df4397b0SStefano Zampini /*S
51687497f52SBarry Smith      PetscObject - any PETSc object, `PetscViewer`, `Mat`, `Vec`, `KSP` etc
517df4397b0SStefano Zampini 
518df4397b0SStefano Zampini    Level: beginner
519df4397b0SStefano Zampini 
52087497f52SBarry Smith    Notes:
521df4397b0SStefano Zampini    This is the base class from which all PETSc objects are derived from.
522df4397b0SStefano Zampini 
52387497f52SBarry Smith    In certain situations one can cast an object, for example a `Vec`, to a `PetscObject` with (`PetscObject`)vec
52487497f52SBarry Smith 
525db781477SPatrick Sanan .seealso: `PetscObjectDestroy()`, `PetscObjectView()`, `PetscObjectGetName()`, `PetscObjectSetName()`, `PetscObjectReference()`, `PetscObjectDereference()`
526df4397b0SStefano Zampini S*/
527df4397b0SStefano Zampini typedef struct _p_PetscObject *PetscObject;
528df4397b0SStefano Zampini 
529df4397b0SStefano Zampini /*MC
53087497f52SBarry Smith     PetscObjectId - unique integer Id for a `PetscObject`
531df4397b0SStefano Zampini 
532df4397b0SStefano Zampini     Level: developer
533df4397b0SStefano Zampini 
53487497f52SBarry Smith     Note:
53587497f52SBarry 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
53687497f52SBarry Smith     if the objects are the same. Never compare two object pointer values.
537df4397b0SStefano Zampini 
538db781477SPatrick Sanan .seealso: `PetscObjectState`, `PetscObjectGetId()`
539df4397b0SStefano Zampini M*/
540df4397b0SStefano Zampini typedef PetscInt64 PetscObjectId;
541df4397b0SStefano Zampini 
542df4397b0SStefano Zampini /*MC
54387497f52SBarry Smith     PetscObjectState - integer state for a `PetscObject`
544df4397b0SStefano Zampini 
545df4397b0SStefano Zampini     Level: developer
546df4397b0SStefano Zampini 
547df4397b0SStefano Zampini     Notes:
548df4397b0SStefano Zampini     Object state is always-increasing and (for objects that track state) can be used to determine if an object has
549df4397b0SStefano 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.
550df4397b0SStefano Zampini 
551db781477SPatrick Sanan .seealso: `PetscObjectId`, `PetscObjectStateGet()`, `PetscObjectStateIncrease()`, `PetscObjectStateSet()`
552df4397b0SStefano Zampini M*/
553df4397b0SStefano Zampini typedef PetscInt64 PetscObjectState;
554df4397b0SStefano Zampini 
555df4397b0SStefano Zampini /*S
556df4397b0SStefano Zampini      PetscFunctionList - Linked list of functions, possibly stored in dynamic libraries, accessed
557df4397b0SStefano Zampini       by string name
558df4397b0SStefano Zampini 
559df4397b0SStefano Zampini    Level: advanced
560df4397b0SStefano Zampini 
561db781477SPatrick Sanan .seealso: `PetscFunctionListAdd()`, `PetscFunctionListDestroy()`
562df4397b0SStefano Zampini S*/
563df4397b0SStefano Zampini typedef struct _n_PetscFunctionList *PetscFunctionList;
564df4397b0SStefano Zampini 
565df4397b0SStefano Zampini /*E
566df4397b0SStefano Zampini   PetscFileMode - Access mode for a file.
567df4397b0SStefano Zampini 
568df4397b0SStefano Zampini   Level: beginner
569df4397b0SStefano Zampini 
57087497f52SBarry Smith $  `FILE_MODE_UNDEFINED` - initial invalid value
57187497f52SBarry Smith $  `FILE_MODE_READ` - open a file at its beginning for reading
57287497f52SBarry Smith $  `FILE_MODE_WRITE` - open a file at its beginning for writing (will create if the file does not exist)
57387497f52SBarry Smith $  `FILE_MODE_APPEND` - open a file at end for writing
57487497f52SBarry Smith $  `FILE_MODE_UPDATE` - open a file for updating, meaning for reading and writing
57587497f52SBarry Smith $  `FILE_MODE_APPEND_UPDATE` - open a file for updating, meaning for reading and writing, at the end
576df4397b0SStefano Zampini 
577db781477SPatrick Sanan .seealso: `PetscViewerFileSetMode()`
578df4397b0SStefano Zampini E*/
5799371c9d4SSatish Balay typedef enum {
5809371c9d4SSatish Balay   FILE_MODE_UNDEFINED = -1,
5819371c9d4SSatish Balay   FILE_MODE_READ      = 0,
5829371c9d4SSatish Balay   FILE_MODE_WRITE,
5839371c9d4SSatish Balay   FILE_MODE_APPEND,
5849371c9d4SSatish Balay   FILE_MODE_UPDATE,
5859371c9d4SSatish Balay   FILE_MODE_APPEND_UPDATE
5869371c9d4SSatish Balay } PetscFileMode;
587df4397b0SStefano Zampini 
588df4397b0SStefano Zampini typedef void *PetscDLHandle;
5899371c9d4SSatish Balay typedef enum {
5909371c9d4SSatish Balay   PETSC_DL_DECIDE = 0,
5919371c9d4SSatish Balay   PETSC_DL_NOW    = 1,
5929371c9d4SSatish Balay   PETSC_DL_LOCAL  = 2
5939371c9d4SSatish Balay } PetscDLMode;
594df4397b0SStefano Zampini 
595df4397b0SStefano Zampini /*S
5967243573dSPierre Jolivet      PetscObjectList - Linked list of PETSc objects, each accessible by string name
597df4397b0SStefano Zampini 
598df4397b0SStefano Zampini    Level: developer
599df4397b0SStefano Zampini 
60087497f52SBarry Smith    Note:
60187497f52SBarry Smith    Used by `PetscObjectCompose()` and `PetscObjectQuery()`
602df4397b0SStefano Zampini 
603db781477SPatrick Sanan .seealso: `PetscObjectListAdd()`, `PetscObjectListDestroy()`, `PetscObjectListFind()`, `PetscObjectCompose()`, `PetscObjectQuery()`, `PetscFunctionList`
604df4397b0SStefano Zampini S*/
605df4397b0SStefano Zampini typedef struct _n_PetscObjectList *PetscObjectList;
606df4397b0SStefano Zampini 
607df4397b0SStefano Zampini /*S
608df4397b0SStefano Zampini      PetscDLLibrary - Linked list of dynamics libraries to search for functions
609df4397b0SStefano Zampini 
610df4397b0SStefano Zampini    Level: advanced
611df4397b0SStefano Zampini 
612db781477SPatrick Sanan .seealso: `PetscDLLibraryOpen()`
613df4397b0SStefano Zampini S*/
614df4397b0SStefano Zampini typedef struct _n_PetscDLLibrary *PetscDLLibrary;
615df4397b0SStefano Zampini 
616df4397b0SStefano Zampini /*S
617df4397b0SStefano Zampini      PetscContainer - Simple PETSc object that contains a pointer to any required data
618df4397b0SStefano Zampini 
619df4397b0SStefano Zampini    Level: advanced
620df4397b0SStefano Zampini 
62187497f52SBarry Smith    Note:
62287497f52SBarry Smith    This is useful to attach arbitrary data to a `PetscObject` with `PetscObjectCompose()` and `PetscObjectQuery()`
62387497f52SBarry Smith 
62487497f52SBarry Smith .seealso: `PetscObject`, `PetscContainerCreate()`, `PetscObjectCompose()`, `PetscObjectQuery()`
625df4397b0SStefano Zampini S*/
626df4397b0SStefano Zampini typedef struct _p_PetscContainer *PetscContainer;
627df4397b0SStefano Zampini 
628df4397b0SStefano Zampini /*S
629df4397b0SStefano Zampini      PetscRandom - Abstract PETSc object that manages generating random numbers
630df4397b0SStefano Zampini 
631df4397b0SStefano Zampini    Level: intermediate
632df4397b0SStefano Zampini 
633db781477SPatrick Sanan .seealso: `PetscRandomCreate()`, `PetscRandomGetValue()`, `PetscRandomType`
634df4397b0SStefano Zampini S*/
635df4397b0SStefano Zampini typedef struct _p_PetscRandom *PetscRandom;
636df4397b0SStefano Zampini 
637df4397b0SStefano Zampini /*
638df4397b0SStefano Zampini    In binary files variables are stored using the following lengths,
639df4397b0SStefano Zampini   regardless of how they are stored in memory on any one particular
640df4397b0SStefano Zampini   machine. Use these rather then sizeof() in computing sizes for
641df4397b0SStefano Zampini   PetscBinarySeek().
642df4397b0SStefano Zampini */
643df4397b0SStefano Zampini #define PETSC_BINARY_INT_SIZE    (32 / 8)
644df4397b0SStefano Zampini #define PETSC_BINARY_FLOAT_SIZE  (32 / 8)
645df4397b0SStefano Zampini #define PETSC_BINARY_CHAR_SIZE   (8 / 8)
646df4397b0SStefano Zampini #define PETSC_BINARY_SHORT_SIZE  (16 / 8)
647df4397b0SStefano Zampini #define PETSC_BINARY_DOUBLE_SIZE (64 / 8)
648df4397b0SStefano Zampini #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar)
649df4397b0SStefano Zampini 
650df4397b0SStefano Zampini /*E
65187497f52SBarry Smith   PetscBinarySeekType - argument to `PetscBinarySeek()`
652df4397b0SStefano Zampini 
653df4397b0SStefano Zampini   Level: advanced
654df4397b0SStefano Zampini 
655db781477SPatrick Sanan .seealso: `PetscBinarySeek()`, `PetscBinarySynchronizedSeek()`
656df4397b0SStefano Zampini E*/
6579371c9d4SSatish Balay typedef enum {
6589371c9d4SSatish Balay   PETSC_BINARY_SEEK_SET = 0,
6599371c9d4SSatish Balay   PETSC_BINARY_SEEK_CUR = 1,
6609371c9d4SSatish Balay   PETSC_BINARY_SEEK_END = 2
6619371c9d4SSatish Balay } PetscBinarySeekType;
662df4397b0SStefano Zampini 
663df4397b0SStefano Zampini /*E
664df4397b0SStefano Zampini     PetscBuildTwoSidedType - algorithm for setting up two-sided communication
665df4397b0SStefano Zampini 
66687497f52SBarry Smith $  `PETSC_BUILDTWOSIDED_ALLREDUCE` - classical algorithm using an MPI_Allreduce with
667df4397b0SStefano Zampini $      a buffer of length equal to the communicator size. Not memory-scalable due to
668df4397b0SStefano Zampini $      the large reduction size. Requires only MPI-1.
66987497f52SBarry Smith $  `PETSC_BUILDTWOSIDED_IBARRIER` - nonblocking algorithm based on MPI_Issend and MPI_Ibarrier.
670df4397b0SStefano Zampini $      Proved communication-optimal in Hoefler, Siebert, and Lumsdaine (2010). Requires MPI-3.
67187497f52SBarry Smith $  `PETSC_BUILDTWOSIDED_REDSCATTER` - similar to above, but use more optimized function
672df4397b0SStefano Zampini $      that only communicates the part of the reduction that is necessary.  Requires MPI-2.
673df4397b0SStefano Zampini 
674df4397b0SStefano Zampini    Level: developer
675df4397b0SStefano Zampini 
676db781477SPatrick Sanan .seealso: `PetscCommBuildTwoSided()`, `PetscCommBuildTwoSidedSetType()`, `PetscCommBuildTwoSidedGetType()`
677df4397b0SStefano Zampini E*/
678df4397b0SStefano Zampini typedef enum {
679df4397b0SStefano Zampini   PETSC_BUILDTWOSIDED_NOTSET     = -1,
680df4397b0SStefano Zampini   PETSC_BUILDTWOSIDED_ALLREDUCE  = 0,
681df4397b0SStefano Zampini   PETSC_BUILDTWOSIDED_IBARRIER   = 1,
682df4397b0SStefano Zampini   PETSC_BUILDTWOSIDED_REDSCATTER = 2
683df4397b0SStefano Zampini   /* Updates here must be accompanied by updates in finclude/petscsys.h and the string array in mpits.c */
684df4397b0SStefano Zampini } PetscBuildTwoSidedType;
685df4397b0SStefano Zampini 
686aa2d33c1SMatthew G. Knepley /* NOTE: If you change this, you must also change the values in src/vec/f90-mod/petscvec.h */
687df4397b0SStefano Zampini /*E
688df4397b0SStefano Zampini   InsertMode - Whether entries are inserted or added into vectors or matrices
689df4397b0SStefano Zampini 
690df4397b0SStefano Zampini   Level: beginner
691df4397b0SStefano Zampini 
692db781477SPatrick Sanan .seealso: `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`,
693db781477SPatrick Sanan           `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`,
694db781477SPatrick Sanan           `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`
695df4397b0SStefano Zampini E*/
6969371c9d4SSatish Balay typedef enum {
6979371c9d4SSatish Balay   NOT_SET_VALUES,
6989371c9d4SSatish Balay   INSERT_VALUES,
6999371c9d4SSatish Balay   ADD_VALUES,
7009371c9d4SSatish Balay   MAX_VALUES,
7019371c9d4SSatish Balay   MIN_VALUES,
7029371c9d4SSatish Balay   INSERT_ALL_VALUES,
7039371c9d4SSatish Balay   ADD_ALL_VALUES,
7049371c9d4SSatish Balay   INSERT_BC_VALUES,
7059371c9d4SSatish Balay   ADD_BC_VALUES
7069371c9d4SSatish Balay } InsertMode;
707df4397b0SStefano Zampini 
708df4397b0SStefano Zampini /*MC
709df4397b0SStefano Zampini     INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value
710df4397b0SStefano Zampini 
711df4397b0SStefano Zampini     Level: beginner
712df4397b0SStefano Zampini 
713db781477SPatrick Sanan .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`,
714db781477SPatrick Sanan           `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `ADD_VALUES`,
715db781477SPatrick Sanan           `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES`
716df4397b0SStefano Zampini 
717df4397b0SStefano Zampini M*/
718df4397b0SStefano Zampini 
719df4397b0SStefano Zampini /*MC
720df4397b0SStefano Zampini     ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the
721df4397b0SStefano Zampini                 value into that location
722df4397b0SStefano Zampini 
723df4397b0SStefano Zampini     Level: beginner
724df4397b0SStefano Zampini 
725db781477SPatrick Sanan .seealso: `InsertMode`, `VecSetValues()`, `MatSetValues()`, `VecSetValue()`, `VecSetValuesBlocked()`,
726db781477SPatrick Sanan           `VecSetValuesLocal()`, `VecSetValuesBlockedLocal()`, `MatSetValuesBlocked()`, `INSERT_VALUES`,
727db781477SPatrick Sanan           `MatSetValuesBlockedLocal()`, `MatSetValuesLocal()`, `VecScatterBegin()`, `VecScatterEnd()`, `MAX_VALUES`
728df4397b0SStefano Zampini 
729df4397b0SStefano Zampini M*/
730df4397b0SStefano Zampini 
731df4397b0SStefano Zampini /*MC
732df4397b0SStefano Zampini     MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location
733df4397b0SStefano Zampini 
734df4397b0SStefano Zampini     Level: beginner
735df4397b0SStefano Zampini 
736db781477SPatrick Sanan .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES`
737df4397b0SStefano Zampini 
738df4397b0SStefano Zampini M*/
739df4397b0SStefano Zampini 
740421aa1e7SJunchao Zhang /*MC
741421aa1e7SJunchao Zhang     MIN_VALUES - Puts the minimal of the scattered/gathered value and the current value into each location
742421aa1e7SJunchao Zhang 
743421aa1e7SJunchao Zhang     Level: beginner
744421aa1e7SJunchao Zhang 
745db781477SPatrick Sanan .seealso: `InsertMode`, `VecScatterBegin()`, `VecScatterEnd()`, `ADD_VALUES`, `INSERT_VALUES`
746421aa1e7SJunchao Zhang 
747421aa1e7SJunchao Zhang M*/
748421aa1e7SJunchao Zhang 
749df4397b0SStefano Zampini /*S
750df4397b0SStefano Zampini    PetscSubcomm - A decomposition of an MPI communicator into subcommunicators
751df4397b0SStefano Zampini 
752df4397b0SStefano Zampini    Notes:
75387497f52SBarry Smith    After a call to `PetscSubcommSetType()`, `PetscSubcommSetTypeGeneral()`, or `PetscSubcommSetFromOptions()` one may call
75487497f52SBarry Smith $     `PetscSubcommChild()` returns the associated subcommunicator on this process
75587497f52SBarry Smith $     `PetscSubcommContiguousParent()` returns a parent communitor but with all child of the same subcommunicator having contiguous rank
756df4397b0SStefano Zampini 
757df4397b0SStefano Zampini    Sample Usage:
75887497f52SBarry Smith .vb
75987497f52SBarry Smith        `PetscSubcommCreate()`
76087497f52SBarry Smith        `PetscSubcommSetNumber()`
76187497f52SBarry Smith        `PetscSubcommSetType`(`PETSC_SUBCOMM_INTERLACED`);
76287497f52SBarry Smith        ccomm = `PetscSubcommChild()`
76387497f52SBarry Smith        `PetscSubcommDestroy()`
76487497f52SBarry Smith .ve
765df4397b0SStefano Zampini 
766df4397b0SStefano Zampini    Level: advanced
767df4397b0SStefano Zampini 
768df4397b0SStefano Zampini    Notes:
76987497f52SBarry 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
77087497f52SBarry Smith $   `PETSC_SUBCOMM_CONTIGUOUS` - each new communicator contains a set of process with contiguous ranks in the original MPI communicator
77187497f52SBarry Smith $   `PETSC_SUBCOMM_INTERLACED` - each new communictor contains a set of processes equally far apart in rank from the others in that new communicator
772df4397b0SStefano Zampini 
773df4397b0SStefano Zampini    Example: Consider a communicator with six processes split into 3 subcommunicators.
77487497f52SBarry 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
77587497f52SBarry Smith $     `PETSC_SUBCOMM_INTERLACED` - the first communicator contains rank 0,3, the second 1,4 and the third 2,5
776df4397b0SStefano Zampini 
77787497f52SBarry Smith    Developer Note:
77887497f52SBarry Smith    This is used in objects such as `PCREDUNDANT` to manage the subcommunicators on which the redundant computations
779df4397b0SStefano Zampini    are performed.
780df4397b0SStefano Zampini 
781db781477SPatrick Sanan .seealso: `PetscSubcommCreate()`, `PetscSubcommSetNumber()`, `PetscSubcommSetType()`, `PetscSubcommView()`, `PetscSubcommSetFromOptions()`
782df4397b0SStefano Zampini 
783df4397b0SStefano Zampini S*/
784df4397b0SStefano Zampini typedef struct _n_PetscSubcomm *PetscSubcomm;
7859371c9d4SSatish Balay typedef enum {
7869371c9d4SSatish Balay   PETSC_SUBCOMM_GENERAL    = 0,
7879371c9d4SSatish Balay   PETSC_SUBCOMM_CONTIGUOUS = 1,
7889371c9d4SSatish Balay   PETSC_SUBCOMM_INTERLACED = 2
7899371c9d4SSatish Balay } PetscSubcommType;
790df4397b0SStefano Zampini 
791df4397b0SStefano Zampini /*S
792df4397b0SStefano Zampini      PetscHeap - A simple class for managing heaps
793df4397b0SStefano Zampini 
794df4397b0SStefano Zampini    Level: intermediate
795df4397b0SStefano Zampini 
796db781477SPatrick Sanan .seealso: `PetscHeapCreate()`, `PetscHeapAdd()`, `PetscHeapPop()`, `PetscHeapPeek()`, `PetscHeapStash()`, `PetscHeapUnstash()`, `PetscHeapView()`, `PetscHeapDestroy()`
797df4397b0SStefano Zampini S*/
798df4397b0SStefano Zampini typedef struct _PetscHeap *PetscHeap;
799df4397b0SStefano Zampini 
800df4397b0SStefano Zampini typedef struct _n_PetscShmComm *PetscShmComm;
801df4397b0SStefano Zampini typedef struct _n_PetscOmpCtrl *PetscOmpCtrl;
802df4397b0SStefano Zampini 
803df4397b0SStefano Zampini /*S
804df4397b0SStefano Zampini    PetscSegBuffer - a segmented extendable buffer
805df4397b0SStefano Zampini 
806df4397b0SStefano Zampini    Level: developer
807df4397b0SStefano Zampini 
808db781477SPatrick Sanan .seealso: `PetscSegBufferCreate()`, `PetscSegBufferGet()`, `PetscSegBufferExtract()`, `PetscSegBufferDestroy()`
809df4397b0SStefano Zampini S*/
810df4397b0SStefano Zampini typedef struct _n_PetscSegBuffer *PetscSegBuffer;
811df4397b0SStefano Zampini 
812df4397b0SStefano Zampini typedef struct _n_PetscOptionsHelpPrinted *PetscOptionsHelpPrinted;
813df4397b0SStefano Zampini #endif
814