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