Actual source code: petscsys.h
1: /*
2: Provides access to system related and general utility routines.
3: */
6: #include petsc.h
9: EXTERN PetscErrorCode PetscGetArchType(char[],size_t);
10: EXTERN PetscErrorCode PetscGetHostName(char[],size_t);
11: EXTERN PetscErrorCode PetscGetUserName(char[],size_t);
12: EXTERN PetscErrorCode PetscGetProgramName(char[],size_t);
13: EXTERN PetscErrorCode PetscSetProgramName(const char[]);
14: EXTERN PetscErrorCode PetscGetDate(char[],size_t);
16: EXTERN PetscErrorCode PetscSortInt(PetscInt,PetscInt[]);
17: EXTERN PetscErrorCode PetscSortIntWithPermutation(PetscInt,const PetscInt[],PetscInt[]);
18: EXTERN PetscErrorCode PetscSortStrWithPermutation(PetscInt,const char*[],PetscInt[]);
19: EXTERN PetscErrorCode PetscSortIntWithArray(PetscInt,PetscInt[],PetscInt[]);
20: EXTERN PetscErrorCode PetscSortMPIIntWithArray(PetscMPIInt,PetscMPIInt[],PetscMPIInt[]);
21: EXTERN PetscErrorCode PetscSortIntWithScalarArray(PetscInt,PetscInt[],PetscScalar[]);
22: EXTERN PetscErrorCode PetscSortReal(PetscInt,PetscReal[]);
23: EXTERN PetscErrorCode PetscSortRealWithPermutation(PetscInt,const PetscReal[],PetscInt[]);
25: EXTERN PetscErrorCode PetscSetDisplay(void);
26: EXTERN PetscErrorCode PetscGetDisplay(char[],size_t);
28: /*E
29: PetscRandomType - String with the name of a PETSc randomizer
30: with an optional dynamic library name, for example
31: http://www.mcs.anl.gov/petsc/lib.a:myrandcreate()
33: Level: beginner
35: Notes: to use the SPRNG you must have config/configure.py PETSc
36: with the option --download-sprng
38: .seealso: PetscRandomSetType(), PetscRandom
39: E*/
40: #define PetscRandomType char*
41: #define PETSCRAND "rand"
42: #define PETSCRAND48 "rand48"
43: #define PETSCSPRNG "sprng"
45: /* Logging support */
48: EXTERN PetscErrorCode PetscRandomInitializePackage(const char[]);
50: /*S
51: PetscRandom - Abstract PETSc object that manages generating random numbers
53: Level: intermediate
55: Concepts: random numbers
57: .seealso: PetscRandomCreate(), PetscRandomGetValue(), PetscRandomType
58: S*/
59: typedef struct _p_PetscRandom* PetscRandom;
61: /* Dynamic creation and loading functions */
65: EXTERN PetscErrorCode PetscRandomRegisterAll(const char []);
66: EXTERN PetscErrorCode PetscRandomRegister(const char[],const char[],const char[],PetscErrorCode (*)(PetscRandom));
67: EXTERN PetscErrorCode PetscRandomRegisterDestroy(void);
68: EXTERN PetscErrorCode PetscRandomSetType(PetscRandom, const PetscRandomType);
69: EXTERN PetscErrorCode PetscRandomSetFromOptions(PetscRandom);
70: EXTERN PetscErrorCode PetscRandomGetType(PetscRandom, const PetscRandomType*);
71: EXTERN PetscErrorCode PetscRandomViewFromOptions(PetscRandom,char*);
72: EXTERN PetscErrorCode PetscRandomView(PetscRandom,PetscViewer);
74: /*MC
75: PetscRandomRegisterDynamic - Adds a new PetscRandom component implementation
77: Synopsis:
78: PetscErrorCode PetscRandomRegisterDynamic(char *name, char *path, char *func_name, PetscErrorCode (*create_func)(PetscRandom))
80: Not Collective
82: Input Parameters:
83: + name - The name of a new user-defined creation routine
84: . path - The path (either absolute or relative) of the library containing this routine
85: . func_name - The name of routine to create method context
86: - create_func - The creation routine itself
88: Notes:
89: PetscRandomRegisterDynamic() may be called multiple times to add several user-defined randome number generators
91: If dynamic libraries are used, then the fourth input argument (routine_create) is ignored.
93: Sample usage:
94: .vb
95: PetscRandomRegisterDynamic("my_rand","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyPetscRandomtorCreate", MyPetscRandomtorCreate);
96: .ve
98: Then, your random type can be chosen with the procedural interface via
99: .vb
100: PetscRandomCreate(MPI_Comm, PetscRandom *);
101: PetscRandomSetType(PetscRandom,"my_random_name");
102: .ve
103: or at runtime via the option
104: .vb
105: -random_type my_random_name
106: .ve
108: Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
110: For an example of the code needed to interface your own random number generator see
111: src/sys/random/impls/rand/rand.c
112:
113: Level: advanced
115: .keywords: PetscRandom, register
116: .seealso: PetscRandomRegisterAll(), PetscRandomRegisterDestroy(), PetscRandomRegister()
117: M*/
118: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
119: #define PetscRandomRegisterDynamic(a,b,c,d) PetscRandomRegister(a,b,c,0)
120: #else
121: #define PetscRandomRegisterDynamic(a,b,c,d) PetscRandomRegister(a,b,c,d)
122: #endif
124: EXTERN PetscErrorCode PetscRandomCreate(MPI_Comm,PetscRandom*);
125: EXTERN PetscErrorCode PetscRandomGetValue(PetscRandom,PetscScalar*);
126: EXTERN PetscErrorCode PetscRandomGetValueReal(PetscRandom,PetscReal*);
127: EXTERN PetscErrorCode PetscRandomGetValueImaginary(PetscRandom,PetscScalar*);
128: EXTERN PetscErrorCode PetscRandomGetInterval(PetscRandom,PetscScalar*,PetscScalar*);
129: EXTERN PetscErrorCode PetscRandomSetInterval(PetscRandom,PetscScalar,PetscScalar);
130: EXTERN PetscErrorCode PetscRandomSetSeed(PetscRandom,unsigned long);
131: EXTERN PetscErrorCode PetscRandomGetSeed(PetscRandom,unsigned long *);
132: EXTERN PetscErrorCode PetscRandomSeed(PetscRandom);
133: EXTERN PetscErrorCode PetscRandomDestroy(PetscRandom);
135: EXTERN PetscErrorCode PetscGetFullPath(const char[],char[],size_t);
136: EXTERN PetscErrorCode PetscGetRelativePath(const char[],char[],size_t);
137: EXTERN PetscErrorCode PetscGetWorkingDirectory(char[],size_t);
138: EXTERN PetscErrorCode PetscGetRealPath(const char[],char[]);
139: EXTERN PetscErrorCode PetscGetHomeDirectory(char[],size_t);
140: EXTERN PetscErrorCode PetscTestFile(const char[],char,PetscTruth*);
141: EXTERN PetscErrorCode PetscTestDirectory(const char[],char,PetscTruth*);
143: EXTERN PetscErrorCode PetscBinaryRead(int,void*,PetscInt,PetscDataType);
144: EXTERN PetscErrorCode PetscBinarySynchronizedRead(MPI_Comm,int,void*,PetscInt,PetscDataType);
145: EXTERN PetscErrorCode PetscBinarySynchronizedWrite(MPI_Comm,int,void*,PetscInt,PetscDataType,PetscTruth);
146: EXTERN PetscErrorCode PetscBinaryWrite(int,void*,PetscInt,PetscDataType,PetscTruth);
147: EXTERN PetscErrorCode PetscBinaryOpen(const char[],PetscFileMode,int *);
148: EXTERN PetscErrorCode PetscBinaryClose(int);
149: EXTERN PetscErrorCode PetscSharedTmp(MPI_Comm,PetscTruth *);
150: EXTERN PetscErrorCode PetscSharedWorkingDirectory(MPI_Comm,PetscTruth *);
151: EXTERN PetscErrorCode PetscGetTmp(MPI_Comm,char[],size_t);
152: EXTERN PetscErrorCode PetscFileRetrieve(MPI_Comm,const char[],char[],size_t,PetscTruth*);
153: EXTERN PetscErrorCode PetscLs(MPI_Comm,const char[],char[],size_t,PetscTruth*);
155: /*
156: In binary files variables are stored using the following lengths,
157: regardless of how they are stored in memory on any one particular
158: machine. Use these rather then sizeof() in computing sizes for
159: PetscBinarySeek().
160: */
161: #define PETSC_BINARY_INT_SIZE (32/8)
162: #define PETSC_BINARY_FLOAT_SIZE (32/8)
163: #define PETSC_BINARY_CHAR_SIZE (8/8)
164: #define PETSC_BINARY_SHORT_SIZE (16/8)
165: #define PETSC_BINARY_DOUBLE_SIZE (64/8)
166: #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar)
168: /*E
169: PetscBinarySeekType - argument to PetscBinarySeek()
171: Level: advanced
173: .seealso: PetscBinarySeek(), PetscBinarySynchronizedSeek()
174: E*/
175: typedef enum {PETSC_BINARY_SEEK_SET = 0,PETSC_BINARY_SEEK_CUR = 1,PETSC_BINARY_SEEK_END = 2} PetscBinarySeekType;
176: EXTERN PetscErrorCode PetscBinarySeek(int,off_t,PetscBinarySeekType,off_t*);
177: EXTERN PetscErrorCode PetscBinarySynchronizedSeek(MPI_Comm,int,off_t,PetscBinarySeekType,off_t*);
179: EXTERN PetscErrorCode PetscSetDebugTerminal(const char[]);
180: EXTERN PetscErrorCode PetscSetDebugger(const char[],PetscTruth);
181: EXTERN PetscErrorCode PetscSetDefaultDebugger(void);
182: EXTERN PetscErrorCode PetscSetDebuggerFromString(char*);
183: EXTERN PetscErrorCode PetscAttachDebugger(void);
184: EXTERN PetscErrorCode PetscStopForDebugger(void);
186: EXTERN PetscErrorCode PetscGatherNumberOfMessages(MPI_Comm,const PetscMPIInt[],const PetscMPIInt[],PetscMPIInt*);
187: EXTERN PetscErrorCode PetscGatherMessageLengths(MPI_Comm,PetscMPIInt,PetscMPIInt,const PetscMPIInt[],PetscMPIInt**,PetscMPIInt**);
188: EXTERN PetscErrorCode PetscGatherMessageLengths2(MPI_Comm,PetscMPIInt,PetscMPIInt,const PetscMPIInt[],const PetscMPIInt[],PetscMPIInt**,PetscMPIInt**,PetscMPIInt**);
189: EXTERN PetscErrorCode PetscPostIrecvInt(MPI_Comm,PetscMPIInt,PetscMPIInt,const PetscMPIInt[],const PetscMPIInt[],PetscInt***,MPI_Request**);
190: EXTERN PetscErrorCode PetscPostIrecvScalar(MPI_Comm,PetscMPIInt,PetscMPIInt,const PetscMPIInt[],const PetscMPIInt[],PetscScalar***,MPI_Request**);
192: EXTERN PetscErrorCode PetscSSEIsEnabled(MPI_Comm,PetscTruth *,PetscTruth *);
194: /*E
195: InsertMode - Whether entries are inserted or added into vectors or matrices
197: Level: beginner
199: .seealso: VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(),
200: VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(),
201: MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd()
202: E*/
203: typedef enum {NOT_SET_VALUES, INSERT_VALUES, ADD_VALUES, MAX_VALUES} InsertMode;
205: /*MC
206: INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value
208: Level: beginner
210: .seealso: InsertMode, VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(),
211: VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), ADD_VALUES, INSERT_VALUES,
212: MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd()
214: M*/
216: /*MC
217: ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the
218: value into that location
220: Level: beginner
222: .seealso: InsertMode, VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(),
223: VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), ADD_VALUES, INSERT_VALUES,
224: MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd()
226: M*/
228: /*MC
229: MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location
231: Level: beginner
233: .seealso: InsertMode, VecScatterBegin(), VecScatterEnd(), ADD_VALUES, INSERT_VALUES
235: M*/
237: /*E
238: ScatterMode - Determines the direction of a scatter
240: Level: beginner
242: .seealso: VecScatter, VecScatterBegin(), VecScatterEnd()
243: E*/
244: typedef enum {SCATTER_FORWARD=0, SCATTER_REVERSE=1, SCATTER_FORWARD_LOCAL=2, SCATTER_REVERSE_LOCAL=3, SCATTER_LOCAL=2} ScatterMode;
246: /*MC
247: SCATTER_FORWARD - Scatters the values as dictated by the VecScatterCreate() call
249: Level: beginner
251: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD_LOCAL,
252: SCATTER_REVERSE_LOCAL
254: M*/
256: /*MC
257: SCATTER_REVERSE - Moves the values in the opposite direction then the directions indicated in
258: in the VecScatterCreate()
260: Level: beginner
262: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL,
263: SCATTER_REVERSE_LOCAL
265: M*/
267: /*MC
268: SCATTER_FORWARD_LOCAL - Scatters the values as dictated by the VecScatterCreate() call except NO parallel communication
269: is done. Any variables that have be moved between processes are ignored
271: Level: developer
273: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD,
274: SCATTER_REVERSE_LOCAL
276: M*/
278: /*MC
279: SCATTER_REVERSE_LOCAL - Moves the values in the opposite direction then the directions indicated in
280: in the VecScatterCreate() except NO parallel communication
281: is done. Any variables that have be moved between processes are ignored
283: Level: developer
285: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL,
286: SCATTER_REVERSE
288: M*/
290: /*S
291: PetscSubcomm - Context of MPI subcommunicators, used by PCREDUNDANT
293: Level: advanced
295: Concepts: communicator, create
296: S*/
297: typedef struct _n_PetscSubcomm* PetscSubcomm;
299: struct _n_PetscSubcomm {
300: MPI_Comm parent; /* parent communicator */
301: MPI_Comm dupparent; /* duplicate parent communicator, under which the processors of this subcomm have contiguous rank */
302: MPI_Comm comm; /* this communicator */
303: PetscInt n; /* num of subcommunicators under the parent communicator */
304: PetscInt color; /* color of processors belong to this communicator */
305: };
307: EXTERN PetscErrorCode PetscSubcommCreate(MPI_Comm,PetscInt,PetscSubcomm*);
308: EXTERN PetscErrorCode PetscSubcommDestroy(PetscSubcomm);
311: #endif /* __PETSCSYS_H */