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