diff --git a/H5Fed/applications/gmsh2h5fed.cc b/H5Fed/applications/gmsh2h5fed.cc index 3d9b337..f020bae 100644 --- a/H5Fed/applications/gmsh2h5fed.cc +++ b/H5Fed/applications/gmsh2h5fed.cc @@ -123,7 +123,10 @@ int main(int argc, char **argv) // Vector for the gmshs tetrahedrons. std::vector > gmshTetrahedronTag; gmshTetrahedronTag.clear(); - + // Vector for the gmshs triangles. + std::vector > gmshTriangle; + gmshTriangle.clear(); + // Make an instance of the vtk class. gmsh gmshInFile; @@ -148,9 +151,9 @@ int main(int argc, char **argv) // Open H5Fed file for writing. Filename and file write access comes // from command line parameters. if (writeFileForce == false) - h5fedFile.open(hdf5fedOutputFile,FILE_CREATE); + h5fedFile.open(hdf5fedOutputFile,H5Fed::FILE_CREATE); else - h5fedFile.open(hdf5fedOutputFile,FILE_CREATE_FORCE); + h5fedFile.open(hdf5fedOutputFile,H5Fed::FILE_CREATE_FORCE); // Create the group hierarchie in the hdf5fed file. h5fedFile.createGroupHierarchie(); @@ -168,7 +171,6 @@ int main(int argc, char **argv) h5fedFile.wCoord3d(gmshNodes); // Every node in h5fed file, so we can save memory. gmshNodes.clear(); - //Get a vector with all tetrahedrons from gmsh file. gmshTetrahedron = gmshInFile.gmshTetrahedron(); for(int varI = 0; varI gmshTriangleBoundaryIndex; + gmshTriangleBoundaryIndex.resize(0,gmshTriangle.size()); + // Write the triangles to the h5fed file as level zero boundary, the + // first one. + h5fedFile.wTriangleB(0,0,gmshTriangle, gmshTriangleBoundaryIndex); + // Every triangle in h5fed file, so we can save memory. + gmshTriangle.clear(); + /* + for(int varI = 0; varI > elem; std::vector materialIndex; - // Read the tetrahedrons of the h5fed file an print them. - h5fedFile.rTetrahedron((unsigned int)0, elem, materialIndex); +/* h5fedFile.rTetrahedron((unsigned int)0, elem, materialIndex); for(int varI = 0; varI > coord; h5fedFile.rCoord3d(coord); @@ -132,6 +142,8 @@ int main(int argc, char **argv) coord[varI][1], coord[varI][2]); } + +*/ // Close H5Fed file. h5fedFile.close(); diff --git a/H5Fed/applications/h5feddump.hh b/H5Fed/applications/h5feddump.hh index a70cab5..de862e5 100644 --- a/H5Fed/applications/h5feddump.hh +++ b/H5Fed/applications/h5feddump.hh @@ -50,7 +50,7 @@ using namespace physicomath; using namespace nonsciconst; -using namespace H5Fed; +//using namespace H5Fed; //using namespace gmshtohdf5fed; #endif /*PHIDIAS3D_H_*/ diff --git a/H5Fed/libsrc/gmsh/gmsh.cc b/H5Fed/libsrc/gmsh/gmsh.cc index 54bf701..6a48ffa 100644 --- a/H5Fed/libsrc/gmsh/gmsh.cc +++ b/H5Fed/libsrc/gmsh/gmsh.cc @@ -373,3 +373,8 @@ std::vector< std::vector > gmsh::gmshTetrahedronTag() { return gmshTetrahedronTag_; } + +std::vector< std::vector > gmsh::gmshTriangle() +{ + return gmshTriangle_; +} diff --git a/H5Fed/libsrc/gmsh/gmsh.hh b/H5Fed/libsrc/gmsh/gmsh.hh index 629d754..c00a2bf 100644 --- a/H5Fed/libsrc/gmsh/gmsh.hh +++ b/H5Fed/libsrc/gmsh/gmsh.hh @@ -92,6 +92,7 @@ namespace gmshtohdf5fed std::vector gmshNodeNumber(); std::vector< std::vector > gmshTetrahedron(); std::vector< std::vector > gmshTetrahedronTag(); + std::vector< std::vector > gmshTriangle(); private: string fileName_; diff --git a/H5Fed/libsrc/h5fed/h5fed.hh b/H5Fed/libsrc/h5fed/h5fed.hh index f016bef..d44aa48 100644 --- a/H5Fed/libsrc/h5fed/h5fed.hh +++ b/H5Fed/libsrc/h5fed/h5fed.hh @@ -336,7 +336,7 @@ public: } }; - // Write 3dim coordinates to h5fed file. + // Read 3dim coordinates from h5fed file. int rCoord3d (std::vector >& coord) { // All these operations are only allowed, if there is a valid file @@ -457,7 +457,7 @@ public: { // Set the name of the dataset, we want to read. std::string datasetName = H5FED_D_TETMESH; - rElement_(datasetName, level, elem, materialIndex); + rElement_(datasetName, level, -1, elem, materialIndex); return OKCODE; }; @@ -473,17 +473,49 @@ public: // Select the data type in which the elements should be stored. hid_t dataType = H5FED_MESH_ELEM_DATATYPE; // This function does the real work for all elements. - wElement_(datasetName, level, elemDim, elem, materialIndex, dataType); + wElement_(datasetName, level, -1, elemDim, elem, materialIndex, dataType); return OKCODE; - } + int wTriangleB(unsigned int level, + unsigned int number, + std::vector< std::vector >& elem, + std::vector& boundaryIndex) + { + // Set dimension of an elements vector. + unsigned int elemDim = H5FED_TRIANGLE_N_NODE; + // Set the name of the dataset, we want to operate. + std::string datasetName = H5FED_D_TRIANGLEBOUNDARY; + // Select the data type in which the elements should be stored. + hid_t dataType = H5FED_MESH_ELEM_DATATYPE; + // This function does the real work for all elements. + wElement_(datasetName, level, (int)number, elemDim, elem, boundaryIndex, dataType); + return OKCODE; + } + + // Read and return boundary triangles and respective boundary index of the + // given level and number. + int rTriangleB(unsigned int level, + unsigned int number, + std::vector >& elem, + std::vector& boundaryIndex) + { + // Set the name of the dataset, we want to read. + std::string datasetName = H5FED_D_TRIANGLEBOUNDARY; + rElement_(datasetName, level, (int)number, elem, boundaryIndex); + return OKCODE; + }; + + // This function gets some attributes of the element, it should insert and // insert it to the given dataset. // Here we do the index mapping. // datasetNameBlank: the name of the elements dataset without the level! // (example: ../TETMESH_L) // level: the hierarchy level of the elements. + // number: if there are different meshes on the same level (i.e. for + // boudaries, they are numbered. For no numbering choose + // number < 0. // elemDim: the number of nodes a single element has (tet = 4, line = 2, ..) // elem: the outer vector contains all elements, // the inner vector contains the elements node numbers @@ -492,6 +524,7 @@ public: // the material index in the file. int wElement_(std::string datasetNameBlank, unsigned int level, + int number, unsigned int elemDim, std::vector< std::vector >& elem, std::vector& materialIndex, @@ -503,6 +536,10 @@ public: { // Make datasetName with the datasetNameBlank and the level. std::string datasetName = datasetNameBlank + stringify(level); + if (number >= 0) + { + datasetName = datasetName + "_K" + stringify(number); + } // Check if the dataset with the given datasetName already exists: // if it exists, abort; @@ -616,7 +653,8 @@ public: // Set the appropriate material list! // ===> This is not implementes yet! <=== // See warning above. - element[dim_out[1]-1] = materialIndex[varI]; +// element[dim_out[1]-1] = materialIndex[varI]; + element[dim_out[1]-1] = 0; // Select hyperslab ('region') in file dataspace. hdf5Status = H5Sselect_hyperslab(hdf5DataspaceId, H5S_SELECT_SET, @@ -658,12 +696,16 @@ public: // vetor of vectors and a vector. // datasetNameBlank: the name of the elements dataset without the level! // (example: ../TETMESH_L) - // level: the hierarchy level of the elements. + // level: the hierarchy level of the elements + // number: if there are different meshes on the same level (i.e. for + // boudaries, they are numbered. For no numbering choose + // number < 0. // elem: the outer vector gets all elements, // the inner vectors get the elements node numbers. // materialIndex: the material index to an elemen. int rElement_(std::string datasetNameBlank, unsigned int level, + int number, std::vector< std::vector >& elem, std::vector& materialIndex) { @@ -673,6 +715,10 @@ public: { // Make datasetName with the datasetNameBlank and the level. std::string datasetName = datasetNameBlank + stringify(level); + if (number >= 0) + { + datasetName = datasetName + "_K" + stringify(number); + } // Check if the dataset with the given datasetName exists: // if it does not return errorcode, else continue. diff --git a/H5Fed/libsrc/h5fed/h5fedconst.hh b/H5Fed/libsrc/h5fed/h5fedconst.hh index 66e8b2f..4a80f70 100644 --- a/H5Fed/libsrc/h5fed/h5fedconst.hh +++ b/H5Fed/libsrc/h5fed/h5fedconst.hh @@ -47,6 +47,7 @@ const std::string H5FED_D_PRISMATICMESH (H5FED_G_VOLUME_MESH+"/PRISMATICMESH_L" const std::string H5FED_D_PYRAMIDMESH (H5FED_G_VOLUME_MESH+"/PYRAMIDMESH_L"); const std::string H5FED_D_TRIANGLEMESH (H5FED_G_VOLUME_MESH+"/TRIANGLEMESH_L"); const std::string H5FED_D_QUADRANGLEMESH (H5FED_G_VOLUME_MESH+"/QUADRANGLEMESH_L"); +const std::string H5FED_D_TRIANGLEBOUNDARY (H5FED_G_BOUNDARY_MESH+"/BOUNDARY_TRIANGLE_L"); // How much nodes have a geometric figure. const unsigned short int H5FED_TET_N_NODE = 4;