1 /* 2 PetscViewers are objects where other objects can be looked at or stored. 3 */ 4 5 #if !defined(__PETSCVIEWER_H) 6 #define __PETSCVIEWER_H 7 8 #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus) 9 extern "C" { 10 #endif 11 12 /*S 13 PetscViewer - Abstract PETSc object that helps view (in ASCII, binary, graphically etc) 14 other PETSc objects 15 16 Level: beginner 17 18 Concepts: viewing 19 20 .seealso: PetscViewerCreate(), PetscViewerSetType(), PetscViewerType 21 S*/ 22 typedef struct _p_PetscViewer* PetscViewer; 23 24 #if defined(PETSC_USE_EXTERN_CXX) && defined(__cplusplus) 25 } 26 #endif 27 28 #include <petscsys.h> 29 30 PETSC_EXTERN PetscClassId PETSC_VIEWER_CLASSID; 31 32 /*J 33 PetscViewerType - String with the name of a PETSc PETScViewer 34 35 Level: beginner 36 37 .seealso: PetscViewerSetType(), PetscViewer 38 J*/ 39 typedef const char* PetscViewerType; 40 #define PETSCVIEWERSOCKET "socket" 41 #define PETSCVIEWERASCII "ascii" 42 #define PETSCVIEWERBINARY "binary" 43 #define PETSCVIEWERSTRING "string" 44 #define PETSCVIEWERDRAW "draw" 45 #define PETSCVIEWERVU "vu" 46 #define PETSCVIEWERMATHEMATICA "mathematica" 47 #define PETSCVIEWERNETCDF "netcdf" 48 #define PETSCVIEWERHDF5 "hdf5" 49 #define PETSCVIEWERVTK "vtk" 50 #define PETSCVIEWERMATLAB "matlab" 51 #define PETSCVIEWERAMS "ams" 52 53 PETSC_EXTERN PetscFunctionList PetscViewerList; 54 PETSC_EXTERN PetscErrorCode PetscViewerRegisterAll(const char *); 55 PETSC_EXTERN PetscErrorCode PetscViewerRegisterDestroy(void); 56 PETSC_EXTERN PetscErrorCode PetscViewerInitializePackage(const char[]); 57 58 PETSC_EXTERN PetscErrorCode PetscViewerRegister(const char*,const char*,const char*,PetscErrorCode (*)(PetscViewer)); 59 60 /*MC 61 PetscViewerRegisterDynamic - Adds a viewer 62 63 Synopsis 64 #include "petscviewer.h" 65 PetscErrorCode PetscViewerRegisterDynamic(const char *name_solver,const char *path,const char *name_create,PetscErrorCode (*routine_create)(PetscViewer)) 66 67 Not Collective 68 69 Input Parameters: 70 + name_solver - name of a new user-defined viewer 71 . path - path (either absolute or relative) the library containing this viewer 72 . name_create - name of routine to create method context 73 - routine_create - routine to create method context 74 75 Level: developer 76 77 Notes: 78 PetscViewerRegisterDynamic() may be called multiple times to add several user-defined viewers. 79 80 If dynamic libraries are used, then the fourth input argument (routine_create) 81 is ignored. 82 83 Sample usage: 84 .vb 85 PetscViewerRegisterDynamic("my_viewer_type",/home/username/my_lib/lib/libO/solaris/mylib.a, 86 "MyViewerCreate",MyViewerCreate); 87 .ve 88 89 Then, your solver can be chosen with the procedural interface via 90 $ PetscViewerSetType(viewer,"my_viewer_type") 91 or at runtime via the option 92 $ -viewer_type my_viewer_type 93 94 Concepts: registering^Viewers 95 96 .seealso: PetscViewerRegisterAll(), PetscViewerRegisterDestroy() 97 M*/ 98 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 99 #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,0) 100 #else 101 #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,d) 102 #endif 103 104 PETSC_EXTERN PetscErrorCode PetscViewerCreate(MPI_Comm,PetscViewer*); 105 PETSC_EXTERN PetscErrorCode PetscViewerSetFromOptions(PetscViewer); 106 PETSC_EXTERN PetscErrorCode PetscViewerASCIIOpenWithFILE(MPI_Comm,FILE*,PetscViewer*); 107 108 PETSC_EXTERN PetscErrorCode PetscViewerASCIIOpen(MPI_Comm,const char[],PetscViewer*); 109 PETSC_EXTERN PetscErrorCode PetscViewerASCIISetFILE(PetscViewer,FILE*); 110 PETSC_EXTERN PetscErrorCode PetscViewerBinaryOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*); 111 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetFlowControl(PetscViewer,PetscInt*); 112 PETSC_EXTERN PetscErrorCode PetscViewerBinarySetFlowControl(PetscViewer,PetscInt); 113 PETSC_EXTERN PetscErrorCode PetscViewerBinarySetMPIIO(PetscViewer); 114 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIO(PetscViewer,PetscBool *); 115 #if defined(PETSC_HAVE_MPIIO) 116 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIODescriptor(PetscViewer,MPI_File*); 117 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetMPIIOOffset(PetscViewer,MPI_Offset*); 118 PETSC_EXTERN PetscErrorCode PetscViewerBinaryAddMPIIOOffset(PetscViewer,MPI_Offset); 119 #endif 120 121 PETSC_EXTERN PetscErrorCode PetscViewerSocketOpen(MPI_Comm,const char[],int,PetscViewer*); 122 PETSC_EXTERN PetscErrorCode PetscViewerStringOpen(MPI_Comm,char[],PetscInt,PetscViewer*); 123 PETSC_EXTERN PetscErrorCode PetscViewerDrawOpen(MPI_Comm,const char[],const char[],int,int,int,int,PetscViewer*); 124 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaOpen(MPI_Comm, int, const char[], const char[], PetscViewer *); 125 PETSC_EXTERN PetscErrorCode PetscViewerSiloOpen(MPI_Comm, const char[], PetscViewer *); 126 PETSC_EXTERN PetscErrorCode PetscViewerMatlabOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*); 127 128 PETSC_EXTERN PetscErrorCode PetscViewerGetType(PetscViewer,PetscViewerType*); 129 PETSC_EXTERN PetscErrorCode PetscViewerSetType(PetscViewer,PetscViewerType); 130 PETSC_EXTERN PetscErrorCode PetscViewerDestroy(PetscViewer*); 131 PETSC_EXTERN PetscErrorCode PetscViewerGetSingleton(PetscViewer,PetscViewer*); 132 PETSC_EXTERN PetscErrorCode PetscViewerRestoreSingleton(PetscViewer,PetscViewer*); 133 PETSC_EXTERN PetscErrorCode PetscViewerGetSubcomm(PetscViewer,MPI_Comm,PetscViewer*); 134 PETSC_EXTERN PetscErrorCode PetscViewerRestoreSubcomm(PetscViewer,MPI_Comm,PetscViewer*); 135 136 PETSC_EXTERN PetscErrorCode PetscViewerSetUp(PetscViewer); 137 PETSC_EXTERN PetscErrorCode PetscViewerView(PetscViewer,PetscViewer); 138 139 PETSC_EXTERN PetscErrorCode PetscViewerSetOptionsPrefix(PetscViewer,const char[]); 140 PETSC_EXTERN PetscErrorCode PetscViewerAppendOptionsPrefix(PetscViewer,const char[]); 141 PETSC_EXTERN PetscErrorCode PetscViewerGetOptionsPrefix(PetscViewer,const char*[]); 142 143 /*E 144 PetscViewerFormat - Way a viewer presents the object 145 146 Level: beginner 147 148 The values below are also listed in finclude/petscviewer.h. If another values is added below it 149 must also be added there. 150 151 .seealso: PetscViewerSetFormat(), PetscViewer, PetscViewerType, PetscViewerPushFormat(), PetscViewerPopFormat() 152 E*/ 153 typedef enum { 154 PETSC_VIEWER_DEFAULT, 155 PETSC_VIEWER_ASCII_MATLAB, 156 PETSC_VIEWER_ASCII_MATHEMATICA, 157 PETSC_VIEWER_ASCII_IMPL, 158 PETSC_VIEWER_ASCII_INFO, 159 PETSC_VIEWER_ASCII_INFO_DETAIL, 160 PETSC_VIEWER_ASCII_COMMON, 161 PETSC_VIEWER_ASCII_SYMMODU, 162 PETSC_VIEWER_ASCII_INDEX, 163 PETSC_VIEWER_ASCII_DENSE, 164 PETSC_VIEWER_ASCII_MATRIXMARKET, 165 PETSC_VIEWER_ASCII_VTK, 166 PETSC_VIEWER_ASCII_VTK_CELL, 167 PETSC_VIEWER_ASCII_VTK_COORDS, 168 PETSC_VIEWER_ASCII_PCICE, 169 PETSC_VIEWER_ASCII_PYTHON, 170 PETSC_VIEWER_ASCII_FACTOR_INFO, 171 PETSC_VIEWER_ASCII_LATEX, 172 PETSC_VIEWER_DRAW_BASIC, 173 PETSC_VIEWER_DRAW_LG, 174 PETSC_VIEWER_DRAW_CONTOUR, 175 PETSC_VIEWER_DRAW_PORTS, 176 PETSC_VIEWER_VTK_VTS, 177 PETSC_VIEWER_VTK_VTU, 178 PETSC_VIEWER_BINARY_MATLAB, 179 PETSC_VIEWER_NATIVE, 180 PETSC_VIEWER_NOFORMAT 181 } PetscViewerFormat; 182 PETSC_EXTERN const char *const PetscViewerFormats[]; 183 184 PETSC_EXTERN PetscErrorCode PetscViewerSetFormat(PetscViewer,PetscViewerFormat); 185 PETSC_EXTERN PetscErrorCode PetscViewerPushFormat(PetscViewer,PetscViewerFormat); 186 PETSC_EXTERN PetscErrorCode PetscViewerPopFormat(PetscViewer); 187 PETSC_EXTERN PetscErrorCode PetscViewerGetFormat(PetscViewer,PetscViewerFormat*); 188 PETSC_EXTERN PetscErrorCode PetscViewerFlush(PetscViewer); 189 190 PETSC_EXTERN PetscErrorCode PetscOptionsGetViewer(MPI_Comm,const char[],const char[],PetscViewer*,PetscViewerFormat*,PetscBool*); 191 PETSC_EXTERN PetscErrorCode PetscOptionsViewer(const char[],const char[],const char[],PetscViewer*,PetscViewerFormat *,PetscBool *); 192 193 /* 194 Operations explicit to a particular class of viewers 195 */ 196 197 PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetPointer(PetscViewer,FILE**); 198 PETSC_EXTERN PetscErrorCode PetscViewerFileGetMode(PetscViewer,PetscFileMode*); 199 PETSC_EXTERN PetscErrorCode PetscViewerFileSetMode(PetscViewer,PetscFileMode); 200 PETSC_EXTERN PetscErrorCode PetscViewerASCIIPrintf(PetscViewer,const char[],...); 201 PETSC_EXTERN PetscErrorCode PetscViewerASCIISynchronizedPrintf(PetscViewer,const char[],...); 202 PETSC_EXTERN PetscErrorCode PetscViewerASCIISynchronizedAllow(PetscViewer,PetscBool); 203 PETSC_EXTERN PetscErrorCode PetscViewerASCIIPushTab(PetscViewer); 204 PETSC_EXTERN PetscErrorCode PetscViewerASCIIPopTab(PetscViewer); 205 PETSC_EXTERN PetscErrorCode PetscViewerASCIIUseTabs(PetscViewer,PetscBool ); 206 PETSC_EXTERN PetscErrorCode PetscViewerASCIISetTab(PetscViewer,PetscInt); 207 PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetTab(PetscViewer,PetscInt*); 208 PETSC_EXTERN PetscErrorCode PetscViewerASCIIAddTab(PetscViewer,PetscInt); 209 PETSC_EXTERN PetscErrorCode PetscViewerASCIISubtractTab(PetscViewer,PetscInt); 210 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetDescriptor(PetscViewer,int*); 211 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetInfoPointer(PetscViewer,FILE **); 212 PETSC_EXTERN PetscErrorCode PetscViewerBinaryRead(PetscViewer,void*,PetscInt,PetscDataType); 213 PETSC_EXTERN PetscErrorCode PetscViewerBinaryWrite(PetscViewer,void*,PetscInt,PetscDataType,PetscBool ); 214 PETSC_EXTERN PetscErrorCode PetscViewerStringSPrintf(PetscViewer,const char[],...); 215 PETSC_EXTERN PetscErrorCode PetscViewerStringSetString(PetscViewer,char[],PetscInt); 216 PETSC_EXTERN PetscErrorCode PetscViewerDrawClear(PetscViewer); 217 PETSC_EXTERN PetscErrorCode PetscViewerDrawSetHold(PetscViewer,PetscBool); 218 PETSC_EXTERN PetscErrorCode PetscViewerDrawGetHold(PetscViewer,PetscBool*); 219 PETSC_EXTERN PetscErrorCode PetscViewerDrawSetPause(PetscViewer,PetscReal); 220 PETSC_EXTERN PetscErrorCode PetscViewerDrawGetPause(PetscViewer,PetscReal*); 221 PETSC_EXTERN PetscErrorCode PetscViewerDrawSetInfo(PetscViewer,const char[],const char[],int,int,int,int); 222 PETSC_EXTERN PetscErrorCode PetscViewerDrawResize(PetscViewer,int,int); 223 PETSC_EXTERN PetscErrorCode PetscViewerDrawSetBounds(PetscViewer,PetscInt,const PetscReal*); 224 PETSC_EXTERN PetscErrorCode PetscViewerDrawGetBounds(PetscViewer,PetscInt*,const PetscReal**); 225 PETSC_EXTERN PetscErrorCode PetscViewerSocketSetConnection(PetscViewer,const char[],int); 226 PETSC_EXTERN PetscErrorCode PetscViewerBinarySkipInfo(PetscViewer); 227 PETSC_EXTERN PetscErrorCode PetscViewerBinarySetSkipOptions(PetscViewer,PetscBool ); 228 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetSkipOptions(PetscViewer,PetscBool *); 229 PETSC_EXTERN PetscErrorCode PetscViewerBinarySetSkipHeader(PetscViewer,PetscBool); 230 PETSC_EXTERN PetscErrorCode PetscViewerBinaryGetSkipHeader(PetscViewer,PetscBool*); 231 PETSC_EXTERN PetscErrorCode PetscViewerBinaryReadStringArray(PetscViewer,char***); 232 PETSC_EXTERN PetscErrorCode PetscViewerBinaryWriteStringArray(PetscViewer,char**); 233 234 PETSC_EXTERN PetscErrorCode PetscViewerFileSetName(PetscViewer,const char[]); 235 PETSC_EXTERN PetscErrorCode PetscViewerFileGetName(PetscViewer,const char**); 236 237 PETSC_EXTERN PetscErrorCode PetscViewerVUGetPointer(PetscViewer, FILE**); 238 PETSC_EXTERN PetscErrorCode PetscViewerVUSetVecSeen(PetscViewer, PetscBool ); 239 PETSC_EXTERN PetscErrorCode PetscViewerVUGetVecSeen(PetscViewer, PetscBool *); 240 PETSC_EXTERN PetscErrorCode PetscViewerVUPrintDeferred(PetscViewer, const char [], ...); 241 PETSC_EXTERN PetscErrorCode PetscViewerVUFlushDeferred(PetscViewer); 242 243 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaInitializePackage(const char[]); 244 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaFinalizePackage(void); 245 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaGetName(PetscViewer, const char **); 246 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaSetName(PetscViewer, const char []); 247 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaClearName(PetscViewer); 248 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaSkipPackets(PetscViewer, int); 249 250 PETSC_EXTERN PetscErrorCode PetscViewerSiloGetName(PetscViewer, char **); 251 PETSC_EXTERN PetscErrorCode PetscViewerSiloSetName(PetscViewer, const char []); 252 PETSC_EXTERN PetscErrorCode PetscViewerSiloClearName(PetscViewer); 253 PETSC_EXTERN PetscErrorCode PetscViewerSiloGetMeshName(PetscViewer, char **); 254 PETSC_EXTERN PetscErrorCode PetscViewerSiloSetMeshName(PetscViewer, const char []); 255 PETSC_EXTERN PetscErrorCode PetscViewerSiloClearMeshName(PetscViewer); 256 257 PETSC_EXTERN PetscErrorCode PetscViewerNetcdfOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*); 258 PETSC_EXTERN PetscErrorCode PetscViewerNetcdfGetID(PetscViewer, int *); 259 260 #ifdef PETSC_HAVE_HDF5 261 #include <hdf5.h> 262 PETSC_EXTERN PetscErrorCode PetscViewerHDF5GetFileId(PetscViewer,hid_t*); 263 PETSC_EXTERN PetscErrorCode PetscViewerHDF5OpenGroup(PetscViewer, hid_t *, hid_t *); 264 265 /* On 32 bit systems HDF5 is limited by size of integer, because hsize_t is defined as size_t */ 266 #define PETSC_HDF5_INT_MAX 2147483647 267 #define PETSC_HDF5_INT_MIN -2147483647 268 269 #undef __FUNCT__ 270 #define __FUNCT__ "PetscHDF5IntCast" 271 PETSC_STATIC_INLINE PetscErrorCode PetscHDF5IntCast(PetscInt a,hsize_t *b) 272 { 273 PetscFunctionBegin; 274 #if defined(PETSC_USE_64BIT_INDICES) && (PETSC_SIZEOF_SIZE_T == 4) 275 if ((a) > PETSC_HDF5_INT_MAX) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Array too long for HDF5"); 276 #endif 277 *b = (hsize_t)(a); 278 PetscFunctionReturn(0); 279 } 280 #endif 281 282 PETSC_EXTERN PetscErrorCode PetscViewerHDF5WriteSDS(PetscViewer,float *,int,int *,int); 283 284 PETSC_EXTERN PetscErrorCode PetscViewerHDF5Open(MPI_Comm,const char[],PetscFileMode,PetscViewer*); 285 PETSC_EXTERN PetscErrorCode PetscViewerHDF5PushGroup(PetscViewer,const char *); 286 PETSC_EXTERN PetscErrorCode PetscViewerHDF5PopGroup(PetscViewer); 287 PETSC_EXTERN PetscErrorCode PetscViewerHDF5GetGroup(PetscViewer, const char **); 288 PETSC_EXTERN PetscErrorCode PetscViewerHDF5IncrementTimestep(PetscViewer); 289 PETSC_EXTERN PetscErrorCode PetscViewerHDF5SetTimestep(PetscViewer,PetscInt); 290 PETSC_EXTERN PetscErrorCode PetscViewerHDF5GetTimestep(PetscViewer,PetscInt*); 291 292 typedef enum {PETSC_VTK_POINT_FIELD, PETSC_VTK_POINT_VECTOR_FIELD, PETSC_VTK_CELL_FIELD, PETSC_VTK_CELL_VECTOR_FIELD} PetscViewerVTKFieldType; 293 PETSC_EXTERN PetscErrorCode PetscViewerVTKAddField(PetscViewer,PetscObject,PetscErrorCode (*PetscViewerVTKWriteFunction)(PetscObject,PetscViewer),PetscViewerVTKFieldType,PetscObject); 294 PETSC_EXTERN PetscErrorCode PetscViewerVTKOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*); 295 296 /* 297 These are all the default viewers that do not have 298 to be explicitly opened 299 */ 300 PETSC_EXTERN PetscViewer PETSC_VIEWER_STDOUT_(MPI_Comm); 301 PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetStdout(MPI_Comm,PetscViewer*); 302 PETSC_EXTERN PetscViewer PETSC_VIEWER_STDERR_(MPI_Comm); 303 PETSC_EXTERN PetscErrorCode PetscViewerASCIIGetStderr(MPI_Comm,PetscViewer*); 304 PETSC_EXTERN PetscViewer PETSC_VIEWER_DRAW_(MPI_Comm); 305 PETSC_EXTERN PetscViewer PETSC_VIEWER_SOCKET_(MPI_Comm); 306 PETSC_EXTERN PetscViewer PETSC_VIEWER_BINARY_(MPI_Comm); 307 PETSC_EXTERN PetscViewer PETSC_VIEWER_MATLAB_(MPI_Comm); 308 PETSC_EXTERN PetscViewer PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE; 309 310 #define PETSC_VIEWER_STDERR_SELF PETSC_VIEWER_STDERR_(PETSC_COMM_SELF) 311 #define PETSC_VIEWER_STDERR_WORLD PETSC_VIEWER_STDERR_(PETSC_COMM_WORLD) 312 313 /*MC 314 PETSC_VIEWER_STDOUT_WORLD - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD) 315 316 Level: beginner 317 M*/ 318 #define PETSC_VIEWER_STDOUT_WORLD PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD) 319 320 /*MC 321 PETSC_VIEWER_STDOUT_SELF - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF) 322 323 Level: beginner 324 M*/ 325 #define PETSC_VIEWER_STDOUT_SELF PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF) 326 327 /*MC 328 PETSC_VIEWER_DRAW_WORLD - same as PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD) 329 330 Level: intermediate 331 M*/ 332 #define PETSC_VIEWER_DRAW_WORLD PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD) 333 334 /*MC 335 PETSC_VIEWER_DRAW_SELF - same as PETSC_VIEWER_DRAW_(PETSC_COMM_SELF) 336 337 Level: intermediate 338 M*/ 339 #define PETSC_VIEWER_DRAW_SELF PETSC_VIEWER_DRAW_(PETSC_COMM_SELF) 340 341 /*MC 342 PETSC_VIEWER_SOCKET_WORLD - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD) 343 344 Level: intermediate 345 M*/ 346 #define PETSC_VIEWER_SOCKET_WORLD PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD) 347 348 /*MC 349 PETSC_VIEWER_SOCKET_SELF - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF) 350 351 Level: intermediate 352 M*/ 353 #define PETSC_VIEWER_SOCKET_SELF PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF) 354 355 /*MC 356 PETSC_VIEWER_BINARY_WORLD - same as PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD) 357 358 Level: intermediate 359 M*/ 360 #define PETSC_VIEWER_BINARY_WORLD PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD) 361 362 /*MC 363 PETSC_VIEWER_BINARY_SELF - same as PETSC_VIEWER_BINARY_(PETSC_COMM_SELF) 364 365 Level: intermediate 366 M*/ 367 #define PETSC_VIEWER_BINARY_SELF PETSC_VIEWER_BINARY_(PETSC_COMM_SELF) 368 369 /*MC 370 PETSC_VIEWER_MATLAB_WORLD - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD) 371 372 Level: intermediate 373 M*/ 374 #define PETSC_VIEWER_MATLAB_WORLD PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD) 375 376 /*MC 377 PETSC_VIEWER_MATLAB_SELF - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF) 378 379 Level: intermediate 380 M*/ 381 #define PETSC_VIEWER_MATLAB_SELF PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF) 382 383 #define PETSC_VIEWER_MATHEMATICA_WORLD (PetscViewerInitializeMathematicaWorld_Private(),PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE) 384 385 #undef __FUNCT__ 386 #define __FUNCT__ "PetscViewerFlowControlStart" 387 PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlStart(PetscViewer viewer,PetscInt *mcnt,PetscInt *cnt) 388 { 389 PetscErrorCode ierr; 390 PetscFunctionBegin; 391 ierr = PetscViewerBinaryGetFlowControl(viewer,mcnt);CHKERRQ(ierr); 392 ierr = PetscViewerBinaryGetFlowControl(viewer,cnt);CHKERRQ(ierr); 393 PetscFunctionReturn(0); 394 } 395 396 #undef __FUNCT__ 397 #define __FUNCT__ "PetscViewerFlowControlStepMaster" 398 PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlStepMaster(PetscViewer viewer,PetscInt i,PetscInt *mcnt,PetscInt cnt) 399 { 400 PetscErrorCode ierr; 401 MPI_Comm comm; 402 403 PetscFunctionBegin; 404 ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr); 405 if (i >= *mcnt) { 406 *mcnt += cnt; 407 ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr); 408 } 409 PetscFunctionReturn(0); 410 } 411 412 #undef __FUNCT__ 413 #define __FUNCT__ "PetscViewerFlowControlEndMaster" 414 PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlEndMaster(PetscViewer viewer,PetscInt *mcnt) 415 { 416 PetscErrorCode ierr; 417 MPI_Comm comm; 418 PetscFunctionBegin; 419 ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr); 420 *mcnt = 0; 421 ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr); 422 PetscFunctionReturn(0); 423 } 424 425 #undef __FUNCT__ 426 #define __FUNCT__ "PetscViewerFlowControlStepWorker" 427 PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlStepWorker(PetscViewer viewer,PetscMPIInt rank,PetscInt *mcnt) 428 { 429 PetscErrorCode ierr; 430 MPI_Comm comm; 431 PetscFunctionBegin; 432 ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr); 433 while (PETSC_TRUE) { 434 if (rank < *mcnt) break; 435 ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr); 436 } 437 PetscFunctionReturn(0); 438 } 439 440 #undef __FUNCT__ 441 #define __FUNCT__ "PetscViewerFlowControlEndWorker" 442 PETSC_STATIC_INLINE PetscErrorCode PetscViewerFlowControlEndWorker(PetscViewer viewer,PetscInt *mcnt) 443 { 444 PetscErrorCode ierr; 445 MPI_Comm comm; 446 PetscFunctionBegin; 447 ierr = PetscObjectGetComm((PetscObject)viewer,&comm);CHKERRQ(ierr); 448 while (PETSC_TRUE) { 449 ierr = MPI_Bcast(mcnt,1,MPIU_INT,0,comm);CHKERRQ(ierr); 450 if (!*mcnt) break; 451 } 452 PetscFunctionReturn(0); 453 } 454 455 /* 456 PetscViewer writes to MATLAB .mat file 457 */ 458 PETSC_EXTERN PetscErrorCode PetscViewerMatlabPutArray(PetscViewer,int,int,const PetscScalar*,const char*); 459 PETSC_EXTERN PetscErrorCode PetscViewerMatlabGetArray(PetscViewer,int,int,PetscScalar*,const char*); 460 PETSC_EXTERN PetscErrorCode PetscViewerMatlabPutVariable(PetscViewer,const char*,void*); 461 462 /*S 463 PetscViewers - Abstract collection of PetscViewers. It is just an expandable array of viewers. 464 465 Level: intermediate 466 467 Concepts: viewing 468 469 .seealso: PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, PetscViewer, PetscViewersCreate(), 470 PetscViewersGetViewer() 471 S*/ 472 typedef struct _n_PetscViewers* PetscViewers; 473 PETSC_EXTERN PetscErrorCode PetscViewersCreate(MPI_Comm,PetscViewers*); 474 PETSC_EXTERN PetscErrorCode PetscViewersDestroy(PetscViewers*); 475 PETSC_EXTERN PetscErrorCode PetscViewersGetViewer(PetscViewers,PetscInt,PetscViewer*); 476 477 #if defined(PETSC_HAVE_AMS) 478 #include <ams.h> 479 PETSC_EXTERN PetscErrorCode PetscViewerAMSSetCommName(PetscViewer,const char[]); 480 PETSC_EXTERN PetscErrorCode PetscViewerAMSGetAMSComm(PetscViewer,AMS_Comm *); 481 PETSC_EXTERN PetscErrorCode PetscViewerAMSOpen(MPI_Comm,const char[],PetscViewer*); 482 PETSC_EXTERN PetscErrorCode PetscViewerAMSLock(PetscViewer); 483 PETSC_EXTERN PetscViewer PETSC_VIEWER_AMS_(MPI_Comm); 484 PETSC_EXTERN PetscErrorCode PETSC_VIEWER_AMS_Destroy(MPI_Comm); 485 #define PETSC_VIEWER_AMS_WORLD PETSC_VIEWER_AMS_(PETSC_COMM_WORLD) 486 #endif 487 488 #endif 489