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 extern PetscCookie PETSC_DLLEXPORT PETSC_RANDOM_COOKIE; 28 29 #define PETSCRAND "petscrand" 30 #define PETSCRAND48 "petscrand48" 31 #define SPRNG "sprng" 32 #define PetscRandomType const char* 33 34 /* Logging support */ 35 extern PETSCVEC_DLLEXPORT PetscCookie PETSC_RANDOM_COOKIE; 36 37 EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscRandomInitializePackage(char *); 38 39 /*S 40 PetscRandom - Abstract PETSc object that manages generating random numbers 41 42 Level: intermediate 43 44 Concepts: random numbers 45 46 .seealso: PetscRandomCreate(), PetscRandomGetValue() 47 S*/ 48 typedef struct _p_PetscRandom* PetscRandom; 49 50 /* Dynamic creation and loading functions */ 51 extern PetscFList PetscRandomList; 52 extern PetscTruth PetscRandomRegisterAllCalled; 53 54 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomRegisterAll(const char []); 55 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomRegister(const char[],const char[],const char[],PetscErrorCode (*)(PetscRandom)); 56 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomRegisterDestroy(void); 57 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomSetType(PetscRandom, PetscRandomType); 58 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomSetFromOptions(PetscRandom); 59 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomPrintHelp(PetscRandom); 60 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomGetType(PetscRandom, PetscRandomType *); 61 62 /*MC 63 PetscRandomRegisterDynamic - Adds a new PetscRandom component implementation 64 65 Synopsis: 66 PetscErrorCode PetscRandomRegisterDynamic(char *name, char *path, char *func_name, PetscErrorCode (*create_func)(PetscRandom)) 67 68 Not Collective 69 70 Input Parameters: 71 + name - The name of a new user-defined creation routine 72 . path - The path (either absolute or relative) of the library containing this routine 73 . func_name - The name of routine to create method context 74 - create_func - The creation routine itself 75 76 Notes: 77 PetscRandomRegisterDynamic() may be called multiple times to add several user-defined vectors 78 79 If dynamic libraries are used, then the fourth input argument (routine_create) is ignored. 80 81 Sample usage: 82 .vb 83 PetscRandomRegisterDynamic("my_rand","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyPetscRandomtorCreate", MyPetscRandomtorCreate); 84 .ve 85 86 Then, your random type can be chosen with the procedural interface via 87 .vb 88 PetscRandomCreate(MPI_Comm, PetscRandom *); 89 PetscRandomSetType(PetscRandom,"my_random_name"); 90 .ve 91 or at runtime via the option 92 .vb 93 -random_type my_random_name 94 .ve 95 96 Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values. 97 If your function is not being put into a shared library then use PetscRandomRegister() instead 98 99 Level: advanced 100 101 .keywords: PetscRandom, register 102 .seealso: PetscRandomRegisterAll(), PetscRandomRegisterDestroy(), PetscRandomRegister() 103 M*/ 104 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 105 #define PetscRandomRegisterDynamic(a,b,c,d) PetscRandomRegister(a,b,c,0) 106 #else 107 #define PetscRandomRegisterDynamic(a,b,c,d) PetscRandomRegister(a,b,c,d) 108 #endif 109 110 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomCreate(MPI_Comm,PetscRandom*); 111 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomGetValue(PetscRandom,PetscScalar*); 112 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomGetValueReal(PetscRandom,PetscReal*); 113 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomGetValueImaginary(PetscRandom,PetscScalar*); 114 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomGetInterval(PetscRandom,PetscScalar*,PetscScalar*); 115 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomSetInterval(PetscRandom,PetscScalar,PetscScalar); 116 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomSetSeed(PetscRandom,unsigned long); 117 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomGetSeed(PetscRandom,unsigned long *); 118 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomSeed(PetscRandom); 119 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomDestroy(PetscRandom); 120 121 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetFullPath(const char[],char[],size_t); 122 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetRelativePath(const char[],char[],size_t); 123 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetWorkingDirectory(char[],size_t); 124 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetRealPath(char[],char[]); 125 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetHomeDirectory(char[],size_t); 126 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTestFile(const char[],char,PetscTruth*); 127 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTestDirectory(const char[],char,PetscTruth*); 128 129 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinaryRead(int,void*,PetscInt,PetscDataType); 130 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedBinaryRead(MPI_Comm,int,void*,PetscInt,PetscDataType); 131 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedBinaryWrite(MPI_Comm,int,void*,PetscInt,PetscDataType,PetscTruth); 132 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinaryWrite(int,void*,PetscInt,PetscDataType,PetscTruth); 133 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinaryOpen(const char[],PetscFileMode,int *); 134 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinaryClose(int); 135 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSharedTmp(MPI_Comm,PetscTruth *); 136 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSharedWorkingDirectory(MPI_Comm,PetscTruth *); 137 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetTmp(MPI_Comm,char *,size_t); 138 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFileRetrieve(MPI_Comm,const char *,char *,size_t,PetscTruth*); 139 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLs(MPI_Comm,const char[],char*,size_t,PetscTruth*); 140 141 /* 142 In binary files variables are stored using the following lengths, 143 regardless of how they are stored in memory on any one particular 144 machine. Use these rather then sizeof() in computing sizes for 145 PetscBinarySeek(). 146 */ 147 #define PETSC_BINARY_INT_SIZE (32/8) 148 #define PETSC_BINARY_FLOAT_SIZE (32/8) 149 #define PETSC_BINARY_CHAR_SIZE (8/8) 150 #define PETSC_BINARY_SHORT_SIZE (16/8) 151 #define PETSC_BINARY_DOUBLE_SIZE (64/8) 152 #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar) 153 154 /*E 155 PetscBinarySeekType - argument to PetscBinarySeek() 156 157 Level: advanced 158 159 .seealso: PetscBinarySeek(), PetscSynchronizedBinarySeek() 160 E*/ 161 typedef enum {PETSC_BINARY_SEEK_SET = 0,PETSC_BINARY_SEEK_CUR = 1,PETSC_BINARY_SEEK_END = 2} PetscBinarySeekType; 162 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinarySeek(int,off_t,PetscBinarySeekType,off_t*); 163 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedBinarySeek(MPI_Comm,int,off_t,PetscBinarySeekType,off_t*); 164 165 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetDebugger(const char[],PetscTruth); 166 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetDefaultDebugger(void); 167 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetDebuggerFromString(char*); 168 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscAttachDebugger(void); 169 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStopForDebugger(void); 170 171 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGatherNumberOfMessages(MPI_Comm,PetscMPIInt*,PetscMPIInt*,PetscMPIInt*); 172 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGatherMessageLengths(MPI_Comm,PetscMPIInt,PetscMPIInt,PetscMPIInt*,PetscMPIInt**,PetscMPIInt**); 173 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGatherMessageLengths2(MPI_Comm,PetscMPIInt,PetscMPIInt,PetscMPIInt*,PetscMPIInt*,PetscMPIInt**,PetscMPIInt**,PetscMPIInt**); 174 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPostIrecvInt(MPI_Comm,PetscMPIInt,PetscMPIInt,PetscMPIInt*,PetscMPIInt*,PetscInt***,MPI_Request**); 175 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPostIrecvScalar(MPI_Comm,PetscMPIInt,PetscMPIInt,PetscMPIInt*,PetscMPIInt*,PetscScalar***,MPI_Request**); 176 177 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSSEIsEnabled(MPI_Comm,PetscTruth *,PetscTruth *); 178 179 /*E 180 InsertMode - Whether entries are inserted or added into vectors or matrices 181 182 Level: beginner 183 184 .seealso: VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(), 185 VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), 186 MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd() 187 E*/ 188 typedef enum {NOT_SET_VALUES, INSERT_VALUES, ADD_VALUES, MAX_VALUES} InsertMode; 189 190 /*MC 191 INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value 192 193 Level: beginner 194 195 .seealso: InsertMode, VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(), 196 VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), ADD_VALUES, INSERT_VALUES, 197 MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd() 198 199 M*/ 200 201 /*MC 202 ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the 203 value into that location 204 205 Level: beginner 206 207 .seealso: InsertMode, VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(), 208 VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), ADD_VALUES, INSERT_VALUES, 209 MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd() 210 211 M*/ 212 213 /*MC 214 MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location 215 216 Level: beginner 217 218 .seealso: InsertMode, VecScatterBegin(), VecScatterEnd(), ADD_VALUES, INSERT_VALUES 219 220 M*/ 221 222 /*E 223 ScatterMode - Determines the direction of a scatter 224 225 Level: beginner 226 227 .seealso: VecScatter, VecScatterBegin(), VecScatterEnd() 228 E*/ 229 typedef enum {SCATTER_FORWARD=0, SCATTER_REVERSE=1, SCATTER_FORWARD_LOCAL=2, SCATTER_REVERSE_LOCAL=3, SCATTER_LOCAL=2} ScatterMode; 230 231 /*MC 232 SCATTER_FORWARD - Scatters the values as dictated by the VecScatterCreate() call 233 234 Level: beginner 235 236 .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD_LOCAL, 237 SCATTER_REVERSE_LOCAL 238 239 M*/ 240 241 /*MC 242 SCATTER_REVERSE - Moves the values in the opposite direction then the directions indicated in 243 in the VecScatterCreate() 244 245 Level: beginner 246 247 .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL, 248 SCATTER_REVERSE_LOCAL 249 250 M*/ 251 252 /*MC 253 SCATTER_FORWARD_LOCAL - Scatters the values as dictated by the VecScatterCreate() call except NO parallel communication 254 is done. Any variables that have be moved between processes are ignored 255 256 Level: developer 257 258 .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD, 259 SCATTER_REVERSE_LOCAL 260 261 M*/ 262 263 /*MC 264 SCATTER_REVERSE_LOCAL - Moves the values in the opposite direction then the directions indicated in 265 in the VecScatterCreate() except NO parallel communication 266 is done. Any variables that have be moved between processes are ignored 267 268 Level: developer 269 270 .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL, 271 SCATTER_REVERSE 272 273 M*/ 274 275 276 PETSC_EXTERN_CXX_END 277 #endif /* __PETSCSYS_H */ 278