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