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