Actual source code: petscviewer.h

      1: /*
      2:      PetscViewers are objects where other objects can be looked at or stored.
      3: */

     10: #endif

     12: /*S
     13:      PetscViewer - Abstract PETSc object that helps view (in ASCII, binary, graphically etc)
     14:          other PETSc objects

     16:    Level: beginner

     18:   Concepts: viewing

     20: .seealso:  PetscViewerCreate(), PetscViewerSetType(), PetscViewerType
     21: S*/
     22: typedef struct _p_PetscViewer* PetscViewer;

     25: }
     26: #endif

     28:  #include petsc.h

     32: #endif

     37: }
     38: #endif

     41: /*
     42:     petsc.h must be included AFTER the definition of PetscViewer for ADIC to
     43:    process correctly.
     44: */
     46: /*E
     47:     PetscViewerType - String with the name of a PETSc PETScViewer

     49:    Level: beginner

     51: .seealso: PetscViewerSetType(), PetscViewer
     52: E*/
     53: #define PetscViewerType const char*
     54: #define PETSC_VIEWER_SOCKET       "socket"
     55: #define PETSC_VIEWER_ASCII        "ascii"
     56: #define PETSC_VIEWER_BINARY       "binary"
     57: #define PETSC_VIEWER_STRING       "string"
     58: #define PETSC_VIEWER_DRAW         "draw"
     59: #define PETSC_VIEWER_VU           "vu"
     60: #define PETSC_VIEWER_MATHEMATICA  "mathematica"
     61: #define PETSC_VIEWER_SILO         "silo"
     62: #define PETSC_VIEWER_NETCDF       "netcdf"
     63: #define PETSC_VIEWER_HDF4         "hdf4"
     64: #define PETSC_VIEWER_MATLAB       "matlab"

     67: EXTERN PetscErrorCode  PetscViewerRegisterAll(const char *);
     68: EXTERN PetscErrorCode  PetscViewerRegisterDestroy(void);
     69: EXTERN PetscErrorCode  PetscViewerInitializePackage(const char[]);

     71: EXTERN PetscErrorCode  PetscViewerRegister(const char*,const char*,const char*,PetscErrorCode (*)(PetscViewer));

     73: /*MC
     74:    PetscViewerRegisterDynamic - Adds a method to the Krylov subspace solver package.

     76:    Synopsis:
     77:    PetscErrorCode PetscViewerRegisterDynamic(char *name_solver,char *path,char *name_create,PetscErrorCode (*routine_create)(PetscViewer))

     79:    Not Collective

     81:    Input Parameters:
     82: +  name_solver - name of a new user-defined solver
     83: .  path - path (either absolute or relative) the library containing this solver
     84: .  name_create - name of routine to create method context
     85: -  routine_create - routine to create method context

     87:    Level: developer

     89:    Notes:
     90:    PetscViewerRegisterDynamic() may be called multiple times to add several user-defined solvers.

     92:    If dynamic libraries are used, then the fourth input argument (routine_create)
     93:    is ignored.

     95:    Sample usage:
     96: .vb
     97:    PetscViewerRegisterDynamic("my_viewer_type",/home/username/my_lib/lib/libO/solaris/mylib.a,
     98:                "MyViewerCreate",MyViewerCreate);
     99: .ve

    101:    Then, your solver can be chosen with the procedural interface via
    102: $     PetscViewerSetType(ksp,"my_viewer_type")
    103:    or at runtime via the option
    104: $     -viewer_type my_viewer_type

    106:   Concepts: registering^Viewers

    108: .seealso: PetscViewerRegisterAll(), PetscViewerRegisterDestroy()
    109: M*/
    110: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
    111: #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,0)
    112: #else
    113: #define PetscViewerRegisterDynamic(a,b,c,d) PetscViewerRegister(a,b,c,d)
    114: #endif

    116: EXTERN PetscErrorCode  PetscViewerCreate(MPI_Comm,PetscViewer*);
    117: PetscPolymorphicSubroutine(PetscViewerCreate,(PetscViewer *v),(PETSC_COMM_SELF,v))
    118: EXTERN PetscErrorCode  PetscViewerSetFromOptions(PetscViewer);

    120: EXTERN PetscErrorCode  PetscViewerASCIIOpen(MPI_Comm,const char[],PetscViewer*);
    121: EXTERN PetscErrorCode  PetscViewerBinaryCreate(MPI_Comm,PetscViewer*);
    122: EXTERN PetscErrorCode  PetscViewerBinaryOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
    123: EXTERN PetscErrorCode  PetscViewerSocketOpen(MPI_Comm,const char[],int,PetscViewer*);
    124: EXTERN PetscErrorCode  PetscViewerStringOpen(MPI_Comm,char[],PetscInt,PetscViewer*);
    125: EXTERN PetscErrorCode  PetscViewerDrawOpen(MPI_Comm,const char[],const char[],int,int,int,int,PetscViewer*);
    126: EXTERN PetscErrorCode  PetscViewerMathematicaOpen(MPI_Comm, int, const char[], const char[], PetscViewer *);
    127: EXTERN PetscErrorCode  PetscViewerSiloOpen(MPI_Comm, const char[], PetscViewer *);
    128: EXTERN PetscErrorCode  PetscViewerMatlabOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);

    130: EXTERN PetscErrorCode  PetscViewerGetType(PetscViewer,PetscViewerType*);
    131: EXTERN PetscErrorCode  PetscViewerSetType(PetscViewer,PetscViewerType);
    132: EXTERN PetscErrorCode  PetscViewerDestroy(PetscViewer);
    133: EXTERN PetscErrorCode  PetscViewerGetSingleton(PetscViewer,PetscViewer*);
    134: EXTERN PetscErrorCode  PetscViewerRestoreSingleton(PetscViewer,PetscViewer*);
    135: EXTERN PetscErrorCode  PetscViewerGetSubcomm(PetscViewer,MPI_Comm,PetscViewer*);
    136: EXTERN PetscErrorCode  PetscViewerRestoreSubcomm(PetscViewer,MPI_Comm,PetscViewer*);

    138: EXTERN PetscErrorCode  PetscViewerSetUp(PetscViewer);
    139: EXTERN PetscErrorCode  PetscViewerView(PetscViewer,PetscViewer);

    141: EXTERN PetscErrorCode  PetscViewerSetOptionsPrefix(PetscViewer,const char[]);
    142: EXTERN PetscErrorCode  PetscViewerAppendOptionsPrefix(PetscViewer,const char[]);
    143: EXTERN PetscErrorCode  PetscViewerGetOptionsPrefix(PetscViewer,const char*[]);

    145: /*E
    146:     PetscViewerFormat - Way a viewer presents the object

    148:    Level: beginner

    150: .seealso: PetscViewerSetFormat(), PetscViewer, PetscViewerType, PetscViewerPushFormat(), PetscViewerPopFormat()
    151: E*/
    152: typedef enum {
    153:   PETSC_VIEWER_ASCII_DEFAULT,
    154:   PETSC_VIEWER_ASCII_MATLAB,
    155:   PETSC_VIEWER_ASCII_MATHEMATICA,
    156:   PETSC_VIEWER_ASCII_IMPL,
    157:   PETSC_VIEWER_ASCII_INFO,
    158:   PETSC_VIEWER_ASCII_INFO_DETAIL,
    159:   PETSC_VIEWER_ASCII_COMMON,
    160:   PETSC_VIEWER_ASCII_SYMMODU,
    161:   PETSC_VIEWER_ASCII_INDEX,
    162:   PETSC_VIEWER_ASCII_DENSE,
    163:   PETSC_VIEWER_ASCII_VTK,
    164:   PETSC_VIEWER_ASCII_VTK_CELL,
    165:   PETSC_VIEWER_ASCII_VTK_COORDS,
    166:   PETSC_VIEWER_ASCII_PCICE,
    167:   PETSC_VIEWER_ASCII_PYLITH,
    168:   PETSC_VIEWER_ASCII_PYLITH_LOCAL,
    169:   PETSC_VIEWER_BINARY_DEFAULT,
    170:   PETSC_VIEWER_BINARY_NATIVE,
    171:   PETSC_VIEWER_DRAW_BASIC,
    172:   PETSC_VIEWER_DRAW_LG,
    173:   PETSC_VIEWER_DRAW_CONTOUR,
    174:   PETSC_VIEWER_DRAW_PORTS,
    175:   PETSC_VIEWER_NATIVE,
    176:   PETSC_VIEWER_NOFORMAT,
    177:   PETSC_VIEWER_ASCII_FACTOR_INFO} PetscViewerFormat;

    179: EXTERN PetscErrorCode  PetscViewerSetFormat(PetscViewer,PetscViewerFormat);
    180: EXTERN PetscErrorCode  PetscViewerPushFormat(PetscViewer,PetscViewerFormat);
    181: EXTERN PetscErrorCode  PetscViewerPopFormat(PetscViewer);
    182: EXTERN PetscErrorCode  PetscViewerGetFormat(PetscViewer,PetscViewerFormat*);
    183: EXTERN PetscErrorCode  PetscViewerFlush(PetscViewer);

    185: /*S
    186:      PetscViewerASCIIMonitor - Context for the default KSP, SNES and TS monitors that print
    187:                                   ASCII strings of residual norms etc.

    190:    Level: advanced

    192:   Concepts: viewing, monitoring

    194: .seealso:  PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, KSPMonitorSet(), SNESMonitorSet(), TSMonitorSet(),
    195:            KSPMonitorDefault(), SNESMonitorDefault()

    197: S*/
    198: struct _p_PetscViewerASCIIMonitor {
    199:   PetscViewer viewer;
    200:   PetscInt    tabs;
    201: };
    202: typedef struct _p_PetscViewerASCIIMonitor* PetscViewerASCIIMonitor;

    204: EXTERN PetscErrorCode  PetscViewerASCIIMonitorCreate(MPI_Comm,const char *,PetscInt,PetscViewerASCIIMonitor*);
    205: EXTERN PetscErrorCode  PetscViewerASCIIMonitorDestroy(PetscViewerASCIIMonitor);
    206: EXTERN PetscErrorCode  PetscViewerASCIIMonitorPrintf(PetscViewerASCIIMonitor,const char[],...);

    208: /*
    209:    Operations explicit to a particular class of viewers
    210: */

    212: EXTERN PetscErrorCode  PetscViewerASCIIGetPointer(PetscViewer,FILE**);
    213: EXTERN PetscErrorCode  PetscViewerFileGetMode(PetscViewer,PetscFileMode*);
    214: EXTERN PetscErrorCode  PetscViewerFileSetMode(PetscViewer,PetscFileMode);
    215: EXTERN PetscErrorCode  PetscViewerASCIIPrintf(PetscViewer,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
    216: EXTERN PetscErrorCode  PetscViewerASCIISynchronizedPrintf(PetscViewer,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
    217: EXTERN PetscErrorCode  PetscViewerASCIIPushTab(PetscViewer);
    218: EXTERN PetscErrorCode  PetscViewerASCIIPopTab(PetscViewer);
    219: EXTERN PetscErrorCode  PetscViewerASCIIUseTabs(PetscViewer,PetscTruth);
    220: EXTERN PetscErrorCode  PetscViewerASCIISetTab(PetscViewer,PetscInt);
    221: EXTERN PetscErrorCode  PetscViewerBinaryGetDescriptor(PetscViewer,int*);
    222: EXTERN PetscErrorCode  PetscViewerBinaryGetInfoPointer(PetscViewer,FILE **);
    223: EXTERN PetscErrorCode  PetscViewerBinaryRead(PetscViewer,void*,PetscInt,PetscDataType);
    224: EXTERN PetscErrorCode  PetscViewerBinaryWrite(PetscViewer,void*,PetscInt,PetscDataType,PetscTruth);
    225: EXTERN PetscErrorCode  PetscViewerStringSPrintf(PetscViewer,const char[],...) PETSC_PRINTF_FORMAT_CHECK(2,3);
    226: EXTERN PetscErrorCode  PetscViewerStringSetString(PetscViewer,char[],PetscInt);
    227: EXTERN PetscErrorCode  PetscViewerDrawClear(PetscViewer);
    228: EXTERN PetscErrorCode  PetscViewerDrawSetInfo(PetscViewer,const char[],const char[],int,int,int,int);
    229: EXTERN PetscErrorCode  PetscViewerSocketSetConnection(PetscViewer,const char[],PetscInt);
    230: EXTERN PetscErrorCode  PetscViewerBinarySkipInfo(PetscViewer);
    231: EXTERN PetscErrorCode  PetscViewerBinaryLoadInfo(PetscViewer);
    232: EXTERN PetscErrorCode  PetscViewerBinarySetSkipOptions(PetscViewer,PetscTruth);
    233: EXTERN PetscErrorCode  PetscViewerBinaryGetSkipOptions(PetscViewer,PetscTruth*);
    234: EXTERN PetscErrorCode  PetscViewerBinaryReadStringArray(PetscViewer,char***);
    235: EXTERN PetscErrorCode  PetscViewerBinaryWriteStringArray(PetscViewer,char**);

    237: EXTERN PetscErrorCode  PetscViewerFileSetName(PetscViewer,const char[]);
    238: EXTERN PetscErrorCode  PetscViewerFileGetName(PetscViewer,char**);

    240: EXTERN PetscErrorCode  PetscPLAPACKInitializePackage(const char[]);
    241: EXTERN PetscErrorCode  PetscPLAPACKFinalizePackage(void);

    243: EXTERN PetscErrorCode  PetscViewerVUGetPointer(PetscViewer, FILE**);
    244: EXTERN PetscErrorCode  PetscViewerVUSetVecSeen(PetscViewer, PetscTruth);
    245: EXTERN PetscErrorCode  PetscViewerVUGetVecSeen(PetscViewer, PetscTruth *);
    246: EXTERN PetscErrorCode  PetscViewerVUPrintDeferred(PetscViewer, const char [], ...) PETSC_PRINTF_FORMAT_CHECK(2,3);
    247: EXTERN PetscErrorCode  PetscViewerVUFlushDeferred(PetscViewer);

    249: EXTERN PetscErrorCode  PetscViewerMathematicaInitializePackage(const char[]);
    250: EXTERN PetscErrorCode  PetscViewerMathematicaFinalizePackage(void);
    251: EXTERN PetscErrorCode  PetscViewerMathematicaGetName(PetscViewer, const char **);
    252: EXTERN PetscErrorCode  PetscViewerMathematicaSetName(PetscViewer, const char []);
    253: EXTERN PetscErrorCode  PetscViewerMathematicaClearName(PetscViewer);
    254: EXTERN PetscErrorCode  PetscViewerMathematicaSkipPackets(PetscViewer, int);

    256: EXTERN PetscErrorCode  PetscViewerSiloGetName(PetscViewer, char **);
    257: EXTERN PetscErrorCode  PetscViewerSiloSetName(PetscViewer, const char []);
    258: EXTERN PetscErrorCode  PetscViewerSiloClearName(PetscViewer);
    259: EXTERN PetscErrorCode  PetscViewerSiloGetMeshName(PetscViewer, char **);
    260: EXTERN PetscErrorCode  PetscViewerSiloSetMeshName(PetscViewer, const char []);
    261: EXTERN PetscErrorCode  PetscViewerSiloClearMeshName(PetscViewer);

    263: EXTERN PetscErrorCode  PetscViewerNetcdfOpen(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
    264: EXTERN PetscErrorCode  PetscViewerNetcdfGetID(PetscViewer, int *);

    266: EXTERN PetscErrorCode  PetscViewerHDF4Open(MPI_Comm,const char[],PetscFileMode,PetscViewer*);
    267: EXTERN PetscErrorCode  PetscViewerHDF4WriteSDS(PetscViewer,float *,int,int *,int);

    269: /*
    270:      These are all the default viewers that do not have
    271:    to be explicitly opened
    272: */
    273: EXTERN PetscViewer  PETSC_VIEWER_STDOUT_(MPI_Comm);
    274: EXTERN PetscErrorCode  PetscViewerASCIIGetStdout(MPI_Comm,PetscViewer*);
    275: EXTERN PetscViewer  PETSC_VIEWER_STDERR_(MPI_Comm);
    276: EXTERN PetscErrorCode  PetscViewerASCIIGetStderr(MPI_Comm,PetscViewer*);
    277: EXTERN PetscViewer  PETSC_VIEWER_DRAW_(MPI_Comm);
    278: EXTERN PetscViewer  PETSC_VIEWER_SOCKET_(MPI_Comm);
    279: EXTERN PetscViewer  PETSC_VIEWER_BINARY_(MPI_Comm);
    280: EXTERN PetscViewer  PETSC_VIEWER_MATLAB_(MPI_Comm);
    281: EXTERN PetscViewer PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE;

    283: #define PETSC_VIEWER_STDERR_SELF  PETSC_VIEWER_STDERR_(PETSC_COMM_SELF)
    284: #define PETSC_VIEWER_STDERR_WORLD PETSC_VIEWER_STDERR_(PETSC_COMM_WORLD)

    286: /*MC
    287:   PETSC_VIEWER_STDOUT_WORLD  - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)

    289:   Level: beginner
    290: M*/
    291: #define PETSC_VIEWER_STDOUT_WORLD PETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD)

    293: /*MC
    294:   PETSC_VIEWER_STDOUT_SELF  - same as PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)

    296:   Level: beginner
    297: M*/
    298: #define PETSC_VIEWER_STDOUT_SELF  PETSC_VIEWER_STDOUT_(PETSC_COMM_SELF)

    300: /*MC
    301:   PETSC_VIEWER_DRAW_WORLD  - same as PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)

    303:   Level: intermediate
    304: M*/
    305: #define PETSC_VIEWER_DRAW_WORLD   PETSC_VIEWER_DRAW_(PETSC_COMM_WORLD)

    307: /*MC
    308:   PETSC_VIEWER_DRAW_SELF  - same as PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)

    310:   Level: intermediate
    311: M*/
    312: #define PETSC_VIEWER_DRAW_SELF    PETSC_VIEWER_DRAW_(PETSC_COMM_SELF)

    314: /*MC
    315:   PETSC_VIEWER_SOCKET_WORLD  - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)

    317:   Level: intermediate
    318: M*/
    319: #define PETSC_VIEWER_SOCKET_WORLD PETSC_VIEWER_SOCKET_(PETSC_COMM_WORLD)

    321: /*MC
    322:   PETSC_VIEWER_SOCKET_SELF  - same as PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)

    324:   Level: intermediate
    325: M*/
    326: #define PETSC_VIEWER_SOCKET_SELF  PETSC_VIEWER_SOCKET_(PETSC_COMM_SELF)

    328: /*MC
    329:   PETSC_VIEWER_BINARY_WORLD  - same as PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)

    331:   Level: intermediate
    332: M*/
    333: #define PETSC_VIEWER_BINARY_WORLD PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD)

    335: /*MC
    336:   PETSC_VIEWER_BINARY_SELF  - same as PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)

    338:   Level: intermediate
    339: M*/
    340: #define PETSC_VIEWER_BINARY_SELF  PETSC_VIEWER_BINARY_(PETSC_COMM_SELF)

    342: /*MC
    343:   PETSC_VIEWER_MATLAB_WORLD  - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)

    345:   Level: intermediate
    346: M*/
    347: #define PETSC_VIEWER_MATLAB_WORLD PETSC_VIEWER_MATLAB_(PETSC_COMM_WORLD)

    349: /*MC
    350:   PETSC_VIEWER_MATLAB_SELF  - same as PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)

    352:   Level: intermediate
    353: M*/
    354: #define PETSC_VIEWER_MATLAB_SELF  PETSC_VIEWER_MATLAB_(PETSC_COMM_SELF)

    356: #define PETSC_VIEWER_MATHEMATICA_WORLD (PetscViewerInitializeMathematicaWorld_Private(),PETSC_VIEWER_MATHEMATICA_WORLD_PRIVATE)

    358: /*
    359:    petscViewer writes to Matlab .mat file
    360: */
    361: EXTERN PetscErrorCode  PetscViewerMatlabPutArray(PetscViewer,int,int,PetscScalar*,char*);
    362: EXTERN PetscErrorCode  PetscViewerMatlabGetArray(PetscViewer,int,int,PetscScalar*,char*);
    363: EXTERN PetscErrorCode  PetscViewerMatlabPutVariable(PetscViewer,const char*,void*);

    365: /*S
    366:      PetscViewers - Abstract collection of PetscViewers

    368:    Level: intermediate

    370:   Concepts: viewing

    372: .seealso:  PetscViewerCreate(), PetscViewerSetType(), PetscViewerType, PetscViewer, PetscViewersCreate(),
    373:            PetscViewersGetViewer()
    374: S*/
    375: typedef struct _n_PetscViewers* PetscViewers;
    376: EXTERN PetscErrorCode  PetscViewersCreate(MPI_Comm,PetscViewers*);
    377: EXTERN PetscErrorCode  PetscViewersDestroy(PetscViewers);
    378: EXTERN PetscErrorCode  PetscViewersGetViewer(PetscViewers,PetscInt,PetscViewer*);

    381: #endif