From 20407ca628bc72394bad03ec76807b606b563d4f Mon Sep 17 00:00:00 2001 From: graham Date: Wed, 5 Aug 2009 15:27:06 +0100 Subject: [PATCH] Moved vertex size and alignment setting to an external function. Still needs to have a stored point rebuild mechanism. Added functions to decide when and how to rebuild and store the surface conformation. conformToSurface is now private, so only move can be called from outside the conformalVoronoiMesh class. --- .../utilities/mesh/generation/cvMesh/cvMesh.C | 2 - .../conformalVoronoiMesh.C | 694 +++++++++--------- .../conformalVoronoiMesh.H | 32 +- 3 files changed, 395 insertions(+), 333 deletions(-) diff --git a/applications/utilities/mesh/generation/cvMesh/cvMesh.C b/applications/utilities/mesh/generation/cvMesh/cvMesh.C index 6fad72474c..d8782c4f73 100644 --- a/applications/utilities/mesh/generation/cvMesh/cvMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/cvMesh.C @@ -62,8 +62,6 @@ int main(int argc, char *argv[]) Info<< nl << "Time = " << runTime.timeName() << endl; mesh.move(); - - // mesh.conformToSurface(); } mesh.writeMesh(); diff --git a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index f2b04c14eb..a810c335dd 100644 --- a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -104,9 +104,7 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh insertInitialPoints(); - conformToSurface(); - - storeSurfaceConformation(); + buildSurfaceConformation(COARSE); if(cvMeshControls().objOutput()) { @@ -908,6 +906,358 @@ Foam::conformalVoronoiMesh::sizeAndAlignmentTree() const return sizeAndAlignmentTree_(); } +void Foam::conformalVoronoiMesh::setVertexSizeAndAlignment() +{ + Info<< nl << " Looking up target cell alignment and size" << endl; + + scalar spanSqr = cvMeshControls().spanSqr(); + + const indexedOctree& tree = sizeAndAlignmentTree(); + + for + ( + Triangulation::Finite_vertices_iterator vit = finite_vertices_begin(); + vit != finite_vertices_end(); + vit++ + ) + { + if (vit->internalOrBoundaryPoint()) + { + point pt(topoint(vit->point())); + + pointIndexHit info = tree.findNearest(pt, spanSqr); + + vit->alignment() = storedAlignments_[info.index()]; + + vit->targetCellSize() = storedSizes_[info.index()]; + } + } + + // Info<< nl << " Calculating target cell alignment and size" << endl; + + // for + // ( + // Triangulation::Finite_vertices_iterator vit = finite_vertices_begin(); + // vit != finite_vertices_end(); + // vit++ + // ) + // { + // if (vit->internalOrBoundaryPoint()) + // { + // point pt(topoint(vit->point())); + + // vit->alignment() = requiredAlignment(pt); + + // vit->targetCellSize() = targetCellSize(pt); + // } + // } +} + + +void Foam::conformalVoronoiMesh::conformToSurface() +{ + reconformationMode reconfMode = reconformationControl(); + + if (reconfMode == NONE) + { + // Reinsert stored surface conformation + reinsertSurfaceConformation(); + } + else + { + // Rebuild, insert and store new surface conformation + buildSurfaceConformation(reconfMode); + } +} + +Foam::conformalVoronoiMesh::reconformationMode +Foam::conformalVoronoiMesh::reconformationControl() const +{ + if (!runTime_.run()) + { + Info<< nl << " Rebuilding surface conformation for final output" + << endl; + + return FINE; + } + else if(runTime_.timeIndex() % 10 == 0) + { + Info<< nl << " Rebuilding surface conformation " + << "HARD CODED TO EVERY 10 STEPS" << endl; + + return COARSE; + } + + return NONE; +} + +void Foam::conformalVoronoiMesh::buildSurfaceConformation +( + reconformationMode reconfMode +) +{ + Info<< nl << " Build surface conformation with option " + << reconfMode << endl; + + timeCheck(); + + startOfSurfacePointPairs_ = number_of_vertices(); + + // Initialise containers to store the edge conformation locations + DynamicList newEdgeLocations; + + pointField existingEdgeLocations(0); + + autoPtr > edgeLocationTree; + + // Initialise the edgeLocationTree + buildEdgeLocationTree(edgeLocationTree, existingEdgeLocations); + + label initialTotalHits = 0; + + // Initial surface protrusion conformation - nearest surface point + { + Info<< " EDGE DISTANCE COEFFS HARD-CODED." << endl; + scalar edgeSearchDistCoeffSqr = sqr(1.1); + scalar surfacePtReplaceDistCoeffSqr = sqr(0.5); + + DynamicList surfaceHits; + DynamicList