diff --git a/databases/Vs/CMakeLists.txt b/databases/Vs/CMakeLists.txt index c84db2270a343d86c91f015c64bc73f25c5bfb93..f804a0930111b7d268ed973334efb98dd934b818 100644 --- a/databases/Vs/CMakeLists.txt +++ b/databases/Vs/CMakeLists.txt @@ -18,12 +18,6 @@ ${COMMON_SOURCES} avtVsFileFormat.C avtVsOptions.C VsFilter.C -VsH5Attribute.C -VsH5Dataset.C -VsH5File.C -VsH5Group.C -VsH5Object.C -VsH5Reader.C VsLog.C VsMDMesh.C VsMDVariable.C @@ -38,6 +32,13 @@ VsVariable.C VsVariableWithMesh.C VsRegistry.C VsRegistryObject.C +VsGroup.C +VsObject.C +VsDataset.C +VsAttribute.C +VsFile.C +VsReader.C +VsStaggeredField.C ) SET(LIBE_SOURCES @@ -46,12 +47,6 @@ ${COMMON_SOURCES} avtVsFileFormat.C avtVsOptions.C VsFilter.C -VsH5Attribute.C -VsH5Dataset.C -VsH5File.C -VsH5Group.C -VsH5Object.C -VsH5Reader.C VsLog.C VsMDMesh.C VsMDVariable.C @@ -66,6 +61,12 @@ VsVariable.C VsVariableWithMesh.C VsRegistry.C VsRegistryObject.C +VsGroup.C +VsObject.C +VsDataset.C +VsAttribute.C +VsFile.C +VsReader.C ) INCLUDE_DIRECTORIES( diff --git a/databases/Vs/VsApi.h b/databases/Vs/VsApi.h new file mode 100644 index 0000000000000000000000000000000000000000..0cd4a4ae62e227cdf178c2f3035c79f0650d16c5 --- /dev/null +++ b/databases/Vs/VsApi.h @@ -0,0 +1,28 @@ +/* + * Main header file for VsApi + * + * + * $Id: $ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/databases/Vs/VsH5Attribute.C b/databases/Vs/VsAttribute.C similarity index 76% rename from databases/Vs/VsH5Attribute.C rename to databases/Vs/VsAttribute.C index cd5e635cb7f0b2b1e5f2ec5e3ba2adf8cf2cdf0b..7112c5a98398ed1031389face723a18b59586906 100644 --- a/databases/Vs/VsH5Attribute.C +++ b/databases/Vs/VsAttribute.C @@ -1,21 +1,21 @@ /* - * VsH5Attribute.cpp + * VsAttribute.cpp * * Created on: Apr 28, 2010 * Author: mdurant */ -#include "VsH5Attribute.h" +#include "VsAttribute.h" #include "VsLog.h" #include -VsH5Attribute::VsH5Attribute(VsH5Object* parentObject, std::string attName, hid_t id): - VsH5Object(parentObject->registry, parentObject, attName, id) { +VsAttribute::VsAttribute(VsObject* parentObject, std::string attName, hid_t id): + VsObject(parentObject->registry, parentObject, attName, id) { dataType = H5Aget_type(id); } -VsH5Attribute::~VsH5Attribute() { +VsAttribute::~VsAttribute() { hid_t id = getId(); if (id != -1) { H5Aclose(id); @@ -23,7 +23,7 @@ VsH5Attribute::~VsH5Attribute() { } } -void VsH5Attribute::write() { +void VsAttribute::write() const { std::string offset = ""; for (int i = 0; i < getDepth(); ++i) { offset += " "; @@ -33,7 +33,7 @@ void VsH5Attribute::write() { } // Total length -size_t VsH5Attribute::getLength() { +size_t VsAttribute::getLength() const { size_t len = 1; for (size_t i = 0; i < dims.size(); ++i) { len *= dims[i]; @@ -41,14 +41,14 @@ size_t VsH5Attribute::getLength() { return len; } -herr_t VsH5Attribute::getStringValue(std::string* val) { +int VsAttribute::getStringValue(std::string* val) { hid_t atype = H5Aget_type(getId()); H5T_class_t type = H5Tget_class(atype); hid_t aspace = H5Aget_space(getId()); size_t rank = H5Sget_simple_extent_ndims(aspace); if (type != H5T_STRING) { - VsLog::warningLog() <<"VsH5Attribute::getStringValue() - Requested attribute " <clear(); return -1; @@ -56,7 +56,7 @@ herr_t VsH5Attribute::getStringValue(std::string* val) { //Yes, this is correct (rank != 0) if (rank != 0) { - VsLog::warningLog() <<"VsH5Attribute::getStringValue() - Requested attribute " <clear(); return -1; @@ -65,7 +65,7 @@ herr_t VsH5Attribute::getStringValue(std::string* val) { size_t len = H5Aget_storage_size(getId()); val->resize(len); char* v = new char[len]; - herr_t err = H5Aread(getId(), atype, v); + int err = H5Aread(getId(), atype, v); // JRC: is this right? // err = H5Aread(id, H5T_NATIVE_CHAR, v); for (size_t i = 0; i < len; ++i) { @@ -74,7 +74,7 @@ herr_t VsH5Attribute::getStringValue(std::string* val) { //and uses the 5th character for the null terminator //In h5dump this shows up as a string "mesh" being declared as 5 characters //If dumped to a terminal, it prints like so: "mesh^@" - VsLog::warningLog() <<"VsH5Attribute::getStringValue() - Found null char inside string attribute: " <resize(i); break; } @@ -86,8 +86,8 @@ herr_t VsH5Attribute::getStringValue(std::string* val) { // JRC: This fat interface may not scale? What about // scalar attributes? -herr_t VsH5Attribute::getIntVectorValue(std::vector* ivals) { - herr_t err; +int VsAttribute::getIntVectorValue(std::vector* ivals) { + int err; size_t npoints; hid_t atype = H5Aget_type(getId()); H5T_class_t type = H5Tget_class(atype); @@ -95,7 +95,7 @@ herr_t VsH5Attribute::getIntVectorValue(std::vector* ivals) { size_t rank = H5Sget_simple_extent_ndims(aspace); if (type != H5T_INTEGER) { - VsLog::warningLog() <<"VsH5Attribute::getIntVectorValue() - Requested attribute " <resize(0); return -1; @@ -125,9 +125,9 @@ herr_t VsH5Attribute::getIntVectorValue(std::vector* ivals) { // JRC: This fat interface may not scale? What about // scalar attributes? -herr_t VsH5Attribute::getFloatVectorValue(std::vector* fvals) { +int VsAttribute::getFloatVectorValue(std::vector* fvals) { - herr_t err = 0; + int err = 0; size_t npoints; hid_t atype = H5Aget_type(getId()); H5T_class_t type = H5Tget_class(atype); @@ -135,7 +135,7 @@ herr_t VsH5Attribute::getFloatVectorValue(std::vector* fvals) { size_t rank = H5Sget_simple_extent_ndims(aspace); if (type != H5T_FLOAT) { - VsLog::warningLog() <<"VsH5Attribute::getFloatVectorValue() - Requested attribute " <resize(0); return -1; @@ -164,8 +164,8 @@ herr_t VsH5Attribute::getFloatVectorValue(std::vector* fvals) { // JRC: This fat interface may not scale? What about // scalar attributes? -herr_t VsH5Attribute::getDoubleVectorValue(std::vector* dvals) { - herr_t err = 0; +int VsAttribute::getDoubleVectorValue(std::vector* dvals) { + int err = 0; size_t npoints; hid_t atype = H5Aget_type(getId()); H5T_class_t type = H5Tget_class(atype); @@ -173,7 +173,7 @@ herr_t VsH5Attribute::getDoubleVectorValue(std::vector* dvals) { size_t rank = H5Sget_simple_extent_ndims(aspace); if (type != H5T_FLOAT) { - VsLog::warningLog() <<"VsH5Attribute::getDoubleVectorValue() - Requested attribute " <resize(0); return -1; diff --git a/databases/Vs/VsAttribute.h b/databases/Vs/VsAttribute.h new file mode 100644 index 0000000000000000000000000000000000000000..dc994c1d26f9db836dd521f4b7eed6f047a19efe --- /dev/null +++ b/databases/Vs/VsAttribute.h @@ -0,0 +1,44 @@ +/** + * @file VsAttribute.h + * + * @class VsAttribute + * @brief Represents an hdf5 attribute from an hdf5 file. + * + * Saves the name and hdf5 id of an attribute. Provides + * accessors to retrieve the actual value of the attribute + * from the file. + * + * Created on: Apr 28, 2010 + * Author: mdurant + */ + +#ifndef VS_ATTRIBUTE_H_ +#define VS_ATTRIBUTE_H_ + +#include "VsObject.h" +#include +#include +#include + +class VsAttribute: public VsObject { +public: + VsAttribute(VsObject* parentObject, std::string attName, hid_t id); + virtual ~VsAttribute(); + + void write() const; + hid_t getType() const { return dataType; } + size_t getLength() const; + + // Get the value of this attribute + // CAUTION: Calling the incorrect accessor will result in invalid or null data + int getStringValue(std::string* val); + int getIntVectorValue(std::vector* ivals); + int getFloatVectorValue(std::vector* fvals); + int getDoubleVectorValue(std::vector* dvals); + +private: + hid_t dataType; + std::vector dims; +}; + +#endif /* VS_ATTRIBUTE_H_ */ diff --git a/databases/Vs/VsH5Dataset.C b/databases/Vs/VsDataset.C similarity index 63% rename from databases/Vs/VsH5Dataset.C rename to databases/Vs/VsDataset.C index b656ac3d34d76aa749c29f8d50cd43dab9574c21..cc8335e930ebbb74d05127a5cd72fadd2209b854 100644 --- a/databases/Vs/VsH5Dataset.C +++ b/databases/Vs/VsDataset.C @@ -1,12 +1,12 @@ /* - * VsH5Dataset.cpp + * VsDataset.cpp * * Created on: Apr 27, 2010 * Author: mdurant */ -#include "VsH5Dataset.h" -#include "VsH5Attribute.h" +#include "VsDataset.h" +#include "VsAttribute.h" #include "VsLog.h" #include "VsSchema.h" #include @@ -19,8 +19,9 @@ #include "VsVariable.h" #include "VsVariableWithMesh.h" -VsH5Dataset::VsH5Dataset(VsRegistry* r, VsH5Object* parentObject, std::string datasetName, hid_t id): - VsH5Object(r, parentObject, datasetName, id){ +VsDataset::VsDataset(VsRegistry* r, VsObject* parentObject, + const std::string& datasetName, hid_t id): + VsObject(r, parentObject, datasetName, id){ dataType = H5Tget_native_type(H5Dget_type(id), H5T_DIR_DEFAULT); loadDims(); @@ -28,7 +29,7 @@ VsH5Dataset::VsH5Dataset(VsRegistry* r, VsH5Object* parentObject, std::string da registry->add(this); } -VsH5Dataset::~VsH5Dataset() { +VsDataset::~VsDataset() { hid_t id = this->getId(); if (id != -1) { H5Dclose(id); @@ -40,7 +41,7 @@ VsH5Dataset::~VsH5Dataset() { // Total length -size_t VsH5Dataset::getLength() { +size_t VsDataset::getLength() const { size_t len = 1; for (size_t i = 0; i < dims.size(); ++i) { len *= dims[i]; @@ -48,12 +49,12 @@ size_t VsH5Dataset::getLength() { return len; } -void VsH5Dataset::loadDims() { +void VsDataset::loadDims() { hid_t space = H5Dget_space(getId()); size_t rank = H5Sget_simple_extent_ndims(space); if (rank <= 0) { - VsLog::errorLog() <<"VsH5Dataset::loadDims() - Rank was <= 0 for dataset: " < sdim(rank); @@ -64,15 +65,14 @@ void VsH5Dataset::loadDims() { } } -std::vector VsH5Dataset::getDims() { +std::vector VsDataset::getDims() const { return dims; } -void VsH5Dataset::write() { +void VsDataset::write() const { std::string offset = ""; for (int i = 0; i < getDepth(); ++i) { offset += " "; } - - VsLog::debugLog() << offset< +#include "VsObject.h" +#include +#include +#include + +class VsAttribute; + +class VsDataset : public VsObject { + +public: + + /** + * Constructor + */ + VsDataset(VsRegistry* r, VsObject* parentObject, + const std::string& datasetName, hid_t id); + + /** + * Destructor + */ + virtual ~VsDataset(); + + /** + * Write debug information to log file + */ + void write() const; + + /** + * Get the total number of data values + * @return number + */ + size_t getLength() const; + + /** + * Get the dimensions + * @return number of values along each axis + */ + std::vector getDims() const; + + /** + * Get the number of dimensions (rank) + * @return number + */ + size_t getNumDims() const { return this->dims.size(); } + + /** + * Get the hdf5 type + * @return type + */ + hid_t getType() const { return this->dataType; } + +private: + std::vector dims; + hid_t dataType; + std::vector attributes; + + void loadDims(); +}; + +#endif /* VS_DATASET_H_ */ diff --git a/databases/Vs/VsH5File.C b/databases/Vs/VsFile.C similarity index 86% rename from databases/Vs/VsH5File.C rename to databases/Vs/VsFile.C index 4a8d102005afab37593e406c2d1fdeb120abbab2..77f96f63ebae1331cf0174c41403ff1c9796c760 100644 --- a/databases/Vs/VsH5File.C +++ b/databases/Vs/VsFile.C @@ -1,27 +1,24 @@ /* - * VsH5File.cpp + * VsFile.cpp * * Created on: Apr 27, 2010 * Author: mdurant */ -#include "VsH5File.h" +#include "VsFile.h" #include "VsLog.h" -#include "VsFilter.h" #include "hdf5.h" -#include "visit-hdf5.h" -#include "VsH5Dataset.h" -#include "VsH5Group.h" +#include "VsDataset.h" +#include "VsGroup.h" #include "VsVariable.h" #include "VsVariableWithMesh.h" #include "VsRectilinearMesh.h" #include "VsUniformMesh.h" #include "VsUnstructuredMesh.h" #include "VsStructuredMesh.h" -//#include -VsH5File::VsH5File(VsRegistry* r, std::string name, hid_t id): - VsH5Object(r, NULL, name, id) { +VsFile::VsFile(VsRegistry* r, std::string name, hid_t id): + VsObject(r, NULL, name, id) { fileName = name; VsLog::debugLog() <<"File name is: " < +#include "VsGroup.h" +#include "VsObject.h" +#include + +class VsFile : public VsObject { +public: + VsFile(VsRegistry* r, std::string name, hid_t id); + virtual ~VsFile(); + + std::string getName() const; + void write() const; + +private: + std::string fileName; +}; + +#endif /* VS_FILE_H_ */ diff --git a/databases/Vs/VsFilter.C b/databases/Vs/VsFilter.C index 52691093f9336b916b98cafeaf464b512a6a5915..0bbf5c0a69afcf707c368f2d9a5d67069c561e7f 100644 --- a/databases/Vs/VsFilter.C +++ b/databases/Vs/VsFilter.C @@ -1,13 +1,11 @@ #include -#include -#if HDF5_VERSION_GE(1,8,1) /** * * @file VsFilter.cpp * * @brief Implementation for inspecting an HDF5 file * - * @version $Id: VsFilter.C 496 2009-08-05 22:57:22Z mdurant $ + * @version $Id: VsFilter.cpp 2 2013-02-20 20:11:25Z sveta $ * * Copyright © 2007-2008, Tech-X Corporation * See LICENSE file for conditions of use. @@ -21,63 +19,30 @@ #include #include #include "VsLog.h" -#include "VsH5File.h" -#include "VsH5Object.h" -#include "VsH5Dataset.h" -#include "VsH5Attribute.h" +#include "VsFile.h" +#include "VsObject.h" +#include "VsDataset.h" +#include "VsAttribute.h" #include "VsRegistry.h" -// -// These routines detect whether the file looks like a certain flavor of -// HDF5 file reader. If the flavor is detected, we throw an exception so -// the proper reader can be used instead of Vs. -// - -static bool IsTyphonIO(int fileId) -{ - // - //See if file is TyphonIO/TyphonIO[v0] format - // - hid_t tio_root = H5Gopen(fileId, "/", H5P_DEFAULT); - hid_t tio_version = H5Aopen_name(tio_root, "TIO_version_major"); - if (tio_version >= 0) - { - H5Aclose(tio_version); - H5Gclose(tio_root); - VsLog::errorLog() <<"VsH5File::DetectTyphonIO(): Cannot be a Vs file because it looks like a TyphonIO file." << std::endl; - return true; - } - if (tio_root >= 0) H5Gclose(tio_root); - hid_t tio_info = H5Gopen(fileId, "/TyphonIO_FileInfo", H5P_DEFAULT); - if (tio_info >= 0) - { - H5Gclose(tio_info); - VsLog::errorLog() <<"VsH5File::DetectTyphonIO(): Cannot be a Vs file because it looks like a TyphonIO file." << std::endl; - return true; - } - return false; -} struct RECURSION_DATA { VsRegistry* registry; - VsH5Object* parent; + VsObject* parent; }; -VsH5File* VsFilter::readFile(VsRegistry* registry, std::string fileName) { +VsFile* VsFilter::readFile(VsRegistry* registry, std::string fileName) { hid_t fapl = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fclose_degree(fapl, H5F_CLOSE_SEMI); hid_t fileId = H5Fopen(fileName.c_str(), H5F_ACC_RDONLY, fapl); H5Pclose(fapl); if (fileId < 0) { - VsLog::errorLog() << "VsH5File::readFile(): HDF5 error opening the file '" + VsLog::errorLog() << "VsFile::readFile(): HDF5 error opening the file '" << fileName << "'." << std::endl; return NULL; } - VsH5File* file = new VsH5File(registry, fileName, fileId); - - //Check to see if its a TyphonIO fileI - if (IsTyphonIO(fileId)) return NULL; - + VsFile* file = new VsFile(registry, fileName, fileId); + RECURSION_DATA data; data.registry = registry; data.parent = NULL; @@ -86,7 +51,7 @@ VsH5File* VsFilter::readFile(VsRegistry* registry, std::string fileName) { return file; } -herr_t VsFilter::visitLinks(hid_t locId, const char* name, +int VsFilter::visitLinks(hid_t locId, const char* name, const H5L_info_t *linfo, void* opdata) { VsLog::debugLog() <<"VsFilter::visitLinks() - looking at object " <(opdata); - VsH5Group* parent = static_cast< VsH5Group*> (data->parent); + VsGroup* parent = static_cast< VsGroup*> (data->parent); VsRegistry* registry = data->registry; VsLog::debugLog() << "VsFilter::visitGroup: node '" << name @@ -214,7 +179,7 @@ herr_t VsFilter::visitGroup(hid_t locId, const char* name, void* opdata) { return 0; } - VsH5Group* newGroup = new VsH5Group(registry, parent, name, groupId); + VsGroup* newGroup = new VsGroup(registry, parent, name, groupId); RECURSION_DATA nextLevelData; nextLevelData.registry = registry; @@ -228,7 +193,7 @@ herr_t VsFilter::visitGroup(hid_t locId, const char* name, void* opdata) { VsLog::debugLog() <<"VsFilter::visitGroup(): Recursing on children of group " <getFullName() <(opdata); - VsH5Group* parent = static_cast< VsH5Group*>(data->parent); + VsGroup* parent = static_cast< VsGroup*>(data->parent); VsRegistry* registry = data->registry; VsLog::debugLog() << "VsFilter::visitDataset: node '" << name @@ -246,7 +211,7 @@ herr_t VsFilter::visitDataset(hid_t locId, const char* name, void* opdata) { hid_t datasetId = H5Dopen(locId, name, H5P_DEFAULT); - VsH5Dataset* newDataset = new VsH5Dataset(registry, parent, name, datasetId); + VsDataset* newDataset = new VsDataset(registry, parent, name, datasetId); //If unable to get a handle to the hdf5 object, we just drop the object //But return 0 to continue iterating over objects @@ -267,10 +232,10 @@ herr_t VsFilter::visitDataset(hid_t locId, const char* name, void* opdata) { return 0; } -herr_t VsFilter::visitAttrib(hid_t dId, const char* name, +int VsFilter::visitAttrib(hid_t dId, const char* name, const H5A_info_t* ai, void* opdata) { RECURSION_DATA* data = static_cast< RECURSION_DATA* >(opdata); - VsH5Object* parent = data->parent; + VsObject* parent = data->parent; VsLog::debugLog() << "VsFilter::visitAttrib(...): getting attribute '" << name << "'." << std::endl; @@ -288,4 +253,3 @@ herr_t VsFilter::visitAttrib(hid_t dId, const char* name, return 0; } -#endif diff --git a/databases/Vs/VsFilter.h b/databases/Vs/VsFilter.h index 899716e05d1954799994cb6c78f6604a2f1cd31b..1f63b07f541719cfed0983cb43b196ffcdc15dc9 100644 --- a/databases/Vs/VsFilter.h +++ b/databases/Vs/VsFilter.h @@ -7,14 +7,12 @@ * * VsFilter contains a set of static classes that interface * with hdf5 recursive reading routines. VsFilter creates - * VsH5Group, VsH5Dataset, and VsH5Attribute objects to + * VsGroup, VsDataset, and VsAttribute objects to * represent the contents of the hdf5 file. * * Copyright © 2008 by Tech-X Corporation */ #include -#include -#if HDF5_VERSION_GE(1, 8, 1) #ifndef VS_FILTER #define VS_FILTER @@ -24,7 +22,7 @@ #include // metadata -#include "VsH5File.h" +#include "VsFile.h" #include class VsRegistry; @@ -32,7 +30,7 @@ class VsRegistry; class VsFilter { public: - static VsH5File* readFile(VsRegistry* registry, std::string fileName); + static VsFile* readFile(VsRegistry* registry, std::string fileName); virtual ~VsFilter() {} @@ -40,14 +38,13 @@ protected: VsFilter(); // Visit links, group or dataset - static herr_t visitLinks(hid_t group, const char* name, const H5L_info_t* linfo, void* opdata); - static herr_t visitGroup(hid_t group, const char* name, void* opdata); - static herr_t visitDataset(hid_t group, const char* name, void* opdata); + static int visitLinks(hid_t group, const char* name, const H5L_info_t* linfo, void* opdata); + static int visitGroup(hid_t group, const char* name, void* opdata); + static int visitDataset(hid_t group, const char* name, void* opdata); // Visit attribute - static herr_t visitAttrib(hid_t group, const char* name, const H5A_info_t* ai, void* opdata); + static int visitAttrib(hid_t group, const char* name, const H5A_info_t* ai, void* opdata); }; #endif -#endif diff --git a/databases/Vs/VsH5Group.C b/databases/Vs/VsGroup.C similarity index 68% rename from databases/Vs/VsH5Group.C rename to databases/Vs/VsGroup.C index 47b5dec493fd222c37a3fa64dbb5b80068fc4b78..efcadfa5fb2a3d7c02da7f93c85cdd6c2963178c 100644 --- a/databases/Vs/VsH5Group.C +++ b/databases/Vs/VsGroup.C @@ -1,27 +1,27 @@ /* - * VsH5Group.cpp + * VsGroup.cpp * * Created on: Apr 27, 2010 * Author: mdurant */ -#include "VsH5Group.h" -#include "VsH5Dataset.h" +#include "VsGroup.h" +#include "VsDataset.h" #include "VsLog.h" #include "VsSchema.h" #include "VsMesh.h" #include "VsUtils.h" #include #include -#include "VsH5Attribute.h" +#include "VsAttribute.h" -VsH5Group::VsH5Group(VsRegistry* r, VsH5Object* parentObject, std::string groupName, hid_t id): - VsH5Object(r, parentObject, groupName, id) { +VsGroup::VsGroup(VsRegistry* r, VsObject* parentObject, std::string groupName, hid_t id): + VsObject(r, parentObject, groupName, id) { registry->add(this); } -VsH5Group::~VsH5Group() { +VsGroup::~VsGroup() { VsLog::debugLog() <<"Deleting group: " <getId(); @@ -33,7 +33,7 @@ VsH5Group::~VsH5Group() { registry->remove(this); } -void VsH5Group::write() { +void VsGroup::write() const { //calculate how much indentation to use std::string offset = ""; for (int i = 0; i < getDepth(); ++i) diff --git a/databases/Vs/VsGroup.h b/databases/Vs/VsGroup.h new file mode 100644 index 0000000000000000000000000000000000000000..c64254f8331c9fa26c2c074fc3e2faceb9166f78 --- /dev/null +++ b/databases/Vs/VsGroup.h @@ -0,0 +1,36 @@ +/** + * @file VsGroup.h + * + * @class VsGroup + * @brief Represents an hdf5 group from an hdf5 file. + * + * Provides accessors to get attributes and datasets + * from a group in an hdf5 file. + * + * Created on: Apr 27, 2010 + * Author: mdurant + */ + +#ifndef VS_GROUP_H_ +#define VS_GROUP_H_ + +#include +#include +#include + +#include "VsObject.h" +#include + +class VsAttribute; +class VsDataset; + +class VsGroup : public VsObject { +public: + VsGroup(VsRegistry* r, VsObject* parentObject, std::string groupName, hid_t id); + virtual ~VsGroup(); + + void write() const; + +}; + +#endif /* VS_GROUP_H_ */ diff --git a/databases/Vs/VsH5Attribute.h b/databases/Vs/VsH5Attribute.h deleted file mode 100644 index 1e5e94373cbd1cd2476430b429103f45a89d64df..0000000000000000000000000000000000000000 --- a/databases/Vs/VsH5Attribute.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @file VsH5Attribute.h - * - * @class VsH5Attribute - * @brief Represents an hdf5 attribute from an hdf5 file. - * - * Saves the name and hdf5 id of an attribute. Provides - * accessors to retrieve the actual value of the attribute - * from the file. - * - * Created on: Apr 28, 2010 - * Author: mdurant - */ - -#ifndef VSH5ATTRIBUTE_H_ -#define VSH5ATTRIBUTE_H_ - -#include "VsH5Object.h" -#include -#include -#include - -class VsH5Attribute: public VsH5Object { -public: - VsH5Attribute(VsH5Object* parentObject, std::string attName, hid_t id); - virtual ~VsH5Attribute(); - - void write(); - hid_t getType() { return dataType; } - size_t getLength(); - - // Get the value of this attribute - // CAUTION: Calling the incorrect accessor will result in invalid or null data - herr_t getStringValue(std::string* val); - herr_t getIntVectorValue(std::vector* ivals); - herr_t getFloatVectorValue(std::vector* fvals); - herr_t getDoubleVectorValue(std::vector* dvals); - -private: - hid_t dataType; - std::vector dims; -}; - -#endif /* VSH5ATTRIBUTE_H_ */ diff --git a/databases/Vs/VsH5Dataset.h b/databases/Vs/VsH5Dataset.h deleted file mode 100644 index a98e45b9ed55fb0ae2c89fcc0cef12fa7a7c96aa..0000000000000000000000000000000000000000 --- a/databases/Vs/VsH5Dataset.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file VsH5Dataset.h - * - * @class VsH5Dataset - * @brief Represents a dataset from an hdf5 file. - * - * Provides accessors to retrieve attributes and data from - * the hdf5 file. - * - * Created on: Apr 27, 2010 - * Author: mdurant - */ - -#ifndef VSH5DATASET_H_ -#define VSH5DATASET_H_ - -#include -#include "VsH5Object.h" -#include -#include -#include - -class VsH5Attribute; - -class VsH5Dataset : public VsH5Object { -public: - VsH5Dataset(VsRegistry* r, VsH5Object* parentObject, std::string datasetName, hid_t id); - virtual ~VsH5Dataset(); - - void write(); - size_t getLength(); - std::vector getDims(); - hid_t getType() { return dataType; } - -private: - std::vector dims; - hid_t dataType; - std::vector attributes; - - void loadDims(); -}; - -#endif /* VSH5DATASET_H_ */ diff --git a/databases/Vs/VsH5File.h b/databases/Vs/VsH5File.h deleted file mode 100644 index 51bea96ba85d5256d978a4a4899df9901d192a2b..0000000000000000000000000000000000000000 --- a/databases/Vs/VsH5File.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @file VsH5File.h - * - * @class VsH5File - * @brief Represents an hdf5 data file - * - * Created on: Apr 27, 2010 - * Author: mdurant - */ - -#ifndef VSH5FILE_H_ -#define VSH5FILE_H_ - -#include -#include "VsH5Group.h" -#include "VsH5Object.h" -#include - -class VsH5File : public VsH5Object { -public: - VsH5File(VsRegistry* r, std::string name, hid_t id); - virtual ~VsH5File(); - - std::string getName(); - void write(); - -private: - std::string fileName; -}; - -#endif /* VSH5FILE_H_ */ diff --git a/databases/Vs/VsH5Group.h b/databases/Vs/VsH5Group.h deleted file mode 100644 index b356dd4f65db3a277cb0b0852134e7ac993a7ef2..0000000000000000000000000000000000000000 --- a/databases/Vs/VsH5Group.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file VsH5Group.h - * - * @class VsH5Group - * @brief Represents an hdf5 group from an hdf5 file. - * - * Provides accessors to get attributes and datasets - * from a group in an hdf5 file. - * - * Created on: Apr 27, 2010 - * Author: mdurant - */ - -#ifndef VSH5GROUP_H_ -#define VSH5GROUP_H_ - -#include -#include -#include - -#include "VsH5Object.h" -#include - -class VsH5Attribute; -class VsH5Dataset; - -class VsH5Group : public VsH5Object { -public: - VsH5Group(VsRegistry* r, VsH5Object* parentObject, std::string groupName, hid_t id); - virtual ~VsH5Group(); - - void write(); - -private: - -}; - -#endif /* VSH5GROUP_H_ */ diff --git a/databases/Vs/VsH5Object.C b/databases/Vs/VsH5Object.C deleted file mode 100644 index 30d239b384b1da2b72b0f75f99817833ffe76356..0000000000000000000000000000000000000000 --- a/databases/Vs/VsH5Object.C +++ /dev/null @@ -1,84 +0,0 @@ -/* - * VsH5Object.cpp - * - * Created on: Apr 27, 2010 - * Author: mdurant - */ - -#include "VsH5Object.h" -#include "VsUtils.h" -#include "VsH5Attribute.h" -#include "VsH5Group.h" -#include "VsH5Dataset.h" -#include - -VsH5Object::VsH5Object(VsRegistry* r, VsH5Object* parentObject, std::string objectName, hid_t id): - VsRegistryObject(r) { - parent = parentObject; - name = makeCanonicalName(objectName); - resourceId = id; - - if (parent) { - depth = parent->getDepth() + 1; - fullName = makeCanonicalName(parentObject->getFullName(), objectName); - } else { - depth = 0; - fullName = makeCanonicalName(objectName); - } - -} - -VsH5Object::~VsH5Object() { - std::map::const_iterator it; - for (it = attributes.begin(); it != attributes.end(); it++) { - VsH5Attribute* att = (*it).second; - delete(att); - } - - attributes.clear(); -} - -std::map* VsH5Object::getAllAttributes() { - return &attributes; -} - -std::string VsH5Object::getShortName() { - return name; -} - -std::string VsH5Object::getFullName() { - return fullName; -} - -std::string VsH5Object::getPath() { - if (parent) { - return parent->getFullName(); - } - - return "/"; -} - -hid_t VsH5Object::getId() { - return resourceId; -} - -int VsH5Object::getDepth() { - return depth; -} - -void VsH5Object::addAttribute(std::string name, hid_t id) { - VsH5Attribute* att = new VsH5Attribute(this, name, id); - - attributes[name] = att; - //TODO check for duplicates - //TODO check for validity -} - -VsH5Attribute* VsH5Object::getAttribute (std::string name) { - std::map::iterator it = attributes.find(name); - if (it != attributes.end()) { - return (*it).second; - } - - return NULL; -} diff --git a/databases/Vs/VsH5Object.h b/databases/Vs/VsH5Object.h deleted file mode 100644 index d26100f07397d10d0395ab7946ae4d89f7d99e36..0000000000000000000000000000000000000000 --- a/databases/Vs/VsH5Object.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @file VsH5Object.h - * - * @class VsH5Object - * @brief Superclass for all objects present in an hdf5 file. - * - * Provides a common interface for all objects that are - * directly present in an hdf5 file. Maintains the hierarchy - * structure present in the data file. - * - * Created on: Apr 27, 2010 - * Author: mdurant - */ - -#ifndef VSH5OBJECT_H_ -#define VSH5OBJECT_H_ - -#include -#include -#include -#include -#include "VsRegistryObject.h" - -class VsH5Attribute; - -class VsH5Object : public VsRegistryObject { -public: - VsH5Object(VsRegistry* r, VsH5Object* parentObject, std::string objectName, hid_t id); - virtual ~VsH5Object(); - - std::string getShortName(); - std::string getFullName(); - std::string getPath(); - hid_t getId(); - int getDepth(); - - void addAttribute(std::string name, hid_t id); - VsH5Attribute* getAttribute(std::string name); - std::map* getAllAttributes(); - -private: - std::string name; - std::string fullName; - VsH5Object* parent; - hid_t resourceId; - int depth; - - std::map attributes; - -}; - -#endif /* VSH5OBJECT_H_ */ diff --git a/databases/Vs/VsH5Reader.C b/databases/Vs/VsH5Reader.C deleted file mode 100644 index 841bfbece4bffe95eaf9d76f5cd6877b211c19a8..0000000000000000000000000000000000000000 --- a/databases/Vs/VsH5Reader.C +++ /dev/null @@ -1,458 +0,0 @@ -#include -#include -#include - -#if HDF5_VERSION_GE(1,8,1) - -/** - * - * @file VsH5Reader.cpp - * - * @brief Implementation reader of data for VSH5 schema - * - * @version $Id: VsH5Reader.C 496 2009-08-05 22:57:22Z mdurant $ - * - * Copyright © 2007-2008, Tech-X Corporation - * See LICENSE file for conditions of use. - * - */ - -#include -#include - -#include -#include -#include -#include "VsH5Dataset.h" -#include "VsH5Attribute.h" -#include "VsMDVariable.h" -#include "VsMDMesh.h" -#include "VsMesh.h" -#include "VsVariable.h" -#include "VsVariableWithMesh.h" -#include "VsRectilinearMesh.h" -#include "VsUnstructuredMesh.h" -#include "VsStructuredMesh.h" -#include "VsUniformMesh.h" -#include "VsLog.h" -#include "VsRegistry.h" - -#define __CLASS__ "VsH5Reader::" - - -int VsH5Reader::numInstances = 0; - -VsH5Reader::VsH5Reader(const std::string& nm, VsRegistry* r) { - - numInstances++; - VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "This VsH5Reader is #" - << numInstances << std::endl; - - VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "VsH5Reader::VsH5Reader(" << nm << ") entering." << std::endl; - - if (numInstances > 1) { - VsLog::warningLog() - << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "Warning! More than one concurrent copy of VsH5Reader." << std::endl; - VsLog::warningLog() - << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "Warning! Debug messages may be interleaved." << std::endl; - } - - registry = r; - - // Read raw hdf5 metadata - fileData = VsFilter::readFile(registry, nm); - if (!fileData) { - VsLog::errorLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "Unable to load metadata from file." << std::endl; - EXCEPTION1(InvalidFilesException, nm.c_str()); - } - - //debugging output of raw hdf5 objects - registry->writeAllGroups(); - registry->writeAllDatasets(); - - //Build "Core" (Mesh and Var) objects - registry->buildGroupObjects(); - registry->buildDatasetObjects(); - - //Build MD objects - registry->buildMDMeshes(); - registry->buildMDVars(); - - //Register "transformed" meshes, and then variables - registry->buildTransformedMeshes(); - registry->buildTransformedVariables(); - - //debugging output - registry->writeAllMeshes(); - registry->writeAllExpressions(); - registry->writeAllVariables(); - registry->writeAllVariablesWithMesh(); - registry->writeAllMDMeshes(); - registry->writeAllMDVariables(); - - //Do a third pass to create components - registry->createComponents(); - - // Was this even a vizschema file? - if ((registry->numMeshes() == 0) && - (registry->numVariables() == 0) && - (registry->numExpressions() == 0) && - (registry->numVariablesWithMesh() == 0) && - (registry->numMDMeshes() == 0) && - (registry->numMDVariables() == 0)) { - VsLog::errorLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "file format not recognized." << std::endl; - EXCEPTION1(InvalidFilesException, nm.c_str()); - } - - VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "exiting." << std::endl; -} - - -VsH5Reader::~VsH5Reader() { - - VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "Entering." << std::endl; - - if (fileData) { - delete (fileData); - fileData = NULL; - } - - VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "Exiting." << std::endl; -} - - -herr_t VsH5Reader::getDataSet( VsH5Dataset* dataSet, - void* data, - // Use these variables for adjusting - // the read memory space. - std::string indexOrder, // Index ordering - int components, // Index for a component - int* srcMins, // start locations - int* srcCounts, // number of entries - int* srcStrides, // stride in memory - - // Use these variables for adjusting - // the write memory space. - int mdims, // spatial dims (rank) - int* destSizes, // overall memory size - int* destMins, // start locations - int* destCounts, // number of entries - int* destStrides ) const // stride in memory -{ - // components = -2 No component array (i.e. scalar variable) - // components = -1 Component array present but read all values. - // (i.e. vector variable or point coordinates) - // component >= 0 Component array present read single value at that index. - if (dataSet == NULL) { - VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "Requested dataset is null?" << std::endl; - return -1; - } - - if (data == NULL) { - VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "Data storage is null?" << std::endl; - return -1; - } - - herr_t err = 0; - - // No index ordering info so read all data. - if (indexOrder.length() == 0) - { - err = H5Dread(dataSet->getId(), dataSet->getType(), - H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - - if (err < 0) { - VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "Error " << err - << " in reading variable " << dataSet->getFullName() - << "." << std::endl; - return err; - } - } - - // mins, counts, and/or strides so hyperslab. - else - { - hid_t dataspace = H5Dget_space(dataSet->getId()); - - int ndims = H5Sget_simple_extent_ndims(dataspace); - - if (ndims == 0) { - VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "Unable to load dimensions for variable." - << "Returning -1." << std::endl; - return -1; - } - - std::vector dims(ndims); - - int ndim = H5Sget_simple_extent_dims(dataspace, &(dims[0]), NULL); - - if( ndim != ndims ) { - VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "Data dimensions not match. " << std::endl; - return -1; - } - - VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "about to set up arguments." << std::endl; - - std::vector count(ndims); - std::vector start(ndims); - std::vector stride(ndims); - - // FORTRAN ordering. - if((indexOrder == VsSchema::compMinorFKey) || - (indexOrder == VsSchema::compMajorFKey)) - { - // No components - [iz][iy][ix] - if( components == -2 ) - { - for (unsigned int i = 0; i destSize(ndims); - - std::vector destCount(ndims); - std::vector destStart(ndims); - std::vector destStride(ndims); - - if( mdims == 0 ) - memspace = H5Screate_simple(ndims, &(count[0]), NULL); - else - { - for( int i=0; igetId(), dataSet->getType(), memspace, dataspace, - H5P_DEFAULT, data); - - if (err < 0) { - VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << ": error " << err - << " in reading dataset." << std::endl; - } - - err = H5Sclose(memspace); - err = H5Sclose(dataspace); - } - - VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " - << "Returning " << err << "." << std::endl; - return err; -} - -#endif diff --git a/databases/Vs/VsLog.h b/databases/Vs/VsLog.h index 533e817b4b234755c9fbda12a26665df9e82f3bd..e7e3cd3142124eff7dbe3b58aa2e4d6c7b055ddd 100644 --- a/databases/Vs/VsLog.h +++ b/databases/Vs/VsLog.h @@ -19,6 +19,12 @@ class VsLog { public: + /** + * Initialize logger + * @param d3 low level debug messages + * @param d4 medium level debug messages + * @param d5 fine grain debug messages + */ static void initialize(std::ostream& d3, std::ostream& d4, std::ostream& d5) { if (singleton) { return; @@ -27,6 +33,14 @@ public: singleton = new VsLog(d3, d4, d5); } + /** + * finalize logger + */ + static void finalize() { + if (singleton) delete singleton; + singleton = NULL; + } + static std::ostream& errorLog(); static std::ostream& warningLog(); static std::ostream& debugLog(); @@ -34,7 +48,7 @@ public: private: //Constructor & destructor are never called, this is a static-only class VsLog(std::ostream& d3, std::ostream& d4, std::ostream& d5); - ~VsLog(); + ~VsLog() {}; static VsLog* singleton; diff --git a/databases/Vs/VsMDMesh.C b/databases/Vs/VsMDMesh.C index 87fdce321a857ae18a86a41721193a57cef7941a..eb7529935c27a93aaf7cc6e0a23a743857d1e753 100644 --- a/databases/Vs/VsMDMesh.C +++ b/databases/Vs/VsMDMesh.C @@ -34,7 +34,7 @@ VsMDMesh::~VsMDMesh() { registry->remove(this); } -void VsMDMesh::write() { +void VsMDMesh::write() const { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << getFullName() << " " << "Kind: " << kind << " " @@ -74,16 +74,16 @@ bool VsMDMesh::addBlock(VsMesh* newBlock) { } blocks.push_back(newBlock); - newBlock->setMDMesh(this, (int)blocks.size() - 1); + newBlock->setMDMesh(this, blocks.size() - 1); return true; } -unsigned int VsMDMesh::getNumBlocks() { +size_t VsMDMesh::getNumBlocks() const { return blocks.size(); } -std::string VsMDMesh::getNameForBlock(unsigned int domain) { +std::string VsMDMesh::getNameForBlock(size_t domain) const { if (domain >= blocks.size()) return NULL; @@ -91,7 +91,7 @@ std::string VsMDMesh::getNameForBlock(unsigned int domain) { return foundMesh->getFullName(); } -VsMesh* VsMDMesh::getBlock(unsigned int domain) { +VsMesh* VsMDMesh::getBlock(size_t domain) const { if (domain >= blocks.size()) return NULL; @@ -99,32 +99,32 @@ VsMesh* VsMDMesh::getBlock(unsigned int domain) { return foundMesh; } -std::string VsMDMesh::getMeshKind() { +std::string VsMDMesh::getMeshKind() const { return kind; } -bool VsMDMesh::isUniformMesh() { +bool VsMDMesh::isUniformMesh() const { return ((kind == VsSchema::Uniform::key) || (kind == VsSchema::Uniform::key_deprecated)); } -bool VsMDMesh::isRectilinearMesh() { +bool VsMDMesh::isRectilinearMesh() const { return (kind == VsSchema::Rectilinear::key); } -bool VsMDMesh::isUnstructuredMesh() { +bool VsMDMesh::isUnstructuredMesh() const { return (kind == VsSchema::Unstructured::key); } -bool VsMDMesh::isStructuredMesh() { +bool VsMDMesh::isStructuredMesh() const { return (kind == VsSchema::structuredMeshKey); } -int VsMDMesh::getNumSpatialDims() { +int VsMDMesh::getNumSpatialDims() const { return numSpatialDims; } -std::string VsMDMesh::getFullName() { +std::string VsMDMesh::getFullName() const { // Note: MD meshes do not have a path. Their name is exactly what // is declared in the "vsMD" attribute This is because an MD mesh // may be made up of meshes in different paths, and we would have to diff --git a/databases/Vs/VsMDMesh.h b/databases/Vs/VsMDMesh.h index 3b9f5cd008749e3dd4b1997899126a1531792dad..41a163571aa0689d31e74f92d7713fd45603f9aa 100644 --- a/databases/Vs/VsMDMesh.h +++ b/databases/Vs/VsMDMesh.h @@ -25,24 +25,23 @@ class VsMDMesh : public VsRegistryObject { public: VsMDMesh(VsMesh* firstMesh, std::string mdMeshName); virtual ~VsMDMesh(); - void write(); + void write() const; bool addBlock(VsMesh* newBlock); - unsigned int getNumBlocks(); - std::string getNameForBlock(unsigned int domain); - VsMesh* getBlock(unsigned int domain); - std::string getMeshKind(); - bool isUniformMesh(); - bool isRectilinearMesh(); - bool isUnstructuredMesh(); - bool isStructuredMesh(); - int getNumSpatialDims(); - std::string getFullName(); - + size_t getNumBlocks() const; + std::string getNameForBlock(size_t domain) const; + VsMesh* getBlock(size_t domain) const; + std::string getMeshKind() const; + bool isUniformMesh() const; + bool isRectilinearMesh() const; + bool isUnstructuredMesh() const; + bool isStructuredMesh() const; + int getNumSpatialDims() const; + std::string getFullName() const; + +private: /** List of all subordinate blocks in this mesh * Order is important (block 0 = blocks[0], etc)*/ - std::vector blocks; //TODO make private -private: - + std::vector blocks; /** The kind of the mesh (e.g., structured, uniform, ... */ std::string kind; diff --git a/databases/Vs/VsMDVariable.C b/databases/Vs/VsMDVariable.C index 1d2cdb6e228d01fd4294c6b38125cd5bd8527b33..0cab14eebee2ff17724919661e9c27e1c4257fb6 100644 --- a/databases/Vs/VsMDVariable.C +++ b/databases/Vs/VsMDVariable.C @@ -24,7 +24,7 @@ VsMDVariable::VsMDVariable(VsVariable* firstVar, VsMDMesh* mdMesh, std::string m numComponents = -1; //MD Var should have same number of blocks as MD Mesh - blocks.resize(mdMesh->blocks.size()); + blocks.resize(mdMesh->getNumBlocks()); registry->add(this); } @@ -40,7 +40,7 @@ VsMDVariable::~VsMDVariable() { //we look for user-specified component names in each subordinate variable //we return the first one we find -std::string VsMDVariable::getLabel(int componentIndex) { +std::string VsMDVariable::getLabel(int componentIndex) const{ std::string name; name.clear(); for (unsigned int i = 0; i < blocks.size(); i++) { @@ -52,10 +52,22 @@ std::string VsMDVariable::getLabel(int componentIndex) { return ""; } -bool VsMDVariable::isZonal() { +bool VsMDVariable::isZonal() const { return (centering == VsSchema::zonalCenteringKey); } +bool VsMDVariable::isNodal() const { + return (centering == VsSchema::nodalCenteringKey); +} + +bool VsMDVariable::isEdge() const { + return (centering == VsSchema::edgeCenteringKey); +} + +bool VsMDVariable::isFace() const { + return (centering == VsSchema::faceCenteringKey); +} + bool VsMDVariable::addBlock(VsVariable* newBlock) { //all blocks must match //Special note here: the mesh of newBlock will be the NON-MD mesh @@ -94,11 +106,11 @@ bool VsMDVariable::addBlock(VsVariable* newBlock) { return true; } -unsigned int VsMDVariable::getNumBlocks() { +size_t VsMDVariable::getNumBlocks() const { return blocks.size(); } -std::string VsMDVariable::getNameForBlock(unsigned int domain) { +std::string VsMDVariable::getNameForBlock(size_t domain) const { if (domain >= blocks.size()) return NULL; @@ -106,7 +118,7 @@ std::string VsMDVariable::getNameForBlock(unsigned int domain) { return foundVar->getFullName(); } -VsVariable* VsMDVariable::getBlock(unsigned int domain) { +VsVariable* VsMDVariable::getBlock(size_t domain) const { if (domain >= blocks.size()) return NULL; @@ -115,16 +127,16 @@ VsVariable* VsMDVariable::getBlock(unsigned int domain) { } // Get mesh name -std::string VsMDVariable::getMesh() { +std::string VsMDVariable::getMesh() const { return mesh; } -std::string VsMDVariable::getCentering() { +std::string VsMDVariable::getCentering() const { return centering; } // Get hdf5 type -hid_t VsMDVariable::getType() { +hid_t VsMDVariable::getType() const { if (!blocks.empty()) { return blocks[0]->getType(); } @@ -133,17 +145,17 @@ hid_t VsMDVariable::getType() { } // Get name -std::string VsMDVariable::getName() { +std::string VsMDVariable::getName() const { return name; } // Get full name -std::string VsMDVariable::getFullName() { +std::string VsMDVariable::getFullName() const { return makeCanonicalName(path, name); } // Write -void VsMDVariable::write() { +void VsMDVariable::write() const { VsLog::debugLog() <<" MDVar: " < 1) { for (size_t i = 0; i < numComps; i++) { - registry->registerComponent(getFullName(), (int)i, getLabel(i)); + registry->registerComponent(getFullName(), i, getLabel(i)); } } diff --git a/databases/Vs/VsMDVariable.h b/databases/Vs/VsMDVariable.h index 4db3fffca97727d5912f168ae93842e72dd29d4f..f0fe1b1093c82a61a7bcc2564201ed97fc5b0d14 100644 --- a/databases/Vs/VsMDVariable.h +++ b/databases/Vs/VsMDVariable.h @@ -27,28 +27,31 @@ class VsMDVariable : public VsRegistryObject { public: VsMDVariable(VsVariable* firstVar, VsMDMesh* mdMesh, std::string mdVarName); virtual ~VsMDVariable(); - std::string getLabel(int componentIndex); - bool isZonal(); + std::string getLabel(int componentIndex) const; + bool isZonal() const; + bool isNodal() const; + bool isEdge() const; + bool isFace() const; bool addBlock(VsVariable* newBlock); - unsigned int getNumBlocks(); - std::string getNameForBlock(unsigned int domain); - VsVariable* getBlock(unsigned int domain); - std::string getMesh(); - std::string getCentering(); - hid_t getType(); - std::string getName(); - std::string getFullName(); - void write(); + size_t getNumBlocks() const; + std::string getNameForBlock(size_t domain) const; + VsVariable* getBlock(size_t domain) const; + std::string getMesh() const; + std::string getCentering() const; + hid_t getType() const; + std::string getName() const; + std::string getFullName() const; + void write() const; - /** List of all subordinate blocks in this var - * Order is important (block 0 = blocks[0], etc)*/ - std::vector blocks; //TODO make private - void createComponents(); - size_t getNumComps(); + size_t getNumComps() const; private: - int numComponents; + mutable int numComponents; + + /** List of all subordinate blocks in this var + * Order is important (block 0 = blocks[0], etc)*/ + std::vector blocks; std::string name; diff --git a/databases/Vs/VsMesh.C b/databases/Vs/VsMesh.C index ac8538611d10de0a49121e01cf2f8f409fa9cf80..137d1f308effc4d2a7d3934ad75fa66df6eca684 100644 --- a/databases/Vs/VsMesh.C +++ b/databases/Vs/VsMesh.C @@ -6,13 +6,13 @@ */ #include "VsMesh.h" -#include "VsH5Dataset.h" -#include "VsH5Attribute.h" +#include "VsDataset.h" +#include "VsAttribute.h" #include "VsUnstructuredMesh.h" #include "VsStructuredMesh.h" #include "VsRectilinearMesh.h" #include "VsUniformMesh.h" -#include "VsH5Group.h" +#include "VsGroup.h" #include "VsSchema.h" #include "VsLog.h" #include "VsUtils.h" @@ -21,7 +21,7 @@ #define __CLASS__ "VsMesh::" -VsMesh::VsMesh(VsH5Object* object):VsRegistryObject(object->registry) { +VsMesh::VsMesh(VsObject* object):VsRegistryObject(object->registry) { numSpatialDims = -1; numTopologicalDims = -1; indexOrder = VsSchema::compMinorCKey; @@ -44,7 +44,7 @@ VsMesh::~VsMesh() { registry->remove(this); } -bool VsMesh::hasTransform() { +bool VsMesh::hasTransform() const { std::string transformName = getTransformName(); if ((transformName == VsSchema::zrphiTransformKey) && (numSpatialDims == 3)) { return true; @@ -55,11 +55,11 @@ bool VsMesh::hasTransform() { return false; } -std::string VsMesh::getTransformName() { +std::string VsMesh::getTransformName() const { //Look for the vsTransform attribute //and either retrieve the value or leave the name empty std::string transformName; - VsH5Attribute* transformNameAtt = getAttribute(VsSchema::transformKey); + VsAttribute* transformNameAtt = getAttribute(VsSchema::transformKey); if (transformNameAtt) { transformNameAtt->getStringValue(&transformName); } @@ -77,10 +77,10 @@ std::string VsMesh::getTransformName() { return transformName; } -std::string VsMesh::getTransformedMeshName() { +std::string VsMesh::getTransformedMeshName() const { //Look for the vsTransformName key std::string transformedMeshName; - VsH5Attribute* transformedMeshNameAtt = getAttribute(VsSchema::transformedMeshKey); + VsAttribute* transformedMeshNameAtt = getAttribute(VsSchema::transformedMeshKey); if (transformedMeshNameAtt) { transformedMeshNameAtt->getStringValue(&transformedMeshName); if (!transformedMeshName.empty()) { @@ -100,22 +100,22 @@ std::string VsMesh::getTransformedMeshName() { return transformedMeshName; } -bool VsMesh::isFortranOrder() { +bool VsMesh::isFortranOrder() const { return ((indexOrder == VsSchema::compMinorFKey) || (indexOrder == VsSchema::compMajorFKey)); } -bool VsMesh::isCompMinor() { +bool VsMesh::isCompMinor() const { return ((indexOrder == VsSchema::compMinorCKey) || (indexOrder == VsSchema::compMinorFKey)); } -bool VsMesh::isCompMajor() { +bool VsMesh::isCompMajor() const { return ((indexOrder == VsSchema::compMajorCKey) || (indexOrder == VsSchema::compMajorFKey)); } -void VsMesh::write() { +void VsMesh::write() const { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << getFullName() << " " << "Kind: " << getKind() << " " @@ -124,27 +124,27 @@ void VsMesh::write() { << "NumTopologicalDims: " << numTopologicalDims << std::endl; } -size_t VsMesh::getNumSpatialDims() { +size_t VsMesh::getNumSpatialDims() const { return numSpatialDims; } -size_t VsMesh::getNumTopologicalDims() { +size_t VsMesh::getNumTopologicalDims() const { return numTopologicalDims; } -std::string VsMesh::getPath() { +std::string VsMesh::getPath() const { return h5Object->getPath(); } -std::string VsMesh::getShortName() { +std::string VsMesh::getShortName() const { return h5Object->getShortName(); } -std::string VsMesh::getFullName() { +std::string VsMesh::getFullName() const { return h5Object->getFullName(); } -std::string VsMesh::getIndexOrder() { +std::string VsMesh::getIndexOrder() const { return indexOrder; } @@ -153,16 +153,16 @@ void VsMesh::setMDMesh(VsMDMesh* md, int dNumber) { domainNumber = dNumber; } -int VsMesh::getDomainNumber() { +int VsMesh::getDomainNumber() const { return domainNumber; } -VsMDMesh* VsMesh::getMDMesh() { +VsMDMesh* VsMesh::getMDMesh() const { return mdMesh; } -void VsMesh::getStringAttribute(std::string attName, std::string* value) { - VsH5Attribute* att = getAttribute(attName); +void VsMesh::getStringAttribute(std::string attName, std::string* value) const { + VsAttribute* att = getAttribute(attName); if (att) { att->getStringValue(value); } else { @@ -170,11 +170,11 @@ void VsMesh::getStringAttribute(std::string attName, std::string* value) { } } -VsH5Attribute* VsMesh::getAttribute(std::string name) { +VsAttribute* VsMesh::getAttribute(std::string name) const { return h5Object->getAttribute(name); } -VsMesh* VsMesh::buildObject(VsH5Dataset* dataset) { +VsMesh* VsMesh::buildObject(VsDataset* dataset) { if (!dataset) { VsLog::warningLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "dataset is null? Returning null." << std::endl; @@ -182,7 +182,7 @@ VsMesh* VsMesh::buildObject(VsH5Dataset* dataset) { } //What is the declared kind of this dataset? - VsH5Attribute* kindAtt = dataset->getAttribute(VsSchema::kindAtt); + VsAttribute* kindAtt = dataset->getAttribute(VsSchema::kindAtt); if (!kindAtt) { VsLog::warningLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "Unable to find attribute " << VsSchema::kindAtt @@ -206,7 +206,7 @@ VsMesh* VsMesh::buildObject(VsH5Dataset* dataset) { return NULL; } -VsMesh* VsMesh::buildObject(VsH5Group* group) { +VsMesh* VsMesh::buildObject(VsGroup* group) { if (!group) { VsLog::warningLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "Group is null? Returning null." << std::endl; @@ -214,7 +214,7 @@ VsMesh* VsMesh::buildObject(VsH5Group* group) { } //What is the declared kind of this group? - VsH5Attribute* kindAtt = group->getAttribute(VsSchema::kindAtt); + VsAttribute* kindAtt = group->getAttribute(VsSchema::kindAtt); if (!kindAtt) { VsLog::warningLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "Unable to find attribute " << VsSchema::kindAtt @@ -244,7 +244,6 @@ VsMesh* VsMesh::buildObject(VsH5Group* group) { } bool VsMesh::initializeRoot() { - //herr_t VsMesh::initialize(VsGMeta* gm, VsMeshMeta& mm) const { VsLog::debugLog() <<"VsMesh::initializeRoot() - Entering" << std::endl; if (!h5Object) { @@ -256,13 +255,13 @@ bool VsMesh::initializeRoot() { //look for md mesh attribute //save for later - //VsH5Attribute* mdAtt = h5Object->getAttribute(VsSchema::mdAtt); + //VsAttribute* mdAtt = h5Object->getAttribute(VsSchema::mdAtt); //if (mdAtt) { // mdAtt->getStringValue(&(this->mdName)); //} //Get & validate Index Order - VsH5Attribute* indexOrderAtt = + VsAttribute* indexOrderAtt = h5Object->getAttribute(VsSchema::indexOrderAtt); if (indexOrderAtt) { @@ -286,7 +285,7 @@ bool VsMesh::initializeRoot() { return true; } -std::string VsMesh::getAxisLabel(unsigned int axis) { +std::string VsMesh::getAxisLabel(size_t axis) const { std::string axisNames; this->getStringAttribute(VsSchema::axisLabelsAtt, &axisNames); diff --git a/databases/Vs/VsMesh.h b/databases/Vs/VsMesh.h index 19e5568cf33393adeb9593e0de43794268343beb..6a39483474a0a1bfa4ff02560fb5846a8a0ec896 100644 --- a/databases/Vs/VsMesh.h +++ b/databases/Vs/VsMesh.h @@ -21,55 +21,55 @@ #include "VsRegistryObject.h" class VsMDMesh; -class VsH5Dataset; -class VsH5Group; -class VsH5Attribute; -class VsH5Object; +class VsDataset; +class VsGroup; +class VsAttribute; +class VsObject; class VsMesh : public VsRegistryObject { public: virtual ~VsMesh(); - void write(); - bool isFortranOrder(); - bool isCompMinor(); - bool isCompMajor(); + void write() const; + bool isFortranOrder() const; + bool isCompMinor() const; + bool isCompMajor() const; - virtual bool isUniformMesh() { return false; } - virtual bool isRectilinearMesh() { return false; } - virtual bool isStructuredMesh() { return false; } - virtual bool isUnstructuredMesh() { return false; } + virtual bool isUniformMesh() const { return false; } + virtual bool isRectilinearMesh() const { return false; } + virtual bool isStructuredMesh() const { return false; } + virtual bool isUnstructuredMesh() const { return false; } - virtual std::string getShortName(); - virtual std::string getPath(); + virtual std::string getShortName() const; + virtual std::string getPath() const; - std::string getFullName(); - void getStringAttribute(std::string attName, std::string* value); - std::string getIndexOrder(); - virtual std::string getKind() = 0; - size_t getNumSpatialDims(); - size_t getNumTopologicalDims(); + std::string getFullName() const; + std::string getIndexOrder() const; + virtual std::string getKind() const = 0; + size_t getNumSpatialDims() const; + size_t getNumTopologicalDims() const; - VsH5Attribute* getAttribute(std::string name); - static VsMesh* buildObject(VsH5Dataset* dataset); - static VsMesh* buildObject(VsH5Group* group); + static VsMesh* buildObject(VsDataset* dataset); + static VsMesh* buildObject(VsGroup* group); - std::string getAxisLabel(unsigned int axis); + std::string getAxisLabel(size_t axis) const; - virtual void getMeshDataDims(std::vector& dims) = 0; + virtual void getCellDims(std::vector& dims) const = 0; void setMDMesh(VsMDMesh* mdMesh, int dNumber); - int getDomainNumber(); - VsMDMesh* getMDMesh(); + int getDomainNumber() const ; + VsMDMesh* getMDMesh() const ; - virtual bool hasTransform(); - virtual std::string getTransformName(); - virtual std::string getTransformedMeshName(); + VsAttribute* getAttribute(std::string name) const; + virtual bool hasTransform() const; + virtual std::string getTransformName() const; + virtual std::string getTransformedMeshName() const; protected: - VsMesh(VsH5Object* object); + VsMesh(VsObject* object); virtual bool initialize() = 0; bool initializeRoot(); + void getStringAttribute(std::string attName, std::string* value) const; /** The spatial dimensionality */ size_t numSpatialDims; @@ -84,7 +84,7 @@ protected: /** Index order (Fortran vs C style) */ std::string indexOrder; - VsH5Object* h5Object; + VsObject* h5Object; /** Stuff for meshes that are subordinate blocks of MD Meshes**/ int domainNumber; diff --git a/databases/Vs/VsObject.C b/databases/Vs/VsObject.C new file mode 100644 index 0000000000000000000000000000000000000000..60499920ac7f17471779aa8a20e873b83d4ff0fe --- /dev/null +++ b/databases/Vs/VsObject.C @@ -0,0 +1,90 @@ +/* + * VsObject.cpp + * + * Created on: Apr 27, 2010 + * Author: mdurant + */ + +#include "VsObject.h" +#include "VsUtils.h" +#include "VsAttribute.h" +#include "VsGroup.h" +#include "VsDataset.h" +#include "VsLog.h" +#include + +VsObject::VsObject(VsRegistry* r, VsObject* parentObject, + const std::string& objectName, hid_t id): + VsRegistryObject(r) { + + parent = parentObject; + name = makeCanonicalName(objectName); + resourceId = id; + + if (parent) { + depth = parent->getDepth() + 1; + fullName = makeCanonicalName(parentObject->getFullName(), objectName); + } else { + depth = 0; + fullName = makeCanonicalName(objectName); + } + +} + +VsObject::~VsObject() { + std::map::const_iterator it; + for (it = attributes.begin(); it != attributes.end(); it++) { + VsAttribute* att = (*it).second; + delete(att); + } + + attributes.clear(); +} + +const std::map& VsObject::getAllAttributes() const { + return attributes; +} + +std::string VsObject::getShortName() const { + return name; +} + +std::string VsObject::getFullName() const { + return fullName; +} + +std::string VsObject::getPath() const { + if (parent) { + return parent->getFullName(); + } + + return "/"; +} + +hid_t VsObject::getId() const { + return resourceId; +} + +int VsObject::getDepth() const { + return depth; +} + +void VsObject::addAttribute(const std::string name, hid_t id) { + VsLog::debugLog() << "VsObject::addAttribute '" << name << "', id: "<< id<< std::endl; + VsAttribute* att = new VsAttribute(this, name, id); + attributes[name] = att; +} + +VsAttribute* VsObject::getAttribute (const std::string name) const { + +// return attributes.find(name)->second; + + std::map::const_iterator it = attributes.find(name); + if (it != attributes.end()) { + VsLog::debugLog() << "VsObject::getAttribute " << name <<" "<second<< std::endl; + return (*it).second; + } + VsLog::debugLog() << "VsObject::getAttribute: '" << name << "' not found" << std::endl; + + return NULL; +} diff --git a/databases/Vs/VsObject.h b/databases/Vs/VsObject.h new file mode 100644 index 0000000000000000000000000000000000000000..f47e551e1d9dca883a21728b7968bcc888657afd --- /dev/null +++ b/databases/Vs/VsObject.h @@ -0,0 +1,53 @@ +/** + * @file VsObject.h + * + * @class VsObject + * @brief Superclass for all objects present in an hdf5 file. + * + * Provides a common interface for all objects that are + * directly present in an hdf5 file. Maintains the hierarchy + * structure present in the data file. + * + * Created on: Apr 27, 2010 + * Author: mdurant + */ + +#ifndef VS_OBJECT_H_ +#define VS_OBJECT_H_ + +#include +#include +#include +#include +#include "VsRegistryObject.h" + +class VsAttribute; + +class VsObject : public VsRegistryObject { +public: + VsObject(VsRegistry* r, VsObject* parentObject, + const std::string& objectName, hid_t id); + virtual ~VsObject(); + + std::string getShortName() const; + std::string getFullName() const; + std::string getPath() const; + hid_t getId() const; + int getDepth() const; + + void addAttribute(const std::string name, hid_t id); + VsAttribute* getAttribute(const std::string name) const; + const std::map& getAllAttributes() const; + +private: + std::string name; + std::string fullName; + VsObject* parent; + hid_t resourceId; + int depth; + + std::map attributes; + +}; + +#endif /* VS_OBJECT_H_ */ diff --git a/databases/Vs/VsReader.C b/databases/Vs/VsReader.C new file mode 100644 index 0000000000000000000000000000000000000000..61e5d0906c696d9eabfa952e7e4e874ff231c410 --- /dev/null +++ b/databases/Vs/VsReader.C @@ -0,0 +1,458 @@ +#include + +/** + * + * @file VsReader.cpp + * + * @brief Implementation reader of data for VSH5 schema + * + * @version $Id: VsReader.cpp 64 2013-04-24 21:09:55Z pletzer $ + * + * Copyright © 2007-2008, Tech-X Corporation + * See LICENSE file for conditions of use. + * + */ + +#include +#include + +#include +#include +#include +#include "VsDataset.h" +#include "VsAttribute.h" +#include "VsMDVariable.h" +#include "VsMDMesh.h" +#include "VsMesh.h" +#include "VsVariable.h" +#include "VsVariableWithMesh.h" +#include "VsRectilinearMesh.h" +#include "VsUnstructuredMesh.h" +#include "VsStructuredMesh.h" +#include "VsUniformMesh.h" +#include "VsLog.h" +#include "VsRegistry.h" +#include "VsFilter.h" + +#define __CLASS__ "VsReader::" + + +int VsReader::numInstances = 0; + +VsReader::VsReader(const std::string& nm, VsRegistry* r) { + + numInstances++; + VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "This VsReader is #" + << numInstances << std::endl; + + VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "VsReader::VsReader(" << nm << ") entering." << std::endl; + + if (numInstances > 1) { + VsLog::warningLog() + << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "Warning! More than one concurrent copy of VsReader." << std::endl; + VsLog::warningLog() + << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "Warning! Debug messages may be interleaved." << std::endl; + } + + registry = r; + + // Read raw hdf5 metadata + fileData = VsFilter::readFile(registry, nm); + if (!fileData) { + VsLog::errorLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "Unable to load metadata from file." << std::endl; +//SVETA: need to reimplement + //EXCEPTION1(InvalidFilesException, nm.c_str()); + } + + //debugging output of raw hdf5 objects + registry->writeAllGroups(); + registry->writeAllDatasets(); + + //Build "Core" (Mesh and Var) objects + registry->buildGroupObjects(); + registry->buildDatasetObjects(); + + //Build MD objects + registry->buildMDMeshes(); + registry->buildMDVars(); + + //Register "transformed" meshes, and then variables + registry->buildTransformedMeshes(); + registry->buildTransformedVariables(); + + //debugging output + registry->writeAllMeshes(); + registry->writeAllExpressions(); + registry->writeAllVariables(); + registry->writeAllVariablesWithMesh(); + registry->writeAllMDMeshes(); + registry->writeAllMDVariables(); + + //Do a third pass to create components + registry->createComponents(); + + // Was this even a vizschema file? + if ((registry->numMeshes() == 0) && + (registry->numVariables() == 0) && + (registry->numExpressions() == 0) && + (registry->numVariablesWithMesh() == 0) && + (registry->numMDMeshes() == 0) && + (registry->numMDVariables() == 0)) { + VsLog::errorLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "file format not recognized." << std::endl; +// SVETA: NEED TO REIMPL + //EXCEPTION1(InvalidFilesException, nm.c_str()); + } + + VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "exiting." << std::endl; +} + + +VsReader::~VsReader() { + + VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "Entering." << std::endl; + + if (fileData) { + delete (fileData); + fileData = NULL; + } + + VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "Exiting." << std::endl; +} + + +int VsReader::getData( VsDataset* dataSet, + void* data, + // Use these variables for adjusting + // the read memory space. + std::string indexOrder, // Index ordering + int components, // Index for a component + int* srcMins, // start locations + int* srcCounts, // number of entries + int* srcStrides, // stride in memory + + // Use these variables for adjusting + // the write memory space. + int mdims, // spatial dims (rank) + int* destSizes, // overall memory size + int* destMins, // start locations + int* destCounts, // number of entries + int* destStrides ) const // stride in memory +{ + // components = -2 No component array (i.e. scalar variable) + // components = -1 Component array present but read all values. + // (i.e. vector variable or point coordinates) + // component >= 0 Component array present read single value at that index. + + if (dataSet == NULL) { + VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "Requested dataset is null?" << std::endl; + return -1; + } + + if (data == NULL) { + VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "Data storage is null?" << std::endl; + return -1; + } + + int err = 0; + + // No index ordering info so read all data. + if (indexOrder.length() == 0) + { + err = H5Dread(dataSet->getId(), dataSet->getType(), + H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + + if (err < 0) { + VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "Error " << err + << " in reading variable " << dataSet->getFullName() + << "." << std::endl; + return err; + } + } + + // mins, counts, and/or strides so hyperslab. + else + { + hid_t dataspace = H5Dget_space(dataSet->getId()); + + int ndims = H5Sget_simple_extent_ndims(dataspace); + + if (ndims == 0) { + VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "Unable to load dimensions for variable." + << "Returning -1." << std::endl; + return -1; + } + + std::vector dims(ndims); + + int ndim = H5Sget_simple_extent_dims(dataspace, &(dims[0]), NULL); + + if( ndim != ndims ) { + VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "Data dimensions not match. " << std::endl; + return -1; + } + + VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "about to set up arguments." << std::endl; + + std::vector count(ndims); + std::vector start(ndims); + std::vector stride(ndims); + + // FORTRAN ordering. + if((indexOrder == VsSchema::compMinorFKey) || + (indexOrder == VsSchema::compMajorFKey)) + { + // No components - [iz][iy][ix] + if( components == -2 ) + { + for (unsigned int i = 0; i destSize(ndims); + + std::vector destCount(ndims); + std::vector destStart(ndims); + std::vector destStride(ndims); + + if( mdims == 0 ) + memspace = H5Screate_simple(ndims, &(count[0]), NULL); + else + { + for( int i=0; igetId(), dataSet->getType(), memspace, dataspace, + H5P_DEFAULT, data); + + if (err < 0) { + VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << ": error " << err + << " in reading dataset." << std::endl; + } + + err = H5Sclose(memspace); + err = H5Sclose(dataspace); + } + + + VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " + << "Returning " << err << "." << std::endl; + return err; +} + diff --git a/databases/Vs/VsH5Reader.h b/databases/Vs/VsReader.h similarity index 61% rename from databases/Vs/VsH5Reader.h rename to databases/Vs/VsReader.h index 8237bc162b49b83e3c52f5e36373477090996af5..ffe91136aa5f2cf2f9136f274f0d6f0031a99606 100644 --- a/databases/Vs/VsH5Reader.h +++ b/databases/Vs/VsReader.h @@ -1,7 +1,7 @@ /** - * @file VsH5Reader.h + * @file VsReader.h * - * @class VsH5Reader + * @class VsReader * * @brief Interface for retrieving structure and data of an hdf5 file. * @@ -13,14 +13,10 @@ */ #include -#include -#if HDF5_VERSION_GE(1, 8, 1) +#ifndef VS_READER_H_ +#define VS_READER_H_ -#ifndef VS_H5_READER -#define VS_H5_READER - -#include #include #include @@ -29,31 +25,32 @@ class VsVariableWithMesh; class VsMDMesh; class VsMesh; class VsMDVariable; -class VsH5File; +class VsFile; class VsRegistry; class VsUnstructuredMesh; class VsStructuredMesh; class VsUniformMesh; class VsRectilinearMesh; - +class VsDataset; /** - * VsH5Reader is a class for getting the vizschema metadata of objects + * VsReader is a class for getting the vizschema metadata of objects * in and HDF5 file and also being able to return such objects. */ -class VsH5Reader { +class VsReader { public: /** * Constructor. * @param filename the name of the HDF5 file + * @param r Empty VsRegistry object */ - VsH5Reader(const std::string& filename, VsRegistry* r); + VsReader(const std::string& filename, VsRegistry* r); /** * Destructor. */ - ~VsH5Reader(); + ~VsReader(); /** * Get the values of the whole dataset. @@ -72,33 +69,31 @@ public: * @param destCounts - optional, counts array, up to three dimension * @param destStrides - optional, stride array, up to three dimension **/ - herr_t getDataSet( VsH5Dataset* dataset, - void* data, + int getData( VsDataset* dataset, + void* data, - // Use these variables for adjusting - // the read memory space. - std::string indexOrder = std::string(""), - int components = 0, - int* srcMins = 0, - int* srcCounts = 0, - int* srcStrides = 0, + // Use these variables for adjusting + // the read memory space. + std::string indexOrder = std::string(""), + int components = 0, + int* srcMins = 0, + int* srcCounts = 0, + int* srcStrides = 0, - // Use these variables for adjusting - // the write memory space. - int mdims = 0, - int* destSizes = 0, - int* destMins = 0, - int* destCounts = 0, - int* destStrides = 0 ) const; + // Use these variables for adjusting + // the write memory space. + int mdims = 0, + int* destSizes = 0, + int* destMins = 0, + int* destCounts = 0, + int* destStrides = 0 ) const; private: - VsH5File* fileData; + VsFile* fileData; static int numInstances; VsRegistry* registry; }; -#endif - -#endif +#endif // VS_READER_H_ diff --git a/databases/Vs/VsRectilinearMesh.C b/databases/Vs/VsRectilinearMesh.C index ceef85ed912efaa90383bb4fcfbafaf1d0d3759f..2352a8607d2ffcf530faf049e36fb47f3ef8eb46 100644 --- a/databases/Vs/VsRectilinearMesh.C +++ b/databases/Vs/VsRectilinearMesh.C @@ -7,9 +7,9 @@ #include "VsRectilinearMesh.h" #include "VsSchema.h" -#include "VsH5Dataset.h" -#include "VsH5Group.h" -#include "VsH5Attribute.h" +#include "VsDataset.h" +#include "VsGroup.h" +#include "VsAttribute.h" #include "VsLog.h" #include "VsUtils.h" @@ -18,7 +18,7 @@ #define __CLASS__ "VsRectilinearMesh::" -VsRectilinearMesh::VsRectilinearMesh(VsH5Group* group):VsMesh(group) { +VsRectilinearMesh::VsRectilinearMesh(VsGroup* group):VsMesh(group) { } @@ -26,9 +26,9 @@ VsRectilinearMesh::~VsRectilinearMesh() { } -hid_t VsRectilinearMesh::getDataType() { +hid_t VsRectilinearMesh::getDataType() const{ - VsH5Dataset* axis0 = getAxisDataset(0); + VsDataset* axis0 = getAxisDataset(0); if (!axis0) { VsLog::errorLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " @@ -41,11 +41,11 @@ hid_t VsRectilinearMesh::getDataType() { if (axis0 && axis0->getType() == H5T_NATIVE_DOUBLE) return H5T_NATIVE_DOUBLE; - VsH5Dataset* axis1 = getAxisDataset(1); + VsDataset* axis1 = getAxisDataset(1); if (axis1 && axis1->getType() == H5T_NATIVE_DOUBLE) return H5T_NATIVE_DOUBLE; - VsH5Dataset* axis2 = getAxisDataset(2); + VsDataset* axis2 = getAxisDataset(2); if (axis2 && axis2->getType() == H5T_NATIVE_DOUBLE) return H5T_NATIVE_DOUBLE; @@ -53,7 +53,7 @@ hid_t VsRectilinearMesh::getDataType() { } -VsRectilinearMesh* VsRectilinearMesh::buildRectilinearMesh(VsH5Group* group) { +VsRectilinearMesh* VsRectilinearMesh::buildRectilinearMesh(VsGroup* group) { VsRectilinearMesh* newMesh = new VsRectilinearMesh(group); bool success = newMesh->initialize(); @@ -78,9 +78,9 @@ bool VsRectilinearMesh::initialize() { // Rectilinear meshes are defined by a series of arrays. Each array // represents one spatial dimension i.e. numSpatialDims = number of // arrays. - VsH5Dataset* axis0 = getAxisDataset(0); - VsH5Dataset* axis1 = getAxisDataset(1); - VsH5Dataset* axis2 = getAxisDataset(2); + VsDataset* axis0 = getAxisDataset(0); + VsDataset* axis1 = getAxisDataset(1); + VsDataset* axis2 = getAxisDataset(2); if (!axis0) { VsLog::errorLog() @@ -153,7 +153,7 @@ bool VsRectilinearMesh::initialize() { } -std::string VsRectilinearMesh::getAxisDatasetName(int axisNumber) { +std::string VsRectilinearMesh::getAxisDatasetName(int axisNumber) const { if ((axisNumber < 0) || (axisNumber > 2)) { return ""; } @@ -174,7 +174,7 @@ std::string VsRectilinearMesh::getAxisDatasetName(int axisNumber) { std::string axisName; //First see if the user has specified a name for the dataset - VsH5Attribute* axisNameAtt = getAttribute(axisKey); + VsAttribute* axisNameAtt = getAttribute(axisKey); if (axisNameAtt) { axisNameAtt->getStringValue(&axisName); if (!axisName.empty()) { @@ -199,22 +199,22 @@ std::string VsRectilinearMesh::getAxisDatasetName(int axisNumber) { return makeCanonicalName(getFullName(), axisName); } -VsH5Dataset* VsRectilinearMesh::getAxisDataset(int axisNumber) { +VsDataset* VsRectilinearMesh::getAxisDataset(int axisNumber) const { std::string axisDatasetName = getAxisDatasetName(axisNumber); if (axisDatasetName.empty()) { return NULL; } - VsH5Dataset* answer = registry->getDataset(axisDatasetName); + VsDataset* answer = registry->getDataset(axisDatasetName); return answer; //could be NULL } -std::string VsRectilinearMesh::getKind() { +std::string VsRectilinearMesh::getKind() const { return VsSchema::Rectilinear::key; } -void VsRectilinearMesh::getMeshDataDims(std::vector& dims) +void VsRectilinearMesh::getCellDims(std::vector& dims) const { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "Entering." << std::endl; @@ -223,7 +223,7 @@ void VsRectilinearMesh::getMeshDataDims(std::vector& dims) // arrays. // Require at least one axis - VsH5Dataset* axis0Data = getAxisDataset(0); + VsDataset* axis0Data = getAxisDataset(0); if (!axis0Data) { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "Unable to find information for axis 0." << " " @@ -236,7 +236,7 @@ void VsRectilinearMesh::getMeshDataDims(std::vector& dims) dims[0] = axis0Data->getDims().front(); // If a first axis exists, check for a second axis - VsH5Dataset* axis1Data = getAxisDataset(1); + VsDataset* axis1Data = getAxisDataset(1); if (axis1Data == NULL) { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "Unable to find information for axis 1." << std::endl; @@ -247,7 +247,7 @@ void VsRectilinearMesh::getMeshDataDims(std::vector& dims) dims[1] = axis1Data->getDims().front(); // If a second axis exists, check for a third axis - VsH5Dataset* axis2Data = getAxisDataset(2); + VsDataset* axis2Data = getAxisDataset(2); if (axis2Data == NULL) { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "Unable to find information for axis 2." << std::endl; @@ -267,8 +267,8 @@ void VsRectilinearMesh::getMeshDataDims(std::vector& dims) } -void VsRectilinearMesh::getNumMeshDims(std::vector& dims) +void VsRectilinearMesh::getNodeDims(std::vector& dims) const { // Simple case get the data dims and return; - getMeshDataDims( dims ); + getCellDims( dims ); } diff --git a/databases/Vs/VsRectilinearMesh.h b/databases/Vs/VsRectilinearMesh.h index 801b18404c6dd0ec43a24ce96cfc978bc2214c89..6b2370452a0cac29dad71c90a572d95bd036cf3e 100644 --- a/databases/Vs/VsRectilinearMesh.h +++ b/databases/Vs/VsRectilinearMesh.h @@ -14,27 +14,27 @@ #include "VsMesh.h" #include -class VsH5Dataset; -class VsH5Group; +class VsDataset; +class VsGroup; class VsRectilinearMesh: public VsMesh { public: virtual ~VsRectilinearMesh(); - hid_t getDataType(); - std::string getAxisDatasetName(int axisNumber); - VsH5Dataset* getAxisDataset(int axisNumber); + hid_t getDataType() const; + std::string getAxisDatasetName(int axisNumber) const; + VsDataset* getAxisDataset(int axisNumber) const; - virtual bool isRectilinearMesh() { return true; } - static VsRectilinearMesh* buildRectilinearMesh(VsH5Group* group); + virtual bool isRectilinearMesh() const { return true; } + static VsRectilinearMesh* buildRectilinearMesh(VsGroup* group); - virtual std::string getKind(); + virtual std::string getKind() const; - virtual void getMeshDataDims(std::vector& dims); - virtual void getNumMeshDims(std::vector& dims); + virtual void getCellDims(std::vector& dims) const; + virtual void getNodeDims(std::vector& dims) const; private: - VsRectilinearMesh(VsH5Group* group); + VsRectilinearMesh(VsGroup* group); virtual bool initialize(); }; diff --git a/databases/Vs/VsRegistry.C b/databases/Vs/VsRegistry.C index 647041b112f85b70d6a06806bbce7568fb976954..c8df4d3fddd3ca08cbc0b79703f2b31edead01fb 100644 --- a/databases/Vs/VsRegistry.C +++ b/databases/Vs/VsRegistry.C @@ -6,12 +6,12 @@ */ #include "VsRegistry.h" -#include "VsH5Dataset.h" -#include "VsH5Group.h" +#include "VsDataset.h" +#include "VsGroup.h" #include "VsMesh.h" #include "VsUtils.h" #include "VsLog.h" -#include "VsH5Attribute.h" +#include "VsAttribute.h" #include "VsSchema.h" #include "VsVariable.h" #include "VsVariableWithMesh.h" @@ -46,10 +46,10 @@ void VsRegistry::deleteAllObjects() { deletingObjects = false; } -/*********** VsH5Groups ***********/ -void VsRegistry::add(VsH5Group* group) { +/*********** VsGroups ***********/ +void VsRegistry::add(VsGroup* group) { //check for duplicate long name - VsH5Group* found = this->getGroup(group->getFullName()); + VsGroup* found = this->getGroup(group->getFullName()); if (found) { VsLog::errorLog() <<"VsRegistry::add() - Group already exists with this long name: " <getFullName() <getShortName()); } -VsH5Group* VsRegistry::getGroup(const std::string& name) { +VsGroup* VsRegistry::getGroup(const std::string& name) { std::string fullName = makeCanonicalName(name); - std::map::iterator it = allGroups.find(fullName); + std::map::iterator it = allGroups.find(fullName); if (it != allGroups.end()) { return (*it).second; } @@ -93,9 +93,9 @@ VsH5Group* VsRegistry::getGroup(const std::string& name) { } void VsRegistry::deleteAllGroups() { - for (std::map::const_iterator it = allGroups.begin(); + for (std::map::const_iterator it = allGroups.begin(); it != allGroups.end(); it++) { - VsH5Group* group = it->second; + VsGroup* group = it->second; delete(group); } @@ -103,27 +103,27 @@ void VsRegistry::deleteAllGroups() { allGroupsShort.clear(); } -void VsRegistry::writeAllGroups() { - VsLog::debugLog() <<"********** BEGIN VsH5Groups *********" <::const_iterator it = allGroups.begin(); + for (std::map::const_iterator it = allGroups.begin(); it != allGroups.end(); it++) { - VsH5Group* group = it->second; + VsGroup* group = it->second; group->write(); } - VsLog::debugLog() <<"********** END VsH5Groups *********" <::const_iterator it = allGroups.begin(); + for (std::map::const_iterator it = allGroups.begin(); it != allGroups.end(); it++) { - VsH5Group* group = it->second; + VsGroup* group = it->second; VsLog::debugLog() <<"VsRegistry::buildGroupObjects - Building object " <getFullName() <getAttribute(VsSchema::typeAtt); + VsAttribute* typeAtt = group->getAttribute(VsSchema::typeAtt); if (!typeAtt) { VsLog::warningLog() <<"VsRegistry::buildGroupObjects - unable to find attribute " <getFullName() <getAttribute(VsSchema::timeAtt); + VsAttribute* timeAtt = group->getAttribute(VsSchema::timeAtt); if (timeAtt) { std::vector in; - herr_t err = timeAtt->getFloatVectorValue(&in); + int err = timeAtt->getFloatVectorValue(&in); if (err < 0) { VsLog::debugLog() <<"VsRegistry::loadTime(): Error " <getAttribute(VsSchema::cycleAtt); + VsAttribute* cycleAtt = group->getAttribute(VsSchema::cycleAtt); if (cycleAtt) { std::vector in; - herr_t err = cycleAtt->getIntVectorValue(&in); + int err = cycleAtt->getIntVectorValue(&in); if (err < 0) { VsLog::debugLog() <<"VsRegistry::loadTime(): Error " <getDataset(dataset->getFullName()); + VsDataset* found = this->getDataset(dataset->getFullName()); if (found) { VsLog::errorLog() <<"VsRegistry::add() - Dataset already exists with this long name: " <getFullName() <getShortName()); } -VsH5Dataset* VsRegistry::getDataset(const std::string& name) { +VsDataset* VsRegistry::getDataset(const std::string& name) { std::string fullName = makeCanonicalName(name); - std::map::iterator it = allDatasets.find(fullName); + std::map::iterator it = allDatasets.find(fullName); if (it != allDatasets.end()) { return (*it).second; } @@ -255,9 +256,9 @@ VsH5Dataset* VsRegistry::getDataset(const std::string& name) { } void VsRegistry::deleteAllDatasets() { - for (std::map::const_iterator it = allDatasets.begin(); + for (std::map::const_iterator it = allDatasets.begin(); it != allDatasets.end(); it++) { - VsH5Dataset* dataset = it->second; + VsDataset* dataset = it->second; delete(dataset); } @@ -265,16 +266,16 @@ void VsRegistry::deleteAllDatasets() { allDatasetsShort.clear(); } -void VsRegistry::writeAllDatasets() { - VsLog::debugLog() <<"********** BEGIN VsH5Datasets *********" <::const_iterator it = allDatasets.begin(); + for (std::map::const_iterator it = allDatasets.begin(); it != allDatasets.end(); it++) { - VsH5Dataset* dataset = it->second; + VsDataset* dataset = it->second; dataset->write(); } - VsLog::debugLog() <<"********** END VsH5Datasets *********" < varDatasets; - std::vector varWithMeshDatasets; - for (std::map::const_iterator it = allDatasets.begin(); + std::vector varDatasets; + std::vector varWithMeshDatasets; + for (std::map::const_iterator it = allDatasets.begin(); it != allDatasets.end(); it++) { - VsH5Dataset* dataset = it->second; + VsDataset* dataset = it->second; VsLog::debugLog() <<"VsRegistry::buildDatasetObjects() - looking at dataset " <getFullName() <getAttribute(VsSchema::typeAtt); + VsAttribute* typeAtt = dataset->getAttribute(VsSchema::typeAtt); if (!typeAtt) { VsLog::warningLog() <<"VsRegistry::buildDatasetObjects() - unable to find attribute " <getAttribute(VsSchema::meshAtt); + VsAttribute* meshAtt = dataset->getAttribute(VsSchema::meshAtt); if (meshAtt) { VsLog::warningLog() <<"VsRegistry::buildDatasetObjects() - Found attribute " <::const_iterator it = varDatasets.begin(); + for (std::vector::const_iterator it = varDatasets.begin(); it != varDatasets.end(); it++) { - VsH5Dataset* dataset = *it; - VsLog::debugLog() <<"VsRegistry::buildDatasetObjects() - looking at var dataset " <getFullName() <getTimeGroup() != NULL)) { @@ -338,9 +338,9 @@ void VsRegistry::buildDatasetObjects() { } //Second pass to do all variables with mesh - for (std::vector::const_iterator it = varWithMeshDatasets.begin(); + for (std::vector::const_iterator it = varWithMeshDatasets.begin(); it != varWithMeshDatasets.end(); it++) { - VsH5Dataset* dataset = *it; + VsDataset* dataset = *it; VsLog::debugLog() <<"VsRegistry::buildDatasetObjects() - looking at varWithMesh dataset " <getFullName() <& names) { names.push_back(it->first); } -void VsRegistry::writeAllMDMeshes() { +void VsRegistry::writeAllMDMeshes() const { if (allMDMeshes.empty()) { VsLog::debugLog() <<"*********** NO MDMESHES ********" <::const_iterator it = allMDMeshes.begin(); it != allMDMeshes.end(); it++) { VsMDMesh* meshMeta = it->second; - for (unsigned int i = 0; i < meshMeta->blocks.size(); i++) { - if (fullName == makeCanonicalName(meshMeta->blocks[i]->getFullName())) { + for (unsigned int i = 0; i < meshMeta->getNumBlocks(); i++) { + if (fullName == makeCanonicalName(meshMeta->getBlock(i)->getFullName())) { VsLog::debugLog() << "VsMDMesh::getMDParentForMesh(" <::const_iterator it = allMDMeshes.begin(); it != allMDMeshes.end(); it++) { VsMDMesh* meshMeta = it->second; - for (unsigned int i = 0; i < meshMeta->blocks.size(); i++) { - if (meshMeta->blocks[i]->getFullName() == name) { - VsLog::debugLog() << "VsH5Reader::findSubordinateMDMesh(" <blocks[i]; + for (size_t i = 0; i < meshMeta->getNumBlocks(); i++) { + if (meshMeta->getBlock(i)->getFullName() == name) { + VsLog::debugLog() << "VsReader::findSubordinateMDMesh(" <getBlock(i); } } } @@ -531,7 +531,7 @@ void VsRegistry::buildMDMeshes() { VsLog::errorLog() <<"VsRegistry::buildMDMeshes() - mesh is NULL?" <getAttribute(VsSchema::mdAtt); + VsAttribute* mdMeshNameAttribute = mesh->getAttribute(VsSchema::mdAtt); std::string mdMeshName = ""; if (mdMeshNameAttribute) { mdMeshNameAttribute->getStringValue(&mdMeshName); @@ -653,7 +653,7 @@ void VsRegistry::deleteAllVariables() { allVariablesShort.clear(); } -void VsRegistry::writeAllVariables() { +void VsRegistry::writeAllVariables() const { if (allVariables.empty()) { VsLog::debugLog() <<"*********** NO VSVARIABLES ********" <& names) { names.push_back(it->first); } -void VsRegistry::writeAllMDVariables() { +void VsRegistry::writeAllMDVariables() const { if (allMDVariables.empty()) { VsLog::debugLog() <<"*********** NO MDVARIABLES ********" <getAttribute(VsSchema::mdAtt); + VsAttribute* mdVarAtt = var->getAttribute(VsSchema::mdAtt); if (!mdVarAtt) { continue; } @@ -784,10 +784,10 @@ VsVariable* VsRegistry::findSubordinateMDVar(const std::string& name) { VsLog::debugLog() << "VsRegistry::findSubordinateMDVar(" <::const_iterator it = allMDVariables.begin(); it != allMDVariables.end(); it++) { VsMDVariable* varMeta = it->second; - for (unsigned int i = 0; i < varMeta->blocks.size(); i++) { - if (varMeta->blocks[i]->getFullName() == name) { + for (unsigned int i = 0; i < varMeta->getNumBlocks(); i++) { + if (varMeta->getBlock(i)->getFullName() == name) { VsLog::debugLog() << "VsRegistry::findSubordinateMDVar(" <blocks[i]; + return varMeta->getBlock(i); } } } @@ -852,7 +852,7 @@ void VsRegistry::deleteAllVariablesWithMesh() { allVariablesWithMeshShort.clear(); } -void VsRegistry::writeAllVariablesWithMesh() { +void VsRegistry::writeAllVariablesWithMesh() const { if (allVariablesWithMesh.empty()) { VsLog::debugLog() <<"********** NO VsVariablesWithMesh *********" <getFullName() <::const_iterator k; - for (k = group->getAllAttributes()->begin(); k != group->getAllAttributes()->end(); ++k) { - VsH5Attribute* att = (*k).second; + std::map::const_iterator k; + for (k = group->getAllAttributes().begin(); k != group->getAllAttributes().end(); ++k) { + VsAttribute* att = (*k).second; if (att->getShortName() != VsSchema::typeAtt) { std::string s; - herr_t err = att->getStringValue(&s); + int err = att->getStringValue(&s); if (err == 0) { addExpression(att->getShortName(), s); } @@ -981,7 +981,7 @@ void VsRegistry::buildExpressions(VsH5Group* group) { VsLog::debugLog() <<"VsRegistry::buildExpressions() exiting." < foundPair = componentNames[i]; if (foundPair.first == componentName) { - VsLog::debugLog() <<"VsH5Reader::getComponentInfo(" <first = foundPair.second.first; namePair->second = foundPair.second.second; return; @@ -1106,12 +1106,12 @@ std::string VsRegistry::getComponentName(const std::string& varName, std::pair foundPair = componentNames[i]; NamePair tempNamePair = foundPair.second; if ((tempNamePair.first == varName) && (tempNamePair.second == componentNumber)) { - VsLog::debugLog() <<"VsH5Reader::getComponentInfo(" < foundPair = componentNames[i]; tempNamePair = foundPair.second; if ((tempNamePair.first == varName) && (tempNamePair.second == componentNumber)) { - VsLog::debugLog() <<"VsH5Reader::getComponentInfo(" <first = tempNamePair.first; namePair->second = tempNamePair.second; return; } } - VsLog::debugLog() <<"VsH5Reader::getComponentInfo(" <first = ""; namePair->second = -1; diff --git a/databases/Vs/VsRegistry.h b/databases/Vs/VsRegistry.h index 075f8905ed25af3254b77f886c600db33e11716b..cc6e14825612e374de2eed5efe7463c5d93cdd64 100644 --- a/databases/Vs/VsRegistry.h +++ b/databases/Vs/VsRegistry.h @@ -17,8 +17,8 @@ #ifndef VSREGISTRY_H_ #define VSREGISTRY_H_ -class VsH5Dataset; -class VsH5Group; +class VsDataset; +class VsGroup; class VsMesh; class VsVariableWithMesh; class VsVariable; @@ -38,24 +38,24 @@ public: void deleteAllObjects(); //DATASETS - void add(VsH5Dataset* obj); - void remove(VsH5Dataset* obj); - VsH5Dataset* getDataset(const std::string& name); + void add(VsDataset* obj); + void remove(VsDataset* obj); + VsDataset* getDataset(const std::string& name); void deleteAllDatasets(); - void writeAllDatasets(); + void writeAllDatasets() const; int numDatasets(); void buildDatasetObjects(); //GROUPS - void add(VsH5Group* obj); - void remove(VsH5Group* obj); - VsH5Group* getGroup(const std::string& name); + void add(VsGroup* obj); + void remove(VsGroup* obj); + VsGroup* getGroup(const std::string& name); void deleteAllGroups(); - void writeAllGroups(); + void writeAllGroups() const; int numGroups(); void buildGroupObjects(); - void loadTime(VsH5Group* group); - void loadRunInfo(VsH5Group* group); + void loadTime(VsGroup* group); + void loadRunInfo(VsGroup* group); //MESHES void add(VsMesh* mesh); @@ -63,14 +63,14 @@ public: VsMesh* getMesh(const std::string& name); void getAllMeshNames(std::vector& names); void deleteAllMeshes(); - void writeAllMeshes(); + void writeAllMeshes() const; int numMeshes(); //MD MESHES void add(VsMDMesh* var); void remove(VsMDMesh* var); void buildMDMeshes(); - void writeAllMDMeshes(); + void writeAllMDMeshes() const; VsMDMesh* getMDMesh(const std::string& name); VsMDMesh* getMDParentForMesh(const std::string& name); VsMesh* findSubordinateMDMesh(const std::string& name); @@ -83,7 +83,7 @@ public: VsVariable* getVariable(const std::string& name); void getAllVariableNames(std::vector& names); void deleteAllVariables(); - void writeAllVariables(); + void writeAllVariables() const; int numVariables(); //VARIABLES WITH MESH @@ -92,7 +92,7 @@ public: VsVariableWithMesh* getVariableWithMesh(const std::string& name); void getAllVariableWithMeshNames(std::vector& names); void deleteAllVariablesWithMesh(); - void writeAllVariablesWithMesh(); + void writeAllVariablesWithMesh() const; int numVariablesWithMesh(); // TRANSFORMED MESH NAMES @@ -107,7 +107,7 @@ public: void add(VsMDVariable* var); void remove(VsMDVariable* var); void buildMDVars(); - void writeAllMDVariables(); + void writeAllMDVariables() const; VsMDVariable* getMDVariable(const std::string& name); void getAllMDVariableNames(std::vector& names); int numMDVariables(); @@ -118,9 +118,9 @@ public: void buildTransformedVariables(); //VsVars - void buildExpressions(VsH5Group* group); + void buildExpressions(VsGroup* group); void addExpression(const std::string& name, const std::string& value); - void writeAllExpressions(); + void writeAllExpressions() const; std::map* getAllExpressions(); int numExpressions(); @@ -150,11 +150,11 @@ private: */ bool deletingObjects; - std::map allDatasets; - std::map allDatasetsShort; + std::map allDatasets; + std::map allDatasetsShort; - std::map allGroups; - std::map allGroupsShort; + std::map allGroups; + std::map allGroupsShort; std::map allMeshes; std::map allMeshesShort; diff --git a/databases/Vs/VsRegistryObject.h b/databases/Vs/VsRegistryObject.h index a6587ba9a8731511b674abf85fd640a8ca37beeb..5d2dc303927db48c81af80206bc08fbb1b0817f6 100644 --- a/databases/Vs/VsRegistryObject.h +++ b/databases/Vs/VsRegistryObject.h @@ -21,6 +21,7 @@ public: VsRegistryObject(VsRegistry* r); virtual ~VsRegistryObject(); VsRegistry* getRegistry(); + virtual void write() const = 0; VsRegistry* registry; }; diff --git a/databases/Vs/VsSchema.C b/databases/Vs/VsSchema.C index 1963b73a326b009de9327ef67ec8c18cd63cb182..d567736b5969aafe0a0af6a09143c0ca269e3f7e 100644 --- a/databases/Vs/VsSchema.C +++ b/databases/Vs/VsSchema.C @@ -1,6 +1,4 @@ #include -#include -#if HDF5_VERSION_GE(1,8,1) /** * @file VsSchema.cpp * @@ -37,6 +35,10 @@ std::string VsSchema::vsVarsKey = "vsVars"; std::string VsSchema::zonalCenteringKey = "zonal"; std::string VsSchema::nodalCenteringKey = "nodal"; // Default +// New to VsSchema 4.0 +std::string VsSchema::edgeCenteringKey = "edge"; +std::string VsSchema::faceCenteringKey = "face"; + // Index ordering... std::string VsSchema::compMajorCKey = "compMajorC"; //currently not supported std::string VsSchema::compMinorCKey = "compMinorC"; //default ordering @@ -112,4 +114,3 @@ std::string VsSchema::timeGroupAtt = "vsTimeGroup"; //Run info std::string VsSchema::runInfoKey = "runInfo"; std::string VsSchema::softwareAtt = "vsSoftware"; -#endif diff --git a/databases/Vs/VsSchema.h b/databases/Vs/VsSchema.h index c6763e0e2db5fd99c15df9bf3bdf6454497256a8..7fed910bd0ad5d52b276f08b0c149ac7b4d3a67e 100644 --- a/databases/Vs/VsSchema.h +++ b/databases/Vs/VsSchema.h @@ -7,9 +7,6 @@ * Copyright © 2008 by Tech-X Corporation */ #include -#include -#if HDF5_VERSION_GE(1, 8, 1) - #ifndef VS_SCHEMA #define VS_SCHEMA @@ -38,8 +35,10 @@ struct VsSchema { static std::string vsVarsKey; static std::string varWithMeshKey; static std::string meshKey; - static std::string zonalCenteringKey; static std::string nodalCenteringKey;// Default + static std::string edgeCenteringKey; + static std::string faceCenteringKey; + static std::string zonalCenteringKey; static std::string structuredMeshKey; // Index ordering... @@ -120,5 +119,4 @@ struct VsSchema { }; #endif -#endif diff --git a/databases/Vs/VsStaggeredField.C b/databases/Vs/VsStaggeredField.C new file mode 100644 index 0000000000000000000000000000000000000000..08e645c135c464c822da10cc19d8fecf18f1ac82 --- /dev/null +++ b/databases/Vs/VsStaggeredField.C @@ -0,0 +1,268 @@ +/* + * VsStaggeredField.cpp + * + * Created on: Apr 23, 2013 + * Author: pletzer + */ + +#include "VsStaggeredField.h" +#include "VsLog.h" +#include "VsSchema.h" +#include + +template +VsStaggeredField::VsStaggeredField(size_t subRes) { + + this->subRes = subRes; + this->oriDataPtr = 0; + this->totNumOriCells = 0; + this->totNumNewCells = 0; + this->totNumOriVals = 0; + this->totNumNewVals = 0; + this->twoPowSubRes = 0; + this->numNeighbors = 0; + this->numTopoDims = 0; + this->indexComp = -1; + this->indexOrder = VsSchema::compMajorCKey; + this->centering = VsSchema::nodalCenteringKey; + + this->oriCellDims.clear(); + this->oriCellDimProd.clear(); + this->newCellDims.clear(); + this->newCellDimProd.clear(); +} + +template +VsStaggeredField::~VsStaggeredField() { +} + +template +void +VsStaggeredField::setDataPtr(const TYPE* dataPtr, + size_t numDims, + const int dims[], + const std::string& indexOrder, + const std::string& centering) { + + this->oriDataPtr = dataPtr; + this->numTopoDims = numDims - 1; // assume dims also contains the number of components + this->indexOrder = indexOrder; + this->centering = centering; + + this->indexComp = 0; + if (indexOrder == VsSchema::compMinorCKey || + indexOrder == VsSchema::compMinorFKey) { + this->indexComp = numDims - 1; + } + + this->twoPowSubRes = 1; + for (size_t i = 0; i < this->subRes; ++i) { + this->twoPowSubRes *= 2; + } + + this->numNeighbors = 1; + for (size_t i = 0; i < this->numTopoDims; ++i) { + this->numNeighbors *= 2; + } + + this->oriCellDims.resize(this->numTopoDims); + size_t offset = 0; + for (size_t i = 0; i < numDims; ++i) { + if (i != this->indexComp) { + this->oriCellDims[i] = dims[i + offset]; + } + else { + offset = 1; + } + } + + this->newCellDims.resize(this->numTopoDims); + for (size_t i = 0; i < this->numTopoDims; ++i) { + this->newCellDims[i] = this->oriCellDims[i] * this->twoPowSubRes; + } + + this->oriCellDimProd.resize(this->numTopoDims); + this->oriCellDimProd[this->numTopoDims - 1] = 1; + this->newCellDimProd.resize(this->numTopoDims); + this->newCellDimProd[this->numTopoDims - 1] = 1; + for (size_t i = this->numTopoDims - 2; i >= 0; --i) { + this->oriCellDimProd[i] = this->oriCellDimProd[i + 1] * this->oriCellDims[i + 1]; + this->newCellDimProd[i] = this->newCellDimProd[i + 1] * this->newCellDims[i + 1]; + } + + this->totNumOriCells = 1; + this->totNumNewCells = 1; + this->totNumOriVals = 1; + this->totNumNewVals = 1; + for (size_t i = 0; i < this->numTopoDims; ++i) { + this->totNumOriCells *= this->oriCellDims[i]; + this->totNumNewCells *= this->newCellDims[i]; + this->totNumOriVals *= (this->oriCellDims[i] + 1); + this->totNumNewVals *= (this->newCellDims[i] + 1); + } + +} + +template +std::vector +VsStaggeredField::getNewNodalDataDims() const { + std::vector dims(this->numTopoDims + 1); + int offset = 0; + for (int i = 0; i < this->numTopoDims + 1; ++i) { + if (i != this->indexComp) { + dims[i] = this->newCellDims[i - offset] + 1; // data always have dimension of nodal data + } + else { + offset = 1; + } + } + return dims; +} + +template +void +VsStaggeredField::getNewNodalData(TYPE* dataPtr) const +{ + std::vector< std::valarray > neighVals(this->numNeighbors); + std::vector< std::valarray > sigmaVals(this->numNeighbors); + for (size_t bigIndx = 0; bigIndx < this->totNumOriCells; ++bigIndx) { + std::valarray oriCellInds = this->getOriCellIndexSet(bigIndx); + for (size_t n = 0; n < this->numNeighbors; ++n) { + sigmaVals[n] = this->getOriDisplacements(n); + size_t bigIndxNeigh = this->getOriBigIndex(oriCellInds + sigmaVals[n]); + neighVals[n] = this->getOriFieldVals(bigIndxNeigh); + } + + // iterate over subgrid + for (size_t subBigIndx = 0; subBigIndx < this->numNeighbors; ++subBigIndx) { + std::valarray subCellInds = this->getSubCellIndexSet(subBigIndx); + std::valarray newCellInds = oriCellInds*this->numNeighbors + subCellInds; + size_t newBigIndx = this->getNewBigIndex(newCellInds); + std::valarray xi = std::valarray(subCellInds) / this->twoPowSubRes; + this->setNewFieldVals(newBigIndx, xi, sigmaVals, neighVals, dataPtr); + } + } +} + +template +std::valarray +VsStaggeredField::getOriCellIndexSet(size_t bigIndex) const { + return (bigIndex / this->oriCellDimProd) % this->oriCellDims; +} + +template +std::valarray +VsStaggeredField::getOriDisplacements(size_t subBigIndex) const { + return (subBigIndex / this->twoPowSubRes) % 2; +} + +template +size_t +VsStaggeredField::getOriBigIndex(const std::valarray& indx) const { + size_t res = 0; + for (size_t i = 0; i < this->numTopoDims; ++i) { + res += indx[i] * this->dimCellProd[i]; + } + return res; +} + +template +std::valarray +VsStaggeredField::getOriFieldVals(size_t bigInx) const { + std::valarray res(this->numComps); + if (this->compIndex == 0) { + for (size_t j = 0; j < this->numComps; ++j) { + res[j] = this->oriData[j*this->totNumOriVals + bigInx]; + } + } + else { + for (size_t j = 0; j < this->numComps; ++j) { + res[j] = this->oriData[bigInx*this->numComps + j]; + } + } + return res; +} + +template +std::valarray +VsStaggeredField::getSubCellIndexSet(size_t subBigIndex) const { + return (subBigIndex / this->subCellDimProd) % this->twoPowSubRes; +} + +template +size_t +VsStaggeredField::getNewBigIndex(const std::valarray& newCellInds) const { + size_t res = 0; + for (size_t i = 0; i < this->numTopoDims; ++i) { + res += newCellInds[i] * this->newCellDimProd[i]; + } + return res; +} + +template +void +VsStaggeredField::fillNewVals(size_t newBigIndx, + const std::valarray& xiVals, + const std::vector< std::valarray >& sigmaVals, + const std::vector< std::valarray >& neighVals, + TYPE* dataPtr) const { + switch (this->centering) { + case 'n': + this->setNodalInterpFieldVals(newBigIndx, xiVals, sigmaVals, neighVals, dataPtr); + break; + case 'e': + this->setEdgeInterpFieldVals(newBigIndx, xiVals, sigmaVals, neighVals, dataPtr); + break; + case 'f': + this->setFaceInterpFieldVals(newBigIndx, xiVals, sigmaVals, neighVals, dataPtr); + break; + default: + this->setZonalInterpFieldVals(newBigIndx, xiVals, sigmaVals, neighVals, dataPtr); + } +} + +template +void +VsStaggeredField::setNodalInterpFieldVals(size_t newBigIndx, + const std::valarray& xiVals, + const std::vector< std::valarray >& sigmaVals, + const std::vector< std::valarray >& neighVals, + TYPE* dataPtr) const { + // TO IMPLEMENT +} + +template +void +VsStaggeredField::setEdgeInterpFieldVals(size_t newBigIndx, + const std::valarray& xiVals, + const std::vector< std::valarray >& sigmaVals, + const std::vector< std::valarray >& neighVals, + TYPE* dataPtr) const { + // TO IMPLEMENT +} + +template +void +VsStaggeredField::setFaceInterpFieldVals(size_t newBigIndx, + const std::valarray& xiVals, + const std::vector< std::valarray >& sigmaVals, + const std::vector< std::valarray >& neighVals, + TYPE* dataPtr) const { + // TO IMPLEMENT +} + +template +void +VsStaggeredField::setZonalInterpFieldVals(size_t newBigIndx, + const std::valarray& xiVals, + const std::vector< std::valarray >& sigmaVals, + const std::vector< std::valarray >& neighVals, + TYPE* dataPtr) const { + // TO IMPLEMENT +} + +// explicit instantiations +//template class VsStaggeringField; +//template class VsStaggeringField; +//template class VsStaggeringField; + diff --git a/databases/Vs/VsStaggeredField.h b/databases/Vs/VsStaggeredField.h new file mode 100644 index 0000000000000000000000000000000000000000..b19b6bdd4a56ef26856be42641f9fc3943dc79f9 --- /dev/null +++ b/databases/Vs/VsStaggeredField.h @@ -0,0 +1,154 @@ +/** + * @file VsStaggeredField.h + * + * @class VsStaggeredField + * @brief Represents staggered fields in memory + * + * Created on: Apr 23, 2013 + * Author: pletzer + */ + +#ifndef VS_STAGGERED_FIELD_H_ +#define VS_STAGGERED_FIELD_H_ + +#include +#include "VsObject.h" +#include +#include + +template +class VsStaggeredField { + +public: + + /** + * Constructor + * @param subRes sub-grid resolution, number of sub-cells is 2^subRes in each direction + */ + VsStaggeredField(size_t subRes); + + /** + * Destructor + */ + virtual ~VsStaggeredField(); + + /** + * Set the data pointer + * @param dataPtr data pointer + * @param numDims number of dimensions (incl. components) + * @param dims dimensions along each axis (incl. component axis) + * @param indexOrder index order (e.g. VsSchema::compMajorFKey) + * @param centering (e.g. VsSchema::faceCenteringKey) + */ + void setDataPtr(const TYPE* dataPtr, size_t numDims, const int dims[], + const std::string& indexOrder, const std::string& centering); + + /** + * Get the interpolated field dimensions + * @return dimensions along each axis (incl. component axis) + */ + std::vector getNewNodalDataDims() const; + + /** + * Get the new field data values + * @param pointer to the new data, caller is responsible to allocating and freeing + */ + void getNewNodalData(TYPE* dataPtr) const; + + +private: + + std::valarray getOriCellIndexSet(size_t bigIndx) const; + std::valarray getOriDisplacements(size_t subBigIndx) const; + size_t getOriBigIndex(const std::valarray& indx) const; + std::valarray getOriFieldVals(size_t bigInx) const; + std::valarray getSubCellIndexSet(size_t subBigIndex) const; + size_t getNewBigIndex(const std::valarray& newCellInds) const; + + /** + * Fill interpolated values + * @param newBigInd big (flat) index of the new data array + * @param sigmaVals displacements (array of 1s and 0s) from the original cells + * @param neighVals field values corresponding to the sigmaVals displacements + * @param dataPtr pointer to the new data, some values will be filled in + */ + void fillNewVals(size_t newBigIndx, + const std::valarray& xiVals, + const std::vector< std::valarray >& sigmaVals, + const std::vector< std::valarray >& neighVals, + TYPE* dataPtr) const; + + + void setNodalInterpFieldVals(size_t newBigIndx, + const std::valarray& xiVals, + const std::vector< std::valarray >& sigmaVals, + const std::vector< std::valarray >& neighVals, + TYPE* dataPtr) const; + void setEdgeInterpFieldVals(size_t newBigIndx, + const std::valarray& xiVals, + const std::vector< std::valarray >& sigmaVals, + const std::vector< std::valarray >& neighVals, + TYPE* dataPtr) const; + void setFaceInterpFieldVals(size_t newBigIndx, + const std::valarray& xiVals, + const std::vector< std::valarray >& sigmaVals, + const std::vector< std::valarray >& neighVals, + TYPE* dataPtr) const; + void setZonalInterpFieldVals(size_t newBigIndx, + const std::valarray& xiVals, + const std::vector< std::valarray >& sigmaVals, + const std::vector< std::valarray >& neighVals, + TYPE* dataPtr) const; + + + /** number of sub-cells is 2^subRes in each topological direction */ + size_t subRes; + + /** pointer to the original data, assumed to have dimension nodal data times number of components */ + TYPE* oriDataPtr; + + /** total number of original grid cells */ + size_t totNumOriCells; + + /** total number of new grid cells */ + size_t totNumNewCells; + + /** total number of data values (number of nodes times number of components) */ + size_t totNumOriVals; + + /** total number of new data values (number of nodes times number of components) */ + size_t totNumNewVals; + + /** 2^subRes */ + size_t twoPowSubRes; + + /** number neighbors forming a cell (2^d) */ + size_t numNeighbors; + + /** number of topological dimensions */ + size_t numTopoDims; + + /** component index */ + int indexComp; + + /** index order, see VsSchema */ + std::string indexOrder; + + /** type of field centering (nodal, edge, ...) */ + std::string centering; + + /** number of cells along each direction for the original data */ + std::valarray oriCellDim; + + /** number of cells along each direction for the new data */ + std::valarray newCellDims; + + /** array to map big index to index set for original data */ + std::valarray oriCellDimProd; + + /** array to map big index to index set for new data */ + std::valarray newCellDimProd; + +}; + +#endif /* VS_STAGGERED_FIELD_H_ */ diff --git a/databases/Vs/VsStructuredMesh.C b/databases/Vs/VsStructuredMesh.C index 4bea94723a8b81367304442ca8df1dfaeced973a..d84c41591f13c79d26325a3c2a809469356deca2 100644 --- a/databases/Vs/VsStructuredMesh.C +++ b/databases/Vs/VsStructuredMesh.C @@ -6,9 +6,9 @@ */ #include "VsStructuredMesh.h" -#include "VsH5Attribute.h" +#include "VsAttribute.h" #include "VsSchema.h" -#include "VsH5Dataset.h" +#include "VsDataset.h" #include "VsLog.h" #include "VsUtils.h" @@ -17,7 +17,7 @@ #define __CLASS__ "VsStructuredMesh::" -VsStructuredMesh::VsStructuredMesh(VsH5Dataset* data):VsMesh(data) { +VsStructuredMesh::VsStructuredMesh(VsDataset* data):VsMesh(data) { maskAtt = NULL; } @@ -26,7 +26,7 @@ VsStructuredMesh::~VsStructuredMesh() { } -VsStructuredMesh* VsStructuredMesh::buildStructuredMesh(VsH5Dataset* dataset) +VsStructuredMesh* VsStructuredMesh::buildStructuredMesh(VsDataset* dataset) { VsStructuredMesh* newMesh = new VsStructuredMesh(dataset); bool success = newMesh->initialize(); @@ -51,13 +51,13 @@ bool VsStructuredMesh::initialize() VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "Entering" <getDataset(getFullName()); + VsDataset* dm = registry->getDataset(getFullName()); std::vector< int > dims = dm->getDims(); // Determine num spatial dims. For a structured mesh, it is the size // of the last component of the dataset. - int index = ((VsH5Dataset*)h5Object)->getDims().size() - 1; + int index = ((VsDataset*)h5Object)->getDims().size() - 1; if (dims.empty()) { @@ -126,18 +126,18 @@ bool VsStructuredMesh::initialize() } -std::string VsStructuredMesh::getKind() { +std::string VsStructuredMesh::getKind() const { return VsSchema::structuredMeshKey; } -void VsStructuredMesh::getMeshDataDims(std::vector& dims) +void VsStructuredMesh::getCellDims(std::vector& dims) const { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "Entering." << std::endl; // Read dataset's dims - VsH5Dataset* dm = registry->getDataset(getFullName()); + VsDataset* dm = registry->getDataset(getFullName()); if (!dm) { VsLog::errorLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " @@ -174,9 +174,9 @@ void VsStructuredMesh::getMeshDataDims(std::vector& dims) } -void VsStructuredMesh::getNumMeshDims(std::vector& dims) +void VsStructuredMesh::getNodeDims(std::vector& dims) const { - getMeshDataDims(dims); + getCellDims(dims); // Lop off the spatial dimension. if( dims.size() > 1 ) @@ -193,7 +193,7 @@ void VsStructuredMesh::getNumMeshDims(std::vector& dims) } } -std::string VsStructuredMesh::getMaskName() +std::string VsStructuredMesh::getMaskName() const { if (!maskAtt) { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " @@ -202,7 +202,7 @@ std::string VsStructuredMesh::getMaskName() } std::string maskName; - herr_t err = maskAtt->getStringValue(&maskName); + int err = maskAtt->getStringValue(&maskName); if (err < 0) { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "Cannot get mask name from attribute, returning empty string." << std::endl; diff --git a/databases/Vs/VsStructuredMesh.h b/databases/Vs/VsStructuredMesh.h index 7aa08eafd2de7556e78d1611de28f974f6c735a5..d8396f4984d3a43e52a6a289f05457d93b9dce75 100644 --- a/databases/Vs/VsStructuredMesh.h +++ b/databases/Vs/VsStructuredMesh.h @@ -14,32 +14,32 @@ #include "VsMesh.h" #include -class VsH5Dataset; +class VsDataset; class VsStructuredMesh: public VsMesh { public: virtual ~VsStructuredMesh(); - virtual bool isStructuredMesh() { return true; } - virtual std::string getKind(); + virtual bool isStructuredMesh() const { return true; } + virtual std::string getKind() const; - static VsStructuredMesh* buildStructuredMesh(VsH5Dataset* data); + static VsStructuredMesh* buildStructuredMesh(VsDataset* data); - virtual void getMeshDataDims(std::vector& dims); - virtual void getNumMeshDims(std::vector& dims); + virtual void getCellDims(std::vector& dims) const; + virtual void getNodeDims(std::vector& dims) const; /** * Get the mask variable name * @return name or empty string if no mask */ - virtual std::string getMaskName(); + virtual std::string getMaskName() const; private: - VsStructuredMesh(VsH5Dataset* data); + VsStructuredMesh(VsDataset* data); virtual bool initialize(); /** name of the mask array (optional) */ - VsH5Attribute* maskAtt; + VsAttribute* maskAtt; }; #endif /* VSSTRUCTUREDMESH_H_ */ diff --git a/databases/Vs/VsUniformMesh.C b/databases/Vs/VsUniformMesh.C index 3563c05f5e54fcdc4d7e667a0f2469417908b9b9..345d09ff6633d86d973358d11d5bc6610e1c5656 100644 --- a/databases/Vs/VsUniformMesh.C +++ b/databases/Vs/VsUniformMesh.C @@ -6,9 +6,9 @@ */ #include "VsUniformMesh.h" -#include "VsH5Attribute.h" +#include "VsAttribute.h" #include "VsSchema.h" -#include "VsH5Group.h" +#include "VsGroup.h" #include "VsLog.h" #include "VsUtils.h" @@ -17,7 +17,7 @@ #define __CLASS__ "VsUniformMesh::" -VsUniformMesh::VsUniformMesh(VsH5Group* group):VsMesh(group) { +VsUniformMesh::VsUniformMesh(VsGroup* group):VsMesh(group) { numCellsAtt = NULL; startCellAtt = NULL; lowerBoundsAtt = NULL; @@ -28,7 +28,7 @@ VsUniformMesh::VsUniformMesh(VsH5Group* group):VsMesh(group) { VsUniformMesh::~VsUniformMesh() { } -VsUniformMesh* VsUniformMesh::buildUniformMesh(VsH5Group* group) +VsUniformMesh* VsUniformMesh::buildUniformMesh(VsGroup* group) { VsUniformMesh* newMesh = new VsUniformMesh(group); bool success = newMesh->initialize(); @@ -80,7 +80,7 @@ bool VsUniformMesh::initialize() std::vector dims; - herr_t err = numCellsAtt->getIntVectorValue(&dims); + int err = numCellsAtt->getIntVectorValue(&dims); if (!err) { numSpatialDims = dims.size(); } else { @@ -221,7 +221,7 @@ bool VsUniformMesh::initialize() } -hid_t VsUniformMesh::getDataType() { +hid_t VsUniformMesh::getDataType() const { if (lowerBoundsAtt->getType() == H5T_NATIVE_DOUBLE) return H5T_NATIVE_DOUBLE; @@ -233,15 +233,15 @@ hid_t VsUniformMesh::getDataType() { } -std::string VsUniformMesh::getKind() { +std::string VsUniformMesh::getKind() const { return VsSchema::Uniform::key; } -herr_t VsUniformMesh::getLowerBounds(std::vector* fVals) { +int VsUniformMesh::getLowerBounds(std::vector* fVals) { hid_t type = lowerBoundsAtt->getType(); - herr_t err = 0; + int err = 0; if (isDoubleType(type)) { std::vector dVals; @@ -267,10 +267,10 @@ herr_t VsUniformMesh::getLowerBounds(std::vector* fVals) { } -herr_t VsUniformMesh::getUpperBounds(std::vector* fVals) { +int VsUniformMesh::getUpperBounds(std::vector* fVals) { hid_t type = upperBoundsAtt->getType(); - herr_t err = 0; + int err = 0; if (isDoubleType(type)) { std::vector dVals; err = upperBoundsAtt->getDoubleVectorValue(&dVals); @@ -293,7 +293,7 @@ herr_t VsUniformMesh::getUpperBounds(std::vector* fVals) { } -herr_t VsUniformMesh::getStartCell(std::vector* startCell) { +int VsUniformMesh::getStartCell(std::vector* startCell) { if (startCellAtt == NULL) { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "Mesh does not have optional attribute: " @@ -301,7 +301,7 @@ herr_t VsUniformMesh::getStartCell(std::vector* startCell) { return -1; } - herr_t err = startCellAtt->getIntVectorValue(startCell); + int err = startCellAtt->getIntVectorValue(startCell); if (err < 0) { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " @@ -313,7 +313,7 @@ herr_t VsUniformMesh::getStartCell(std::vector* startCell) { } -void VsUniformMesh::getMeshDataDims(std::vector& dims) +void VsUniformMesh::getCellDims(std::vector& dims) const { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "Entering." << std::endl; @@ -323,10 +323,10 @@ void VsUniformMesh::getMeshDataDims(std::vector& dims) } -void VsUniformMesh::getNumMeshDims(std::vector& dims) +void VsUniformMesh::getNodeDims(std::vector& dims) const { // Get the number of cells - getMeshDataDims(dims); + getCellDims(dims); // The number of nodes will be one more than the number of cells; for (unsigned int i = 0; i < dims.size(); i++) diff --git a/databases/Vs/VsUniformMesh.h b/databases/Vs/VsUniformMesh.h index eba0f57ed70e23b539cd5c9f1571c9d30b1da5b0..839dc08d5cfd3f9bd1d3ed2cc6c1e03d8439bec2 100644 --- a/databases/Vs/VsUniformMesh.h +++ b/databases/Vs/VsUniformMesh.h @@ -14,33 +14,33 @@ #include "VsMesh.h" #include -class VsH5Group; +class VsGroup; class VsUniformMesh: public VsMesh { public: virtual ~VsUniformMesh(); - hid_t getDataType(); + hid_t getDataType() const; - virtual bool isUniformMesh() { return true; } - virtual std::string getKind(); + virtual bool isUniformMesh() const { return true; } + virtual std::string getKind() const; - static VsUniformMesh* buildUniformMesh(VsH5Group* group); + static VsUniformMesh* buildUniformMesh(VsGroup* group); - herr_t getLowerBounds(std::vector* fVals); - herr_t getUpperBounds(std::vector* fVals); - herr_t getStartCell(std::vector* startCell); + int getLowerBounds(std::vector* fVals); + int getUpperBounds(std::vector* fVals); + int getStartCell(std::vector* startCell); - virtual void getMeshDataDims(std::vector& dims); - virtual void getNumMeshDims(std::vector& dims); + virtual void getCellDims(std::vector& dims) const; + virtual void getNodeDims(std::vector& dims) const; private: //required attributes - VsH5Attribute* numCellsAtt; - VsH5Attribute* lowerBoundsAtt; - VsH5Attribute* upperBoundsAtt; - VsH5Attribute* startCellAtt; + VsAttribute* numCellsAtt; + VsAttribute* lowerBoundsAtt; + VsAttribute* upperBoundsAtt; + VsAttribute* startCellAtt; - VsUniformMesh(VsH5Group* group); + VsUniformMesh(VsGroup* group); virtual bool initialize(); }; diff --git a/databases/Vs/VsUnstructuredMesh.C b/databases/Vs/VsUnstructuredMesh.C index 508c23652055cf24e3a54f49a2c8bbf662380f8a..c3244b2bed1a70046c3f29ce73624e19427500f3 100644 --- a/databases/Vs/VsUnstructuredMesh.C +++ b/databases/Vs/VsUnstructuredMesh.C @@ -7,14 +7,14 @@ #include "VsUnstructuredMesh.h" #include "VsSchema.h" -#include "VsH5Dataset.h" +#include "VsDataset.h" #include "VsUtils.h" -#include "VsH5Group.h" +#include "VsGroup.h" #include "VsLog.h" #define __CLASS__ "VsUnstructuredMesh::" -VsUnstructuredMesh::VsUnstructuredMesh(VsH5Group* group):VsMesh(group) { +VsUnstructuredMesh::VsUnstructuredMesh(VsGroup* group):VsMesh(group) { numPoints = 0; numCells = 0; splitPoints = false; @@ -24,33 +24,33 @@ VsUnstructuredMesh::~VsUnstructuredMesh() { } //Tweak for Nautilus -std::string VsUnstructuredMesh::getNodeCorrectionDatasetName() { +std::string VsUnstructuredMesh::getNodeCorrectionDatasetName() const { return makeCanonicalName(getFullName(), "localToGlobalNodeMapping"); } -bool VsUnstructuredMesh::hasNodeCorrectionData() { +bool VsUnstructuredMesh::hasNodeCorrectionData() const { std::string datasetName = getNodeCorrectionDatasetName(); //Look for a node correction list - VsH5Dataset* nodeCorrectionDataset = registry->getDataset(datasetName); + VsDataset* nodeCorrectionDataset = registry->getDataset(datasetName); return (nodeCorrectionDataset != NULL); } //end tweak -unsigned int VsUnstructuredMesh::getNumPoints() { +size_t VsUnstructuredMesh::getNumPoints() const { return numPoints; } -unsigned int VsUnstructuredMesh::getNumCells() { +size_t VsUnstructuredMesh::getNumCells() const { return numCells; } -bool VsUnstructuredMesh::usesSplitPoints() { +bool VsUnstructuredMesh::usesSplitPoints() const { return splitPoints; } -std::string VsUnstructuredMesh::getPointsDatasetName() { +std::string VsUnstructuredMesh::getPointsDatasetName() const { //First see if the user has specified a name for the dataset std::string pointsName; getStringAttribute(VsSchema::Unstructured::vsPoints, &pointsName); @@ -63,7 +63,7 @@ std::string VsUnstructuredMesh::getPointsDatasetName() { VsSchema::Unstructured::defaultPointsName); } -std::string VsUnstructuredMesh::getPointsDatasetName(int i) { +std::string VsUnstructuredMesh::getPointsDatasetName(int i) const { std::string attributeName; switch (i) { @@ -91,13 +91,13 @@ std::string VsUnstructuredMesh::getPointsDatasetName(int i) { return fullName; } -hid_t VsUnstructuredMesh::getDataType() { - VsH5Dataset* pointsDataset = getPointsDataset(); +hid_t VsUnstructuredMesh::getDataType() const { + VsDataset* pointsDataset = getPointsDataset(); if (pointsDataset != NULL) { return pointsDataset->getType(); } - VsH5Dataset* points0Dataset = getPointsDataset(0); + VsDataset* points0Dataset = getPointsDataset(0); if (points0Dataset != NULL) { return points0Dataset->getType(); } @@ -105,29 +105,29 @@ hid_t VsUnstructuredMesh::getDataType() { return H5T_NATIVE_FLOAT; } -VsH5Dataset* VsUnstructuredMesh::getPointsDataset(int i) { +VsDataset* VsUnstructuredMesh::getPointsDataset(int i) const { std::string pointsName = getPointsDatasetName(i); if (pointsName.empty()) { return NULL; } - VsH5Dataset* answer = registry->getDataset(pointsName); + VsDataset* answer = registry->getDataset(pointsName); return answer; //could be NULL } -VsH5Dataset* VsUnstructuredMesh::getPointsDataset() { +VsDataset* VsUnstructuredMesh::getPointsDataset() const { std::string pointsName = getPointsDatasetName(); if (pointsName.empty()) { return NULL; } - VsH5Dataset* answer = registry->getDataset(pointsName); + VsDataset* answer = registry->getDataset(pointsName); return answer; //could be NULL } -std::string VsUnstructuredMesh::getPolygonsDatasetName() { +std::string VsUnstructuredMesh::getPolygonsDatasetName() const { //First see if the user has specified a name for the dataset std::string polygonsName; getStringAttribute(VsSchema::Unstructured::vsPolygons, &polygonsName); @@ -138,7 +138,7 @@ std::string VsUnstructuredMesh::getPolygonsDatasetName() { return makeCanonicalName(getFullName(), VsSchema::Unstructured::defaultPolygonsName); } -VsH5Dataset* VsUnstructuredMesh::getPolygonsDataset() { +VsDataset* VsUnstructuredMesh::getPolygonsDataset() const { std::string polygonsName = getPolygonsDatasetName(); if (polygonsName.empty()) { return NULL; @@ -147,7 +147,7 @@ VsH5Dataset* VsUnstructuredMesh::getPolygonsDataset() { return registry->getDataset(polygonsName); } -std::string VsUnstructuredMesh::getPolyhedraDatasetName() { +std::string VsUnstructuredMesh::getPolyhedraDatasetName() const { //First see if the user has specified a name for the dataset std::string polyhedraName; getStringAttribute(VsSchema::Unstructured::vsPolyhedra, &polyhedraName); @@ -158,7 +158,7 @@ std::string VsUnstructuredMesh::getPolyhedraDatasetName() { return makeCanonicalName(getFullName(), VsSchema::Unstructured::defaultPolyhedraName); } -VsH5Dataset* VsUnstructuredMesh::getPolyhedraDataset() { +VsDataset* VsUnstructuredMesh::getPolyhedraDataset() const { std::string polyhedraName = getPolyhedraDatasetName(); if (polyhedraName.empty()) { return NULL; @@ -167,7 +167,7 @@ VsH5Dataset* VsUnstructuredMesh::getPolyhedraDataset() { return registry->getDataset(polyhedraName); } -std::string VsUnstructuredMesh::getLinesDatasetName() { +std::string VsUnstructuredMesh::getLinesDatasetName() const { //First see if the user has specified a name for the dataset std::string linesName; getStringAttribute(VsSchema::Unstructured::vsLines, &linesName); @@ -178,7 +178,7 @@ std::string VsUnstructuredMesh::getLinesDatasetName() { return makeCanonicalName(getFullName(), VsSchema::Unstructured::defaultLinesName); } -VsH5Dataset* VsUnstructuredMesh::getLinesDataset() { +VsDataset* VsUnstructuredMesh::getLinesDataset() const { std::string linesName = getLinesDatasetName(); if (linesName.empty()) { return NULL; @@ -187,7 +187,7 @@ VsH5Dataset* VsUnstructuredMesh::getLinesDataset() { return registry->getDataset(linesName); } -std::string VsUnstructuredMesh::getTrianglesDatasetName() { +std::string VsUnstructuredMesh::getTrianglesDatasetName() const { //First see if the user has specified a name for the dataset std::string trianglesName; getStringAttribute(VsSchema::Unstructured::vsTriangles, &trianglesName); @@ -198,7 +198,7 @@ std::string VsUnstructuredMesh::getTrianglesDatasetName() { return makeCanonicalName(getFullName(), VsSchema::Unstructured::defaultTrianglesName); } -VsH5Dataset* VsUnstructuredMesh::getTrianglesDataset() { +VsDataset* VsUnstructuredMesh::getTrianglesDataset() const { std::string trianglesName = getTrianglesDatasetName(); if (trianglesName.empty()) { return NULL; @@ -207,7 +207,7 @@ VsH5Dataset* VsUnstructuredMesh::getTrianglesDataset() { return registry->getDataset(trianglesName); } -std::string VsUnstructuredMesh::getQuadrilateralsDatasetName() { +std::string VsUnstructuredMesh::getQuadrilateralsDatasetName() const { //First see if the user has specified a name for the dataset std::string quadrilateralsName; getStringAttribute(VsSchema::Unstructured::vsQuadrilaterals, &quadrilateralsName); @@ -218,7 +218,7 @@ std::string VsUnstructuredMesh::getQuadrilateralsDatasetName() { return makeCanonicalName(getFullName(), VsSchema::Unstructured::defaultQuadrilateralsName); } -VsH5Dataset* VsUnstructuredMesh::getQuadrilateralsDataset() { +VsDataset* VsUnstructuredMesh::getQuadrilateralsDataset() const { std::string quadrilateralsName = getQuadrilateralsDatasetName(); if (quadrilateralsName.empty()) { return NULL; @@ -227,7 +227,7 @@ VsH5Dataset* VsUnstructuredMesh::getQuadrilateralsDataset() { return registry->getDataset(quadrilateralsName); } -std::string VsUnstructuredMesh::getTetrahedralsDatasetName() { +std::string VsUnstructuredMesh::getTetrahedralsDatasetName() const { //First see if the user has specified a name for the dataset std::string tetrahedralsName; getStringAttribute(VsSchema::Unstructured::vsTetrahedrals, &tetrahedralsName); @@ -238,7 +238,7 @@ std::string VsUnstructuredMesh::getTetrahedralsDatasetName() { return makeCanonicalName(getFullName(), VsSchema::Unstructured::defaultTetrahedralsName); } -VsH5Dataset* VsUnstructuredMesh::getTetrahedralsDataset() { +VsDataset* VsUnstructuredMesh::getTetrahedralsDataset() const { std::string tetrahedralsName = getTetrahedralsDatasetName(); if (tetrahedralsName.empty()) { return NULL; @@ -247,7 +247,7 @@ VsH5Dataset* VsUnstructuredMesh::getTetrahedralsDataset() { return registry->getDataset(tetrahedralsName); } -std::string VsUnstructuredMesh::getPyramidsDatasetName() { +std::string VsUnstructuredMesh::getPyramidsDatasetName() const { //First see if the user has specified a name for the dataset std::string pyramidsName; getStringAttribute(VsSchema::Unstructured::vsPyramids, &pyramidsName); @@ -258,7 +258,7 @@ std::string VsUnstructuredMesh::getPyramidsDatasetName() { return makeCanonicalName(getFullName(), VsSchema::Unstructured::defaultPyramidsName); } -VsH5Dataset* VsUnstructuredMesh::getPyramidsDataset() { +VsDataset* VsUnstructuredMesh::getPyramidsDataset() const { std::string pyramidsName = getPyramidsDatasetName(); if (pyramidsName.empty()) { return NULL; @@ -267,7 +267,7 @@ VsH5Dataset* VsUnstructuredMesh::getPyramidsDataset() { return registry->getDataset(pyramidsName); } -std::string VsUnstructuredMesh::getPrismsDatasetName() { +std::string VsUnstructuredMesh::getPrismsDatasetName() const { //First see if the user has specified a name for the dataset std::string prismsName; getStringAttribute(VsSchema::Unstructured::vsPrisms, &prismsName); @@ -278,7 +278,7 @@ std::string VsUnstructuredMesh::getPrismsDatasetName() { return makeCanonicalName(getFullName(), VsSchema::Unstructured::defaultPrismsName); } -VsH5Dataset* VsUnstructuredMesh::getPrismsDataset() { +VsDataset* VsUnstructuredMesh::getPrismsDataset() const { std::string prismsName = getPrismsDatasetName(); if (prismsName.empty()) { return NULL; @@ -287,7 +287,7 @@ VsH5Dataset* VsUnstructuredMesh::getPrismsDataset() { return registry->getDataset(prismsName); } -std::string VsUnstructuredMesh::getHexahedralsDatasetName() { +std::string VsUnstructuredMesh::getHexahedralsDatasetName() const { //First see if the user has specified a name for the dataset std::string hexahedralsName; getStringAttribute(VsSchema::Unstructured::vsHexahedrals, &hexahedralsName); @@ -298,7 +298,7 @@ std::string VsUnstructuredMesh::getHexahedralsDatasetName() { return makeCanonicalName(getFullName(), VsSchema::Unstructured::defaultHexahedralsName); } -VsH5Dataset* VsUnstructuredMesh::getHexahedralsDataset() { +VsDataset* VsUnstructuredMesh::getHexahedralsDataset() const { std::string hexahedralsName = getHexahedralsDatasetName(); if (hexahedralsName.empty()) { return NULL; @@ -307,7 +307,7 @@ VsH5Dataset* VsUnstructuredMesh::getHexahedralsDataset() { return registry->getDataset(hexahedralsName); } -VsUnstructuredMesh* VsUnstructuredMesh::buildUnstructuredMesh(VsH5Group* group) { +VsUnstructuredMesh* VsUnstructuredMesh::buildUnstructuredMesh(VsGroup* group) { VsUnstructuredMesh* newMesh = new VsUnstructuredMesh(group); bool success = newMesh->initialize(); @@ -327,7 +327,7 @@ VsUnstructuredMesh* VsUnstructuredMesh::buildUnstructuredMesh(VsH5Group* group) bool VsUnstructuredMesh::initialize() { //For an unstructured mesh, spatial dimensionality is... complicated - VsH5Dataset* pointsDataset = getPointsDataset(); + VsDataset* pointsDataset = getPointsDataset(); if (pointsDataset != NULL) { splitPoints = false; @@ -356,9 +356,9 @@ bool VsUnstructuredMesh::initialize() { << "vsPoints1 = " <getDataset(connectivityDatasetName); std::vector connectivityDims = connectivityMeta->getDims(); @@ -435,7 +435,7 @@ bool VsUnstructuredMesh::initialize() { return initializeRoot(); } -bool VsUnstructuredMesh::isPointMesh() { +bool VsUnstructuredMesh::isPointMesh() const { return ((getPolygonsDataset() == NULL) && (getPolyhedraDataset() == NULL) && @@ -449,11 +449,11 @@ bool VsUnstructuredMesh::isPointMesh() { (getHexahedralsDataset() == NULL)); } -std::string VsUnstructuredMesh::getKind() { +std::string VsUnstructuredMesh::getKind() const { return VsSchema::Unstructured::key; } -void VsUnstructuredMesh::getMeshDataDims(std::vector& dims) +void VsUnstructuredMesh::getCellDims(std::vector& dims) const { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "entering" << std::endl; diff --git a/databases/Vs/VsUnstructuredMesh.h b/databases/Vs/VsUnstructuredMesh.h index eff27941e04202cae09fbfd271e60aad17972e51..948cb6c143073758538aadfedba93fe48b90ff70 100644 --- a/databases/Vs/VsUnstructuredMesh.h +++ b/databases/Vs/VsUnstructuredMesh.h @@ -15,59 +15,59 @@ #include #include -class VsH5Group; +class VsGroup; class VsUnstructuredMesh: public VsMesh { public: virtual ~VsUnstructuredMesh(); - unsigned int getNumPoints(); - unsigned int getNumCells(); + size_t getNumPoints() const; + size_t getNumCells() const; - static VsUnstructuredMesh* buildUnstructuredMesh(VsH5Group* group); + static VsUnstructuredMesh* buildUnstructuredMesh(VsGroup* group); - virtual bool isUnstructuredMesh() { return true; } - virtual std::string getKind(); + virtual bool isUnstructuredMesh() const { return true; } + virtual std::string getKind() const; //Tweak for Nautilus - bool hasNodeCorrectionData(); - std::string getNodeCorrectionDatasetName(); + bool hasNodeCorrectionData() const; + std::string getNodeCorrectionDatasetName() const; //end tweak - bool usesSplitPoints(); - std::string getPointsDatasetName(); - std::string getPointsDatasetName(int i); - hid_t getDataType(); + bool usesSplitPoints() const; + std::string getPointsDatasetName() const; + std::string getPointsDatasetName(int i) const; + hid_t getDataType() const; - VsH5Dataset* getPointsDataset(); - VsH5Dataset* getPointsDataset(int i); - std::string getPolygonsDatasetName(); - VsH5Dataset* getPolygonsDataset(); - std::string getPolyhedraDatasetName(); - VsH5Dataset* getPolyhedraDataset(); - std::string getLinesDatasetName(); - VsH5Dataset* getLinesDataset(); - std::string getTrianglesDatasetName(); - VsH5Dataset* getTrianglesDataset(); - std::string getQuadrilateralsDatasetName(); - VsH5Dataset* getQuadrilateralsDataset(); - std::string getTetrahedralsDatasetName(); - VsH5Dataset* getTetrahedralsDataset(); - std::string getPyramidsDatasetName(); - VsH5Dataset* getPyramidsDataset(); - std::string getPrismsDatasetName(); - VsH5Dataset* getPrismsDataset(); - std::string getHexahedralsDatasetName(); - VsH5Dataset* getHexahedralsDataset(); - bool isPointMesh(); + VsDataset* getPointsDataset() const; + VsDataset* getPointsDataset(int i) const; + std::string getPolygonsDatasetName() const; + VsDataset* getPolygonsDataset() const; + std::string getPolyhedraDatasetName() const; + VsDataset* getPolyhedraDataset() const; + std::string getLinesDatasetName() const; + VsDataset* getLinesDataset() const; + std::string getTrianglesDatasetName() const; + VsDataset* getTrianglesDataset() const; + std::string getQuadrilateralsDatasetName() const; + VsDataset* getQuadrilateralsDataset() const; + std::string getTetrahedralsDatasetName() const; + VsDataset* getTetrahedralsDataset() const; + std::string getPyramidsDatasetName() const; + VsDataset* getPyramidsDataset() const; + std::string getPrismsDatasetName() const; + VsDataset* getPrismsDataset() const; + std::string getHexahedralsDatasetName() const; + VsDataset* getHexahedralsDataset() const; + bool isPointMesh() const; - virtual void getMeshDataDims(std::vector& dims); + virtual void getCellDims(std::vector& dims) const; private: - VsUnstructuredMesh(VsH5Group* group); + VsUnstructuredMesh(VsGroup* group); virtual bool initialize(); - unsigned int numPoints; - unsigned int numCells; + size_t numPoints; + size_t numCells; bool splitPoints; }; diff --git a/databases/Vs/VsUtils.C b/databases/Vs/VsUtils.C index 2d5112260d8d2c1c21220c17aeb2250f2587561c..816aed5ff83e3352e401e8ac76bd5484a08e37b8 100644 --- a/databases/Vs/VsUtils.C +++ b/databases/Vs/VsUtils.C @@ -1,6 +1,4 @@ #include -#include -#if HDF5_VERSION_GE(1,8,1) #include #include @@ -18,7 +16,7 @@ void getDims(hid_t id, bool isDataset, std::vector& dims) { } } */ -std::string makeCanonicalName(std::string name) { +std::string makeCanonicalName(const std::string& name) { std::string answer = name; //remove the leading slash(es) if it(they) exist(s) @@ -29,7 +27,8 @@ std::string makeCanonicalName(std::string name) { return answer; } -std::string makeCanonicalName(std::string path, std::string name) { +std::string makeCanonicalName(const std::string& path, + const std::string& name) { std::string answer = name; //only prepend the path if it is not empty, and if "name" does not start with '/' if ((path.length() > 0) && (name.length() > 0) && (name[0] != '/')) { @@ -198,7 +197,8 @@ void printType(hid_t dataType) { }*/ // Break a string into pieces -void tokenize(std::string text, char separator, std::vector& tokens) { +void tokenize(const std::string& text, + char separator, std::vector& tokens) { //start with a clean list of tokens tokens.clear(); @@ -228,7 +228,9 @@ void tokenize(std::string text, char separator, std::vector& tokens } //Adjusts var dimensions stored in an array of hsize_t -void adjustSize_hsize_t(hsize_t *dims, unsigned int rank, std::vector stride, int before, int after) { +void adjustSize_hsize_t(hsize_t *dims, unsigned int rank, + const std::vector& stride, + int before, int after) { //apply transform to each dimension for (unsigned int i = 0; i < rank; i++) { dims[i] += before; @@ -244,7 +246,9 @@ void adjustSize_hsize_t(hsize_t *dims, unsigned int rank, std::vector strid } //Adjusts var dimensions stored in a vector int -void adjustSize_vector(std::vector* dims, int rank, std::vector stride, int before, int after) { +void adjustSize_vector(std::vector* dims, int rank, + const std::vector& stride, + int before, int after) { //apply transform to each dimension for (int i = 0; i < rank; i++) { (*dims)[i] += before; @@ -258,4 +262,3 @@ void adjustSize_vector(std::vector* dims, int rank, std::vector stride (*dims)[i] += after; } } -#endif diff --git a/databases/Vs/VsUtils.h b/databases/Vs/VsUtils.h index 68400bdd587ada600784f42642a9736187df8e50..2c15a0022a7d68e533e55a325cbc00fa9557b2f6 100644 --- a/databases/Vs/VsUtils.h +++ b/databases/Vs/VsUtils.h @@ -8,11 +8,9 @@ */ #include -#include -#if HDF5_VERSION_GE(1, 8, 1) -#ifndef VS_UTILS -#define VS_UTILS +#ifndef VS_UTILS_H +#define VS_UTILS_H #include #include @@ -20,19 +18,26 @@ // Get dimensions of a dataset or attribute //void getDims(hid_t id, bool isDataset, std::vector& dims); -// Create fully qualified name from an object name -// This means strip the leading "/" if it exists -std::string makeCanonicalName(std::string name); +/** + * Create fully qualified name from an object name + * @param name object name + * @return object name without leading "/" + */ +std::string makeCanonicalName(const std::string& name); -// Create fully qualified name from object path and name -// i.e. path + "/" + name -// Then strip the leading "/" if it exists -std::string makeCanonicalName(std::string path, std::string name); +/** + * Create fully qualified name from object path and name, + * @param path + * @param name + * @return path + "/" + name (without leading "/") + */ +std::string makeCanonicalName(const std::string& path, + const std::string& name); // Compare two object names to a target name -// Return the name that is "closest" to the target -// If the two object names are identical, returns the first -//std::string getClosestName(std::string name1, std::string name2, std::string target); +// @return the name that is "closest" to the target +// @note If the two object names are identical, will return the first +//std::string getClosestName(const std::string& name1, const std::string& name2, const std::string& target); /** * Check data type @@ -79,11 +84,16 @@ bool isUnsignedCharType(hid_t dataType); void printType(hid_t dataType); // Break a string into pieces -void tokenize(std::string text, char separator, std::vector& tokens); +void tokenize(const std::string& text, + char separator, std::vector& tokens); + +void adjustSize_hsize_t(hsize_t* dims, unsigned int rank, + const std::vector& stride, + int before, int after); +void adjustSize_vector(std::vector* dims, int rank, + const std::vector& stride, + int before, int after); -void adjustSize_hsize_t(hsize_t* dims, unsigned int rank, std::vector stride, int before, int after); -void adjustSize_vector(std::vector* dims, int rank, std::vector stride, int before, int after); -#endif -#endif +#endif // VS_UTILS_H diff --git a/databases/Vs/VsVariable.C b/databases/Vs/VsVariable.C index 3501855290f7a26f894192899db9e30d8164e95b..6f307a178d21700b35b26fc890d5a570cdf69dc4 100644 --- a/databases/Vs/VsVariable.C +++ b/databases/Vs/VsVariable.C @@ -7,9 +7,9 @@ #include "VsVariable.h" #include "VsSchema.h" -#include "VsH5Dataset.h" +#include "VsDataset.h" #include "VsLog.h" -#include "VsH5Attribute.h" +#include "VsAttribute.h" #include "VsMDVariable.h" #include "VsMDMesh.h" #include "VsUtils.h" @@ -21,7 +21,7 @@ #define __CLASS__ "VsVariable::" -VsVariable::VsVariable(VsH5Dataset* data): +VsVariable::VsVariable(VsDataset* data): VsRegistryObject(data->registry) { indexOrder = VsSchema::compMinorCKey; //default dataset = 0; @@ -44,84 +44,98 @@ VsVariable::~VsVariable() { registry->remove(this); } -bool VsVariable::isZonal() { +bool VsVariable::isZonal() const { return (centering == VsSchema::zonalCenteringKey); } -bool VsVariable::isFortranOrder() { +bool VsVariable::isNodal() const { + return (centering == VsSchema::nodalCenteringKey); +} + +bool VsVariable::isEdge() const { + return (centering == VsSchema::edgeCenteringKey); +} + +bool VsVariable::isFace() const { + return (centering == VsSchema::faceCenteringKey); +} + +bool VsVariable::isFortranOrder() const { return ((indexOrder == VsSchema::compMinorFKey) || (indexOrder == VsSchema::compMajorFKey)); } -bool VsVariable::isCompMinor() { +bool VsVariable::isCompMinor() const { return ((indexOrder == VsSchema::compMinorCKey) || (indexOrder == VsSchema::compMinorFKey)); } -bool VsVariable::isCompMajor() { +bool VsVariable::isCompMajor() const { return ((indexOrder == VsSchema::compMajorCKey) || (indexOrder == VsSchema::compMajorFKey)); } // Get dims -std::vector VsVariable::getDims() { +std::vector VsVariable::getDims() const { return dataset->getDims(); } // Get mesh name -std::string VsVariable::getMeshName() { +std::string VsVariable::getMeshName() const { return meshName; } -VsMesh* VsVariable::getMesh() { +VsMesh* VsVariable::getMesh() const { return meshMeta; } -bool VsVariable::hasTransform() { +bool VsVariable::hasTransform() const { return meshMeta && meshMeta->hasTransform(); } // Get hdf5 type -hid_t VsVariable::getType() { +hid_t VsVariable::getType() const { return dataset->getType(); } // Get length needed to store all elements in their format -size_t VsVariable::getLength() { +size_t VsVariable::getLength() const { return dataset->getLength(); } // Get name -std::string VsVariable::getShortName () { +std::string VsVariable::getShortName () const { return dataset->getShortName(); } -hid_t VsVariable::getId() { +hid_t VsVariable::getId() const { return dataset->getId(); } // Get path -std::string VsVariable::getPath() { +std::string VsVariable::getPath() const { return dataset->getPath(); } // Get transformed name -std::string VsVariable::getFullTransformedName() { +std::string VsVariable::getFullTransformedName() const { return getFullName() + "_transform"; } // Get full name -std::string VsVariable::getFullName() { +std::string VsVariable::getFullName() const { return dataset->getFullName(); } // Find attribute by name, or return NULL if not found -VsH5Attribute* VsVariable::getAttribute(const std::string& name) { +VsAttribute* VsVariable::getAttribute(const std::string& name) const { + VsLog::debugLog() << "getatt " << name <getAttribute(name) << std::endl; return dataset->getAttribute(name); } -std::string VsVariable::getStringAttribute(const std::string& name) { - VsH5Attribute* foundAtt = getAttribute(name); +std::string VsVariable::getStringAttribute(const std::string& name) const { + VsLog::debugLog() << "getstringatt " << name <getAttribute(name) << std::endl; + VsAttribute* foundAtt = getAttribute(name); if (foundAtt == NULL) return ""; std::string result = ""; @@ -129,7 +143,7 @@ std::string VsVariable::getStringAttribute(const std::string& name) { return result; } -void VsVariable::write() { +void VsVariable::write() const { VsLog::debugLog() << getFullName() <initialize(); if (success) { @@ -166,7 +181,8 @@ bool VsVariable::initialize() { VsLog::debugLog() <<"VsVariable::initialize() - Entering." <getAttribute(VsSchema::meshAtt); + VsAttribute* meshNameAtt = dataset->getAttribute(VsSchema::meshAtt); + VsLog::debugLog() <<"VsVariable:: meshNameAtt." <meshMeta = registry->getMesh(this->meshName); + VsLog::debugLog() <<"VsVariable:: meshMeta." <meshMeta) { VsLog::errorLog() <<"VsVariable::initialize() - Unable to find mesh with name " <meshName <getAttribute(VsSchema::indexOrderAtt); + VsAttribute* indexOrderAtt = dataset->getAttribute(VsSchema::indexOrderAtt); + VsLog::debugLog() <<"VsVariable:: indexorder." <getStringValue(&(this->indexOrder)); } //Get vsTimeGroup (optional attribute) - VsH5Attribute* timeGroupAtt = dataset->getAttribute(VsSchema::timeGroupAtt); + VsLog::debugLog() <<"VsVariable:: timeGroupAtt: " <getAttribute(VsSchema::timeGroupAtt); + VsLog::debugLog() <<"VsVariable:: timeGroupAtt: "<< timeGroupAtt <getStringValue(&timeGroupName); @@ -201,7 +221,7 @@ bool VsVariable::initialize() { } //Get centering (optional attribute) - VsH5Attribute* centeringAtt = dataset->getAttribute(VsSchema::centeringAtt); + VsAttribute* centeringAtt = dataset->getAttribute(VsSchema::centeringAtt); if (centeringAtt) { centeringAtt->getStringValue(&(this->centering)); } @@ -210,11 +230,11 @@ bool VsVariable::initialize() { if (this->nodeOffsetAtt) { std::vector nodeOffsetFloat(3, 0); std::vector nodeOffsetInt(3, 0); - herr_t err = this->nodeOffsetAtt->getDoubleVectorValue(&this->nodeOffset); + int err = this->nodeOffsetAtt->getDoubleVectorValue(&this->nodeOffset); if (err < 0) { - herr_t err2 = this->nodeOffsetAtt->getFloatVectorValue(&nodeOffsetFloat); + int err2 = this->nodeOffsetAtt->getFloatVectorValue(&nodeOffsetFloat); if (err2 < 0) { - herr_t err3 = this->nodeOffsetAtt->getIntVectorValue(&nodeOffsetInt); + int err3 = this->nodeOffsetAtt->getIntVectorValue(&nodeOffsetInt); if (err3 < 0) { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "Cannot get vector nodeOffset." << std::endl; @@ -246,7 +266,7 @@ bool VsVariable::initialize() { //Get user-specified labels for components //labels is a comma-delimited list of strings - VsH5Attribute* componentNamesAtt = dataset->getAttribute(VsSchema::labelsAtt); + VsAttribute* componentNamesAtt = dataset->getAttribute(VsSchema::labelsAtt); if (componentNamesAtt) { std::string names; componentNamesAtt->getStringValue(&names); @@ -257,14 +277,14 @@ bool VsVariable::initialize() { return true; } -size_t VsVariable::getNumComps() { +size_t VsVariable::getNumComps() const{ VsLog::debugLog() << "VsVariable::getNumComps(): Entering." << std::endl; std::vector dataDims = getDims(); //load the mesh dimensions std::vector meshDims; - meshMeta->getMeshDataDims(meshDims); + meshMeta->getCellDims(meshDims); //did we get a reasonable value? if (meshDims.empty()) { @@ -328,28 +348,11 @@ size_t VsVariable::getNumComps() { res = 1; goto dimwarn; } - - // ARS - do we really want this check??? The mesh and data dim check - // above should match. This allows a mesh and data to be of - // different sizes. Which can mess up the index select. - if (dataDims.size() == 1) - { + if ((dataDims.size() == 1) + || ((dataDims.size() == 2) && (dataDims[0] == 1))) { res = 1; goto dimwarn; } - - // ARS - do we really want this check??? The mesh and data dim check - // above should match. Also this allows data which should be a - // component to slide through as a true scalar. - if(dataDims.size() == 2 && - ((isCompMajor() && dataDims[0] == 1) || - (!isCompMajor() && dataDims[1] == 1)) ) - { - res = 1; - goto dimwarn; - } - - if (meshDims.size() != (dataDims.size() - 1) ) { VsLog::debugLog() << "VsVariable::getNumComps(): error - mesh '" << getMeshName() << "' has dimensions of size, " << meshDims.size() << ", while dataset '" << @@ -360,10 +363,10 @@ size_t VsVariable::getNumComps() { } // check that each of mesh sizes are correct (for compMinor data here) - if (isCompMajor()) { - res = dataDims.front(); - } else { + if (!isCompMajor()) { res = dataDims.back(); + } else { + res = dataDims.front(); } dimwarn: @@ -402,9 +405,9 @@ void VsVariable::createComponents() { //I.E. instead of a singleton named "var_0", we just call it "var" if (numComps > 1) { for (size_t i = 0; i < numComps; ++i) { - registry->registerComponent(getFullName(), (int)i, getLabel(i)); + registry->registerComponent(getFullName(), i, getLabel(i)); if (transformExists) { - registry->registerComponent(getFullTransformedName(), (int)i, getLabel(i)); + registry->registerComponent(getFullTransformedName(), i, getLabel(i)); } } } diff --git a/databases/Vs/VsVariable.h b/databases/Vs/VsVariable.h index fe5935db9eb4f71c3c1219fadb10cd3c18f2ebed..c4c2e42d39a0ebb02032a16de6986f5e2af3e06d 100644 --- a/databases/Vs/VsVariable.h +++ b/databases/Vs/VsVariable.h @@ -13,77 +13,83 @@ #include #include "VsRegistryObject.h" +#include "VsGroup.h" #include #include #include -class VsH5Attribute; -class VsH5Dataset; +class VsAttribute; +class VsDataset; class VsMesh; class VsVariable : public VsRegistryObject { public: virtual ~VsVariable(); - bool isZonal(); + bool isZonal() const; + bool isNodal() const; + bool isEdge() const; + bool isFace() const; - bool isFortranOrder(); - bool isCompMinor(); - bool isCompMajor(); + bool isFortranOrder() const; + bool isCompMinor() const; + bool isCompMajor() const; - std::vector getDims(); + std::vector getDims() const; /** Get name of mesh that this variable belongs to. */ - std::string getMeshName(); - VsMesh* getMesh(); + std::string getMeshName() const; + VsMesh* getMesh() const; /** Does this variable have a transformed version? */ - bool hasTransform(); + bool hasTransform() const; /** Get hdf5 type */ - hid_t getType(); + hid_t getType() const; /** Get length needed to store all elements in their format */ - size_t getLength(); + size_t getLength() const; /** Get short name */ - std::string getShortName(); + std::string getShortName() const; /** Get path */ - std::string getPath(); + std::string getPath() const; /** Get full name */ - std::string getFullName(); + std::string getFullName() const; /** Find attribute by name, or return NULL if not found */ - VsH5Attribute* getAttribute(const std::string& name); + VsAttribute* getAttribute(const std::string& name) const; - std::string getStringAttribute(const std::string& name); + std::string getStringAttribute(const std::string& name) const; + + /** Get user-specified name for a variable component. */ + std::string getLabel(size_t i) const; /** Supply debugging output. */ - virtual void write(); + virtual void write() const; /** Get user-specified name for a variable component. */ - std::string getLabel(unsigned int i); - - std::string getCentering() { return centering; } - std::string getIndexOrder() { return indexOrder; } - hid_t getId(); + + std::string getCentering() const { return centering;} + std::string getIndexOrder() const { return indexOrder; } + hid_t getId() const; - VsH5Group* getTimeGroup() { return timeGroup; } + VsGroup* getTimeGroup() const { return timeGroup; } /** Public method to initialize object. * Returns NULL on error.*/ - static VsVariable* buildObject(VsH5Dataset* dataset); + static VsVariable* buildObject(VsDataset* dataset); /** Get the transformed name */ - std::string getFullTransformedName(); + std::string getFullTransformedName() const; void createTransformedVariable(); void createComponents(); - size_t getNumComps(); + size_t getNumComps() const; /** * Get the node offset @@ -98,7 +104,7 @@ public: bool hasNodeOffset() const; protected: - VsVariable(VsH5Dataset* data); + VsVariable(VsDataset* data); /** Private method to initialize object. * Returns false on error.*/ @@ -115,10 +121,10 @@ protected: std::string centering; /** Time group */ - VsH5Group* timeGroup; + VsGroup* timeGroup; /** Dataset used to construct this object. */ - VsH5Dataset* dataset; + VsDataset* dataset; /** User-specified names of the components of this variable. */ std::vector labelNames; @@ -127,7 +133,7 @@ protected: std::string path; /** lower node offset array (optional) */ - VsH5Attribute* nodeOffsetAtt; + VsAttribute* nodeOffsetAtt; /** node offsets with respect to base node */ std::vector nodeOffset; diff --git a/databases/Vs/VsVariableWithMesh.C b/databases/Vs/VsVariableWithMesh.C index bf04b5d7b1633a7b849eee17e73cdc854acba004..a82ae195328326256267be3046ad3087809fd468 100644 --- a/databases/Vs/VsVariableWithMesh.C +++ b/databases/Vs/VsVariableWithMesh.C @@ -7,9 +7,9 @@ #include "VsVariableWithMesh.h" #include "VsSchema.h" -#include "VsH5Dataset.h" +#include "VsDataset.h" #include "VsLog.h" -#include "VsH5Attribute.h" +#include "VsAttribute.h" #include "VsUtils.h" #include @@ -19,7 +19,7 @@ #define __CLASS__ "VsStructuredMesh::" -VsVariableWithMesh::VsVariableWithMesh(VsH5Dataset* data): +VsVariableWithMesh::VsVariableWithMesh(VsDataset* data): VsRegistryObject(data->registry) { indexOrder = VsSchema::compMinorCKey; dataset = data; @@ -32,37 +32,49 @@ VsVariableWithMesh::~VsVariableWithMesh() { registry->remove(this); } -unsigned int VsVariableWithMesh::getNumSpatialDims() { +size_t VsVariableWithMesh::getNumSpatialDims() const { return spatialIndices.size(); } -bool VsVariableWithMesh::isZonal() { +bool VsVariableWithMesh::isZonal() const { return (centering == VsSchema::zonalCenteringKey); } -bool VsVariableWithMesh::isCompMinor() { +bool VsVariableWithMesh::isNodal() const { + return (centering == VsSchema::nodalCenteringKey); +} + +bool VsVariableWithMesh::isEdge() const { + return (centering == VsSchema::edgeCenteringKey); +} + +bool VsVariableWithMesh::isFace() const { + return (centering == VsSchema::faceCenteringKey); +} + +bool VsVariableWithMesh::isCompMinor() const { return ((indexOrder == VsSchema::compMinorCKey) || (indexOrder == VsSchema::compMinorFKey)); } -bool VsVariableWithMesh::isCompMajor() { +bool VsVariableWithMesh::isCompMajor() const { return ((indexOrder == VsSchema::compMajorCKey) || (indexOrder == VsSchema::compMajorFKey)); } -std::string VsVariableWithMesh::getFullTransformedName() { +std::string VsVariableWithMesh::getFullTransformedName() const { return getFullName() + "_transform"; } -bool VsVariableWithMesh::hasTransform() { +bool VsVariableWithMesh::hasTransform() const { return (!getTransformName().empty()); } -std::string VsVariableWithMesh::getTransformName() { +std::string VsVariableWithMesh::getTransformName() const { //Look for the vsTransform attribute //and either retrieve the value or leave the name empty std::string transformName; - VsH5Attribute* transformNameAtt = getAttribute(VsSchema::transformKey); + VsAttribute* transformNameAtt = getAttribute(VsSchema::transformKey); if (transformNameAtt) { transformNameAtt->getStringValue(&transformName); } @@ -80,10 +92,10 @@ std::string VsVariableWithMesh::getTransformName() { return transformName; } -std::string VsVariableWithMesh::getTransformedMeshName() { +std::string VsVariableWithMesh::getTransformedMeshName() const { //Look for the vsTransformName key std::string transformedMeshName; - VsH5Attribute* transformedMeshNameAtt = getAttribute(VsSchema::transformedMeshKey); + VsAttribute* transformedMeshNameAtt = getAttribute(VsSchema::transformedMeshKey); if (transformedMeshNameAtt) { transformedMeshNameAtt->getStringValue(&transformedMeshName); if (!transformedMeshName.empty()) { @@ -119,24 +131,24 @@ void VsVariableWithMesh::createTransformedVariableAndMesh() { } // Get dims -std::vector VsVariableWithMesh::getDims() +std::vector VsVariableWithMesh::getDims() const { return dataset->getDims(); } -void VsVariableWithMesh::getMeshDataDims(std::vector& dims) +void VsVariableWithMesh::getCellDims(std::vector& dims) const { dims = dataset->getDims(); } -void VsVariableWithMesh::getNumMeshDims(std::vector& dims) +void VsVariableWithMesh::getNodeDims(std::vector& dims) const { dims.resize(1); dims[0] = getNumPoints(); } -unsigned int VsVariableWithMesh::getNumPoints() +size_t VsVariableWithMesh::getNumPoints() const { if( isCompMinor() ) return dataset->getDims()[0]; @@ -145,44 +157,44 @@ unsigned int VsVariableWithMesh::getNumPoints() } // Get hdf5 type -hid_t VsVariableWithMesh::getType() { +hid_t VsVariableWithMesh::getType() const { return dataset->getType(); } // Get length needed to store all elements in their format -size_t VsVariableWithMesh::getLength() { +size_t VsVariableWithMesh::getLength() const { return dataset->getLength(); } // Get name -std::string VsVariableWithMesh::getShortName () { +std::string VsVariableWithMesh::getShortName () const { return dataset->getShortName(); } -hid_t VsVariableWithMesh::getId() { +hid_t VsVariableWithMesh::getId() const { return dataset->getId(); } // Get path -std::string VsVariableWithMesh::getPath() { +std::string VsVariableWithMesh::getPath() const { return dataset->getPath(); } // Get full name -std::string VsVariableWithMesh::getFullName() { +std::string VsVariableWithMesh::getFullName() const { return dataset->getFullName(); } // Find attribute by name, or return NULL if not found -VsH5Attribute* VsVariableWithMesh::getAttribute(const std::string& name) { +VsAttribute* VsVariableWithMesh::getAttribute(const std::string& name) const { return dataset->getAttribute(name); } -std::string VsVariableWithMesh::getStringAttribute(const std::string& name) { +std::string VsVariableWithMesh::getStringAttribute(const std::string& name) const { std::string result(""); - VsH5Attribute* foundAtt = getAttribute(name); + VsAttribute* foundAtt = getAttribute(name); if (foundAtt) foundAtt->getStringValue(&result); @@ -190,15 +202,15 @@ std::string VsVariableWithMesh::getStringAttribute(const std::string& name) { } //retrieve a particular spatial dimension index from the list //returns -1 on failure -int VsVariableWithMesh::getSpatialDim(size_t index) { - if ((index < 0) || (index > spatialIndices.size())) { +int VsVariableWithMesh::getSpatialDim(size_t index) const { + if (index > spatialIndices.size()) { return -1; } return spatialIndices[index]; } -void VsVariableWithMesh::write() { +void VsVariableWithMesh::write() const { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << getFullName() << " " << "indexOrder = " << indexOrder << " " @@ -227,14 +239,14 @@ bool VsVariableWithMesh::initialize() { //any errors bool numDimsSet = false; - VsH5Attribute* spatialIndicesAtt = getAttribute(VsSchema::spatialIndicesAtt); + VsAttribute* spatialIndicesAtt = getAttribute(VsSchema::spatialIndicesAtt); if (spatialIndicesAtt) { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "found spatialIndices, trying synergia style" << std::endl; std::vector in; - herr_t err = spatialIndicesAtt->getIntVectorValue(&in); + size_t err = spatialIndicesAtt->getIntVectorValue(&in); if (!err) { numDimsSet = true; this->spatialIndices = in; @@ -245,11 +257,11 @@ bool VsVariableWithMesh::initialize() { //NOTE: We load indexOrder regardless of whether we're in synergia //style or not - VsH5Attribute* indexOrderAtt = getAttribute(VsSchema::indexOrderAtt); + VsAttribute* indexOrderAtt = getAttribute(VsSchema::indexOrderAtt); if (indexOrderAtt) { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << "found indexOrder." << std::endl; - herr_t err = indexOrderAtt->getStringValue(&(this->indexOrder)); + int err = indexOrderAtt->getStringValue(&(this->indexOrder)); if (err < 0) { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " << getFullName() @@ -270,7 +282,7 @@ bool VsVariableWithMesh::initialize() { << "Looking for attribute: " << VsSchema::numSpatialDimsAtt << std::endl; - VsH5Attribute* numDimsAtt = getAttribute(VsSchema::numSpatialDimsAtt); + VsAttribute* numDimsAtt = getAttribute(VsSchema::numSpatialDimsAtt); if (!numDimsAtt) { VsLog::warningLog() @@ -284,7 +296,7 @@ bool VsVariableWithMesh::initialize() { } if (numDimsAtt) { std::vector in; - herr_t err = numDimsAtt->getIntVectorValue(&in); + int err = numDimsAtt->getIntVectorValue(&in); if (err < 0) { VsLog::debugLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " @@ -321,7 +333,7 @@ bool VsVariableWithMesh::initialize() { } //Get vsTimeGroup (optional attribute) - VsH5Attribute* timeGroupAtt = dataset->getAttribute(VsSchema::timeGroupAtt); + VsAttribute* timeGroupAtt = dataset->getAttribute(VsSchema::timeGroupAtt); if (timeGroupAtt) { std::string timeGroupName; timeGroupAtt->getStringValue(&timeGroupName); @@ -330,7 +342,7 @@ bool VsVariableWithMesh::initialize() { //Get user-specified labels for components //labels is a comma-delimited list of strings - VsH5Attribute* componentNamesAtt = dataset->getAttribute(VsSchema::labelsAtt); + VsAttribute* componentNamesAtt = dataset->getAttribute(VsSchema::labelsAtt); if (componentNamesAtt) { std::string names; componentNamesAtt->getStringValue(&names); @@ -342,15 +354,16 @@ bool VsVariableWithMesh::initialize() { } // Get user-specified component names -std::string VsVariableWithMesh::getLabel (unsigned int i) { - if ((i >= 0) && (i < labelNames.size()) && !labelNames[i].empty()) { +std::string VsVariableWithMesh::getLabel (size_t i) const { +// if ((i >= 0) && (i < labelNames.size()) && !labelNames[i].empty()) { + if ((i < labelNames.size()) && !labelNames[i].empty()) { return makeCanonicalName(getPath(), labelNames[i]); } return ""; } -VsVariableWithMesh* VsVariableWithMesh::buildObject(VsH5Dataset* dataset) { +VsVariableWithMesh* VsVariableWithMesh::buildObject(VsDataset* dataset) { VsVariableWithMesh* newVar = new VsVariableWithMesh(dataset); bool success = newVar->initialize(); if (success) { @@ -362,7 +375,7 @@ VsVariableWithMesh* VsVariableWithMesh::buildObject(VsH5Dataset* dataset) { return NULL; } -size_t VsVariableWithMesh::getNumComps() { +size_t VsVariableWithMesh::getNumComps() const { std::vector dims = getDims(); if (dims.size() <= 0) { VsLog::errorLog() << __CLASS__ << __FUNCTION__ << " " << __LINE__ << " " @@ -388,9 +401,9 @@ void VsVariableWithMesh::createComponents() { //But i'm going to leave it as-is for now... bool transformExists = hasTransform(); for (size_t i = 0; i < numComps; ++i) { - registry->registerComponent(getFullName(), (int)i, getLabel(i)); + registry->registerComponent(getFullName(), i, getLabel(i)); if (transformExists) { - registry->registerComponent(getFullTransformedName(), (int)i, getLabel(i)); + registry->registerComponent(getFullTransformedName(), i, getLabel(i)); } } diff --git a/databases/Vs/VsVariableWithMesh.h b/databases/Vs/VsVariableWithMesh.h index 588d3cccd8d49dd359d0732e21e6dbb63441c2e5..67184f100b095c613ce71401df7f88c59e0a6373 100644 --- a/databases/Vs/VsVariableWithMesh.h +++ b/databases/Vs/VsVariableWithMesh.h @@ -19,93 +19,96 @@ #include #include -class VsH5Attribute; -class VsH5Dataset; +class VsAttribute; +class VsDataset; class VsVariableWithMesh : public VsRegistryObject { public: virtual ~VsVariableWithMesh(); /** Get the number of spatial dimensions */ - unsigned int getNumSpatialDims(); + size_t getNumSpatialDims() const; /** Retrieve a particular spatial dimension index from the list returns -1 on failure */ - int getSpatialDim(size_t index); + int getSpatialDim(size_t index) const; /** Retrieve the entire list of spatial indices */ - std::vector getSpatialIndices(); + std::vector getSpatialIndices() const; /** Handles tranformation attributes for the "mesh" part of this object */ - virtual bool hasTransform(); - std::string getTransformName(); - std::string getTransformedMeshName(); + virtual bool hasTransform() const; + std::string getTransformName() const; + std::string getTransformedMeshName() const; /** Handles transformation attributes for the "variable" part of this object */ - std::string getFullTransformedName(); + std::string getFullTransformedName() const; void createTransformedVariableAndMesh(); /** Supply debugging output */ - void write(); + void write() const; - bool isZonal(); - bool isCompMinor(); - bool isCompMajor(); + bool isZonal() const; + bool isNodal() const; + bool isEdge() const; + bool isFace() const; + bool isCompMinor() const; + bool isCompMajor() const; /** Get dimensions of associated dataset. */ - std::vector getDims(); + std::vector getDims() const; - unsigned int getNumPoints(); + size_t getNumPoints() const; - virtual void getMeshDataDims(std::vector& dims); - virtual void getNumMeshDims(std::vector& dims); + virtual void getCellDims(std::vector& dims) const; + virtual void getNodeDims(std::vector& dims) const; /** Get hdf5 type */ - hid_t getType(); + hid_t getType() const; /** Get length needed to store all elements in their format */ - size_t getLength(); + size_t getLength() const; /** Get short name */ - std::string getShortName(); + std::string getShortName() const; /** Get path */ - std::string getPath(); + std::string getPath() const; /** Get fully qualified name */ - std::string getFullName(); + std::string getFullName() const; /** Find attribute by name, or return NULL if not found. */ - VsH5Attribute* getAttribute(const std::string& name); + VsAttribute* getAttribute(const std::string& name) const; /** Retrieve the value of the attribute with the given name */ - std::string getStringAttribute(const std::string& name); + std::string getStringAttribute(const std::string& name) const; /** Retrieve the user-specified label for component number i */ - std::string getLabel(unsigned int i); + std::string getLabel(size_t i) const; /** Get the centering string*/ - std::string getCentering() { return centering; } + std::string getCentering() const { return centering; } /** Get the index order string */ - std::string getIndexOrder() { return indexOrder; } + std::string getIndexOrder() const { return indexOrder; } /** Retrieve the hdf5 id of this object. */ - hid_t getId(); + hid_t getId() const; /** Public method to construct a VsVariableWithMesh object. * Returns NULL if an error is encountered. */ - static VsVariableWithMesh* buildObject(VsH5Dataset* dataset); + static VsVariableWithMesh* buildObject(VsDataset* dataset); void createComponents(); - size_t getNumComps(); + size_t getNumComps() const; - VsH5Group* getTimeGroup() { return timeGroup; } + VsGroup* getTimeGroup() const { return timeGroup; } private: /** Private constructor */ - VsVariableWithMesh(VsH5Dataset* dataset); + VsVariableWithMesh(VsDataset* dataset); /** Initializes the data members of the object. * Returns false if an error is found. */ @@ -118,10 +121,10 @@ private: std::string centering; /** Dataset object from which this object was created. */ - VsH5Dataset* dataset; + VsDataset* dataset; /** Time group */ - VsH5Group* timeGroup; + VsGroup* timeGroup; /** List of user-specified names for the components of this variable */ std::vector labelNames; diff --git a/databases/Vs/avtVsFileFormat.C b/databases/Vs/avtVsFileFormat.C index 83a469bb55b1ec05f7eec0108f77d8ee5d7b6060..dab08cde09a3db8f536274bcf4dfa25c32b0901a 100644 --- a/databases/Vs/avtVsFileFormat.C +++ b/databases/Vs/avtVsFileFormat.C @@ -73,15 +73,15 @@ #include "VsVariableWithMesh.h" #include "VsMesh.h" #include "VsMDMesh.h" -#include "VsH5Dataset.h" +#include "VsDataset.h" #include "VsRectilinearMesh.h" #include "VsUniformMesh.h" #include "VsUnstructuredMesh.h" #include "VsStructuredMesh.h" -#include "VsH5Attribute.h" +#include "VsAttribute.h" #include "VsLog.h" #include "VsRegistry.h" -#include "VsH5Reader.h" +#include "VsReader.h" #include "VsSchema.h" #define __CLASS__ "avtVsFileFormat::" @@ -173,7 +173,7 @@ avtVsFileFormat::avtVsFileFormat(const char* filename, EXCEPTION1(InvalidDBTypeException, msg.str().c_str()); } - //NOTE: We used to initialize the VsH5Reader object here + //NOTE: We used to initialize the VsReader object here //But now do it on demand in 'populateDatabaseMetaData' //To minimize I/O @@ -585,7 +585,7 @@ vtkDataSet* avtVsFileFormat::getUniformMesh(VsUniformMesh* uniformMesh, // Read int data std::vector numCells; - uniformMesh->getMeshDataDims(numCells); // Number of cells NOT nodes + uniformMesh->getCellDims(numCells); if (numCells.size() < 0) { std::ostringstream msg; @@ -789,7 +789,7 @@ avtVsFileFormat::getRectilinearMesh(VsRectilinearMesh* rectilinearMesh, // Get dimensions std::vector numNodes; - rectilinearMesh->getMeshDataDims(numNodes); // Number of nodes NOT cells + rectilinearMesh->getNodeDims(numNodes); // Number of nodes NOT cells if (numNodes.size() < 0) { std::ostringstream msg; @@ -862,7 +862,7 @@ avtVsFileFormat::getRectilinearMesh(VsRectilinearMesh* rectilinearMesh, VsLog::debugLog() << __CLASS__ <<"(" <getAxisDataset(i); + VsDataset* axisData = rectilinearMesh->getAxisDataset(i); if (axisData == NULL) { VsLog::debugLog() << __CLASS__ <<"(" <getDataSet(axisData, dataPtr); + herr_t err = reader->getData(axisData, dataPtr); if (err < 0) { VsLog::debugLog() << __CLASS__ <<"(" <getDataset(structuredMesh->getFullName()); if (pointsDataset == NULL) { @@ -1123,7 +1123,7 @@ vtkDataSet* avtVsFileFormat::getStructuredMesh(VsStructuredMesh* structuredMesh, << "Determining dimension of points array." << std::endl; std::vector numNodes; - structuredMesh->getNumMeshDims(numNodes); // Number of nodes NOT cells. + structuredMesh->getNodeDims(numNodes); if (numNodes.size() < 0) { std::ostringstream msg; @@ -1235,12 +1235,12 @@ vtkDataSet* avtVsFileFormat::getStructuredMesh(VsStructuredMesh* structuredMesh, herr_t err; if( haveDataSelections ) - err = reader->getDataSet( pointsDataset, dataPtr, - // -1 read all coordinate components - structuredMesh->getIndexOrder(), -1, - mins, &(gdims[0]), strides ); + err = reader->getData( pointsDataset, dataPtr, + // -1 read all coordinate components + structuredMesh->getIndexOrder(), -1, + mins, &(gdims[0]), strides ); else - err = reader->getDataSet( pointsDataset, dataPtr ); + err = reader->getData( pointsDataset, dataPtr ); if (err < 0) { @@ -1345,7 +1345,7 @@ vtkDataSet* avtVsFileFormat::getStructuredMesh(VsStructuredMesh* structuredMesh, << __FUNCTION__ << " " << __LINE__ << " " << "Mask detected, name is " << maskName << std::endl; // To access the data - VsH5Dataset* mask = registry->getDataset(maskName); + VsDataset* mask = registry->getDataset(maskName); // To access the attributes VsVariable* maskVar = registry->getVariable(maskName); if (!mask || !maskVar) { @@ -1591,20 +1591,20 @@ avtVsFileFormat::getUnstructuredMesh(VsUnstructuredMesh* unstructuredMesh, for( int i=0; igetPointsDataset(i); + VsDataset* pointDataset = unstructuredMesh->getPointsDataset(i); destMins[0] = i; - herr_t err = reader->getDataSet(pointDataset, dataPtr, - unstructuredMesh->getIndexOrder(), - -2, - &srcMins[0], &srcMaxs[0], &srcStrides[0], - 1, &destSize[0], - &destMins[0], &destMaxs[0], &destStrides[0] ); + herr_t err = reader->getData(pointDataset, dataPtr, + unstructuredMesh->getIndexOrder(), + -2, + &srcMins[0], &srcMaxs[0], &srcStrides[0], + 1, &destSize[0], + &destMins[0], &destMaxs[0], &destStrides[0]); if (err < 0) { VsLog::debugLog() << __CLASS__ <<"(" <getPointsDataset(); + VsDataset* pointsDataset = unstructuredMesh->getPointsDataset(); herr_t err; @@ -1660,17 +1660,17 @@ avtVsFileFormat::getUnstructuredMesh(VsUnstructuredMesh* unstructuredMesh, int srcMaxs[1] = {numNodes}; int srcStrides[1] = {strides[0]}; - err = reader->getDataSet( pointsDataset, dataPtr, - // -1 read all coordinate components - unstructuredMesh->getIndexOrder(), -1, - &(srcMins[0]), &(srcMaxs[0]), &(srcStrides[0]) ); + err = reader->getData( pointsDataset, dataPtr, + // -1 read all coordinate components + unstructuredMesh->getIndexOrder(), -1, + &(srcMins[0]), &(srcMaxs[0]), &(srcStrides[0]) ); } else - err = reader->getDataSet(pointsDataset, dataPtr); + err = reader->getData(pointsDataset, dataPtr); if (err < 0) { VsLog::debugLog() << __CLASS__ <<"(" <getDataset(connectivityDatasetName); std::vector connectivityDims = connectivityMeta->getDims(); @@ -1880,17 +1880,17 @@ avtVsFileFormat::getUnstructuredMesh(VsUnstructuredMesh* unstructuredMesh, int srcMaxs[1] = {numCells}; int srcStrides[1] = {strides[0]}; - err = reader->getDataSet( connectivityDataset, vertices, - // -1 read all coordinate components - unstructuredMesh->getIndexOrder(), -1, - &(srcMins[0]), &(srcMaxs[0]), &(srcStrides[0]) ); + err = reader->getData( connectivityDataset, vertices, + // -1 read all coordinate components + unstructuredMesh->getIndexOrder(), -1, + &(srcMins[0]), &(srcMaxs[0]), &(srcStrides[0]) ); } else - err = reader->getDataSet(connectivityDataset, vertices); + err = reader->getData(connectivityDataset, vertices); if (err < 0) { VsLog::debugLog() << __CLASS__ <<"(" <hasNodeCorrectionData()) { - VsH5Dataset* correctionDataset = registry->getDataset(unstructuredMesh->getNodeCorrectionDatasetName()); + VsDataset* correctionDataset = registry->getDataset(unstructuredMesh->getNodeCorrectionDatasetName()); if (correctionDataset) { correctionListSize = correctionDataset->getLength(); int* localToGlobalNodeMapping = new int[correctionListSize]; - reader->getDataSet(correctionDataset, localToGlobalNodeMapping); + reader->getData(correctionDataset, localToGlobalNodeMapping); //Build up a list of which global ids are "taken" by more than one node //And when that happens, remember the local ids that need to be mapped to the original local id @@ -2244,15 +2244,15 @@ vtkDataSet* avtVsFileFormat::getPointMesh(VsVariableWithMesh* variableWithMesh, destMins[0] = i; - VsH5Dataset* variableDataset = + VsDataset* variableDataset = registry->getDataset(variableWithMesh->getFullName()); - err = reader->getDataSet(variableDataset, dataPtr, - variableWithMesh->getIndexOrder(), - componentIndex, - &srcMins[0], &srcMaxs[0], &srcStrides[0], - 1, &destSize[0], - &destMins[0], &destMaxs[0], &destStrides[0] ); + err = reader->getData(variableDataset, dataPtr, + variableWithMesh->getIndexOrder(), + componentIndex, + &srcMins[0], &srcMaxs[0], &srcStrides[0], + 1, &destSize[0], + &destMins[0], &destMaxs[0], &destStrides[0]); if (err < 0) { VsLog::debugLog() << __CLASS__ <<"(" < meshDims; - meshMeta->getMeshDataDims(meshDims); + meshMeta->getCellDims(meshDims); int nPtsInMesh = meshDims[0]; if (varMeta->isZonal()) { if (nPts != (nPtsInMesh - 1)) { @@ -2683,7 +2683,7 @@ vtkDataArray* avtVsFileFormat::GetVar(int domain, const char* requestedName) // these two variables: VsVariable* meta = NULL; VsVariableWithMesh* vmMeta = NULL; - VsH5Dataset* variableDataset = NULL; + VsDataset* variableDataset = NULL; // It could be an MD variable if so, retrieve the md metadata, // look up the "real" variable name using the domain number, and @@ -2696,8 +2696,8 @@ vtkDataArray* avtVsFileFormat::GetVar(int domain, const char* requestedName) << "Found MD metadata for this name: " << name << std::endl; - if (0 <= domain && domain < mdMeta->blocks.size()) { - meta = mdMeta->blocks[domain]; + if (0 <= domain && domain < mdMeta->getNumBlocks()) { + meta = mdMeta->getBlock(domain); name = meta->getFullName(); if( meta ) @@ -2761,16 +2761,31 @@ vtkDataArray* avtVsFileFormat::GetVar(int domain, const char* requestedName) bool hasOffset = false; std::vector offset(3, 0); std::string indexOrder; + bool isEdge = false; + bool isFace = false; size_t numTopologicalDims; // VarWithMesh variable - Note that there is no mesh metadata for // VarWithMesh. if (vmMeta) { + VsLog::debugLog() << __CLASS__ <<"(" <getDims(); varType = vmMeta->getType(); isZonal = true; + std::string centering = vmMeta->getCentering(); + VsLog::debugLog() << __CLASS__ <<"(" <getDims(); varType = meta->getType(); @@ -2787,6 +2805,18 @@ vtkDataArray* avtVsFileFormat::GetVar(int domain, const char* requestedName) if (meta->isZonal()) isZonal = true; + + if (meta->isEdge()) + isEdge = true; + + if (meta->isFace()) + isFace = true; + + VsLog::debugLog() << __CLASS__ <<"(" <getDataSet(variableDataset, dataPtr, - indexOrder, componentIndex, - mins, &(vdims[0]), strides); + herr_t err = reader->getData(variableDataset, dataPtr, + indexOrder, componentIndex, + mins, &(vdims[0]), strides); if (err < 0) { VsLog::debugLog() @@ -2957,11 +2987,11 @@ vtkDataArray* avtVsFileFormat::GetVar(int domain, const char* requestedName) herr_t err; if( haveDataSelections ) - err = reader->getDataSet( variableDataset, dataPtr, - meta->getIndexOrder(), -2, // -2 no components - mins, &(vdims[0]), strides ); + err = reader->getData( variableDataset, dataPtr, + meta->getIndexOrder(), -2, // -2 no components + mins, &(vdims[0]), strides ); else - err = reader->getDataSet( variableDataset, dataPtr ); + err = reader->getData( variableDataset, dataPtr ); if (err < 0) { VsLog::debugLog() @@ -3018,8 +3048,19 @@ vtkDataArray* avtVsFileFormat::GetVar(int domain, const char* requestedName) rv = vtkIntArray::New(); } - //Attach offset information to array - if (hasOffset) { + if (isFace) { + vtkInformation* info = rv->GetInformation(); + info->Set(avtVariableCache::STAGGER(), "face"); + VsLog::debugLog() << __CLASS__ <<"(" <GetInformation(); + info->Set(avtVariableCache::STAGGER(), "edge"); + VsLog::debugLog() << __CLASS__ <<"(" <GetInformation(); info->Set(avtVariableCache::OFFSET_3(), offset[0], offset[1], offset[2]); VsLog::debugLog() << __CLASS__ <<"(" <(meta)->getNumMeshDims(dims); + static_cast(meta)->getNodeDims(dims); for( int i=0; igetNumMeshDims(dims); + rectMesh->getNodeDims(dims); for( int i=0; i(meta)->getNumMeshDims(dims); + static_cast(meta)->getNodeDims(dims); for( int i=0; i dims; - vMeta->getMeshDataDims(dims); + vMeta->getCellDims(dims); if (dims.size() <= 0) { std::ostringstream msg; msg << __CLASS__ <<"(" < void avtVsFileFormat::fillInMaskNodeArray(const std::vector& gdims, - VsH5Dataset *mask, + VsDataset *mask, bool maskIsFortranOrder, vtkUnsignedCharArray *maskedNodes) { int numPoints = gdims[0] * gdims[1] * gdims[2]; std::vector maskArray(numPoints); - herr_t err = reader->getDataSet(mask, &maskArray[0]); + herr_t err = reader->getData(mask, &maskArray[0]); unsigned char* mp = maskedNodes->GetPointer(0); if (err < 0) { VsLog::debugLog() << __CLASS__ <<"(" < #include -#include -//#include +#include +//#include #include #include #include @@ -42,7 +42,7 @@ class VsUniformMesh; class VsStructuredMesh; class VsRectilinearMesh; class VsRegistry; -class VsH5Reader; +class VsReader; /** * avtSTMDFileFormat is a base class for multi-domain, single-time @@ -163,7 +163,7 @@ class avtVsFileFormat: public avtSTMDFileFormat { std::string dataFileName; /** Pointer to the reader */ - VsH5Reader* reader; + VsReader* reader; /** Ensure data has been read **/ void LoadData(); @@ -236,7 +236,7 @@ class avtVsFileFormat: public avtSTMDFileFormat { template void fillInMaskNodeArray(const std::vector& gdims, - VsH5Dataset *mask, bool maskIsFortranOrder, + VsDataset *mask, bool maskIsFortranOrder, vtkUnsignedCharArray *maskedNodes); template