From 3f81e7af007eb896775f0af44a89e8c9ca0e0bd6 Mon Sep 17 00:00:00 2001 From: graham Date: Fri, 13 May 2011 10:12:55 +0100 Subject: [PATCH] ENH: Parallel fill and decomp of space. Initial. --- ...lelHierarchicalDensityWeightedStochastic.C | 455 ++++++++++++++++++ ...lelHierarchicalDensityWeightedStochastic.H | 153 ++++++ 2 files changed, 608 insertions(+) create mode 100644 src/mesh/conformalVoronoiMesh/initialPointsMethod/parallelHierarchicalDensityWeightedStochastic/parallelHierarchicalDensityWeightedStochastic.C create mode 100644 src/mesh/conformalVoronoiMesh/initialPointsMethod/parallelHierarchicalDensityWeightedStochastic/parallelHierarchicalDensityWeightedStochastic.H diff --git a/src/mesh/conformalVoronoiMesh/initialPointsMethod/parallelHierarchicalDensityWeightedStochastic/parallelHierarchicalDensityWeightedStochastic.C b/src/mesh/conformalVoronoiMesh/initialPointsMethod/parallelHierarchicalDensityWeightedStochastic/parallelHierarchicalDensityWeightedStochastic.C new file mode 100644 index 0000000000..e00823d412 --- /dev/null +++ b/src/mesh/conformalVoronoiMesh/initialPointsMethod/parallelHierarchicalDensityWeightedStochastic/parallelHierarchicalDensityWeightedStochastic.C @@ -0,0 +1,455 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "parallelHierarchicalDensityWeightedStochastic.H" +#include "addToRunTimeSelectionTable.H" + +#include "zeroGradientFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(parallelHierarchicalDensityWeightedStochastic, 0); +addToRunTimeSelectionTable +( + initialPointsMethod, + parallelHierarchicalDensityWeightedStochastic, + dictionary +); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void parallelHierarchicalDensityWeightedStochastic::printMeshData +( + const polyMesh& mesh +) const +{ + // Collect all data on master + + globalIndex globalCells(mesh.nCells()); + labelListList patchNeiProcNo(Pstream::nProcs()); + labelListList patchSize(Pstream::nProcs()); + const labelList& pPatches = mesh.globalData().processorPatches(); + patchNeiProcNo[Pstream::myProcNo()].setSize(pPatches.size()); + patchSize[Pstream::myProcNo()].setSize(pPatches.size()); + forAll(pPatches, i) + { + const processorPolyPatch& ppp = refCast + ( + mesh.boundaryMesh()[pPatches[i]] + ); + patchNeiProcNo[Pstream::myProcNo()][i] = ppp.neighbProcNo(); + patchSize[Pstream::myProcNo()][i] = ppp.size(); + } + Pstream::gatherList(patchNeiProcNo); + Pstream::gatherList(patchSize); + + + // Print stats + + globalIndex globalBoundaryFaces(mesh.nFaces()-mesh.nInternalFaces()); + + for (label procI = 0; procI < Pstream::nProcs(); procI++) + { + Info<< endl + << "Processor " << procI << nl + << " Number of cells = " << globalCells.localSize(procI) + << endl; + + label nProcFaces = 0; + + const labelList& nei = patchNeiProcNo[procI]; + + forAll(patchNeiProcNo[procI], i) + { + Info<< " Number of faces shared with processor " + << patchNeiProcNo[procI][i] << " = " << patchSize[procI][i] + << endl; + + nProcFaces += patchSize[procI][i]; + } + + Info<< " Number of processor patches = " << nei.size() << nl + << " Number of processor faces = " << nProcFaces << nl + << " Number of boundary faces = " + << globalBoundaryFaces.localSize(procI) << endl; + } +} + + +bool parallelHierarchicalDensityWeightedStochastic::estimateCellWeight +( + const polyMesh& mesh, + label cellI, + label volType, + scalar& weightEstimate +) const +{ + weightEstimate = 10*scalar(Pstream::myProcNo() + 1.0); + + return false; +} + + +labelList parallelHierarchicalDensityWeightedStochastic::selectRefinementCells +( + const hexRef8& meshCutter, + labelList& volumeStatus, + volScalarField& cellWeights +) const +{ + labelHashSet cellsToRefine; + + const polyMesh& mesh = meshCutter.mesh(); + + // Determine/update the status of each cell + forAll(volumeStatus, cellI) + { + if (volumeStatus[cellI] == searchableSurface::MIXED) + { + if (meshCutter.cellLevel()[cellI] <= minLevels_) + { + cellsToRefine.insert(cellI); + } + } + + if + ( + estimateCellWeight + ( + mesh, + cellI, + volumeStatus[cellI], + cellWeights.internalField()[cellI] + ) + ) + { + cellsToRefine.insert(cellI); + } + } + + return cellsToRefine.toc(); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +parallelHierarchicalDensityWeightedStochastic:: +parallelHierarchicalDensityWeightedStochastic +( + const dictionary& initialPointsDict, + const conformalVoronoiMesh& cvMesh +) +: + initialPointsMethod(typeName, initialPointsDict, cvMesh), + globalTrialPoints_(0), + minCellSizeLimit_ + ( + detailsDict().lookupOrDefault("minCellSizeLimit", 0.0) + ), + minLevels_(readLabel(detailsDict().lookup("minLevels"))), + maxSizeRatio_(readScalar(detailsDict().lookup("maxSizeRatio"))), + volRes_(readLabel(detailsDict().lookup("sampleResolution"))), + surfRes_ + ( + detailsDict().lookupOrDefault