ENH: added writeTetMesh control to dump tets

This commit is contained in:
mattijs
2011-06-24 16:14:41 +01:00
parent 4024c5bca6
commit 5e8b74ad09
5 changed files with 210 additions and 190 deletions

View File

@ -209,198 +209,198 @@ void Foam::conformalVoronoiMesh::calcDualMesh
} }
// void Foam::conformalVoronoiMesh::calcTetMesh void Foam::conformalVoronoiMesh::calcTetMesh
// ( (
// pointField& points, pointField& points,
// faceList& faces, faceList& faces,
// labelList& owner, labelList& owner,
// labelList& neighbour, labelList& neighbour,
// wordList& patchNames, wordList& patchTypes,
// labelList& patchSizes, wordList& patchNames,
// labelList& patchStarts labelList& patchSizes,
// ) labelList& patchStarts
// { )
// labelList vertexMap(number_of_vertices()); {
labelList vertexMap(number_of_vertices());
// label vertI = 0; label vertI = 0;
// points.setSize(number_of_vertices()); points.setSize(number_of_vertices());
// for for
// ( (
// Delaunay::Finite_vertices_iterator vit = finite_vertices_begin(); Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
// vit != finite_vertices_end(); vit != finite_vertices_end();
// ++vit ++vit
// ) )
// { {
// if (vit->internalPoint() || vit->pairPoint()) if (vit->internalPoint() || vit->pairPoint())
// { {
// vertexMap[vit->index()] = vertI; vertexMap[vit->index()] = vertI;
// points[vertI] = topoint(vit->point()); points[vertI] = topoint(vit->point());
// vertI++; vertI++;
// } }
// } }
// points.setSize(vertI); points.setSize(vertI);
// label cellI = 0; label cellI = 0;
// for for
// ( (
// Delaunay::Finite_cells_iterator cit = finite_cells_begin(); Delaunay::Finite_cells_iterator cit = finite_cells_begin();
// cit != finite_cells_end(); cit != finite_cells_end();
// ++cit ++cit
// ) )
// { {
// if (cit->internalOrBoundaryDualVertex()) if (cit->internalOrBoundaryDualVertex())
// { {
// cit->cellIndex() = cellI++; cit->cellIndex() = cellI++;
// } }
// else else
// { {
// cit->cellIndex() = -1; cit->cellIndex() = -1;
// } }
// } }
// patchNames = geometryToConformTo_.patchNames(); patchNames = geometryToConformTo_.patchNames();
// patchNames.setSize(patchNames.size() + 1); patchNames.setSize(patchNames.size() + 1);
// patchNames[patchNames.size() - 1] = "cvMesh_defaultPatch"; patchNames[patchNames.size() - 1] = "cvMesh_defaultPatch";
patchTypes.setSize(patchNames.size(), wallPolyPatch::typeName);
// label nPatches = patchNames.size(); label nPatches = patchNames.size();
// List<DynamicList<face> > patchFaces(nPatches, DynamicList<face>(0)); List<DynamicList<face> > patchFaces(nPatches, DynamicList<face>(0));
// List<DynamicList<label> > patchOwners(nPatches, DynamicList<label>(0)); List<DynamicList<label> > patchOwners(nPatches, DynamicList<label>(0));
// faces.setSize(number_of_facets()); faces.setSize(number_of_facets());
// owner.setSize(number_of_facets()); owner.setSize(number_of_facets());
// neighbour.setSize(number_of_facets()); neighbour.setSize(number_of_facets());
// label faceI = 0; label faceI = 0;
// labelList verticesOnTriFace(3, -1); labelList verticesOnTriFace(3, -1);
// face newFace(verticesOnTriFace); face newFace(verticesOnTriFace);
// for for
// ( (
// Delaunay::Finite_facets_iterator fit = finite_facets_begin(); Delaunay::Finite_facets_iterator fit = finite_facets_begin();
// fit != finite_facets_end(); fit != finite_facets_end();
// ++fit ++fit
// ) )
// { {
// const Cell_handle c1(fit->first); const Cell_handle c1(fit->first);
// const int oppositeVertex = fit->second; const int oppositeVertex = fit->second;
// const Cell_handle c2(c1->neighbor(oppositeVertex)); const Cell_handle c2(c1->neighbor(oppositeVertex));
// label c1I = c1->cellIndex(); label c1I = c1->cellIndex();
// label c2I = c2->cellIndex(); label c2I = c2->cellIndex();
// label ownerCell = -1; label ownerCell = -1;
// label neighbourCell = -1; label neighbourCell = -1;
// if (c1I == -1 && c2I == -1) if (c1I == -1 && c2I == -1)
// { {
// // Both tets are outside, skip // Both tets are outside, skip
// continue; continue;
// } }
// for (label i = 0; i < 3; i++) for (label i = 0; i < 3; i++)
// { {
// verticesOnTriFace[i] = vertexMap verticesOnTriFace[i] = vertexMap
// [ [
// c1->vertex(vertex_triple_index(oppositeVertex, i))->index() c1->vertex(vertex_triple_index(oppositeVertex, i))->index()
// ]; ];
// } }
// newFace = face(verticesOnTriFace); newFace = face(verticesOnTriFace);
// if (c1I == -1 || c2I == -1) if (c1I == -1 || c2I == -1)
// { {
// // Boundary face... // Boundary face...
// if (c1I == -1) if (c1I == -1)
// { {
// //... with c1 outside //... with c1 outside
// ownerCell = c2I; ownerCell = c2I;
// } }
// else else
// { {
// // ... with c2 outside // ... with c2 outside
// ownerCell = c1I; ownerCell = c1I;
// reverse(newFace); reverse(newFace);
// } }
// label patchIndex = geometryToConformTo_.findPatch label patchIndex = geometryToConformTo_.findPatch
// ( (
// newFace.centre(points) newFace.centre(points)
// ); );
// if (patchIndex == -1) if (patchIndex == -1)
// { {
// patchIndex = patchNames.size() - 1; patchIndex = patchNames.size() - 1;
// WarningIn("Foam::conformalVoronoiMesh::calcTetMesh") WarningIn("Foam::conformalVoronoiMesh::calcTetMesh")
// << "Tet face centre at " << nl << "Tet face centre at " << nl
// << newFace.centre(points) << nl << newFace.centre(points) << nl
// << "did not find a surface patch. Adding to " << "did not find a surface patch. Adding to "
// << patchNames[patchIndex] << patchNames[patchIndex]
// << endl; << endl;
// } }
// patchFaces[patchIndex].append(newFace); patchFaces[patchIndex].append(newFace);
// patchOwners[patchIndex].append(ownerCell); patchOwners[patchIndex].append(ownerCell);
// } }
// else else
// { {
// // Internal face... // Internal face...
// if (c1I < c2I) if (c1I < c2I)
// { {
// // ...with c1 as the ownerCell // ...with c1 as the ownerCell
// ownerCell = c1I; ownerCell = c1I;
// neighbourCell = c2I; neighbourCell = c2I;
// reverse(newFace); reverse(newFace);
// } }
// else else
// { {
// // ...with c2 as the ownerCell // ...with c2 as the ownerCell
// ownerCell = c2I; ownerCell = c2I;
// neighbourCell = c1I; neighbourCell = c1I;
// } }
// faces[faceI] = newFace; faces[faceI] = newFace;
// owner[faceI] = ownerCell; owner[faceI] = ownerCell;
// neighbour[faceI] = neighbourCell; neighbour[faceI] = neighbourCell;
// faceI++; faceI++;
// } }
// } }
// label nInternalFaces = faceI; label nInternalFaces = faceI;
// faces.setSize(nInternalFaces); faces.setSize(nInternalFaces);
// owner.setSize(nInternalFaces); owner.setSize(nInternalFaces);
// neighbour.setSize(nInternalFaces); neighbour.setSize(nInternalFaces);
// sortFaces(faces, owner, neighbour); sortFaces(faces, owner, neighbour);
// addPatches addPatches
// ( (
// nInternalFaces, nInternalFaces,
// faces, faces,
// owner, owner,
// patchNames, patchSizes,
// patchSizes, patchStarts,
// patchStarts, patchFaces,
// patchFaces, patchOwners
// patchOwners, );
// false }
// );
// }
void Foam::conformalVoronoiMesh::mergeCloseDualVertices void Foam::conformalVoronoiMesh::mergeCloseDualVertices

View File

@ -238,43 +238,49 @@ void Foam::conformalVoronoiMesh::writeMesh
{ {
writeInternalDelaunayVertices(instance); writeInternalDelaunayVertices(instance);
// { if (cvMeshControls().writeTetMesh())
// pointField points; {
// faceList faces; pointField points;
// labelList owner; faceList faces;
// labelList neighbour; labelList owner;
// wordList patchNames; labelList neighbour;
// labelList patchSizes; wordList patchTypes;
// labelList patchStarts; wordList patchNames;
// pointField cellCentres; labelList patchSizes;
labelList patchStarts;
pointField cellCentres;
// calcTetMesh calcTetMesh
// ( (
// points, points,
// faces, faces,
// owner, owner,
// neighbour, neighbour,
// patchNames, patchTypes,
// patchSizes, patchNames,
// patchStarts patchSizes,
// ); patchStarts
);
labelList procNeighbours(patchNames.size(), -1);
// Info<< nl << "Writing tetDualMesh to " << instance << endl; Info<< nl << "Writing tetDualMesh to " << instance << endl;
// writeMesh writeMesh
// ( (
// "tetDualMesh", "tetDualMesh",
// instance, instance,
// points, points,
// faces, faces,
// owner, owner,
// neighbour, neighbour,
// patchNames, patchTypes,
// patchSizes, patchNames,
// patchStarts, patchSizes,
// cellCentres patchStarts,
// ); procNeighbours,
// } cellCentres
);
}
{ {
pointField points; pointField points;

View File

@ -271,6 +271,8 @@ Foam::cvControls::cvControls
const dictionary& filteringDict(cvMeshDict_.subDict("polyMeshFiltering")); const dictionary& filteringDict(cvMeshDict_.subDict("polyMeshFiltering"));
writeTetMesh_ = Switch(filteringDict.lookup("writeTetMesh"));
filterSizeCoeff_ = readScalar filterSizeCoeff_ = readScalar
( (
filteringDict.lookup("filterSizeCoeff") filteringDict.lookup("filterSizeCoeff")

View File

@ -218,6 +218,9 @@ class cvControls
// polyMesh filtering controls // polyMesh filtering controls
//- Write tet mesh at output time (it always writes the Voronoi)
Switch writeTetMesh_;
//- Upper limit on the size of faces to be filtered from, //- Upper limit on the size of faces to be filtered from,
// fraction of the local target cell size // fraction of the local target cell size
scalar filterSizeCoeff_; scalar filterSizeCoeff_;
@ -383,6 +386,9 @@ public:
//- Return removalDistCoeff //- Return removalDistCoeff
inline scalar removalDistCoeff() const; inline scalar removalDistCoeff() const;
//- Write tetMesh at output time
inline Switch writeTetMesh() const;
//- Return the filterSizeCoeff //- Return the filterSizeCoeff
inline scalar filterSizeCoeff() const; inline scalar filterSizeCoeff() const;

View File

@ -139,6 +139,12 @@ inline Foam::scalar Foam::cvControls::removalDistCoeff() const
} }
inline Foam::Switch Foam::cvControls::writeTetMesh() const
{
return writeTetMesh_;
}
inline Foam::scalar Foam::cvControls::filterSizeCoeff() const inline Foam::scalar Foam::cvControls::filterSizeCoeff() const
{ {
return filterSizeCoeff_; return filterSizeCoeff_;