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 RANDOM_DEFAULT "random_default" 30 #define RANDOM_DEFAULT_REAL "random_default_real" 31 #define RANDOM_DEFAULT_IMAGINARY "random_default_imaginary" 32 #define PETSC_RAND "petsc_rand" 33 #define PETSC_RAND48 "petsc_rand48" 34 #define PetscRandomType const char* 35 36 /* Logging support */ 37 extern PETSCVEC_DLLEXPORT PetscCookie PETSC_RANDOM_COOKIE; 38 39 EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscRandomInitializePackage(char *); 40 41 /*S 42 PetscRandom - Abstract PETSc object that manages generating random numbers 43 44 Level: intermediate 45 46 Concepts: random numbers 47 48 .seealso: PetscRandomCreate(), PetscRandomGetValue() 49 S*/ 50 typedef struct _p_PetscRandom* PetscRandom; 51 52 /* Dynamic creation and loading functions */ 53 extern PetscFList PetscRandomList; 54 extern PetscTruth PetscRandomRegisterAllCalled; 55 56 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomRegisterAll(const char []); 57 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomRegister(const char[],const char[],const char[],PetscErrorCode (*)(PetscRandom*)); 58 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomRegisterDestroy(void); 59 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomSetType(PetscRandom, PetscRandomType); 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,PetscRandomType,PetscRandom*); 111 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomGetValue(PetscRandom,PetscScalar*); 112 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomGetInterval(PetscRandom,PetscScalar*,PetscScalar*); 113 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomSetInterval(PetscRandom,PetscScalar,PetscScalar); 114 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomSetSeed(PetscRandom,unsigned long); 115 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomGetSeed(PetscRandom,unsigned long *); 116 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomSeed(PetscRandom); 117 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscRandomDestroy(PetscRandom); 118 119 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetFullPath(const char[],char[],size_t); 120 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetRelativePath(const char[],char[],size_t); 121 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetWorkingDirectory(char[],size_t); 122 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetRealPath(char[],char[]); 123 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetHomeDirectory(char[],size_t); 124 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTestFile(const char[],char,PetscTruth*); 125 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscTestDirectory(const char[],char,PetscTruth*); 126 127 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinaryRead(int,void*,PetscInt,PetscDataType); 128 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedBinaryRead(MPI_Comm,int,void*,PetscInt,PetscDataType); 129 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedBinaryWrite(MPI_Comm,int,void*,PetscInt,PetscDataType,PetscTruth); 130 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinaryWrite(int,void*,PetscInt,PetscDataType,PetscTruth); 131 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinaryOpen(const char[],PetscFileMode,int *); 132 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinaryClose(int); 133 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSharedTmp(MPI_Comm,PetscTruth *); 134 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSharedWorkingDirectory(MPI_Comm,PetscTruth *); 135 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGetTmp(MPI_Comm,char *,size_t); 136 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscFileRetrieve(MPI_Comm,const char *,char *,size_t,PetscTruth*); 137 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscLs(MPI_Comm,const char[],char*,size_t,PetscTruth*); 138 139 /* 140 In binary files variables are stored using the following lengths, 141 regardless of how they are stored in memory on any one particular 142 machine. Use these rather then sizeof() in computing sizes for 143 PetscBinarySeek(). 144 */ 145 #define PETSC_BINARY_INT_SIZE (32/8) 146 #define PETSC_BINARY_FLOAT_SIZE (32/8) 147 #define PETSC_BINARY_CHAR_SIZE (8/8) 148 #define PETSC_BINARY_SHORT_SIZE (16/8) 149 #define PETSC_BINARY_DOUBLE_SIZE (64/8) 150 #define PETSC_BINARY_SCALAR_SIZE sizeof(PetscScalar) 151 152 /*E 153 PetscBinarySeekType - argument to PetscBinarySeek() 154 155 Level: advanced 156 157 .seealso: PetscBinarySeek(), PetscSynchronizedBinarySeek() 158 E*/ 159 typedef enum {PETSC_BINARY_SEEK_SET = 0,PETSC_BINARY_SEEK_CUR = 1,PETSC_BINARY_SEEK_END = 2} PetscBinarySeekType; 160 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscBinarySeek(int,off_t,PetscBinarySeekType,off_t*); 161 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSynchronizedBinarySeek(MPI_Comm,int,off_t,PetscBinarySeekType,off_t*); 162 163 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetDebugger(const char[],PetscTruth); 164 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetDefaultDebugger(void); 165 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSetDebuggerFromString(char*); 166 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscAttachDebugger(void); 167 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscStopForDebugger(void); 168 169 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGatherNumberOfMessages(MPI_Comm,PetscMPIInt*,PetscMPIInt*,PetscMPIInt*); 170 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGatherMessageLengths(MPI_Comm,PetscMPIInt,PetscMPIInt,PetscMPIInt*,PetscMPIInt**,PetscMPIInt**); 171 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscGatherMessageLengths2(MPI_Comm,PetscMPIInt,PetscMPIInt,PetscMPIInt*,PetscMPIInt*,PetscMPIInt**,PetscMPIInt**,PetscMPIInt**); 172 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPostIrecvInt(MPI_Comm,PetscMPIInt,PetscMPIInt,PetscMPIInt*,PetscMPIInt*,PetscInt***,MPI_Request**); 173 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscPostIrecvScalar(MPI_Comm,PetscMPIInt,PetscMPIInt,PetscMPIInt*,PetscMPIInt*,PetscScalar***,MPI_Request**); 174 175 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscSSEIsEnabled(MPI_Comm,PetscTruth *,PetscTruth *); 176 177 /*E 178 InsertMode - Whether entries are inserted or added into vectors or matrices 179 180 Level: beginner 181 182 .seealso: VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(), 183 VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), 184 MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd() 185 E*/ 186 typedef enum {NOT_SET_VALUES, INSERT_VALUES, ADD_VALUES, MAX_VALUES} InsertMode; 187 188 /*MC 189 INSERT_VALUES - Put a value into a vector or matrix, overwrites any previous value 190 191 Level: beginner 192 193 .seealso: InsertMode, VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(), 194 VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), ADD_VALUES, INSERT_VALUES, 195 MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd() 196 197 M*/ 198 199 /*MC 200 ADD_VALUES - Adds a value into a vector or matrix, if there previously was no value, just puts the 201 value into that location 202 203 Level: beginner 204 205 .seealso: InsertMode, VecSetValues(), MatSetValues(), VecSetValue(), VecSetValuesBlocked(), 206 VecSetValuesLocal(), VecSetValuesBlockedLocal(), MatSetValuesBlocked(), ADD_VALUES, INSERT_VALUES, 207 MatSetValuesBlockedLocal(), MatSetValuesLocal(), VecScatterBegin(), VecScatterEnd() 208 209 M*/ 210 211 /*MC 212 MAX_VALUES - Puts the maximum of the scattered/gathered value and the current value into each location 213 214 Level: beginner 215 216 .seealso: InsertMode, VecScatterBegin(), VecScatterEnd(), ADD_VALUES, INSERT_VALUES 217 218 M*/ 219 220 /*E 221 ScatterMode - Determines the direction of a scatter 222 223 Level: beginner 224 225 .seealso: VecScatter, VecScatterBegin(), VecScatterEnd() 226 E*/ 227 typedef enum {SCATTER_FORWARD=0, SCATTER_REVERSE=1, SCATTER_FORWARD_LOCAL=2, SCATTER_REVERSE_LOCAL=3, SCATTER_LOCAL=2} ScatterMode; 228 229 /*MC 230 SCATTER_FORWARD - Scatters the values as dictated by the VecScatterCreate() call 231 232 Level: beginner 233 234 .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD_LOCAL, 235 SCATTER_REVERSE_LOCAL 236 237 M*/ 238 239 /*MC 240 SCATTER_REVERSE - Moves the values in the opposite direction then the directions indicated in 241 in the VecScatterCreate() 242 243 Level: beginner 244 245 .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL, 246 SCATTER_REVERSE_LOCAL 247 248 M*/ 249 250 /*MC 251 SCATTER_FORWARD_LOCAL - Scatters the values as dictated by the VecScatterCreate() call except NO parallel communication 252 is done. Any variables that have be moved between processes are ignored 253 254 Level: developer 255 256 .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD, 257 SCATTER_REVERSE_LOCAL 258 259 M*/ 260 261 /*MC 262 SCATTER_REVERSE_LOCAL - Moves the values in the opposite direction then the directions indicated in 263 in the VecScatterCreate() except NO parallel communication 264 is done. Any variables that have be moved between processes are ignored 265 266 Level: developer 267 268 .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL, 269 SCATTER_REVERSE 270 271 M*/ 272 273 274 PETSC_EXTERN_CXX_END 275 #endif /* __PETSCSYS_H */ 276