6
6
#if !defined(__PETSC_H)
10
Macros for indicating code that should be compiled with a C interface,
11
rather than a C++ interface. Any routines that are dynamically loaded
12
(such as the PCCreate_XXX() routines) must be wrapped so that the name
13
mangler does not change the functions symbol name. This just hides the
14
ugly extern "C" {} wrappers.
8
/* ========================================================================== */
10
This facilitates using C version of PETSc from C++
16
#if defined(__cplusplus)
17
#define EXTERN_C_BEGIN extern "C" {
18
#define EXTERN_C_END }
13
#if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus)
14
#define PETSC_EXTERN_CXX_BEGIN extern "C" {
15
#define PETSC_EXTERN_CXX_END }
20
#define EXTERN_C_BEGIN
17
#define PETSC_EXTERN_CXX_BEGIN
18
#define PETSC_EXTERN_CXX_END
26
20
/* ========================================================================== */
28
22
Current PETSc version number and release date
81
84
typedef enum { PETSC_FALSE,PETSC_TRUE } PetscTruth;
87
PETSC_NULL - standard way of passing in a null or array or pointer
91
Notes: accepted by many PETSc functions to not set a parameter and instead use
94
This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER,
95
PETSC_NULL_DOUBLE_PRECISION etc
97
.seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE
83
100
#define PETSC_NULL 0
103
PETSC_DECIDE - standard way of passing in integer or floating point parameter
104
where you wish PETSc to use the default.
108
.seealso: PETSC_NULL, PETSC_DEFAULT, PETSC_IGNORE, PETSC_DETERMINE
84
111
#define PETSC_DECIDE -1
114
PETSC_DEFAULT - standard way of passing in integer or floating point parameter
115
where you wish PETSc to use the default.
119
.seealso: PETSC_DECIDE, PETSC_NULL, PETSC_IGNORE, PETSC_DETERMINE
85
122
#define PETSC_DEFAULT -2
87
124
#define PETSC_YES PETSC_TRUE
88
125
#define PETSC_NO PETSC_FALSE
128
PETSC_IGNORE - same as PETSC_NULL, means PETSc will ignore this argument
132
Notes: accepted by many PETSc functions to not set a parameter and instead use
135
This macro does not exist in Fortran; you must use PETSC_NULL_INTEGER,
136
PETSC_NULL_DOUBLE_PRECISION etc
138
.seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_NULL, PETSC_DETERMINE
89
141
#define PETSC_IGNORE PETSC_NULL
144
PETSC_DETERMINE - standard way of passing in integer or floating point parameter
145
where you wish PETSc to compute the required value.
149
.seealso: PETSC_DECIDE, PETSC_DEFAULT, PETSC_IGNORE, PETSC_NULL, VecSetSizes()
90
152
#define PETSC_DETERMINE PETSC_DECIDE
155
PETSC_COMM_WORLD - a duplicate of the MPI_COMM_WORLD communicator which represents
160
Notes: PETSC_COMM_WORLD and MPI_COMM_WORLD are equivalent except that passing MPI_COMM_WORLD
161
into PETSc object constructors will result in using more MPI resources since an MPI_Comm_dup()
162
will be done on it internally. We recommend always using PETSC_COMM_WORLD
164
.seealso: PETSC_COMM_SELF
93
167
extern MPI_Comm PETSC_COMM_WORLD;
170
PETSC_COMM_SELF - a duplicate of the MPI_COMM_SELF communicator which represents
175
Notes: PETSC_COMM_SELF and MPI_COMM_SELF are equivalent except that passint MPI_COMM_SELF
176
into PETSc object constructors will result in using more MPI resources since an MPI_Comm_dup()
177
will be done on it internally. We recommend always using PETSC_COMM_SELF
179
.seealso: PETSC_COMM_WORLD
94
182
extern MPI_Comm PETSC_COMM_SELF;
95
184
extern PetscTruth PetscInitializeCalled;
96
185
EXTERN int PetscSetCommWorld(MPI_Comm);
97
186
EXTERN int PetscSetHelpVersionFunctions(int (*)(MPI_Comm),int (*)(MPI_Comm));
187
EXTERN int PetscCommDuplicate(MPI_Comm,MPI_Comm*,int*);
188
EXTERN int PetscCommDestroy(MPI_Comm*);
100
191
PetscMalloc - Allocates memory
159
250
#define PetscFree(a) (*PetscTrFree)((a),__LINE__,__FUNCT__,__FILE__,__SDIR__)
160
EXTERN int (*PetscTrMalloc)(int,int,char*,char*,char*,void**);
161
EXTERN int (*PetscTrFree)(void *,int,char*,char*,char*);
162
EXTERN int PetscSetMalloc(int (*)(int,int,char*,char*,char*,void**),int (*)(void *,int,char*,char*,char*));
251
EXTERN int (*PetscTrMalloc)(size_t,int,const char[],const char[],const char[],void**);
252
EXTERN int (*PetscTrFree)(void *,int,const char[],const char[],const char[]);
253
EXTERN int PetscSetMalloc(int (*)(size_t,int,const char[],const char[],const char[],void**),int (*)(void *,int,const char[],const char[],const char[]));
163
254
EXTERN int PetscClearMalloc(void);
232
323
EXTERN int PetscStrcat(char[],const char[]);
233
324
EXTERN int PetscStrncat(char[],const char[],int);
234
325
EXTERN int PetscStrncpy(char[],const char[],int);
235
EXTERN int PetscStrchr(const char[],char,char **);
326
EXTERN int PetscStrchr(const char[],char,char *[]);
236
327
EXTERN int PetscStrtolower(char[]);
237
EXTERN int PetscStrrchr(const char[],char,char **);
238
EXTERN int PetscStrstr(const char[],const char[],char **);
239
EXTERN int PetscStrallocpy(const char[],char **);
240
EXTERN int PetscStrreplace(MPI_Comm,const char[],char*,int);
328
EXTERN int PetscStrrchr(const char[],char,char *[]);
329
EXTERN int PetscStrstr(const char[],const char[],char *[]);
330
EXTERN int PetscStrallocpy(const char[],char *[]);
331
EXTERN int PetscStrreplace(MPI_Comm,const char[],char[],int);
241
332
#define PetscStrfree(a) ((a) ? PetscFree(a) : 0)
242
333
typedef struct {char token;char *array;char *current;} PetscToken;
243
334
EXTERN int PetscTokenCreate(const char[],const char,PetscToken**);
244
EXTERN int PetscTokenFind(PetscToken*,char **);
335
EXTERN int PetscTokenFind(PetscToken*,char *[]);
245
336
EXTERN int PetscTokenDestroy(PetscToken*);
254
345
#define PetscSum_Op MPI_SUM
347
EXTERN int PetscMaxSum(MPI_Comm,const int[],int*,int*);
258
PetscObject - any PETSc object, PetscViewer, Mat, Vec, SLES etc
350
PetscObject - any PETSc object, PetscViewer, Mat, Vec, KSP etc
354
Note: This is the base class from which all objects appear.
262
356
.seealso: PetscObjectDestroy(), PetscObjectView(), PetscObjectGetName(), PetscObjectSetName()
264
358
typedef struct _p_PetscObject* PetscObject;
303
397
PetscTryMethod - Queries an object for a method, if it exists then calls it.
304
Can support argument checking
398
These are intended to be used only inside PETSc functions.
306
#if defined(PETSC_FORTRAN_STUBS)
307
#define PetscTryMethod(obj,A,B,C) \
309
*ierr = PetscObjectQueryFunction((PetscObject)obj,#A,(PetscVoidFunction)&f);if (*ierr) return; \
310
if (f) {*ierr = (*f)C;if (*ierr) return;}\
313
400
#define PetscTryMethod(obj,A,B,C) \
314
401
0;{ int (*f)B, __ierr; \
315
402
__ierr = PetscObjectQueryFunction((PetscObject)obj,#A,(PetscVoidFunction)&f);CHKERRQ(__ierr); \
316
403
if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\
405
#define PetscUseMethod(obj,A,B,C) \
406
0;{ int (*f)B, __ierr; \
407
__ierr = PetscObjectQueryFunction((PetscObject)obj,A,(PetscVoidFunction)&f);CHKERRQ(__ierr); \
408
if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\
409
else {SETERRQ1(1,"Cannot locate function %s in object",A);} \
321
412
Functions that can act on any PETSc object.
338
429
EXTERN int PetscObjectCompose(PetscObject,const char[],PetscObject);
339
430
EXTERN int PetscObjectQuery(PetscObject,const char[],PetscObject *);
340
431
EXTERN int PetscObjectComposeFunction(PetscObject,const char[],const char[],void (*)(void));
433
typedef void (*FCNVOID)(void); /* cast in next macro should never be extern C */
434
typedef int (*FCNINTVOID)(void); /* used in casts to make sure they are not extern C */
436
PetscObjectComposeFunctionDynamic - Associates a function with a given PETSc object.
438
Collective on PetscObject
441
+ obj - the PETSc object; this must be cast with a (PetscObject), for example,
442
PetscObjectCompose((PetscObject)mat,...);
443
. name - name associated with the child function
444
. fname - name of the function
445
- ptr - function pointer (or PETSC_NULL if using dynamic libraries)
450
int PetscObjectComposeFunctionDynamic(PetscObject obj,const char name[],const char fname[],void *ptr)
453
PetscObjectComposeFunctionDynamic() can be used with any PETSc object (such as
454
Mat, Vec, KSP, SNES, etc.) or any user-provided object.
456
The composed function must be wrapped in a EXTERN_C_BEGIN/END for this to
457
work in C++/complex with dynamic link libraries (PETSC_USE_DYNAMIC_LIBRARIES)
460
Concepts: objects^composing functions
461
Concepts: composing functions
462
Concepts: functions^querying
463
Concepts: objects^querying
464
Concepts: querying objects
466
.seealso: PetscObjectQueryFunction()
341
468
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
342
469
#define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,0)
344
#define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,(void (*)(void))(d))
471
#define PetscObjectComposeFunctionDynamic(a,b,c,d) PetscObjectComposeFunction(a,b,c,(FCNVOID)(d))
346
474
EXTERN int PetscObjectQueryFunction(PetscObject,const char[],void (**)(void));
347
475
EXTERN int PetscObjectSetOptionsPrefix(PetscObject,const char[]);
348
476
EXTERN int PetscObjectAppendOptionsPrefix(PetscObject,const char[]);
349
477
EXTERN int PetscObjectPrependOptionsPrefix(PetscObject,const char[]);
350
478
EXTERN int PetscObjectGetOptionsPrefix(PetscObject,char*[]);
351
479
EXTERN int PetscObjectPublish(PetscObject);
352
EXTERN int PetscObjectChangeTypeName(PetscObject,char *);
353
EXTERN int PetscObjectChangeSerializeName(PetscObject,char *);
480
EXTERN int PetscObjectChangeTypeName(PetscObject,const char[]);
354
481
EXTERN int PetscObjectRegisterDestroy(PetscObject);
355
482
EXTERN int PetscObjectRegisterDestroyAll(void);
356
483
EXTERN int PetscObjectName(PetscObject);
357
EXTERN int PetscTypeCompare(PetscObject,char*,PetscTruth*);
358
EXTERN int PetscSerializeCompare(PetscObject,char*,PetscTruth*);
484
EXTERN int PetscTypeCompare(PetscObject,const char[],PetscTruth*);
361
487
Defines PETSc error handling.
384
510
EXTERN int PetscFListAdd(PetscFList*,const char[],const char[],void (*)(void));
385
511
EXTERN int PetscFListDestroy(PetscFList*);
386
512
EXTERN int PetscFListFind(MPI_Comm,PetscFList,const char[],void (**)(void));
387
EXTERN int PetscFListPrintTypes(MPI_Comm,FILE*,const char[],const char[],char *,char *,PetscFList);
513
EXTERN int PetscFListPrintTypes(MPI_Comm,FILE*,const char[],const char[],const char[],const char[],PetscFList);
388
514
#if defined(PETSC_USE_DYNAMIC_LIBRARIES)
389
515
#define PetscFListAddDynamic(a,b,p,c) PetscFListAdd(a,b,p,0)
491
617
EXTERN int PetscFClose(MPI_Comm,FILE*);
492
618
EXTERN int PetscFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4);
493
619
EXTERN int PetscPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
622
PetscErrorPrintf - Prints error messages.
627
int (*PetscErrorPrintf)(const char format[],...);
630
. format - the usual printf() format string
632
Options Database Keys:
633
. -error_output_stderr - cause error messages to be printed to stderr instead of the
640
This routine is not supported in Fortran.
642
Concepts: error messages^printing
643
Concepts: printing^error messages
645
.seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscHelpPrintf()
494
647
EXTERN int (*PetscErrorPrintf)(const char[],...);
650
PetscHelpPrintf - Prints help messages.
655
int (*PetscHelpPrintf)(const char format[],...);
658
. format - the usual printf() format string
663
This routine is not supported in Fortran.
665
Concepts: help messages^printing
666
Concepts: printing^help messages
668
.seealso: PetscFPrintf(), PetscSynchronizedPrintf(), PetscErrorPrintf()
495
670
EXTERN int (*PetscHelpPrintf)(MPI_Comm,const char[],...);
496
EXTERN int PetscPOpen(MPI_Comm,char *,char*,const char[],FILE **);
672
EXTERN int PetscPOpen(MPI_Comm,const char[],const char[],const char[],FILE **);
497
673
EXTERN int PetscPClose(MPI_Comm,FILE*);
498
674
EXTERN int PetscSynchronizedPrintf(MPI_Comm,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
499
675
EXTERN int PetscSynchronizedFPrintf(MPI_Comm,FILE*,const char[],...) PETSC_PRINTF_FORMAT_CHECK(3,4);
500
676
EXTERN int PetscSynchronizedFlush(MPI_Comm);
501
677
EXTERN int PetscSynchronizedFGets(MPI_Comm,FILE*,int,char[]);
502
EXTERN int PetscStartMatlab(MPI_Comm,char *,char*,FILE**);
503
EXTERN int PetscStartJava(MPI_Comm,char *,char*,FILE**);
504
EXTERN int PetscGetPetscDir(char**);
678
EXTERN int PetscStartMatlab(MPI_Comm,const char[],const char[],FILE**);
679
EXTERN int PetscStartJava(MPI_Comm,const char[],const char[],FILE**);
680
EXTERN int PetscGetPetscDir(const char*[]);
506
682
EXTERN int PetscPopUpSelect(MPI_Comm,char*,char*,int,char**,int*);
836
MPI_Comm - the basic object used by MPI to determine which processes are involved in a
841
Note: This manual page is a place-holder because MPICH does not have a manual page for MPI_Comm
843
.seealso: size, rank, comm, PETSC_COMM_WORLD, PETSC_COMM_SELF
645
847
PetscScalar - PETSc type that represents either a double precision real number or
646
848
a double precision complex number if the code is compiled with BOPT=g_complex or O_complex
852
.seealso: PetscReal, PassiveReal, PassiveScalar
856
PetscReal - PETSc type that represents a double precision real number
860
.seealso: PetscScalar, PassiveReal, PassiveScalar
864
PassiveScalar - PETSc type that represents either a double precision real number or
865
a double precision complex number if the code is compiled with BOPT=g_complex or O_complex
869
This is the same as a PetscScalar except in code that is automatically differentiated it is
870
treated as a constant (not an indendent or dependent variable)
872
.seealso: PetscReal, PassiveReal, PetscScalar
876
PassiveReal - PETSc type that represents a double precision real number
880
This is the same as a PetscReal except in code that is automatically differentiated it is
881
treated as a constant (not an indendent or dependent variable)
883
.seealso: PetscScalar, PetscReal, PassiveScalar