diff --git a/applications/utilities/mesh/generation/cvMesh/Allwclean b/applications/utilities/mesh/generation/cvMesh/Allwclean index 6dd3690c256b786353f55a4a9aad5f01cfbf135c..3eff84006aa70bbe0d2c8b60b9408274c47bad7d 100755 --- a/applications/utilities/mesh/generation/cvMesh/Allwclean +++ b/applications/utilities/mesh/generation/cvMesh/Allwclean @@ -4,5 +4,7 @@ set -x wclean libso conformalVoronoiMesh wclean +wclean cvMeshSurfaceSimplify +wclean cvMeshBackgroundMesh # ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/mesh/generation/cvMesh/Allwmake b/applications/utilities/mesh/generation/cvMesh/Allwmake index f059754bab6f69f793ddfd156f50e914d3cf3d55..2a998cb690a0b5db05aeac1b809031b20de50b96 100755 --- a/applications/utilities/mesh/generation/cvMesh/Allwmake +++ b/applications/utilities/mesh/generation/cvMesh/Allwmake @@ -5,5 +5,6 @@ set -x wmake libso conformalVoronoiMesh wmake wmake cvMeshSurfaceSimplify +wmake cvMeshBackgroundMesh # ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C index 395b6c78b2d60d78e7bf30c61213fc537bceea2a..cf7a1eb9021fd476ba2c4589b51ac07963cbc4e6 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -142,7 +142,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement() zeroGradientFvPatchScalarField::typeName ); - const conformationSurfaces& geometry = cvMesh_.geometryToConformTo(); + const conformationSurfaces& geometry = geometryToConformTo_; decompositionMethod& decomposer = decomposerPtr_(); @@ -512,7 +512,7 @@ bool Foam::backgroundMeshDecomposition::refineCell // Sample the box to find an estimate of the min size, and a volume // estimate when overlapping == true. - const conformationSurfaces& geometry = cvMesh_.geometryToConformTo(); + const conformationSurfaces& geometry = geometryToConformTo_; treeBoundBox cellBb ( @@ -578,7 +578,7 @@ bool Foam::backgroundMeshDecomposition::refineCell forAll(samplePoints, i) { - scalar s = cvMesh_.cellSizeControl().cellSize + scalar s = cellSizeControl_.cellSize ( hitInfo[i].hitPoint() ); @@ -693,7 +693,7 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree() // Overall bb treeBoundBox overallBb(boundaryFacesPtr_().localPoints()); - Random& rnd = cvMesh_.rndGen(); + Random& rnd = rndGen_; bFTreePtr_.reset ( @@ -726,11 +726,11 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree() octreeNearestDistances_ = bFTreePtr_().calcNearestDistance(); - if (cvMesh_.cvMeshControls().objOutput()) + if (cvMeshControls_.objOutput()) { OFstream fStr ( - cvMesh_.time().path() + mesh_.time().path() /"backgroundMeshDecomposition_proc_" + name(Pstream::myProcNo()) + "_boundaryFaces.obj" @@ -777,15 +777,18 @@ Foam::backgroundMeshDecomposition::backgroundMeshDecomposition const conformalVoronoiMesh& cvMesh ) : - coeffsDict_(coeffsDict), - cvMesh_(cvMesh), + runTime_(cvMesh.time()), + geometryToConformTo_(cvMesh.geometryToConformTo()), + cellSizeControl_(cvMesh.cellSizeControl()), + rndGen_(cvMesh.rndGen()), + cvMeshControls_(cvMesh.cvMeshControls()), mesh_ ( IOobject ( fvMesh::defaultRegion, - cvMesh_.time().timeName(), - cvMesh_.time(), + runTime_.timeName(), + runTime_, IOobject::MUST_READ ) ), @@ -805,22 +808,22 @@ Foam::backgroundMeshDecomposition::backgroundMeshDecomposition IOobject ( "decomposeParDict", - cvMesh_.time().system(), - cvMesh_.time(), + runTime_.system(), + runTime_, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ), decomposerPtr_(decompositionMethod::New(decomposeDict_)), mergeDist_(1e-6*mesh_.bounds().mag()), - spanScale_(readScalar(coeffsDict_.lookup("spanScale"))), + spanScale_(readScalar(coeffsDict.lookup("spanScale"))), minCellSizeLimit_ ( - coeffsDict_.lookupOrDefault<scalar>("minCellSizeLimit", 0.0) + coeffsDict.lookupOrDefault<scalar>("minCellSizeLimit", 0.0) ), - minLevels_(readLabel(coeffsDict_.lookup("minLevels"))), - volRes_(readLabel(coeffsDict_.lookup("sampleResolution"))), - maxCellWeightCoeff_(readScalar(coeffsDict_.lookup("maxCellWeightCoeff"))) + minLevels_(readLabel(coeffsDict.lookup("minLevels"))), + volRes_(readLabel(coeffsDict.lookup("sampleResolution"))), + maxCellWeightCoeff_(readScalar(coeffsDict.lookup("maxCellWeightCoeff"))) { if (!Pstream::parRun()) { @@ -854,6 +857,74 @@ Foam::backgroundMeshDecomposition::backgroundMeshDecomposition } +Foam::backgroundMeshDecomposition::backgroundMeshDecomposition +( + const scalar spanScale, + const scalar minCellSizeLimit, + const label minLevels, + const label volRes, + const scalar maxCellWeightCoeff, + + const Time& runTime, + const conformationSurfaces& geometryToConformTo, + const cellSizeControlSurfaces& cellSizeControl, + Random& rndGen, + const cvControls& cvMeshControls +) +: + runTime_(runTime), + geometryToConformTo_(geometryToConformTo), + cellSizeControl_(cellSizeControl), + rndGen_(rndGen), + cvMeshControls_(cvMeshControls), + mesh_ + ( + IOobject + ( + fvMesh::defaultRegion, + runTime_.timeName(), + runTime_, + IOobject::MUST_READ + ) + ), + meshCutter_ + ( + mesh_, + labelList(mesh_.nCells(), 0), + labelList(mesh_.nPoints(), 0) + ), + boundaryFacesPtr_(), + bFTreePtr_(), + octreeNearestDistances_(), + allBackgroundMeshBounds_(Pstream::nProcs()), + globalBackgroundBounds_(), + decomposeDict_ + ( + IOobject + ( + "decomposeParDict", + runTime_.system(), + runTime_, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) + ), + decomposerPtr_(decompositionMethod::New(decomposeDict_)), + mergeDist_(1e-6*mesh_.bounds().mag()), + spanScale_(spanScale), + minCellSizeLimit_(minCellSizeLimit), + minLevels_(minLevels), + volRes_(volRes), + maxCellWeightCoeff_(maxCellWeightCoeff) +{ + // Stand-alone operation + + Info<< nl << "Building initial background mesh decomposition" << endl; + + initialRefinement(); +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::backgroundMeshDecomposition::~backgroundMeshDecomposition() diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H index 01572a48f9a20b93b617ce0ada3e773dbf84860e..910732fa7ac2415857d2274c102f52f3356257dc 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -92,10 +92,22 @@ class backgroundMeshDecomposition // Private data //- Method details dictionary - dictionary coeffsDict_; + //dictionary coeffsDict_; - //- Reference to the conformalVoronoiMesh holding this object - const conformalVoronoiMesh& cvMesh_; + //- Reference to runtime + const Time& runTime_; + + //- Reference to surface + const conformationSurfaces& geometryToConformTo_; + + //- The cell size control object + const cellSizeControlSurfaces& cellSizeControl_; + + //- Random number generator + Random& rndGen_; + + //- Controls + const cvControls& cvMeshControls_; //- Mesh stored on for this processor, specifiying the domain that it // is responsible for. @@ -191,13 +203,29 @@ public: // Constructors - //- Construct from components + //- Construct from components in cvMesh operation backgroundMeshDecomposition ( const dictionary& coeffsDict, const conformalVoronoiMesh& cvMesh ); + //- Construct from components for standalone operation + backgroundMeshDecomposition + ( + const scalar spanScale, + const scalar minCellSizeLimit, + const label minLevels, + const label volRes, + const scalar maxCellWeightCoeff, + + const Time& runTime, + const conformationSurfaces& geometryToConformTo, + const cellSizeControlSurfaces& cellSizeControl, + Random& rndGen, + const cvControls& cvMeshControls + ); + //- Destructor ~backgroundMeshDecomposition(); @@ -299,6 +327,15 @@ public: //- Return the boundBox of this processor inline const treeBoundBox& procBounds() const; + + //- Return the cell level of the underlying mesh + inline const labelList& cellLevel() const; + + //- Return the point level of the underlying mesh + inline const labelList& pointLevel() const; + + //- Return the current decomposition method + inline const decompositionMethod& decomposer() const; }; diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecompositionI.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecompositionI.H index 94a05c4134a0b80e2c18d45fa11edfaf0dd7139f..44a007193d8e85fae30c2b8a024385a2c90fedab 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecompositionI.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecompositionI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,9 +43,30 @@ Foam::backgroundMeshDecomposition::octreeNearestDistances() const } -const Foam::treeBoundBox& Foam::backgroundMeshDecomposition::procBounds() const +const Foam::treeBoundBox& +Foam::backgroundMeshDecomposition::procBounds() const { return allBackgroundMeshBounds_[Pstream::myProcNo()]; } + +const Foam::labelList& Foam::backgroundMeshDecomposition::cellLevel() const +{ + return meshCutter_.cellLevel(); +} + + +const Foam::labelList& Foam::backgroundMeshDecomposition::pointLevel() const +{ + return meshCutter_.pointLevel(); +} + + +const Foam::decompositionMethod& +Foam::backgroundMeshDecomposition::decomposer() const +{ + return decomposerPtr_(); +} + + // ************************************************************************* //