[cig-commits] r13784 - cs/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Wed Dec 17 02:34:11 PST 2008
Author: luis
Date: 2008-12-17 02:34:10 -0800 (Wed, 17 Dec 2008)
New Revision: 13784
Modified:
cs/cigma/trunk/src/Field.cpp
cs/cigma/trunk/src/io_hdf5_reader.cpp
Log:
Take mesh location from HDF5 attribute (must be in same file)
Modified: cs/cigma/trunk/src/Field.cpp
===================================================================
--- cs/cigma/trunk/src/Field.cpp 2008-12-17 10:34:09 UTC (rev 13783)
+++ cs/cigma/trunk/src/Field.cpp 2008-12-17 10:34:10 UTC (rev 13784)
@@ -7,6 +7,8 @@
#include "io_file_reader.h"
#include "io_vtk_reader.h"
+#include "io_hdf5_reader.h"
+#include "io_hdf5.h"
using namespace std;
using namespace cigma;
@@ -20,30 +22,70 @@
TRI_LOG_STR("Field::NewField()");
shared_ptr<Field> field;
+ int status;
if (field_info)
{
TRI_LOG(field_info);
- field = shared_ptr<Field>(new Field);
-
+ //
+ // XXX: move these to respective reader->getField() method
+ //
if (field_info.p_field.is_vtk_file())
{
const string filename = field_info.p_field.filename();
const string location = field_info.p_field.location();
-
- // XXX: move these methods up the hierarchy to FileReader
shared_ptr<FileReader> reader = FileReader::New(filename, "r");
-
VtkReader* vtk = static_cast<VtkReader*>(&(*reader));
+ field = shared_ptr<Field>(new Field);
+ field->dofs = vtk->getDofHandler(location.c_str());
field->mesh = vtk->getMeshPart(0);
field->fe = vtk->getFE(0);
- field->dofs = vtk->getDofHandler(location.c_str());
+ return field;
}
+ else if (field_info.p_field.is_hdf5_file())
+ {
+ const string filename = field_info.p_field.filename();
+ const string location = field_info.p_field.location();
+ shared_ptr<FileReader> reader = FileReader::New(filename, "r");
+ HDF5_Reader* h5 = static_cast<HDF5_Reader*>(&(*reader));
+
+ field = shared_ptr<Field>(new Field);
+ field->dofs = h5->getDofHandler(location.c_str());
+
+ if (field_info.mesh_info)
+ {
+ field->mesh = MeshPart::New(field_info.mesh_info);
+ }
+ else
+ {
+ string meshloc;
+ status = read_scalar_attribute<string>(h5->file, location.c_str(), "MeshLocation", meshloc);
+ if (status < 0)
+ {
+ std::ostringstream stream;
+ stream << "No mesh specified for dataset '"
+ << location << "' in HDF5 file '"
+ << filename << "'" << std::ends;
+ throw cigma::Exception("Field::NewField", stream.str());
+ }
+ field->mesh = h5->getMeshPart(meshloc.c_str());
+ }
+
+ if (field_info.fe_info)
+ {
+ field->fe = FE::New(field_info.fe_info);
+ }
+ else if (field->mesh)
+ {
+ field->fe = shared_ptr<FE>(new FE(field->mesh->getCellType()));
+ }
+ }
else
{
+ field = shared_ptr<Field>(new Field);
+ field->dofs = DofHandler::New(field_info.p_field);
field->mesh = MeshPart::New(field_info.mesh_info);
- field->dofs = DofHandler::New(field_info.p_field);
if (field_info.fe_info)
{
Modified: cs/cigma/trunk/src/io_hdf5_reader.cpp
===================================================================
--- cs/cigma/trunk/src/io_hdf5_reader.cpp 2008-12-17 10:34:09 UTC (rev 13783)
+++ cs/cigma/trunk/src/io_hdf5_reader.cpp 2008-12-17 10:34:10 UTC (rev 13784)
@@ -223,6 +223,15 @@
mesh->connect = this->getElementBlock(eb.c_str());
mesh->cell_type = this->getCellType(loc);
+ if (mesh->cell_type == Cell::NONE)
+ {
+ std::ostringstream stream;
+ stream << "Cell type for mesh '"
+ << loc << "' in HDF5 file '"
+ << filename << "' was not specified" << std::ends;
+ throw cigma::Exception("HDF5_Reader::getMeshPart", stream.str());
+ }
+
if (true)
{
// XXX: move this to a method in MeshPart
@@ -334,7 +343,7 @@
shared_ptr<DofHandler> HDF5_Reader::getDofHandler(const char *loc)
{
- TRI_LOG_STR("HDF5_Reader::getDofHandler");
+ TRI_LOG_STR("HDF5_Reader::getDofHandler()");
shared_ptr<DofHandler> dh(new DofHandler);
int status = this->getDataset(loc, &(dh->dofs), &(dh->nno), &(dh->rank));
if (status < 0)
More information about the CIG-COMMITS
mailing list