mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge commit 'OpenCFD/master' into olesenm
This commit is contained in:
@ -64,7 +64,7 @@ class calcEntry
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
TypeName("calc");
|
ClassName("calc");
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|||||||
@ -32,7 +32,8 @@ Description
|
|||||||
|
|
||||||
patch_YYY_XXX.obj : all face centres of patch YYY
|
patch_YYY_XXX.obj : all face centres of patch YYY
|
||||||
|
|
||||||
Optional: patch faces (as polygons) : patchFaces_YYY_XXX.obj
|
Optional: - patch faces (as polygons) : patchFaces_YYY_XXX.obj
|
||||||
|
- non-manifold edges : patchEdges_YYY_XXX.obj
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ using namespace Foam;
|
|||||||
|
|
||||||
void writeOBJ(const point& pt, Ostream& os)
|
void writeOBJ(const point& pt, Ostream& os)
|
||||||
{
|
{
|
||||||
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
|
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All edges of mesh
|
// All edges of mesh
|
||||||
@ -75,8 +76,7 @@ void writePoints(const polyMesh& mesh, const fileName& timeName)
|
|||||||
{
|
{
|
||||||
const edge& e = mesh.edges()[edgeI];
|
const edge& e = mesh.edges()[edgeI];
|
||||||
|
|
||||||
pointStream << "l " << e.start() + 1 << ' ' << e.end() + 1
|
pointStream << "l " << e.start() + 1 << ' ' << e.end() + 1 << nl;
|
||||||
<< endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +277,47 @@ void writePatchFaces
|
|||||||
{
|
{
|
||||||
patchFaceStream << ' ' << f[fp]+1;
|
patchFaceStream << ' ' << f[fp]+1;
|
||||||
}
|
}
|
||||||
patchFaceStream << endl;
|
patchFaceStream << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void writePatchBoundaryEdges
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const fileName& timeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||||
|
|
||||||
|
forAll(patches, patchI)
|
||||||
|
{
|
||||||
|
const polyPatch& pp = patches[patchI];
|
||||||
|
|
||||||
|
fileName edgeFile
|
||||||
|
(
|
||||||
|
mesh.time().path()
|
||||||
|
/ "patchEdges_" + pp.name() + '_' + timeName + ".obj"
|
||||||
|
);
|
||||||
|
|
||||||
|
Info << "Writing patch edges to " << edgeFile << endl;
|
||||||
|
|
||||||
|
OFstream patchEdgeStream(edgeFile);
|
||||||
|
|
||||||
|
forAll(pp.localPoints(), pointI)
|
||||||
|
{
|
||||||
|
writeOBJ(pp.localPoints()[pointI], patchEdgeStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (label edgeI = pp.nInternalEdges(); edgeI < pp.nEdges(); edgeI++)
|
||||||
|
{
|
||||||
|
if (pp.edgeFaces()[edgeI].size() == 1)
|
||||||
|
{
|
||||||
|
const edge& e = pp.edges()[edgeI];
|
||||||
|
|
||||||
|
patchEdgeStream<< "l " << e[0]+1 << ' ' << e[1]+1 << nl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -339,6 +379,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
timeSelector::addOptions();
|
timeSelector::addOptions();
|
||||||
argList::validOptions.insert("patchFaces", "");
|
argList::validOptions.insert("patchFaces", "");
|
||||||
|
argList::validOptions.insert("patchEdges", "");
|
||||||
argList::validOptions.insert("cell", "cellI");
|
argList::validOptions.insert("cell", "cellI");
|
||||||
argList::validOptions.insert("face", "faceI");
|
argList::validOptions.insert("face", "faceI");
|
||||||
argList::validOptions.insert("point", "pointI");
|
argList::validOptions.insert("point", "pointI");
|
||||||
@ -351,6 +392,7 @@ int main(int argc, char *argv[])
|
|||||||
runTime.functionObjects().off();
|
runTime.functionObjects().off();
|
||||||
|
|
||||||
bool patchFaces = args.optionFound("patchFaces");
|
bool patchFaces = args.optionFound("patchFaces");
|
||||||
|
bool patchEdges = args.optionFound("patchEdges");
|
||||||
bool doCell = args.optionFound("cell");
|
bool doCell = args.optionFound("cell");
|
||||||
bool doPoint = args.optionFound("point");
|
bool doPoint = args.optionFound("point");
|
||||||
bool doFace = args.optionFound("face");
|
bool doFace = args.optionFound("face");
|
||||||
@ -381,19 +423,23 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
writePatchFaces(mesh, runTime.timeName());
|
writePatchFaces(mesh, runTime.timeName());
|
||||||
}
|
}
|
||||||
else if (doCell)
|
if (patchEdges)
|
||||||
|
{
|
||||||
|
writePatchBoundaryEdges(mesh, runTime.timeName());
|
||||||
|
}
|
||||||
|
if (doCell)
|
||||||
{
|
{
|
||||||
label cellI = args.optionRead<label>("cell");
|
label cellI = args.optionRead<label>("cell");
|
||||||
|
|
||||||
writePoints(mesh, cellI, runTime.timeName());
|
writePoints(mesh, cellI, runTime.timeName());
|
||||||
}
|
}
|
||||||
else if (doPoint)
|
if (doPoint)
|
||||||
{
|
{
|
||||||
label pointI = args.optionRead<label>("point");
|
label pointI = args.optionRead<label>("point");
|
||||||
|
|
||||||
writePointCells(mesh, pointI, runTime.timeName());
|
writePointCells(mesh, pointI, runTime.timeName());
|
||||||
}
|
}
|
||||||
else if (doFace)
|
if (doFace)
|
||||||
{
|
{
|
||||||
label faceI = args.optionRead<label>("face");
|
label faceI = args.optionRead<label>("face");
|
||||||
|
|
||||||
@ -415,7 +461,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
meshTools::writeOBJ(str, faceList(1, f), mesh.points());
|
meshTools::writeOBJ(str, faceList(1, f), mesh.points());
|
||||||
}
|
}
|
||||||
else if (doCellSet)
|
if (doCellSet)
|
||||||
{
|
{
|
||||||
word setName(args.option("cellSet"));
|
word setName(args.option("cellSet"));
|
||||||
|
|
||||||
@ -427,7 +473,7 @@ int main(int argc, char *argv[])
|
|||||||
writePoints(mesh, cells.toc(), runTime.timeName());
|
writePoints(mesh, cells.toc(), runTime.timeName());
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (doFaceSet)
|
if (doFaceSet)
|
||||||
{
|
{
|
||||||
word setName(args.option("faceSet"));
|
word setName(args.option("faceSet"));
|
||||||
|
|
||||||
@ -458,7 +504,16 @@ int main(int argc, char *argv[])
|
|||||||
faces.toc()
|
faces.toc()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else if
|
||||||
|
(
|
||||||
|
!patchFaces
|
||||||
|
&& !patchEdges
|
||||||
|
&& !doCell
|
||||||
|
&& !doPoint
|
||||||
|
&& !doFace
|
||||||
|
&& !doCellSet
|
||||||
|
&& !doFaceSet
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// points & edges
|
// points & edges
|
||||||
writePoints(mesh, runTime.timeName());
|
writePoints(mesh, runTime.timeName());
|
||||||
|
|||||||
@ -71,7 +71,8 @@ linearNormalCoeffs
|
|||||||
|
|
||||||
linearDirectionCoeffs
|
linearDirectionCoeffs
|
||||||
{
|
{
|
||||||
direction (0 0 1);
|
direction (0 1 0);
|
||||||
|
thickness 0.05;
|
||||||
}
|
}
|
||||||
|
|
||||||
linearRadialCoeffs
|
linearRadialCoeffs
|
||||||
@ -89,7 +90,7 @@ sigmaRadialCoeffs
|
|||||||
|
|
||||||
// Do front and back need to be merged? Usually only makes sense for 360
|
// Do front and back need to be merged? Usually only makes sense for 360
|
||||||
// degree wedges.
|
// degree wedges.
|
||||||
mergeFaces true;
|
mergeFaces false; //true;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -49,7 +49,7 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
mergePolyMesh::defaultRegion,
|
masterRegion,
|
||||||
runTimeMaster.timeName(),
|
runTimeMaster.timeName(),
|
||||||
runTimeMaster
|
runTimeMaster
|
||||||
)
|
)
|
||||||
@ -63,7 +63,7 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
mergePolyMesh::defaultRegion,
|
addRegion,
|
||||||
runTimeToAdd.timeName(),
|
runTimeToAdd.timeName(),
|
||||||
runTimeToAdd
|
runTimeToAdd
|
||||||
)
|
)
|
||||||
|
|||||||
@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
argList::validArgs.append("master root");
|
argList::validArgs.append("master root");
|
||||||
argList::validArgs.append("master case");
|
argList::validArgs.append("master case");
|
||||||
|
argList::validOptions.insert("masterRegion", "name");
|
||||||
|
|
||||||
argList::validArgs.append("root to add");
|
argList::validArgs.append("root to add");
|
||||||
argList::validArgs.append("case to add");
|
argList::validArgs.append("case to add");
|
||||||
|
argList::validOptions.insert("addRegion", "name");
|
||||||
|
|
||||||
argList args(argc, argv);
|
argList args(argc, argv);
|
||||||
|
|
||||||
@ -15,9 +17,15 @@
|
|||||||
|
|
||||||
fileName rootDirMaster(args.additionalArgs()[0]);
|
fileName rootDirMaster(args.additionalArgs()[0]);
|
||||||
fileName caseDirMaster(args.additionalArgs()[1]);
|
fileName caseDirMaster(args.additionalArgs()[1]);
|
||||||
|
word masterRegion = polyMesh::defaultRegion;
|
||||||
|
args.optionReadIfPresent("masterRegion", masterRegion);
|
||||||
|
|
||||||
fileName rootDirToAdd(args.additionalArgs()[2]);
|
fileName rootDirToAdd(args.additionalArgs()[2]);
|
||||||
fileName caseDirToAdd(args.additionalArgs()[3]);
|
fileName caseDirToAdd(args.additionalArgs()[3]);
|
||||||
|
word addRegion = polyMesh::defaultRegion;
|
||||||
|
args.optionReadIfPresent("addRegion", addRegion);
|
||||||
|
|
||||||
Info<< "Master: " << rootDirMaster << " " << caseDirMaster << nl
|
Info<< "Master: " << rootDirMaster << " " << caseDirMaster
|
||||||
<< "mesh to add: " << rootDirToAdd << " " << caseDirToAdd << endl;
|
<< " region " << masterRegion << nl
|
||||||
|
<< "mesh to add: " << rootDirToAdd << " " << caseDirToAdd
|
||||||
|
<< " region " << addRegion << endl;
|
||||||
|
|||||||
@ -43,6 +43,9 @@ Description
|
|||||||
the largest matching region (-sloppyCellZones). This will accept any
|
the largest matching region (-sloppyCellZones). This will accept any
|
||||||
region that covers more than 50% of the zone. It has to be a subset
|
region that covers more than 50% of the zone. It has to be a subset
|
||||||
so cannot have any cells in any other zone.
|
so cannot have any cells in any other zone.
|
||||||
|
- useCellZonesOnly does not do a walk and uses the cellZones only. Use
|
||||||
|
this if you don't mind having disconnected domains in a single region.
|
||||||
|
This option requires all cells to be in one (and one only) region.
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -609,7 +612,7 @@ void getInterfaceSizes
|
|||||||
// Create mesh for region.
|
// Create mesh for region.
|
||||||
autoPtr<mapPolyMesh> createRegionMesh
|
autoPtr<mapPolyMesh> createRegionMesh
|
||||||
(
|
(
|
||||||
const regionSplit& cellRegion,
|
const labelList& cellRegion,
|
||||||
const EdgeMap<label>& interfaceToPatch,
|
const EdgeMap<label>& interfaceToPatch,
|
||||||
const fvMesh& mesh,
|
const fvMesh& mesh,
|
||||||
const label regionI,
|
const label regionI,
|
||||||
@ -766,7 +769,7 @@ autoPtr<mapPolyMesh> createRegionMesh
|
|||||||
void createAndWriteRegion
|
void createAndWriteRegion
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const fvMesh& mesh,
|
||||||
const regionSplit& cellRegion,
|
const labelList& cellRegion,
|
||||||
const wordList& regionNames,
|
const wordList& regionNames,
|
||||||
const EdgeMap<label>& interfaceToPatch,
|
const EdgeMap<label>& interfaceToPatch,
|
||||||
const label regionI,
|
const label regionI,
|
||||||
@ -1005,7 +1008,8 @@ void createAndWriteRegion
|
|||||||
EdgeMap<label> addRegionPatches
|
EdgeMap<label> addRegionPatches
|
||||||
(
|
(
|
||||||
fvMesh& mesh,
|
fvMesh& mesh,
|
||||||
const regionSplit& cellRegion,
|
const labelList& cellRegion,
|
||||||
|
const label nCellRegions,
|
||||||
const edgeList& interfaces,
|
const edgeList& interfaces,
|
||||||
const EdgeMap<label>& interfaceSizes,
|
const EdgeMap<label>& interfaceSizes,
|
||||||
const wordList& regionNames
|
const wordList& regionNames
|
||||||
@ -1016,7 +1020,7 @@ EdgeMap<label> addRegionPatches
|
|||||||
|
|
||||||
Info<< nl << "Adding patches" << nl << endl;
|
Info<< nl << "Adding patches" << nl << endl;
|
||||||
|
|
||||||
EdgeMap<label> interfaceToPatch(cellRegion.nRegions());
|
EdgeMap<label> interfaceToPatch(nCellRegions);
|
||||||
|
|
||||||
forAll(interfaces, interI)
|
forAll(interfaces, interI)
|
||||||
{
|
{
|
||||||
@ -1108,13 +1112,14 @@ EdgeMap<label> addRegionPatches
|
|||||||
label findCorrespondingRegion
|
label findCorrespondingRegion
|
||||||
(
|
(
|
||||||
const labelList& existingZoneID, // per cell the (unique) zoneID
|
const labelList& existingZoneID, // per cell the (unique) zoneID
|
||||||
const regionSplit& cellRegion,
|
const labelList& cellRegion,
|
||||||
|
const label nCellRegions,
|
||||||
const label zoneI,
|
const label zoneI,
|
||||||
const label minOverlapSize
|
const label minOverlapSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Per region the number of cells in zoneI
|
// Per region the number of cells in zoneI
|
||||||
labelList cellsInZone(cellRegion.nRegions(), 0);
|
labelList cellsInZone(nCellRegions, 0);
|
||||||
|
|
||||||
forAll(cellRegion, cellI)
|
forAll(cellRegion, cellI)
|
||||||
{
|
{
|
||||||
@ -1162,7 +1167,8 @@ label findCorrespondingRegion
|
|||||||
//(
|
//(
|
||||||
// const cellZoneMesh& cellZones,
|
// const cellZoneMesh& cellZones,
|
||||||
// const labelList& existingZoneID, // per cell the (unique) zoneID
|
// const labelList& existingZoneID, // per cell the (unique) zoneID
|
||||||
// const regionSplit& cellRegion,
|
// const labelList& cellRegion,
|
||||||
|
// const label nCellRegions,
|
||||||
// const label zoneI
|
// const label zoneI
|
||||||
//)
|
//)
|
||||||
//{
|
//{
|
||||||
@ -1227,6 +1233,7 @@ label findCorrespondingRegion
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
argList::validOptions.insert("cellZones", "");
|
argList::validOptions.insert("cellZones", "");
|
||||||
|
argList::validOptions.insert("cellZonesOnly", "");
|
||||||
argList::validOptions.insert("blockedFaces", "faceSet");
|
argList::validOptions.insert("blockedFaces", "faceSet");
|
||||||
argList::validOptions.insert("makeCellZones", "");
|
argList::validOptions.insert("makeCellZones", "");
|
||||||
argList::validOptions.insert("largestOnly", "");
|
argList::validOptions.insert("largestOnly", "");
|
||||||
@ -1249,13 +1256,14 @@ int main(int argc, char *argv[])
|
|||||||
<< blockedFacesName << nl << endl;
|
<< blockedFacesName << nl << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool makeCellZones = args.optionFound("makeCellZones");
|
bool makeCellZones = args.optionFound("makeCellZones");
|
||||||
bool largestOnly = args.optionFound("largestOnly");
|
bool largestOnly = args.optionFound("largestOnly");
|
||||||
bool insidePoint = args.optionFound("insidePoint");
|
bool insidePoint = args.optionFound("insidePoint");
|
||||||
bool useCellZones = args.optionFound("cellZones");
|
bool useCellZones = args.optionFound("cellZones");
|
||||||
bool overwrite = args.optionFound("overwrite");
|
bool useCellZonesOnly = args.optionFound("cellZonesOnly");
|
||||||
bool detectOnly = args.optionFound("detectOnly");
|
bool overwrite = args.optionFound("overwrite");
|
||||||
bool sloppyCellZones = args.optionFound("sloppyCellZones");
|
bool detectOnly = args.optionFound("detectOnly");
|
||||||
|
bool sloppyCellZones = args.optionFound("sloppyCellZones");
|
||||||
|
|
||||||
if (insidePoint && largestOnly)
|
if (insidePoint && largestOnly)
|
||||||
{
|
{
|
||||||
@ -1370,13 +1378,37 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Do the topological walk to determine regions
|
// Determine per cell the region it belongs to
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
// regionSplit is the labelList with the region per cell.
|
// cellRegion is the labelList with the region per cell.
|
||||||
regionSplit cellRegion(mesh, blockedFace);
|
labelList cellRegion;
|
||||||
|
label nCellRegions = 0;
|
||||||
|
if (useCellZonesOnly)
|
||||||
|
{
|
||||||
|
label unzonedCellI = findIndex(zoneID, -1);
|
||||||
|
if (unzonedCellI != -1)
|
||||||
|
{
|
||||||
|
FatalErrorIn(args.executable())
|
||||||
|
<< "For the cellZonesOnly option all cells "
|
||||||
|
<< "have to be in a cellZone." << endl
|
||||||
|
<< "Cell " << unzonedCellI
|
||||||
|
<< " at" << mesh.cellCentres()[unzonedCellI]
|
||||||
|
<< " is not in a cellZone. There might be more unzoned cells."
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
cellRegion = zoneID;
|
||||||
|
nCellRegions = gMax(cellRegion)+1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Do a topological walk to determine regions
|
||||||
|
regionSplit regions(mesh, blockedFace);
|
||||||
|
nCellRegions = regions.nRegions();
|
||||||
|
cellRegion.transfer(regions);
|
||||||
|
}
|
||||||
|
|
||||||
Info<< endl << "Number of regions:" << cellRegion.nRegions() << nl << endl;
|
Info<< endl << "Number of regions:" << nCellRegions << nl << endl;
|
||||||
|
|
||||||
|
|
||||||
// Write to manual decomposition option
|
// Write to manual decomposition option
|
||||||
@ -1429,7 +1461,7 @@ int main(int argc, char *argv[])
|
|||||||
// Sizes per region
|
// Sizes per region
|
||||||
// ~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
labelList regionSizes(cellRegion.nRegions(), 0);
|
labelList regionSizes(nCellRegions, 0);
|
||||||
|
|
||||||
forAll(cellRegion, cellI)
|
forAll(cellRegion, cellI)
|
||||||
{
|
{
|
||||||
@ -1489,9 +1521,9 @@ int main(int argc, char *argv[])
|
|||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
// Region per zone
|
// Region per zone
|
||||||
labelList regionToZone(cellRegion.nRegions(), -1);
|
labelList regionToZone(nCellRegions, -1);
|
||||||
// Name of region
|
// Name of region
|
||||||
wordList regionNames(cellRegion.nRegions());
|
wordList regionNames(nCellRegions);
|
||||||
// Zone to region
|
// Zone to region
|
||||||
labelList zoneToRegion(cellZones.size(), -1);
|
labelList zoneToRegion(cellZones.size(), -1);
|
||||||
|
|
||||||
@ -1506,6 +1538,7 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
zoneID,
|
zoneID,
|
||||||
cellRegion,
|
cellRegion,
|
||||||
|
nCellRegions,
|
||||||
zoneI,
|
zoneI,
|
||||||
label(0.5*zoneSizes[zoneI]) // minimum overlap
|
label(0.5*zoneSizes[zoneI]) // minimum overlap
|
||||||
);
|
);
|
||||||
@ -1532,6 +1565,7 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
zoneID,
|
zoneID,
|
||||||
cellRegion,
|
cellRegion,
|
||||||
|
nCellRegions,
|
||||||
zoneI,
|
zoneI,
|
||||||
1 // minimum overlap
|
1 // minimum overlap
|
||||||
);
|
);
|
||||||
@ -1660,7 +1694,7 @@ int main(int argc, char *argv[])
|
|||||||
mesh.clearOut();
|
mesh.clearOut();
|
||||||
|
|
||||||
|
|
||||||
if (cellRegion.nRegions() == 1)
|
if (nCellRegions == 1)
|
||||||
{
|
{
|
||||||
Info<< "Only one region. Doing nothing." << endl;
|
Info<< "Only one region. Doing nothing." << endl;
|
||||||
}
|
}
|
||||||
@ -1671,7 +1705,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Check if region overlaps with existing zone. If so keep.
|
// Check if region overlaps with existing zone. If so keep.
|
||||||
|
|
||||||
for (label regionI = 0; regionI < cellRegion.nRegions(); regionI++)
|
for (label regionI = 0; regionI < nCellRegions; regionI++)
|
||||||
{
|
{
|
||||||
label zoneI = regionToZone[regionI];
|
label zoneI = regionToZone[regionI];
|
||||||
|
|
||||||
@ -1759,6 +1793,7 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
cellRegion,
|
cellRegion,
|
||||||
|
nCellRegions,
|
||||||
interfaces,
|
interfaces,
|
||||||
interfaceSizes,
|
interfaceSizes,
|
||||||
regionNames
|
regionNames
|
||||||
@ -1837,7 +1872,7 @@ int main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Split all
|
// Split all
|
||||||
for (label regionI = 0; regionI < cellRegion.nRegions(); regionI++)
|
for (label regionI = 0; regionI < nCellRegions; regionI++)
|
||||||
{
|
{
|
||||||
Info<< nl
|
Info<< nl
|
||||||
<< "Region " << regionI << nl
|
<< "Region " << regionI << nl
|
||||||
|
|||||||
@ -38,13 +38,14 @@ Description
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
# include "addRegionOption.H"
|
||||||
timeSelector::addOptions();
|
timeSelector::addOptions();
|
||||||
argList::validArgs.append("fieldName");
|
argList::validArgs.append("fieldName");
|
||||||
argList::validArgs.append("patchName");
|
argList::validArgs.append("patchName");
|
||||||
# include "setRootCase.H"
|
# include "setRootCase.H"
|
||||||
# include "createTime.H"
|
# include "createTime.H"
|
||||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||||
# include "createMesh.H"
|
# include "createNamedMesh.H"
|
||||||
|
|
||||||
word fieldName(args.additionalArgs()[0]);
|
word fieldName(args.additionalArgs()[0]);
|
||||||
word patchName(args.additionalArgs()[1]);
|
word patchName(args.additionalArgs()[1]);
|
||||||
|
|||||||
@ -81,7 +81,12 @@ bool Foam::primitiveEntry::expandVariable
|
|||||||
word varName = w(1, w.size()-1);
|
word varName = w(1, w.size()-1);
|
||||||
|
|
||||||
// lookup the variable name in the given dictionary....
|
// lookup the variable name in the given dictionary....
|
||||||
const entry* ePtr = dict.lookupEntryPtr(varName, true, true);
|
// Note: allow wildcards to match? For now disabled since following
|
||||||
|
// would expand internalField to wildcard match and not expected
|
||||||
|
// internalField:
|
||||||
|
// internalField XXX;
|
||||||
|
// boundaryField { ".*" {YYY;} movingWall {value $internalField;}
|
||||||
|
const entry* ePtr = dict.lookupEntryPtr(varName, true, false);
|
||||||
|
|
||||||
// ...if defined insert its tokens into this
|
// ...if defined insert its tokens into this
|
||||||
if (ePtr != NULL)
|
if (ePtr != NULL)
|
||||||
|
|||||||
@ -2509,43 +2509,55 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
(
|
(
|
||||||
const layerParameters& layerParams,
|
const layerParameters& layerParams,
|
||||||
const dictionary& motionDict,
|
const dictionary& motionDict,
|
||||||
|
const labelList& patchIDs,
|
||||||
const label nAllowableErrors,
|
const label nAllowableErrors,
|
||||||
motionSmoother& meshMover,
|
|
||||||
decompositionMethod& decomposer,
|
decompositionMethod& decomposer,
|
||||||
fvMeshDistribute& distributor
|
fvMeshDistribute& distributor
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fvMesh& mesh = meshRefiner_.mesh();
|
fvMesh& mesh = meshRefiner_.mesh();
|
||||||
const indirectPrimitivePatch& pp = meshMover.patch();
|
|
||||||
const labelList& meshPoints = pp.meshPoints();
|
|
||||||
|
|
||||||
// Precalculate mesh edge labels for patch edges
|
autoPtr<indirectPrimitivePatch> pp
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
(
|
||||||
|
meshRefinement::makePatch
|
||||||
labelList meshEdges(pp.nEdges());
|
|
||||||
forAll(pp.edges(), edgeI)
|
|
||||||
{
|
|
||||||
const edge& ppEdge = pp.edges()[edgeI];
|
|
||||||
label v0 = meshPoints[ppEdge[0]];
|
|
||||||
label v1 = meshPoints[ppEdge[1]];
|
|
||||||
meshEdges[edgeI] = meshTools::findEdge
|
|
||||||
(
|
(
|
||||||
mesh.edges(),
|
mesh,
|
||||||
mesh.pointEdges()[v0],
|
patchIDs
|
||||||
v0,
|
)
|
||||||
v1
|
);
|
||||||
);
|
|
||||||
}
|
// Construct iterative mesh mover.
|
||||||
|
Info<< "Constructing mesh displacer ..." << endl;
|
||||||
|
|
||||||
|
autoPtr<motionSmoother> meshMover
|
||||||
|
(
|
||||||
|
new motionSmoother
|
||||||
|
(
|
||||||
|
mesh,
|
||||||
|
pp(),
|
||||||
|
patchIDs,
|
||||||
|
meshRefinement::makeDisplacementField
|
||||||
|
(
|
||||||
|
pointMesh::New(mesh),
|
||||||
|
patchIDs
|
||||||
|
),
|
||||||
|
motionDict
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Point-wise extrusion data
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
// Displacement for all pp.localPoints.
|
// Displacement for all pp.localPoints.
|
||||||
vectorField patchDisp(pp.nPoints(), vector::one);
|
vectorField patchDisp(pp().nPoints(), vector::one);
|
||||||
|
|
||||||
// Number of layers for all pp.localPoints. Note: only valid if
|
// Number of layers for all pp.localPoints. Note: only valid if
|
||||||
// extrudeStatus = EXTRUDE.
|
// extrudeStatus = EXTRUDE.
|
||||||
labelList patchNLayers(pp.nPoints(), 0);
|
labelList patchNLayers(pp().nPoints(), 0);
|
||||||
|
|
||||||
// Whether to add edge for all pp.localPoints.
|
// Whether to add edge for all pp.localPoints.
|
||||||
List<extrudeMode> extrudeStatus(pp.nPoints(), EXTRUDE);
|
List<extrudeMode> extrudeStatus(pp().nPoints(), EXTRUDE);
|
||||||
|
|
||||||
|
|
||||||
// Get number of layer per point from number of layers per patch
|
// Get number of layer per point from number of layers per patch
|
||||||
@ -2554,7 +2566,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
setNumLayers
|
setNumLayers
|
||||||
(
|
(
|
||||||
layerParams.numLayers(), // per patch the num layers
|
layerParams.numLayers(), // per patch the num layers
|
||||||
meshMover.adaptPatchIDs(), // patches that are being moved
|
meshMover().adaptPatchIDs(),// patches that are being moved
|
||||||
pp, // indirectpatch for all faces moving
|
pp, // indirectpatch for all faces moving
|
||||||
|
|
||||||
patchDisp,
|
patchDisp,
|
||||||
@ -2562,6 +2574,9 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
extrudeStatus
|
extrudeStatus
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Precalculate mesh edge labels for patch edges
|
||||||
|
labelList meshEdges(pp().meshEdges(mesh.edges(), mesh.pointEdges()));
|
||||||
|
|
||||||
// Disable extrusion on non-manifold points
|
// Disable extrusion on non-manifold points
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@ -2582,7 +2597,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
(
|
(
|
||||||
pp,
|
pp,
|
||||||
meshEdges,
|
meshEdges,
|
||||||
layerParams.featureAngle()*constant::math::pi/180.0,
|
layerParams.featureAngle()*constant::math::pi/180.0,
|
||||||
|
|
||||||
patchDisp,
|
patchDisp,
|
||||||
patchNLayers,
|
patchNLayers,
|
||||||
@ -2633,14 +2648,15 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Determine (wanted) point-wise layer thickness and expansion ratio
|
// Determine (wanted) point-wise layer thickness and expansion ratio
|
||||||
scalarField thickness(pp.nPoints());
|
scalarField thickness(pp().nPoints());
|
||||||
scalarField minThickness(pp.nPoints());
|
scalarField minThickness(pp().nPoints());
|
||||||
scalarField expansionRatio(pp.nPoints());
|
scalarField expansionRatio(pp().nPoints());
|
||||||
calculateLayerThickness
|
calculateLayerThickness
|
||||||
(
|
(
|
||||||
pp,
|
pp,
|
||||||
meshMover.adaptPatchIDs(),
|
meshMover().adaptPatchIDs(),
|
||||||
layerParams.expansionRatio(),
|
layerParams.expansionRatio(),
|
||||||
|
|
||||||
layerParams.relativeSizes(), // thickness relative to cellsize?
|
layerParams.relativeSizes(), // thickness relative to cellsize?
|
||||||
@ -2663,11 +2679,11 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
|
|
||||||
// Find maximum length of a patch name, for a nicer output
|
// Find maximum length of a patch name, for a nicer output
|
||||||
label maxPatchNameLen = 0;
|
label maxPatchNameLen = 0;
|
||||||
forAll(meshMover.adaptPatchIDs(), i)
|
forAll(meshMover().adaptPatchIDs(), i)
|
||||||
{
|
{
|
||||||
label patchI = meshMover.adaptPatchIDs()[i];
|
label patchI = meshMover().adaptPatchIDs()[i];
|
||||||
word patchName = patches[patchI].name();
|
word patchName = patches[patchI].name();
|
||||||
maxPatchNameLen = max(maxPatchNameLen,label(patchName.size()));
|
maxPatchNameLen = max(maxPatchNameLen, label(patchName.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< nl
|
Info<< nl
|
||||||
@ -2678,9 +2694,9 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
<< setf(ios_base::left) << setw(maxPatchNameLen) << "-----"
|
<< setf(ios_base::left) << setw(maxPatchNameLen) << "-----"
|
||||||
<< setw(0) << " ----- ------ --------- -------" << endl;
|
<< setw(0) << " ----- ------ --------- -------" << endl;
|
||||||
|
|
||||||
forAll(meshMover.adaptPatchIDs(), i)
|
forAll(meshMover().adaptPatchIDs(), i)
|
||||||
{
|
{
|
||||||
label patchI = meshMover.adaptPatchIDs()[i];
|
label patchI = meshMover().adaptPatchIDs()[i];
|
||||||
|
|
||||||
const labelList& meshPoints = patches[patchI].meshPoints();
|
const labelList& meshPoints = patches[patchI].meshPoints();
|
||||||
|
|
||||||
@ -2691,7 +2707,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
|
|
||||||
forAll(meshPoints, patchPointI)
|
forAll(meshPoints, patchPointI)
|
||||||
{
|
{
|
||||||
label ppPointI = pp.meshPointMap()[meshPoints[patchPointI]];
|
label ppPointI = pp().meshPointMap()[meshPoints[patchPointI]];
|
||||||
|
|
||||||
//maxThickness = max(maxThickness, thickness[ppPointI]);
|
//maxThickness = max(maxThickness, thickness[ppPointI]);
|
||||||
//minThickness = min(minThickness, thickness[ppPointI]);
|
//minThickness = min(minThickness, thickness[ppPointI]);
|
||||||
@ -2761,7 +2777,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
IOobject::NO_WRITE,
|
IOobject::NO_WRITE,
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
meshMover.pMesh(),
|
meshMover().pMesh(),
|
||||||
dimensionedScalar("pointMedialDist", dimless, 0.0)
|
dimensionedScalar("pointMedialDist", dimless, 0.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2776,7 +2792,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
IOobject::NO_WRITE,
|
IOobject::NO_WRITE,
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
meshMover.pMesh(),
|
meshMover().pMesh(),
|
||||||
dimensionedVector("dispVec", dimless, vector::zero)
|
dimensionedVector("dispVec", dimless, vector::zero)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2791,7 +2807,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
IOobject::NO_WRITE,
|
IOobject::NO_WRITE,
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
meshMover.pMesh(),
|
meshMover().pMesh(),
|
||||||
dimensionedScalar("medialRatio", dimless, 0.0)
|
dimensionedScalar("medialRatio", dimless, 0.0)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2871,7 +2887,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
{
|
{
|
||||||
pointField oldPatchPos(pp.localPoints());
|
pointField oldPatchPos(pp().localPoints());
|
||||||
|
|
||||||
//// Laplacian displacement shrinking.
|
//// Laplacian displacement shrinking.
|
||||||
//shrinkMeshDistance
|
//shrinkMeshDistance
|
||||||
@ -2886,7 +2902,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
// Medial axis based shrinking
|
// Medial axis based shrinking
|
||||||
shrinkMeshMedialDistance
|
shrinkMeshMedialDistance
|
||||||
(
|
(
|
||||||
meshMover,
|
meshMover(),
|
||||||
meshQualityDict,
|
meshQualityDict,
|
||||||
|
|
||||||
layerParams.nSmoothThickness(),
|
layerParams.nSmoothThickness(),
|
||||||
@ -2908,7 +2924,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Update patchDisp (since not all might have been honoured)
|
// Update patchDisp (since not all might have been honoured)
|
||||||
patchDisp = oldPatchPos - pp.localPoints();
|
patchDisp = oldPatchPos - pp().localPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Truncate displacements that are too small (this will do internal
|
// Truncate displacements that are too small (this will do internal
|
||||||
@ -2916,7 +2932,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
faceSet dummySet(mesh, "wrongPatchFaces", 0);
|
faceSet dummySet(mesh, "wrongPatchFaces", 0);
|
||||||
truncateDisplacement
|
truncateDisplacement
|
||||||
(
|
(
|
||||||
meshMover,
|
meshMover(),
|
||||||
minThickness,
|
minThickness,
|
||||||
dummySet,
|
dummySet,
|
||||||
patchDisp,
|
patchDisp,
|
||||||
@ -2931,7 +2947,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
dumpDisplacement
|
dumpDisplacement
|
||||||
(
|
(
|
||||||
mesh.time().path()/"layer",
|
mesh.time().path()/"layer",
|
||||||
pp,
|
pp(),
|
||||||
patchDisp,
|
patchDisp,
|
||||||
extrudeStatus
|
extrudeStatus
|
||||||
);
|
);
|
||||||
@ -2955,11 +2971,11 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
// Determine per point/per face number of layers to extrude. Also
|
// Determine per point/per face number of layers to extrude. Also
|
||||||
// handles the slow termination of layers when going switching layers
|
// handles the slow termination of layers when going switching layers
|
||||||
|
|
||||||
labelList nPatchPointLayers(pp.nPoints(),-1);
|
labelList nPatchPointLayers(pp().nPoints(),-1);
|
||||||
labelList nPatchFaceLayers(pp.localFaces().size(),-1);
|
labelList nPatchFaceLayers(pp().localFaces().size(),-1);
|
||||||
setupLayerInfoTruncation
|
setupLayerInfoTruncation
|
||||||
(
|
(
|
||||||
meshMover,
|
meshMover(),
|
||||||
patchNLayers,
|
patchNLayers,
|
||||||
extrudeStatus,
|
extrudeStatus,
|
||||||
layerParams.nBufferCellsNoExtrude(),
|
layerParams.nBufferCellsNoExtrude(),
|
||||||
@ -2998,7 +3014,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
addLayer.setRefinement
|
addLayer.setRefinement
|
||||||
(
|
(
|
||||||
invExpansionRatio,
|
invExpansionRatio,
|
||||||
pp,
|
pp(),
|
||||||
labelList(0), // exposed patchIDs, not used for adding layers
|
labelList(0), // exposed patchIDs, not used for adding layers
|
||||||
nPatchFaceLayers, // layers per face
|
nPatchFaceLayers, // layers per face
|
||||||
nPatchPointLayers, // layers per point
|
nPatchPointLayers, // layers per point
|
||||||
@ -3050,8 +3066,8 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
addLayer.updateMesh
|
addLayer.updateMesh
|
||||||
(
|
(
|
||||||
map,
|
map,
|
||||||
identity(pp.size()),
|
identity(pp().size()),
|
||||||
identity(pp.nPoints())
|
identity(pp().nPoints())
|
||||||
);
|
);
|
||||||
|
|
||||||
// Collect layer faces and cells for outside loop.
|
// Collect layer faces and cells for outside loop.
|
||||||
@ -3098,7 +3114,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
(
|
(
|
||||||
addLayer,
|
addLayer,
|
||||||
meshQualityDict,
|
meshQualityDict,
|
||||||
pp,
|
pp(),
|
||||||
newMesh,
|
newMesh,
|
||||||
|
|
||||||
patchDisp,
|
patchDisp,
|
||||||
@ -3107,7 +3123,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
);
|
);
|
||||||
|
|
||||||
Info<< "Extruding " << countExtrusion(pp, extrudeStatus)
|
Info<< "Extruding " << countExtrusion(pp, extrudeStatus)
|
||||||
<< " out of " << returnReduce(pp.size(), sumOp<label>())
|
<< " out of " << returnReduce(pp().size(), sumOp<label>())
|
||||||
<< " faces. Removed extrusion at " << nTotChanged << " faces."
|
<< " faces. Removed extrusion at " << nTotChanged << " faces."
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
@ -3117,8 +3133,8 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reset mesh points and start again
|
// Reset mesh points and start again
|
||||||
meshMover.movePoints(oldPoints);
|
meshMover().movePoints(oldPoints);
|
||||||
meshMover.correct();
|
meshMover().correct();
|
||||||
|
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
}
|
}
|
||||||
@ -3173,6 +3189,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
(
|
(
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
scalarField(mesh.nCells(), 1.0),
|
||||||
decomposer,
|
decomposer,
|
||||||
distributor
|
distributor
|
||||||
);
|
);
|
||||||
@ -3211,7 +3228,7 @@ void Foam::autoLayerDriver::doLayers
|
|||||||
fvMeshDistribute& distributor
|
fvMeshDistribute& distributor
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fvMesh& mesh = meshRefiner_.mesh();
|
const fvMesh& mesh = meshRefiner_.mesh();
|
||||||
|
|
||||||
Info<< nl
|
Info<< nl
|
||||||
<< "Shrinking and layer addition phase" << nl
|
<< "Shrinking and layer addition phase" << nl
|
||||||
@ -3245,59 +3262,80 @@ void Foam::autoLayerDriver::doLayers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
autoPtr<indirectPrimitivePatch> ppPtr
|
// Check that outside of mesh is not multiply connected.
|
||||||
|
checkMeshManifold();
|
||||||
|
|
||||||
|
// Check initial mesh
|
||||||
|
Info<< "Checking initial mesh ..." << endl;
|
||||||
|
labelHashSet wrongFaces(mesh.nFaces()/100);
|
||||||
|
motionSmoother::checkMesh(false, mesh, motionDict, wrongFaces);
|
||||||
|
const label nInitErrors = returnReduce
|
||||||
(
|
(
|
||||||
meshRefinement::makePatch
|
wrongFaces.size(),
|
||||||
(
|
sumOp<label>()
|
||||||
mesh,
|
|
||||||
patchIDs
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
indirectPrimitivePatch& pp = ppPtr();
|
|
||||||
|
|
||||||
// Construct iterative mesh mover.
|
Info<< "Detected " << nInitErrors << " illegal faces"
|
||||||
Info<< "Constructing mesh displacer ..." << endl;
|
<< " (concave, zero area or negative cell pyramid volume)"
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
|
||||||
|
// Balance
|
||||||
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
const pointMesh& pMesh = pointMesh::New(mesh);
|
Info<< nl
|
||||||
|
<< "Doing initial balancing" << nl
|
||||||
motionSmoother meshMover
|
<< "-----------------------" << nl
|
||||||
(
|
|
||||||
mesh,
|
|
||||||
pp,
|
|
||||||
patchIDs,
|
|
||||||
meshRefinement::makeDisplacementField(pMesh, patchIDs),
|
|
||||||
motionDict
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check that outside of mesh is not multiply connected.
|
|
||||||
checkMeshManifold();
|
|
||||||
|
|
||||||
// Check initial mesh
|
|
||||||
Info<< "Checking initial mesh ..." << endl;
|
|
||||||
labelHashSet wrongFaces(mesh.nFaces()/100);
|
|
||||||
motionSmoother::checkMesh(false, mesh, motionDict, wrongFaces);
|
|
||||||
const label nInitErrors = returnReduce
|
|
||||||
(
|
|
||||||
wrongFaces.size(),
|
|
||||||
sumOp<label>()
|
|
||||||
);
|
|
||||||
|
|
||||||
Info<< "Detected " << nInitErrors << " illegal faces"
|
|
||||||
<< " (concave, zero area or negative cell pyramid volume)"
|
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
// Do all topo changes
|
scalarField cellWeights(mesh.nCells(), 1);
|
||||||
addLayers
|
forAll(numLayers, patchI)
|
||||||
|
{
|
||||||
|
if (numLayers[patchI] > 0)
|
||||||
|
{
|
||||||
|
const polyPatch& pp = mesh.boundaryMesh()[patchI];
|
||||||
|
forAll(pp.faceCells(), i)
|
||||||
|
{
|
||||||
|
cellWeights[pp.faceCells()[i]] += numLayers[patchI];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Balance mesh (and meshRefinement). No restriction on face zones
|
||||||
|
// and baffles.
|
||||||
|
autoPtr<mapDistributePolyMesh> map = meshRefiner_.balance
|
||||||
(
|
(
|
||||||
layerParams,
|
false,
|
||||||
motionDict,
|
false,
|
||||||
nInitErrors,
|
cellWeights,
|
||||||
meshMover,
|
|
||||||
decomposer,
|
decomposer,
|
||||||
distributor
|
distributor
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//{
|
||||||
|
// globalIndex globalCells(mesh.nCells());
|
||||||
|
//
|
||||||
|
// Info<< "** Distribution after balancing:" << endl;
|
||||||
|
// for (label procI = 0; procI < Pstream::nProcs(); procI++)
|
||||||
|
// {
|
||||||
|
// Info<< " " << procI << '\t'
|
||||||
|
// << globalCells.localSize(procI) << endl;
|
||||||
|
// }
|
||||||
|
// Info<< endl;
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Do all topo changes
|
||||||
|
addLayers
|
||||||
|
(
|
||||||
|
layerParams,
|
||||||
|
motionDict,
|
||||||
|
patchIDs,
|
||||||
|
nInitErrors,
|
||||||
|
decomposer,
|
||||||
|
distributor
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -523,8 +523,8 @@ public:
|
|||||||
(
|
(
|
||||||
const layerParameters& layerParams,
|
const layerParameters& layerParams,
|
||||||
const dictionary& motionDict,
|
const dictionary& motionDict,
|
||||||
|
const labelList& patchIDs,
|
||||||
const label nAllowableErrors,
|
const label nAllowableErrors,
|
||||||
motionSmoother& meshMover,
|
|
||||||
decompositionMethod& decomposer,
|
decompositionMethod& decomposer,
|
||||||
fvMeshDistribute& distributor
|
fvMeshDistribute& distributor
|
||||||
);
|
);
|
||||||
|
|||||||
@ -35,7 +35,6 @@ License
|
|||||||
#include "refinementSurfaces.H"
|
#include "refinementSurfaces.H"
|
||||||
#include "shellSurfaces.H"
|
#include "shellSurfaces.H"
|
||||||
#include "mapDistributePolyMesh.H"
|
#include "mapDistributePolyMesh.H"
|
||||||
#include "mathConstants.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -210,7 +209,8 @@ Foam::label Foam::autoRefineDriver::featureEdgeRefine
|
|||||||
"feature refinement iteration " + name(iter),
|
"feature refinement iteration " + name(iter),
|
||||||
decomposer_,
|
decomposer_,
|
||||||
distributor_,
|
distributor_,
|
||||||
cellsToRefine
|
cellsToRefine,
|
||||||
|
refineParams.maxLoadUnbalance()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -310,7 +310,8 @@ Foam::label Foam::autoRefineDriver::surfaceOnlyRefine
|
|||||||
"surface refinement iteration " + name(iter),
|
"surface refinement iteration " + name(iter),
|
||||||
decomposer_,
|
decomposer_,
|
||||||
distributor_,
|
distributor_,
|
||||||
cellsToRefine
|
cellsToRefine,
|
||||||
|
refineParams.maxLoadUnbalance()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return iter;
|
return iter;
|
||||||
@ -492,7 +493,8 @@ Foam::label Foam::autoRefineDriver::shellRefine
|
|||||||
"shell refinement iteration " + name(iter),
|
"shell refinement iteration " + name(iter),
|
||||||
decomposer_,
|
decomposer_,
|
||||||
distributor_,
|
distributor_,
|
||||||
cellsToRefine
|
cellsToRefine,
|
||||||
|
refineParams.maxLoadUnbalance()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
meshRefiner_.userFaceData().clear();
|
meshRefiner_.userFaceData().clear();
|
||||||
@ -776,11 +778,14 @@ void Foam::autoRefineDriver::doRefine
|
|||||||
const_cast<Time&>(mesh.time())++;
|
const_cast<Time&>(mesh.time())++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do final balancing. Keep zoned faces on one processor.
|
// Do final balancing. Keep zoned faces on one processor since the
|
||||||
|
// snap phase will convert them to baffles and this only works for
|
||||||
|
// internal faces.
|
||||||
meshRefiner_.balance
|
meshRefiner_.balance
|
||||||
(
|
(
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
|
scalarField(mesh.nCells(), 1), // dummy weights
|
||||||
decomposer_,
|
decomposer_,
|
||||||
distributor_
|
distributor_
|
||||||
);
|
);
|
||||||
|
|||||||
@ -43,7 +43,8 @@ Foam::refinementParameters::refinementParameters
|
|||||||
minRefineCells_(readLabel(dict.lookup("minimumRefine"))),
|
minRefineCells_(readLabel(dict.lookup("minimumRefine"))),
|
||||||
curvature_(readScalar(dict.lookup("curvature"))),
|
curvature_(readScalar(dict.lookup("curvature"))),
|
||||||
nBufferLayers_(readLabel(dict.lookup("nBufferLayers"))),
|
nBufferLayers_(readLabel(dict.lookup("nBufferLayers"))),
|
||||||
keepPoints_(dict.lookup("keepPoints"))
|
keepPoints_(dict.lookup("keepPoints")),
|
||||||
|
maxLoadUnbalance_(dict.lookupOrDefault<scalar>("maxLoadUnbalance",0))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +54,8 @@ Foam::refinementParameters::refinementParameters(const dictionary& dict)
|
|||||||
maxLocalCells_(readLabel(dict.lookup("maxLocalCells"))),
|
maxLocalCells_(readLabel(dict.lookup("maxLocalCells"))),
|
||||||
minRefineCells_(readLabel(dict.lookup("minRefinementCells"))),
|
minRefineCells_(readLabel(dict.lookup("minRefinementCells"))),
|
||||||
nBufferLayers_(readLabel(dict.lookup("nCellsBetweenLevels"))),
|
nBufferLayers_(readLabel(dict.lookup("nCellsBetweenLevels"))),
|
||||||
keepPoints_(pointField(1, dict.lookup("locationInMesh")))
|
keepPoints_(pointField(1, dict.lookup("locationInMesh"))),
|
||||||
|
maxLoadUnbalance_(dict.lookupOrDefault<scalar>("maxLoadUnbalance",0))
|
||||||
{
|
{
|
||||||
scalar featAngle(readScalar(dict.lookup("resolveFeatureAngle")));
|
scalar featAngle(readScalar(dict.lookup("resolveFeatureAngle")));
|
||||||
|
|
||||||
|
|||||||
@ -73,6 +73,9 @@ class refinementParameters
|
|||||||
//- Areas to keep
|
//- Areas to keep
|
||||||
const pointField keepPoints_;
|
const pointField keepPoints_;
|
||||||
|
|
||||||
|
//- Allowed load unbalance
|
||||||
|
scalar maxLoadUnbalance_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
@ -134,6 +137,12 @@ public:
|
|||||||
return keepPoints_;
|
return keepPoints_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Allowed load unbalance
|
||||||
|
scalar maxLoadUnbalance() const
|
||||||
|
{
|
||||||
|
return maxLoadUnbalance_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
|
|
||||||
|
|||||||
@ -552,13 +552,16 @@ void Foam::meshRefinement::calcLocalRegions
|
|||||||
const globalIndex& globalCells,
|
const globalIndex& globalCells,
|
||||||
const labelList& globalRegion,
|
const labelList& globalRegion,
|
||||||
const Map<label>& coupledRegionToMaster,
|
const Map<label>& coupledRegionToMaster,
|
||||||
|
const scalarField& cellWeights,
|
||||||
|
|
||||||
Map<label>& globalToLocalRegion,
|
Map<label>& globalToLocalRegion,
|
||||||
pointField& localPoints
|
pointField& localPoints,
|
||||||
|
scalarField& localWeights
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
globalToLocalRegion.resize(globalRegion.size());
|
globalToLocalRegion.resize(globalRegion.size());
|
||||||
DynamicList<point> localCc(globalRegion.size()/2);
|
DynamicList<point> localCc(globalRegion.size()/2);
|
||||||
|
DynamicList<scalar> localWts(globalRegion.size()/2);
|
||||||
|
|
||||||
forAll(globalRegion, cellI)
|
forAll(globalRegion, cellI)
|
||||||
{
|
{
|
||||||
@ -573,6 +576,7 @@ void Foam::meshRefinement::calcLocalRegions
|
|||||||
// I am master. Allocate region for me.
|
// I am master. Allocate region for me.
|
||||||
globalToLocalRegion.insert(globalRegion[cellI], localCc.size());
|
globalToLocalRegion.insert(globalRegion[cellI], localCc.size());
|
||||||
localCc.append(mesh_.cellCentres()[cellI]);
|
localCc.append(mesh_.cellCentres()[cellI]);
|
||||||
|
localWts.append(cellWeights[cellI]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -581,11 +585,13 @@ void Foam::meshRefinement::calcLocalRegions
|
|||||||
if (globalToLocalRegion.insert(globalRegion[cellI], localCc.size()))
|
if (globalToLocalRegion.insert(globalRegion[cellI], localCc.size()))
|
||||||
{
|
{
|
||||||
localCc.append(mesh_.cellCentres()[cellI]);
|
localCc.append(mesh_.cellCentres()[cellI]);
|
||||||
|
localWts.append(cellWeights[cellI]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
localPoints.transfer(localCc);
|
localPoints.transfer(localCc);
|
||||||
|
localWeights.transfer(localWts);
|
||||||
|
|
||||||
if (localPoints.size() != globalToLocalRegion.size())
|
if (localPoints.size() != globalToLocalRegion.size())
|
||||||
{
|
{
|
||||||
@ -924,6 +930,7 @@ Foam::label Foam::meshRefinement::countHits() const
|
|||||||
// Determine distribution to move connected regions onto one processor.
|
// Determine distribution to move connected regions onto one processor.
|
||||||
Foam::labelList Foam::meshRefinement::decomposeCombineRegions
|
Foam::labelList Foam::meshRefinement::decomposeCombineRegions
|
||||||
(
|
(
|
||||||
|
const scalarField& cellWeights,
|
||||||
const boolList& blockedFace,
|
const boolList& blockedFace,
|
||||||
const List<labelPair>& explicitConnections,
|
const List<labelPair>& explicitConnections,
|
||||||
decompositionMethod& decomposer
|
decompositionMethod& decomposer
|
||||||
@ -965,14 +972,17 @@ Foam::labelList Foam::meshRefinement::decomposeCombineRegions
|
|||||||
|
|
||||||
Map<label> globalToLocalRegion;
|
Map<label> globalToLocalRegion;
|
||||||
pointField localPoints;
|
pointField localPoints;
|
||||||
|
scalarField localWeights;
|
||||||
calcLocalRegions
|
calcLocalRegions
|
||||||
(
|
(
|
||||||
globalCells,
|
globalCells,
|
||||||
globalRegion,
|
globalRegion,
|
||||||
coupledRegionToMaster,
|
coupledRegionToMaster,
|
||||||
|
cellWeights,
|
||||||
|
|
||||||
globalToLocalRegion,
|
globalToLocalRegion,
|
||||||
localPoints
|
localPoints,
|
||||||
|
localWeights
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -984,7 +994,7 @@ Foam::labelList Foam::meshRefinement::decomposeCombineRegions
|
|||||||
|
|
||||||
if (isA<geomDecomp>(decomposer))
|
if (isA<geomDecomp>(decomposer))
|
||||||
{
|
{
|
||||||
regionDistribution = decomposer.decompose(localPoints);
|
regionDistribution = decomposer.decompose(localPoints, localWeights);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -998,7 +1008,12 @@ Foam::labelList Foam::meshRefinement::decomposeCombineRegions
|
|||||||
regionRegions
|
regionRegions
|
||||||
);
|
);
|
||||||
|
|
||||||
regionDistribution = decomposer.decompose(regionRegions, localPoints);
|
regionDistribution = decomposer.decompose
|
||||||
|
(
|
||||||
|
regionRegions,
|
||||||
|
localPoints,
|
||||||
|
localWeights
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1058,6 +1073,7 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
|
|||||||
(
|
(
|
||||||
const bool keepZoneFaces,
|
const bool keepZoneFaces,
|
||||||
const bool keepBaffles,
|
const bool keepBaffles,
|
||||||
|
const scalarField& cellWeights,
|
||||||
decompositionMethod& decomposer,
|
decompositionMethod& decomposer,
|
||||||
fvMeshDistribute& distributor
|
fvMeshDistribute& distributor
|
||||||
)
|
)
|
||||||
@ -1151,6 +1167,7 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
|
|||||||
|
|
||||||
distribution = decomposeCombineRegions
|
distribution = decomposeCombineRegions
|
||||||
(
|
(
|
||||||
|
cellWeights,
|
||||||
blockedFace,
|
blockedFace,
|
||||||
couples,
|
couples,
|
||||||
decomposer
|
decomposer
|
||||||
@ -1170,13 +1187,21 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Normal decomposition
|
// Normal decomposition
|
||||||
distribution = decomposer.decompose(mesh_.cellCentres());
|
distribution = decomposer.decompose
|
||||||
|
(
|
||||||
|
mesh_.cellCentres(),
|
||||||
|
cellWeights
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Normal decomposition
|
// Normal decomposition
|
||||||
distribution = decomposer.decompose(mesh_.cellCentres());
|
distribution = decomposer.decompose
|
||||||
|
(
|
||||||
|
mesh_.cellCentres(),
|
||||||
|
cellWeights
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
|
|||||||
@ -214,9 +214,11 @@ private:
|
|||||||
const globalIndex& globalCells,
|
const globalIndex& globalCells,
|
||||||
const labelList& globalRegion,
|
const labelList& globalRegion,
|
||||||
const Map<label>& coupledRegionToMaster,
|
const Map<label>& coupledRegionToMaster,
|
||||||
|
const scalarField& cellWeights,
|
||||||
|
|
||||||
Map<label>& globalToLocalRegion,
|
Map<label>& globalToLocalRegion,
|
||||||
pointField& localPoints
|
pointField& localPoints,
|
||||||
|
scalarField& localWeights
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Convert region into global index.
|
//- Convert region into global index.
|
||||||
@ -574,6 +576,7 @@ public:
|
|||||||
// (e.g. to keep baffles together)
|
// (e.g. to keep baffles together)
|
||||||
labelList decomposeCombineRegions
|
labelList decomposeCombineRegions
|
||||||
(
|
(
|
||||||
|
const scalarField& cellWeights,
|
||||||
const boolList& blockedFace,
|
const boolList& blockedFace,
|
||||||
const List<labelPair>& explicitConnections,
|
const List<labelPair>& explicitConnections,
|
||||||
decompositionMethod&
|
decompositionMethod&
|
||||||
@ -587,6 +590,7 @@ public:
|
|||||||
(
|
(
|
||||||
const bool keepZoneFaces,
|
const bool keepZoneFaces,
|
||||||
const bool keepBaffles,
|
const bool keepBaffles,
|
||||||
|
const scalarField& cellWeights,
|
||||||
decompositionMethod& decomposer,
|
decompositionMethod& decomposer,
|
||||||
fvMeshDistribute& distributor
|
fvMeshDistribute& distributor
|
||||||
);
|
);
|
||||||
@ -648,7 +652,8 @@ public:
|
|||||||
const string& msg,
|
const string& msg,
|
||||||
decompositionMethod& decomposer,
|
decompositionMethod& decomposer,
|
||||||
fvMeshDistribute& distributor,
|
fvMeshDistribute& distributor,
|
||||||
const labelList& cellsToRefine
|
const labelList& cellsToRefine,
|
||||||
|
const scalar maxLoadUnbalance
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -37,6 +37,7 @@ License
|
|||||||
#include "mapDistributePolyMesh.H"
|
#include "mapDistributePolyMesh.H"
|
||||||
#include "featureEdgeMesh.H"
|
#include "featureEdgeMesh.H"
|
||||||
#include "Cloud.H"
|
#include "Cloud.H"
|
||||||
|
#include "globalIndex.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -1244,40 +1245,122 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::refine
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Do refinement of consistent set of cells followed by truncation and
|
//// Do refinement of consistent set of cells followed by truncation and
|
||||||
// load balancing.
|
//// load balancing.
|
||||||
|
//Foam::autoPtr<Foam::mapDistributePolyMesh>
|
||||||
|
//Foam::meshRefinement::refineAndBalance
|
||||||
|
//(
|
||||||
|
// const string& msg,
|
||||||
|
// decompositionMethod& decomposer,
|
||||||
|
// fvMeshDistribute& distributor,
|
||||||
|
// const labelList& cellsToRefine
|
||||||
|
//)
|
||||||
|
//{
|
||||||
|
// // Do all refinement
|
||||||
|
// refine(cellsToRefine);
|
||||||
|
//
|
||||||
|
// if (debug)
|
||||||
|
// {
|
||||||
|
// Pout<< "Writing refined but unbalanced " << msg
|
||||||
|
// << " mesh to time " << timeName() << endl;
|
||||||
|
// write
|
||||||
|
// (
|
||||||
|
// debug,
|
||||||
|
// mesh_.time().path()
|
||||||
|
// /timeName()
|
||||||
|
// );
|
||||||
|
// Pout<< "Dumped debug data in = "
|
||||||
|
// << mesh_.time().cpuTimeIncrement() << " s" << endl;
|
||||||
|
//
|
||||||
|
// // test all is still synced across proc patches
|
||||||
|
// checkData();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Info<< "Refined mesh in = "
|
||||||
|
// << mesh_.time().cpuTimeIncrement() << " s" << endl;
|
||||||
|
// printMeshInfo(debug, "After refinement " + msg);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// // Load balancing
|
||||||
|
// // ~~~~~~~~~~~~~~
|
||||||
|
//
|
||||||
|
// autoPtr<mapDistributePolyMesh> distMap;
|
||||||
|
//
|
||||||
|
// if (Pstream::nProcs() > 1)
|
||||||
|
// {
|
||||||
|
// scalarField cellWeights(mesh_.nCells(), 1);
|
||||||
|
//
|
||||||
|
// distMap = balance
|
||||||
|
// (
|
||||||
|
// false, //keepZoneFaces
|
||||||
|
// false, //keepBaffles
|
||||||
|
// cellWeights,
|
||||||
|
// decomposer,
|
||||||
|
// distributor
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// Info<< "Balanced mesh in = "
|
||||||
|
// << mesh_.time().cpuTimeIncrement() << " s" << endl;
|
||||||
|
//
|
||||||
|
// printMeshInfo(debug, "After balancing " + msg);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// if (debug)
|
||||||
|
// {
|
||||||
|
// Pout<< "Writing balanced " << msg
|
||||||
|
// << " mesh to time " << timeName() << endl;
|
||||||
|
// write
|
||||||
|
// (
|
||||||
|
// debug,
|
||||||
|
// mesh_.time().path()/timeName()
|
||||||
|
// );
|
||||||
|
// Pout<< "Dumped debug data in = "
|
||||||
|
// << mesh_.time().cpuTimeIncrement() << " s" << endl;
|
||||||
|
//
|
||||||
|
// // test all is still synced across proc patches
|
||||||
|
// checkData();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return distMap;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
// Do load balancing followed by refinement of consistent set of cells.
|
||||||
Foam::autoPtr<Foam::mapDistributePolyMesh>
|
Foam::autoPtr<Foam::mapDistributePolyMesh>
|
||||||
Foam::meshRefinement::refineAndBalance
|
Foam::meshRefinement::refineAndBalance
|
||||||
(
|
(
|
||||||
const string& msg,
|
const string& msg,
|
||||||
decompositionMethod& decomposer,
|
decompositionMethod& decomposer,
|
||||||
fvMeshDistribute& distributor,
|
fvMeshDistribute& distributor,
|
||||||
const labelList& cellsToRefine
|
const labelList& initCellsToRefine,
|
||||||
|
const scalar maxLoadUnbalance
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Do all refinement
|
labelList cellsToRefine(initCellsToRefine);
|
||||||
refine(cellsToRefine);
|
|
||||||
|
|
||||||
if (debug)
|
//{
|
||||||
{
|
// globalIndex globalCells(mesh_.nCells());
|
||||||
Pout<< "Writing refined but unbalanced " << msg
|
//
|
||||||
<< " mesh to time " << timeName() << endl;
|
// Info<< "** Distribution before balancing/refining:" << endl;
|
||||||
write
|
// for (label procI = 0; procI < Pstream::nProcs(); procI++)
|
||||||
(
|
// {
|
||||||
debug,
|
// Info<< " " << procI << '\t'
|
||||||
mesh_.time().path()
|
// << globalCells.localSize(procI) << endl;
|
||||||
/timeName()
|
// }
|
||||||
);
|
// Info<< endl;
|
||||||
Pout<< "Dumped debug data in = "
|
//}
|
||||||
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
|
//{
|
||||||
|
// globalIndex globalCells(cellsToRefine.size());
|
||||||
// test all is still synced across proc patches
|
//
|
||||||
checkData();
|
// Info<< "** Cells to be refined:" << endl;
|
||||||
}
|
// for (label procI = 0; procI < Pstream::nProcs(); procI++)
|
||||||
|
// {
|
||||||
Info<< "Refined mesh in = "
|
// Info<< " " << procI << '\t'
|
||||||
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
|
// << globalCells.localSize(procI) << endl;
|
||||||
printMeshInfo(debug, "After refinement " + msg);
|
// }
|
||||||
|
// Info<< endl;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
// Load balancing
|
// Load balancing
|
||||||
@ -1287,20 +1370,62 @@ Foam::meshRefinement::refineAndBalance
|
|||||||
|
|
||||||
if (Pstream::nProcs() > 1)
|
if (Pstream::nProcs() > 1)
|
||||||
{
|
{
|
||||||
distMap = balance
|
// First check if we need to balance at all. Precalculate number of
|
||||||
|
// cells after refinement and see what maximum difference is.
|
||||||
|
scalar nNewCells = scalar(mesh_.nCells() + 7*cellsToRefine.size());
|
||||||
|
scalar nIdealNewCells =
|
||||||
|
returnReduce(nNewCells, sumOp<scalar>())
|
||||||
|
/ Pstream::nProcs();
|
||||||
|
scalar unbalance = returnReduce
|
||||||
(
|
(
|
||||||
false, //keepZoneFaces
|
mag(1.0-nNewCells/nIdealNewCells),
|
||||||
false, //keepBaffles
|
maxOp<scalar>()
|
||||||
decomposer,
|
|
||||||
distributor
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Info<< "Balanced mesh in = "
|
if (unbalance <= maxLoadUnbalance)
|
||||||
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
|
{
|
||||||
|
Info<< "Skipping balancing since max unbalance " << unbalance
|
||||||
|
<< " in = "
|
||||||
|
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scalarField cellWeights(mesh_.nCells(), 1);
|
||||||
|
forAll(cellsToRefine, i)
|
||||||
|
{
|
||||||
|
cellWeights[cellsToRefine[i]] += 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
distMap = balance
|
||||||
|
(
|
||||||
|
false, //keepZoneFaces
|
||||||
|
false, //keepBaffles
|
||||||
|
cellWeights,
|
||||||
|
decomposer,
|
||||||
|
distributor
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update cells to refine
|
||||||
|
distMap().distributeCellIndices(cellsToRefine);
|
||||||
|
|
||||||
|
Info<< "Balanced mesh in = "
|
||||||
|
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
//{
|
||||||
|
// globalIndex globalCells(mesh_.nCells());
|
||||||
|
//
|
||||||
|
// Info<< "** Distribution after balancing:" << endl;
|
||||||
|
// for (label procI = 0; procI < Pstream::nProcs(); procI++)
|
||||||
|
// {
|
||||||
|
// Info<< " " << procI << '\t'
|
||||||
|
// << globalCells.localSize(procI) << endl;
|
||||||
|
// }
|
||||||
|
// Info<< endl;
|
||||||
|
//}
|
||||||
|
|
||||||
printMeshInfo(debug, "After balancing " + msg);
|
printMeshInfo(debug, "After balancing " + msg);
|
||||||
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "Writing balanced " << msg
|
Pout<< "Writing balanced " << msg
|
||||||
@ -1318,6 +1443,46 @@ Foam::meshRefinement::refineAndBalance
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Refinement
|
||||||
|
// ~~~~~~~~~~
|
||||||
|
|
||||||
|
refine(cellsToRefine);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "Writing refined " << msg
|
||||||
|
<< " mesh to time " << timeName() << endl;
|
||||||
|
write
|
||||||
|
(
|
||||||
|
debug,
|
||||||
|
mesh_.time().path()
|
||||||
|
/timeName()
|
||||||
|
);
|
||||||
|
Pout<< "Dumped debug data in = "
|
||||||
|
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
|
||||||
|
|
||||||
|
// test all is still synced across proc patches
|
||||||
|
checkData();
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "Refined mesh in = "
|
||||||
|
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
|
||||||
|
|
||||||
|
//{
|
||||||
|
// globalIndex globalCells(mesh_.nCells());
|
||||||
|
//
|
||||||
|
// Info<< "** After refinement distribution:" << endl;
|
||||||
|
// for (label procI = 0; procI < Pstream::nProcs(); procI++)
|
||||||
|
// {
|
||||||
|
// Info<< " " << procI << '\t'
|
||||||
|
// << globalCells.localSize(procI) << endl;
|
||||||
|
// }
|
||||||
|
// Info<< endl;
|
||||||
|
//}
|
||||||
|
|
||||||
|
printMeshInfo(debug, "After refinement " + msg);
|
||||||
|
|
||||||
return distMap;
|
return distMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user