From 967b0421971aa62a09013bd58c8aa5613afb2441 Mon Sep 17 00:00:00 2001 From: laurence <laurence> Date: Fri, 9 Aug 2013 12:24:55 +0100 Subject: [PATCH] ENH: Read Delaunay Mesh --- .../DelaunayMesh/DelaunayMesh.C | 91 +++++------ .../DelaunayMesh/DelaunayMeshIO.C | 32 ++-- .../cellShapeControlMesh.C | 149 ------------------ .../conformalVoronoiMesh.C | 2 +- 4 files changed, 60 insertions(+), 214 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.C index 18413046dac..3afdf9cf139 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.C @@ -70,47 +70,48 @@ Foam::DelaunayMesh<Triangulation>::DelaunayMesh ) ); - labelIOField types - ( - IOobject - ( - "types", - runTime.timeName(), - meshName, - runTime, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ) - ); - - labelIOField indices - ( - IOobject + if (pts.headerOk()) + { + labelIOField types ( - "indices", - runTime.timeName(), - meshName, - runTime, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ) - ); + IOobject + ( + "types", + runTime.timeName(), + meshName, + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); - labelIOField processorIndices - ( - IOobject +// Do not read in indices +// labelIOField indices +// ( +// IOobject +// ( +// "indices", +// runTime.timeName(), +// meshName, +// runTime, +// IOobject::MUST_READ, +// IOobject::NO_WRITE +// ) +// ); + + labelIOField processorIndices ( - "processorIndices", - runTime.timeName(), - meshName, - runTime, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ) - ); + IOobject + ( + "processorIndices", + runTime.timeName(), + meshName, + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); - if (pts.headerOk()) - { List<Vb> pointsToInsert(pts.size()); forAll(pointsToInsert, pI) @@ -119,17 +120,9 @@ Foam::DelaunayMesh<Triangulation>::DelaunayMesh Vb ( toPoint(pts[pI]), - (indices.headerOk() ? indices[pI] : -1), - ( - types.headerOk() - ? static_cast<indexedVertexEnum::vertexType>(types[pI]) - : Vb::vtInternal - ), - ( - processorIndices.headerOk() - ? processorIndices[pI] - : Pstream::myProcNo() - ) + pI, + static_cast<indexedVertexEnum::vertexType>(types[pI]), + processorIndices[pI] ); } @@ -140,6 +133,8 @@ Foam::DelaunayMesh<Triangulation>::DelaunayMesh false, false ); + + vertexCount_ = Triangulation::number_of_vertices(); } } diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshIO.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshIO.C index 1a341348b1a..33867a7be5b 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshIO.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshIO.C @@ -361,19 +361,19 @@ Foam::DelaunayMesh<Triangulation>::createMesh // Calculate pts and a map of point index to location in pts. label vertI = 0; - labelIOField indices - ( - IOobject - ( - "indices", - time().timeName(), - name, - time(), - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - Triangulation::number_of_vertices() - ); +// labelIOField indices +// ( +// IOobject +// ( +// "indices", +// time().timeName(), +// name, +// time(), +// IOobject::NO_READ, +// IOobject::AUTO_WRITE +// ), +// Triangulation::number_of_vertices() +// ); labelIOField types ( @@ -414,7 +414,7 @@ Foam::DelaunayMesh<Triangulation>::createMesh { vertexMap(labelPair(vit->index(), vit->procIndex())) = vertI; points[vertI] = topoint(vit->point()); - indices[vertI] = vit->index(); +// indices[vertI] = vit->index(); types[vertI] = static_cast<label>(vit->type()); processorIndices[vertI] = vit->procIndex(); vertI++; @@ -422,7 +422,7 @@ Foam::DelaunayMesh<Triangulation>::createMesh } points.setSize(vertI); - indices.setSize(vertI); +// indices.setSize(vertI); types.setSize(vertI); processorIndices.setSize(vertI); @@ -637,7 +637,7 @@ Foam::DelaunayMesh<Triangulation>::createMesh if (writeDelaunayData) { - indices.write(); +// indices.write(); types.write(); processorIndices.write(); } diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C index f51ff3c07ef..71ba6933fbb 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C @@ -451,155 +451,6 @@ Foam::cellShapeControlMesh::cellShapeControlMesh(const Time& runTime) } -//Foam::triangulatedMesh::triangulatedMesh -//( -// const Time& runTime, -// const fileName& pointsFile, -// const fileName& sizesFile, -// const fileName& alignmentsFile, -// const scalar& defaultCellSize -//) -//: -// defaultCellSize_(defaultCellSize) -//{ -// Info<< " Reading points from file : " << pointsFile << endl; -// -// pointIOField points -// ( -// IOobject -// ( -// pointsFile, -// runTime.constant(), -// runTime, -// IOobject::MUST_READ, -// IOobject::NO_WRITE -// ) -// ); -// -// Info<< " Reading sizes from file : " << sizesFile << endl; -// -// scalarIOField sizes -// ( -// IOobject -// ( -// sizesFile, -// runTime.constant(), -// runTime, -// IOobject::MUST_READ, -// IOobject::NO_WRITE -// ) -// ); -// -// Info<< " Reading alignments from file : " << alignmentsFile << endl; -// -// tensorIOField alignments -// ( -// IOobject -// ( -// alignmentsFile, -// runTime.constant(), -// runTime, -// IOobject::MUST_READ, -// IOobject::NO_WRITE -// ) -// ); -// -// Info<< " Number of points : " << points.size() << endl; -// Info<< " Minimum size : " << min(sizes) << endl; -// Info<< " Average size : " << average(sizes) << endl; -// Info<< " Maximum size : " << max(sizes) << endl; -// -// forAll(points, pI) -// { -// size_t nVert = number_of_vertices(); -// -// Vertex_handle v = insert -// ( -// Point(points[pI].x(), points[pI].y(), points[pI].z()) -// ); -// -// if (number_of_vertices() == nVert) -// { -// Info<< " Failed to insert point : " << points[pI] << endl; -// } -// -// v->targetCellSize() = sizes[pI]; -// -// const tensor& alignment = alignments[pI]; -// -// -// -// v->alignment() = alignment; -// } -// -//// scalar factor = 1.0; -//// label maxIteration = 1; -//// -//// for (label iteration = 0; iteration < maxIteration; ++iteration) -//// { -//// Info<< "Iteration : " << iteration << endl; -//// -//// label nRefined = refineTriangulation(factor); -//// -//// Info<< " Number of cells refined in refinement iteration : " -//// << nRefined << nl << endl; -//// -//// if (nRefined <= 0 && iteration != 0) -//// { -//// break; -//// } -//// -//// factor *= 1.5; -//// } -// -// //writeRefinementTriangulation(); -//} - - -//Foam::triangulatedMesh::triangulatedMesh -//( -// const Time& runTime, -// const DynamicList<Foam::point>& points, -// const DynamicList<scalar>& sizes, -// const DynamicList<tensor>& alignments, -// const scalar& defaultCellSize -//) -//: -// defaultCellSize_(defaultCellSize) -//{ -// forAll(points, pI) -// { -// size_t nVert = number_of_vertices(); -// -// Vertex_handle v = insert -// ( -// Point(points[pI].x(), points[pI].y(), points[pI].z()) -// ); -// -// if (number_of_vertices() == nVert) -// { -// Info<< "Failed to insert point : " << points[pI] << endl; -// } -// -// v->targetCellSize() = sizes[pI]; -// -// v->alignment() = alignments[pI]; -// } -// -// //writeRefinementTriangulation(); -// -// Info<< nl << "Refinement triangulation information: " << endl; -// Info<< " Number of vertices: " << label(number_of_vertices()) << endl; -// Info<< " Number of cells : " -// << label(number_of_finite_cells()) << endl; -// Info<< " Number of faces : " -// << label(number_of_finite_facets()) << endl; -// Info<< " Number of edges : " -// << label(number_of_finite_edges()) << endl; -// Info<< " Dimensionality : " << label(dimension()) << nl << endl; -//} - - // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::cellShapeControlMesh::~cellShapeControlMesh() diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 93dcd83436a..e80ac1818a5 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -528,7 +528,7 @@ void Foam::conformalVoronoiMesh::buildCellSizeAndAlignmentMesh() << (cellSizeMesh.is_valid() ? "valid" : "not valid!" ) << endl; - if (!Pstream::parRun() && foamyHexMeshControls().objOutput()) + if (foamyHexMeshControls().writeCellShapeControlMesh()) { //cellSizeMesh.writeTriangulation(); cellSizeMesh.write(); -- GitLab