From b125db9ecbb585e3c94bfebc1855d6ff1df36c7c Mon Sep 17 00:00:00 2001 From: laurence Date: Tue, 5 Feb 2013 14:47:50 +0000 Subject: [PATCH] ENH: cvMesh: Enable use of regions in conformationSurfaces. Make cell sizing relative to default. --- .../cvMesh/checkCvMesh/meshQualityDict | 73 --- .../cellShapeControl/cellShapeControl.C | 12 +- .../cellShapeControl/cellShapeControl.H | 3 +- .../cellSizeAndAlignmentControl.C | 12 +- .../cellSizeAndAlignmentControl.H | 21 +- .../cellSizeAndAlignmentControls.C | 45 +- .../cellSizeAndAlignmentControls.H | 4 +- .../fileControl/fileControl.C | 11 +- .../fileControl/fileControl.H | 10 +- .../searchableSurfaceControl.C | 512 +++++------------- .../searchableSurfaceControl.H | 22 +- .../cellSizeFunction/cellSizeFunction.C | 18 +- .../cellSizeFunction/cellSizeFunction.H | 13 +- .../linearDistance/linearDistance.C | 18 +- .../linearDistance/linearDistance.H | 5 +- .../linearSpatial/linearSpatial.C | 13 +- .../linearSpatial/linearSpatial.H | 5 +- .../surfaceOffsetLinearDistance.C | 51 +- .../surfaceOffsetLinearDistance.H | 5 +- .../cellSizeFunction/uniform/uniform.C | 7 +- .../cellSizeFunction/uniform/uniform.H | 5 +- .../uniformDistance/uniformDistance.C | 12 +- .../uniformDistance/uniformDistance.H | 5 +- .../automatic/automatic.C | 21 +- .../automatic/automatic.H | 7 +- .../cellSizeCalculationType.C | 15 +- .../cellSizeCalculationType.H | 15 +- .../fieldFromFile/fieldFromFile.C | 13 +- .../fieldFromFile/fieldFromFile.H | 5 +- .../nonUniformField/nonUniformField.C | 24 +- .../nonUniformField/nonUniformField.H | 5 +- .../surfaceCellSizeFunction.C | 13 +- .../surfaceCellSizeFunction.H | 15 +- .../uniformValue/uniformValue.C | 18 +- .../uniformValue/uniformValue.H | 5 +- .../conformalVoronoiMesh.C | 4 +- .../conformalVoronoiMeshCalcDualMesh.C | 19 +- .../conformationSurfaces.C | 440 +++++++++------ .../conformationSurfaces.H | 38 +- .../conformationSurfacesI.H | 15 +- .../cvControls/cvControls.C | 3 +- 41 files changed, 754 insertions(+), 803 deletions(-) delete mode 100644 applications/utilities/mesh/generation/cvMesh/checkCvMesh/meshQualityDict diff --git a/applications/utilities/mesh/generation/cvMesh/checkCvMesh/meshQualityDict b/applications/utilities/mesh/generation/cvMesh/checkCvMesh/meshQualityDict deleted file mode 100644 index fa5319e087..0000000000 --- a/applications/utilities/mesh/generation/cvMesh/checkCvMesh/meshQualityDict +++ /dev/null @@ -1,73 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ - -FoamFile -{ - version 2.0; - format ascii; - - root ""; - case ""; - instance ""; - local ""; - - class dictionary; - object meshQualityDict; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -//- Maximum non-orthogonality allowed. Set to 180 to disable. -maxNonOrtho 65; - -//- Max skewness allowed. Set to <0 to disable. -maxBoundarySkewness 50; -maxInternalSkewness 10; - -//- Max concaveness allowed. Is angle (in degrees) below which concavity -// is allowed. 0 is straight face, <0 would be convex face. -// Set to 180 to disable. -maxConcave 80; - -//- Minimum quality of the tet formed by the face-centre -// and variable base point minimum decomposition triangles and -// the cell centre. This has to be a positive number for tracking -// to work. Set to very negative number (e.g. -1E30) to -// disable. -// <0 = inside out tet, -// 0 = flat tet -// 1 = regular tet -minTetQuality 1e-30; - -//- Minimum pyramid volume. Is absolute volume of cell pyramid. -// Set to a sensible fraction of the smallest cell volume expected. -// Set to very negative number (e.g. -1E30) to disable. -minVol 1e-20; - -//- Minimum face area. Set to <0 to disable. -minArea -1; - -//- Minimum face twist. Set to <-1 to disable. dot product of face normal -//- and face centre triangles normal -minTwist 0.001; - -//- minimum normalised cell determinant -//- 1 = hex, <= 0 = folded or flattened illegal cell -minDeterminant 0.001; - -//- minFaceWeight (0 -> 0.5) -minFaceWeight 0.02; - -//- minVolRatio (0 -> 1) -minVolRatio 0.01; - -//must be >0 for Fluent compatibility -minTriangleTwist -1; - - -// ************************************************************************* // diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControl/cellShapeControl.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControl/cellShapeControl.C index 444a0a4bf0..273ee4033f 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControl/cellShapeControl.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControl/cellShapeControl.C @@ -47,23 +47,23 @@ defineTypeNameAndDebug(cellShapeControl, 0); Foam::cellShapeControl::cellShapeControl ( const Time& runTime, - const dictionary& motionDict, + const cvControls& cvMeshControls, const searchableSurfaces& allGeometry, const conformationSurfaces& geometryToConformTo ) : - dictionary(motionDict), + dictionary(cvMeshControls.cvMeshDict().subDict("motionControl")), runTime_(runTime), allGeometry_(allGeometry), geometryToConformTo_(geometryToConformTo), - defaultCellSize_(readScalar(lookup("defaultCellSize"))), - minimumCellSize_(readScalar(lookup("minimumCellSize"))), + defaultCellSize_(cvMeshControls.defaultCellSize()), + minimumCellSize_(cvMeshControls.minimumCellSize()), shapeControlMesh_(runTime), - aspectRatio_(motionDict), + aspectRatio_(*this), sizeAndAlignment_ ( runTime, - motionDict.subDict("shapeControlFunctions"), + subDict("shapeControlFunctions"), geometryToConformTo_, defaultCellSize_ ) diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControl/cellShapeControl.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControl/cellShapeControl.H index 5c59f648e5..a25d5b8fe7 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControl/cellShapeControl.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControl/cellShapeControl.H @@ -48,6 +48,7 @@ SourceFiles #include "cellSizeAndAlignmentControls.H" #include "cellShapeControlMesh.H" #include "backgroundMeshDecomposition.H" +#include "cvControls.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -104,7 +105,7 @@ public: cellShapeControl ( const Time& runTime, - const dictionary& cellShapeControlDict, + const cvControls& cvMeshControls, const searchableSurfaces& allGeometry, const conformationSurfaces& geometryToConformTo ); diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.C index 29ff61cc27..8cb71a738f 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.C @@ -46,10 +46,12 @@ Foam::cellSizeAndAlignmentControl::cellSizeAndAlignmentControl const Time& runTime, const word& name, const dictionary& controlFunctionDict, - const conformationSurfaces& geometryToConformTo + const conformationSurfaces& geometryToConformTo, + const scalar& defaultCellSize ) : runTime_(runTime), + defaultCellSize_(defaultCellSize), name_(name) {} @@ -62,7 +64,8 @@ Foam::cellSizeAndAlignmentControl::New const Time& runTime, const word& name, const dictionary& controlFunctionDict, - const conformationSurfaces& geometryToConformTo + const conformationSurfaces& geometryToConformTo, + const scalar& defaultCellSize ) { word cellSizeAndAlignmentControlTypeName @@ -70,7 +73,7 @@ Foam::cellSizeAndAlignmentControl::New controlFunctionDict.lookup("type") ); - Info<< " Selecting cellSizeAndAlignmentControl " + Info<< indent << "Selecting cellSizeAndAlignmentControl " << cellSizeAndAlignmentControlTypeName << endl; dictionaryConstructorTable::iterator cstrIter = @@ -99,7 +102,8 @@ Foam::cellSizeAndAlignmentControl::New runTime, name, controlFunctionDict, - geometryToConformTo + geometryToConformTo, + defaultCellSize ) ); } diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.H index 1f8fd878bc..48aede84fd 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.H @@ -57,6 +57,8 @@ protected: const Time& runTime_; + const scalar& defaultCellSize_; + private: @@ -91,9 +93,16 @@ public: const Time& runTime, const word& name, const dictionary& controlFunctionDict, - const conformationSurfaces& geometryToConformTo + const conformationSurfaces& geometryToConformTo, + const scalar& defaultCellSize ), - (runTime, name, controlFunctionDict, geometryToConformTo) + ( + runTime, + name, + controlFunctionDict, + geometryToConformTo, + defaultCellSize + ) ); @@ -106,7 +115,8 @@ public: const Time& runTime, const word& name, const dictionary& controlFunctionDict, - const conformationSurfaces& geometryToConformTo + const conformationSurfaces& geometryToConformTo, + const scalar& defaultCellSize ); @@ -118,7 +128,8 @@ public: const Time& runTime, const word& name, const dictionary& controlFunctionDict, - const conformationSurfaces& geometryToConformTo + const conformationSurfaces& geometryToConformTo, + const scalar& defaultCellSize ); @@ -135,8 +146,6 @@ public: return name_; } - virtual label priority() const = 0; - // Query diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControls.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControls.C index d793bba878..b511798fb7 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControls.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControls.C @@ -63,43 +63,10 @@ bool Foam::cellSizeAndAlignmentControls::evalCellSizeFunctions if (debug) { - Info<< "size function " - << sSC.name() - << " priority " << sSC.priority() - << endl; + Info<< "size function " << sSC.name() << endl; } - if (sSC.priority() < previousPriority) - { - return minSize; - } - - scalar sizeI; - - if (sSC.sizeFunction().cellSize(pt, sizeI)) - { - anyFunctionFound = true; - - if (sSC.priority() == previousPriority) - { - if (sizeI < minSize) - { - minSize = sizeI; - } - } - else - { - minSize = sizeI; - } - - if (debug) - { - Info<< "sizeI " << sizeI - <<" minSize " << minSize << endl; - } - - previousPriority = sSC.priority(); - } + anyFunctionFound = sSC.cellSize(pt, minSize, previousPriority); } } } @@ -115,7 +82,7 @@ Foam::cellSizeAndAlignmentControls::cellSizeAndAlignmentControls const Time& runTime, const dictionary& shapeControlDict, const conformationSurfaces& geometryToConformTo, - const scalar defaultCellSize + const scalar& defaultCellSize ) : shapeControlDict_(shapeControlDict), @@ -135,6 +102,7 @@ Foam::cellSizeAndAlignmentControls::cellSizeAndAlignmentControls ); Info<< nl << "Shape Control : " << shapeControlEntryName << endl; + Info<< incrIndent; controlFunctions_.set ( @@ -144,10 +112,13 @@ Foam::cellSizeAndAlignmentControls::cellSizeAndAlignmentControls runTime, shapeControlEntryName, controlFunctionDict, - geometryToConformTo + geometryToConformTo_, + defaultCellSize_ ) ); + Info<< decrIndent; + functionI++; } } diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControls.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControls.H index 7afa3ff82a..e2d9409401 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControls.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControls.H @@ -56,7 +56,7 @@ class cellSizeAndAlignmentControls PtrList controlFunctions_; - const scalar defaultCellSize_; + const scalar& defaultCellSize_; // Private Member Functions @@ -84,7 +84,7 @@ public: const Time& runTime, const dictionary& shapeControlDict, const conformationSurfaces& geometryToConformTo, - const scalar defaultCellSize + const scalar& defaultCellSize ); diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/fileControl/fileControl.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/fileControl/fileControl.C index 63ac5960a1..9ff3747dba 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/fileControl/fileControl.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/fileControl/fileControl.C @@ -58,7 +58,8 @@ Foam::fileControl::fileControl const Time& runTime, const word& name, const dictionary& controlFunctionDict, - const conformationSurfaces& geometryToConformTo + const conformationSurfaces& geometryToConformTo, + const scalar& defaultCellSize ) : cellSizeAndAlignmentControl @@ -66,14 +67,14 @@ Foam::fileControl::fileControl runTime, name, controlFunctionDict, - geometryToConformTo + geometryToConformTo, + defaultCellSize ), pointsFile_(controlFunctionDict.lookup("pointsFile")), sizesFile_(controlFunctionDict.lookup("sizesFile")), - alignmentsFile_(controlFunctionDict.lookup("alignmentsFile")), - priority_(readLabel(controlFunctionDict.lookup("priority"))) + alignmentsFile_(controlFunctionDict.lookup("alignmentsFile")) { - Info<< indent << "Loading from file... " << nl + Info<< indent << "Loading " << name << " from file:" << nl << indent << " points : " << pointsFile_ << nl << indent << " sizes : " << sizesFile_ << nl << indent << " alignments : " << alignmentsFile_ diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/fileControl/fileControl.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/fileControl/fileControl.H index 93c631e90e..4081c3ab3a 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/fileControl/fileControl.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/fileControl/fileControl.H @@ -58,8 +58,6 @@ class fileControl const fileName alignmentsFile_; - label priority_; - // Private Member Functions @@ -85,7 +83,8 @@ public: const Time& runTime, const word& name, const dictionary& controlFunctionDict, - const conformationSurfaces& geometryToConformTo + const conformationSurfaces& geometryToConformTo, + const scalar& defaultCellSize ); //- Destructor @@ -121,11 +120,6 @@ public: scalarField& sizes, triadField& alignments ) const; - - virtual label priority() const - { - return priority_; - } }; diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/searchableSurfaceControl/searchableSurfaceControl.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/searchableSurfaceControl/searchableSurfaceControl.C index 72251e88ce..8e6dac42b2 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/searchableSurfaceControl/searchableSurfaceControl.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/searchableSurfaceControl/searchableSurfaceControl.C @@ -158,7 +158,8 @@ Foam::searchableSurfaceControl::searchableSurfaceControl const Time& runTime, const word& name, const dictionary& controlFunctionDict, - const conformationSurfaces& geometryToConformTo + const conformationSurfaces& geometryToConformTo, + const scalar& defaultCellSize ) : cellSizeAndAlignmentControl @@ -166,174 +167,91 @@ Foam::searchableSurfaceControl::searchableSurfaceControl runTime, name, controlFunctionDict, - geometryToConformTo + geometryToConformTo, + defaultCellSize ), surfaceName_(controlFunctionDict.lookupOrDefault("surface", name)), searchableSurface_(geometryToConformTo.geometry()[surfaceName_]), geometryToConformTo_(geometryToConformTo), - cellSizeFunction_ - ( - cellSizeFunction::New(controlFunctionDict, searchableSurface_) - ) -// geometryToConformTo_(geometryToConformTo), -// surfaces_(), -// cellSizeFunctions_(), -// triangulatedMesh_() + cellSizeFunctions_(1), + maxPriority_(-1) { -// const dictionary& surfacesDict = coeffDict(); -// -// Info<< nl << "Reading cellSizeControlGeometry" << endl; -// -// surfaces_.setSize(surfacesDict.size()); -// -// cellSizeFunctions_.setSize(surfacesDict.size()); -// -// label surfI = 0; -// -// DynamicList pointsToInsert; -// DynamicList sizesToInsert; -// DynamicList alignmentsToInsert; -// -// forAllConstIter(dictionary, surfacesDict, iter) -// { -// const dictionary& surfaceSubDict -// ( -// surfacesDict.subDict(iter().keyword()) -// ); -// -// // If the "surface" keyword is not found in the dictionary, assume -// // the name of the dictionary is the surface. Distinction required to -// // allow the same surface to be used multiple times to supply multiple -// // cellSizeFunctions -// -// word surfaceName = surfaceSubDict.lookupOrDefault -// ( -// "surface", -// iter().keyword() -// ); -// -// surfaces_[surfI] = allGeometry_.findSurfaceID(surfaceName); -// -// if (surfaces_[surfI] < 0) -// { -// FatalErrorIn -// ( -// "Foam::surfaceControl::surfaceControl" -// ) << "No surface " << surfaceName << " found. " -// << "Valid geometry is " << nl << allGeometry_.names() -// << exit(FatalError); -// } -// -// const searchableSurface& surface = allGeometry_[surfaces_[surfI]]; -// -// Info<< nl << " " << iter().keyword() << nl -// << " surface: " << surfaceName << nl -// << " size : " << surface.size() << endl; -// -// cellSizeFunctions_.set -// ( -// surfI, -// cellSizeFunction::New -// ( -// surfaceSubDict, -// surface -// ) -// ); -// -// surfI++; -// -// if (isA(surface)) -// { -// const triSurfaceMesh& tsm -// = refCast(surface); -// -// const pointField& points = tsm.points(); -// const vectorField& faceNormals = tsm.faceNormals(); -// const labelListList& pointFaces = tsm.pointFaces(); -// -// Info<< " Number of points: " << tsm.nPoints() << endl; -// -// forAll(points, pI) -// { -// const Foam::point& pt = points[pI]; -// const labelList& ptFaces = pointFaces[pI]; -// -// vectorField pointNormals(ptFaces.size()); -// -// forAll(pointNormals, pnI) -// { -// pointNormals[pnI] = faceNormals[ptFaces[pnI]]; -// } -// -// pointsToInsert.append(pt); -// -// // Get the value of the point from surfaceCellSizeFunction. If -// // adding points internally then will need to interpolate. -// scalar newSize = 0; -// -// cellSizeFunctions_[surfI - 1].cellSize(pt, newSize); -// sizesToInsert.append(newSize); -// -// tensor newAlignment = requiredAlignment(pt, pointNormals); -// -// alignmentsToInsert.append(newAlignment); -// } -// } -// } -// -// // Add the global bound box to ensure that all internal point queries -// // will return sizes and alignments -//// boundBox bb = allGeometry_.bounds(); -//// -//// pointField bbPoints = bb.points(); -//// -//// forAll(bbPoints, pI) -//// { -//// pointsToInsert.append(bbPoints[pI]); -//// sizesToInsert.append(defaultCellSize()); -//// alignmentsToInsert.append(tensor(1,0,0,0,1,0,0,0,1)); -//// } -// -// triangulatedMesh_.set -// ( -// new triangulatedMesh -// ( -// runTime, -// pointsToInsert, -// sizesToInsert, -// alignmentsToInsert, -// defaultCellSize() -// ) -// ); -// -// scalar factor = 1.0; -// label maxIteration = cellShapeControlDict.lookupOrDefault