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