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