H5Fed: Add function for triangle boundary.
This commit is contained in:
@@ -123,7 +123,10 @@ int main(int argc, char **argv)
|
||||
// Vector for the gmshs tetrahedrons.
|
||||
std::vector<std::vector<unsigned int> > gmshTetrahedronTag;
|
||||
gmshTetrahedronTag.clear();
|
||||
|
||||
// Vector for the gmshs triangles.
|
||||
std::vector<std::vector<unsigned int> > 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<gmshTetrahedron.size(); varI++)
|
||||
@@ -189,7 +191,22 @@ int main(int argc, char **argv)
|
||||
// rDebug("Elem: %d Nodes: %d; %d", varI, gmshTetrahedronTag[varI][0], gmshTetrahedronTag[varI][1]);
|
||||
}
|
||||
|
||||
|
||||
//Get a vector with all triangles from gmsh file.
|
||||
gmshTriangle = gmshInFile.gmshTriangle();
|
||||
// Boundary Index
|
||||
std::vector<unsigned int> 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<gmshTriangle.size(); varI++)
|
||||
{
|
||||
rDebug("Triangle: %d Nodes: %d; %d; %d; ", varI, gmshTriangle[varI][0], gmshTriangle[varI][1], gmshTriangle[varI][2]);
|
||||
}
|
||||
*/
|
||||
|
||||
// End with the automatic index mapping because we have no further actcion
|
||||
// with an gmsh file index.
|
||||
|
||||
@@ -100,15 +100,14 @@ int main(int argc, char **argv)
|
||||
|
||||
// Open H5Fed file for reading. Filename comes from
|
||||
// command line parameters.
|
||||
h5fedFile.open(hdf5fedFile,FILE_READ);
|
||||
h5fedFile.open(hdf5fedFile,H5Fed::FILE_READ);
|
||||
|
||||
// Vector for the tetrahedorn nodes and the material tag.
|
||||
std::vector< std::vector<unsigned int> > elem;
|
||||
std::vector<unsigned int> 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<elem.size(); varI++)
|
||||
{
|
||||
rDebug("Tet number: %d; nodes: %d %d; %d %d; material index: %d",
|
||||
@@ -119,8 +118,19 @@ int main(int argc, char **argv)
|
||||
elem[varI][3],
|
||||
materialIndex[varI]);
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
// Read the boundary trianglel of the h5fed file an print them.
|
||||
h5fedFile.rTriangleB((unsigned int)0, (unsigned int) 0, elem, materialIndex);
|
||||
for(int varI = 0; varI<elem.size(); varI++)
|
||||
{
|
||||
rDebug("Triangle number: %d; nodes: %d %d; %d; material index: %d",
|
||||
varI,
|
||||
elem[varI][0],
|
||||
elem[varI][1],
|
||||
elem[varI][2],
|
||||
materialIndex[varI]);
|
||||
}
|
||||
/*
|
||||
// Read the 3d coordinates of the h5fed file an print them.
|
||||
std::vector<std::vector< double> > 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();
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
using namespace physicomath;
|
||||
using namespace nonsciconst;
|
||||
using namespace H5Fed;
|
||||
//using namespace H5Fed;
|
||||
//using namespace gmshtohdf5fed;
|
||||
|
||||
#endif /*PHIDIAS3D_H_*/
|
||||
|
||||
@@ -373,3 +373,8 @@ std::vector< std::vector<unsigned int> > gmsh::gmshTetrahedronTag()
|
||||
{
|
||||
return gmshTetrahedronTag_;
|
||||
}
|
||||
|
||||
std::vector< std::vector<unsigned int> > gmsh::gmshTriangle()
|
||||
{
|
||||
return gmshTriangle_;
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ namespace gmshtohdf5fed
|
||||
std::vector<unsigned int> gmshNodeNumber();
|
||||
std::vector< std::vector<unsigned int> > gmshTetrahedron();
|
||||
std::vector< std::vector<unsigned int> > gmshTetrahedronTag();
|
||||
std::vector< std::vector<unsigned int> > gmshTriangle();
|
||||
|
||||
private:
|
||||
string fileName_;
|
||||
|
||||
@@ -336,7 +336,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// Write 3dim coordinates to h5fed file.
|
||||
// Read 3dim coordinates from h5fed file.
|
||||
int rCoord3d (std::vector<std::vector<double> >& 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<unsigned int> >& elem,
|
||||
std::vector<unsigned int>& 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<std::vector<unsigned int> >& elem,
|
||||
std::vector<unsigned int>& 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<unsigned int> >& elem,
|
||||
std::vector<unsigned int>& 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<unsigned int> >& elem,
|
||||
std::vector<unsigned int>& 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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user