-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skeleton for DHM (Dohp HDF5 referencing iMesh) viewers
- Loading branch information
Showing
8 changed files
with
241 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef _DOHPVIEWER_H | ||
#define _DOHPVIEWER_H | ||
|
||
#include "dohptype.h" | ||
#include "dohpfs.h" | ||
|
||
#define PETSC_VIEWER_DHM "dhm" | ||
|
||
PETSC_EXTERN_CXX_BEGIN | ||
|
||
EXTERN dErr dViewerDHMSetFS(PetscViewer,dFS); | ||
EXTERN dErr dViewerDHMSetTime(PetscViewer,dReal); | ||
EXTERN dErr dViewerRegisterAll(const char*); | ||
|
||
PETSC_EXTERN_CXX_END | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "cont.h" | ||
#include "../../../viewer/dhm.h" | ||
|
||
dErr dFSView_Cont_DHM(dFS fs,dViewer viewer) | ||
{ | ||
dErr err; | ||
|
||
dFunctionBegin; | ||
dFunctionReturn(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#include "dhm.h" | ||
#include <../src/sys/viewer/viewerimpl.h> | ||
|
||
PetscErrorCode PetscViewerCreate_DHM(PetscViewer); | ||
|
||
static dErr DHMSetUp(PetscViewer viewer) | ||
{ | ||
dViewer_DHM *dhm = viewer->data; | ||
dErr err; | ||
herr_t herr; | ||
hid_t plist_id,fid; | ||
|
||
dFunctionBegin; | ||
if (dhm->file_id) dFunctionReturn(0); | ||
/* Set attributes for opening the file */ | ||
plist_id = H5Pcreate(H5P_FILE_ACCESS); | ||
herr = H5Pset_fapl_mpio(plist_id,((PetscObject)viewer)->comm,MPI_INFO_NULL);dHCHK(herr); | ||
/* Create or open the file collectively */ | ||
switch (dhm->btype) { | ||
case FILE_MODE_READ: | ||
fid = H5Fopen(dhm->filename,H5F_ACC_RDONLY,plist_id); | ||
if (fid < 0) dERROR(PETSC_ERR_LIB,"H5Fopen(\"%s\",H5F_ACC_RDONLY,...) failed",dhm->filename); | ||
break; | ||
case FILE_MODE_WRITE: | ||
fid = H5Fcreate(dhm->filename,H5F_ACC_TRUNC,H5P_DEFAULT,plist_id); | ||
if (fid < 0) dERROR(PETSC_ERR_LIB,"H5Fcreate(\"%s\",H5F_ACC_TRUNC,...) failed",dhm->filename); | ||
break; | ||
case FILE_MODE_APPEND: | ||
fid = H5Fopen(dhm->filename,H5F_ACC_RDWR,plist_id); | ||
if (fid < 0) dERROR(PETSC_ERR_LIB,"H5Fopen(\"%s\",H5F_ACC_RDWR,...) failed",dhm->filename); | ||
break; | ||
default: | ||
dERROR(PETSC_ERR_ORDER,"Must call PetscViewerFileSetMode() before PetscViewerFileSetName()"); | ||
} | ||
dhm->file_id = fid; | ||
herr = H5Pclose(plist_id);dHCHK(herr); | ||
|
||
/* \todo set up the groups */ | ||
dFunctionReturn(0); | ||
} | ||
|
||
static dErr PetscViewerDestroy_DHM(PetscViewer v) | ||
{ | ||
dErr err; | ||
herr_t herr; | ||
dViewer_DHM *dhm = v->data; | ||
|
||
dFunctionBegin; | ||
err = dFree(dhm->filename);dCHK(err); | ||
if (dhm->file_id) {herr = H5Fclose(dhm->file_id);dHCHK(herr);} | ||
if (dhm->fs) {err = dFSDestroy(dhm->fs);dCHK(err);} | ||
err = dFree(dhm);dCHK(err); | ||
dFunctionReturn(0); | ||
} | ||
|
||
static dErr PetscViewerFileSetName_DHM(PetscViewer v,const char *name) | ||
{ | ||
dViewer_DHM *dhm = v->data; | ||
dErr err; | ||
|
||
dFunctionBegin; | ||
err = dFree(dhm->filename);dCHK(err); | ||
err = PetscStrallocpy(name,&dhm->filename);dCHK(err); | ||
dFunctionReturn(0); | ||
} | ||
|
||
static dErr PetscViewerFileSetMode_DHM(PetscViewer v,PetscFileMode btype) | ||
{ | ||
dViewer_DHM *dhm = v->data; | ||
|
||
dFunctionBegin; | ||
dhm->btype = btype; | ||
dFunctionReturn(0); | ||
} | ||
|
||
static dErr dViewerDHMSetTime_DHM(PetscViewer v,dReal time) | ||
{ | ||
dViewer_DHM *dhm = v->data; | ||
|
||
dFunctionBegin; | ||
dhm->time = time; | ||
dFunctionReturn(0); | ||
} | ||
|
||
static dErr dViewerDHMSetFS_DHM(PetscViewer v,dFS fs) | ||
{ | ||
dViewer_DHM *dhm = v->data; | ||
dErr err; | ||
|
||
dFunctionBegin; | ||
err = PetscObjectReference((dObject)fs);dCHK(err); | ||
if (dhm->fs) {err = dFSDestroy(dhm->fs);dCHK(err);} | ||
dhm->fs = fs; | ||
dFunctionReturn(0); | ||
} | ||
|
||
PetscErrorCode PetscViewerCreate_DHM(PetscViewer v) | ||
{ | ||
dErr err; | ||
dViewer_DHM *dhm; | ||
|
||
dFunctionBegin; | ||
err = PetscNewLog(v,dViewer_DHM,&dhm);dCHK(err); | ||
v->data = (void *) dhm; | ||
v->ops->destroy = PetscViewerDestroy_DHM; | ||
v->ops->flush = 0; | ||
v->iformat = 0; | ||
dhm->btype = (PetscFileMode) -1; | ||
dhm->filename = 0; | ||
|
||
err = PetscObjectComposeFunctionDynamic((PetscObject)v,"PetscViewerFileSetName_C","PetscViewerFileSetName_DHM", | ||
PetscViewerFileSetName_DHM);dCHK(err); | ||
err = PetscObjectComposeFunctionDynamic((PetscObject)v,"PetscViewerFileSetMode_C","PetscViewerFileSetMode_DHM", | ||
PetscViewerFileSetMode_DHM);dCHK(err); | ||
err = PetscObjectComposeFunctionDynamic((PetscObject)v,"dViewerDHMSetFS_C","dViewerDHMSetFS_DHM",dViewerDHMSetFS_DHM);dCHK(err); | ||
err = PetscObjectComposeFunctionDynamic((PetscObject)v,"dViewerDHMSetTime_C","dViewerDHMSetTime_DHM",dViewerDHMSetTime_DHM);dCHK(err); | ||
dFunctionReturn(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* @file dhm.h | ||
* @author Jed Brown <jed@59A2.org> | ||
* @date Sat Oct 24 17:20:17 2009 | ||
* | ||
* @brief DHM is format for storing Dohp vectors in HDF5 with reference to iMesh. | ||
* | ||
* This is a Multiple Time Multiple Domain format. A mesh defines the macro-topology, but can be a heavy object to | ||
* duplicate at every time step, and this duplication is clumsy to deal with for certain applications because it's not | ||
* easy to tell when the mesh changes. The FS defines a function space over the mesh. There can be multiple function | ||
* spaces using the same mesh. The parallel layout is defined by a global offset and size for each entity, stored as | ||
* tags on the mesh. The geometry is defined by a vector in some function space, usually giving locations of nodes (this | ||
* changes every time step in ALE methods). | ||
* | ||
* An outline of the format is | ||
* | ||
* /fs/[ID]/mesh_file_name | ||
* /layout_tags | ||
* /layout_tags_of_coordinate_fs | ||
* /id_of_coordinate_vector | ||
* /times/[ID]/time | ||
* /[FIELD]/id_of_fs | ||
* /vector | ||
* | ||
*/ | ||
|
||
|
||
#include <hdf5.h> | ||
|
||
#define dHCHK(herr) dCHK((dErr)herr) | ||
|
||
#include <dohpviewer.h> | ||
#include <dohpfs.h> | ||
|
||
typedef struct { | ||
char *filename; | ||
PetscFileMode btype; | ||
hid_t file_id; | ||
dReal time; | ||
dFS fs; /* Most writes are with respect to a FS, once written we set to 0 */ | ||
} dViewer_DHM; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <dohpviewer.h> | ||
|
||
EXTERN PetscErrorCode PetscViewerCreate_DHM(PetscViewer); | ||
|
||
dErr dViewerRegisterAll(const char *path) | ||
{ | ||
dErr err; | ||
|
||
dFunctionBegin; | ||
err = PetscViewerRegister(PETSC_VIEWER_DHM,path,"PetscViewerCreate_DHM",PetscViewerCreate_DHM);dCHK(err); | ||
dFunctionReturn(0); | ||
} | ||
|
||
dErr dViewerDHMSetFS(dViewer viewer,dFS fs) | ||
{ | ||
dErr err,(*r)(dViewer,dFS); | ||
|
||
dFunctionBegin; | ||
err = PetscObjectQueryFunction((PetscObject)viewer,"dViewerDHMSetFS_C",(void(**)(void))&r);dCHK(err); | ||
if (r) { | ||
err = (*r)(viewer,fs);dCHK(err); | ||
} | ||
dFunctionReturn(0); | ||
} | ||
|
||
|
||
dErr dViewerDHMSetTime(dViewer viewer,dReal time) | ||
{ | ||
dErr err,(*r)(dViewer,dReal); | ||
|
||
dFunctionBegin; | ||
err = PetscObjectQueryFunction((PetscObject)viewer,"dViewerDHMSetTime_C",(void(**)(void))&r);dCHK(err); | ||
if (r) { | ||
err = (*r)(viewer,time);dCHK(err); | ||
} | ||
dFunctionReturn(0); | ||
} |