Merge commit 'OpenCFD/master' into olesenm

This commit is contained in:
Mark Olesen
2009-09-23 09:14:28 +02:00
16 changed files with 543 additions and 189 deletions

View File

@ -32,7 +32,8 @@ Description
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)
{
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
}
// All edges of mesh
@ -75,8 +76,7 @@ void writePoints(const polyMesh& mesh, const fileName& timeName)
{
const edge& e = mesh.edges()[edgeI];
pointStream << "l " << e.start() + 1 << ' ' << e.end() + 1
<< endl;
pointStream << "l " << e.start() + 1 << ' ' << e.end() + 1 << nl;
}
}
@ -277,7 +277,47 @@ void writePatchFaces
{
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();
argList::validOptions.insert("patchFaces", "");
argList::validOptions.insert("patchEdges", "");
argList::validOptions.insert("cell", "cellI");
argList::validOptions.insert("face", "faceI");
argList::validOptions.insert("point", "pointI");
@ -351,6 +392,7 @@ int main(int argc, char *argv[])
runTime.functionObjects().off();
bool patchFaces = args.optionFound("patchFaces");
bool patchEdges = args.optionFound("patchEdges");
bool doCell = args.optionFound("cell");
bool doPoint = args.optionFound("point");
bool doFace = args.optionFound("face");
@ -381,19 +423,23 @@ int main(int argc, char *argv[])
{
writePatchFaces(mesh, runTime.timeName());
}
else if (doCell)
if (patchEdges)
{
writePatchBoundaryEdges(mesh, runTime.timeName());
}
if (doCell)
{
label cellI = args.optionRead<label>("cell");
writePoints(mesh, cellI, runTime.timeName());
}
else if (doPoint)
if (doPoint)
{
label pointI = args.optionRead<label>("point");
writePointCells(mesh, pointI, runTime.timeName());
}
else if (doFace)
if (doFace)
{
label faceI = args.optionRead<label>("face");
@ -415,7 +461,7 @@ int main(int argc, char *argv[])
meshTools::writeOBJ(str, faceList(1, f), mesh.points());
}
else if (doCellSet)
if (doCellSet)
{
word setName(args.option("cellSet"));
@ -427,7 +473,7 @@ int main(int argc, char *argv[])
writePoints(mesh, cells.toc(), runTime.timeName());
}
else if (doFaceSet)
if (doFaceSet)
{
word setName(args.option("faceSet"));
@ -458,7 +504,16 @@ int main(int argc, char *argv[])
faces.toc()
);
}
else
else if
(
!patchFaces
&& !patchEdges
&& !doCell
&& !doPoint
&& !doFace
&& !doCellSet
&& !doFaceSet
)
{
// points & edges
writePoints(mesh, runTime.timeName());

View File

@ -71,7 +71,8 @@ linearNormalCoeffs
linearDirectionCoeffs
{
direction (0 0 1);
direction (0 1 0);
thickness 0.05;
}
linearRadialCoeffs
@ -89,7 +90,7 @@ sigmaRadialCoeffs
// Do front and back need to be merged? Usually only makes sense for 360
// degree wedges.
mergeFaces true;
mergeFaces false; //true;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -49,7 +49,7 @@ int main(int argc, char *argv[])
(
IOobject
(
mergePolyMesh::defaultRegion,
masterRegion,
runTimeMaster.timeName(),
runTimeMaster
)
@ -63,7 +63,7 @@ int main(int argc, char *argv[])
(
IOobject
(
mergePolyMesh::defaultRegion,
addRegion,
runTimeToAdd.timeName(),
runTimeToAdd
)

View File

@ -2,9 +2,11 @@
argList::validArgs.append("master root");
argList::validArgs.append("master case");
argList::validOptions.insert("masterRegion", "name");
argList::validArgs.append("root to add");
argList::validArgs.append("case to add");
argList::validOptions.insert("addRegion", "name");
argList args(argc, argv);
@ -15,9 +17,15 @@
fileName rootDirMaster(args.additionalArgs()[0]);
fileName caseDirMaster(args.additionalArgs()[1]);
word masterRegion = polyMesh::defaultRegion;
args.optionReadIfPresent("masterRegion", masterRegion);
fileName rootDirToAdd(args.additionalArgs()[2]);
fileName caseDirToAdd(args.additionalArgs()[3]);
word addRegion = polyMesh::defaultRegion;
args.optionReadIfPresent("addRegion", addRegion);
Info<< "Master: " << rootDirMaster << " " << caseDirMaster << nl
<< "mesh to add: " << rootDirToAdd << " " << caseDirToAdd << endl;
Info<< "Master: " << rootDirMaster << " " << caseDirMaster
<< " region " << masterRegion << nl
<< "mesh to add: " << rootDirToAdd << " " << caseDirToAdd
<< " region " << addRegion << endl;

View File

@ -43,6 +43,9 @@ Description
the largest matching region (-sloppyCellZones). This will accept any
region that covers more than 50% of the zone. It has to be a subset
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.
autoPtr<mapPolyMesh> createRegionMesh
(
const regionSplit& cellRegion,
const labelList& cellRegion,
const EdgeMap<label>& interfaceToPatch,
const fvMesh& mesh,
const label regionI,
@ -766,7 +769,7 @@ autoPtr<mapPolyMesh> createRegionMesh
void createAndWriteRegion
(
const fvMesh& mesh,
const regionSplit& cellRegion,
const labelList& cellRegion,
const wordList& regionNames,
const EdgeMap<label>& interfaceToPatch,
const label regionI,
@ -1005,7 +1008,8 @@ void createAndWriteRegion
EdgeMap<label> addRegionPatches
(
fvMesh& mesh,
const regionSplit& cellRegion,
const labelList& cellRegion,
const label nCellRegions,
const edgeList& interfaces,
const EdgeMap<label>& interfaceSizes,
const wordList& regionNames
@ -1016,7 +1020,7 @@ EdgeMap<label> addRegionPatches
Info<< nl << "Adding patches" << nl << endl;
EdgeMap<label> interfaceToPatch(cellRegion.nRegions());
EdgeMap<label> interfaceToPatch(nCellRegions);
forAll(interfaces, interI)
{
@ -1108,13 +1112,14 @@ EdgeMap<label> addRegionPatches
label findCorrespondingRegion
(
const labelList& existingZoneID, // per cell the (unique) zoneID
const regionSplit& cellRegion,
const labelList& cellRegion,
const label nCellRegions,
const label zoneI,
const label minOverlapSize
)
{
// Per region the number of cells in zoneI
labelList cellsInZone(cellRegion.nRegions(), 0);
labelList cellsInZone(nCellRegions, 0);
forAll(cellRegion, cellI)
{
@ -1162,7 +1167,8 @@ label findCorrespondingRegion
//(
// const cellZoneMesh& cellZones,
// const labelList& existingZoneID, // per cell the (unique) zoneID
// const regionSplit& cellRegion,
// const labelList& cellRegion,
// const label nCellRegions,
// const label zoneI
//)
//{
@ -1227,6 +1233,7 @@ label findCorrespondingRegion
int main(int argc, char *argv[])
{
argList::validOptions.insert("cellZones", "");
argList::validOptions.insert("cellZonesOnly", "");
argList::validOptions.insert("blockedFaces", "faceSet");
argList::validOptions.insert("makeCellZones", "");
argList::validOptions.insert("largestOnly", "");
@ -1249,13 +1256,14 @@ int main(int argc, char *argv[])
<< blockedFacesName << nl << endl;
}
bool makeCellZones = args.optionFound("makeCellZones");
bool largestOnly = args.optionFound("largestOnly");
bool insidePoint = args.optionFound("insidePoint");
bool useCellZones = args.optionFound("cellZones");
bool overwrite = args.optionFound("overwrite");
bool detectOnly = args.optionFound("detectOnly");
bool sloppyCellZones = args.optionFound("sloppyCellZones");
bool makeCellZones = args.optionFound("makeCellZones");
bool largestOnly = args.optionFound("largestOnly");
bool insidePoint = args.optionFound("insidePoint");
bool useCellZones = args.optionFound("cellZones");
bool useCellZonesOnly = args.optionFound("cellZonesOnly");
bool overwrite = args.optionFound("overwrite");
bool detectOnly = args.optionFound("detectOnly");
bool sloppyCellZones = args.optionFound("sloppyCellZones");
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.
regionSplit cellRegion(mesh, blockedFace);
// cellRegion is the labelList with the region per cell.
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
@ -1429,7 +1461,7 @@ int main(int argc, char *argv[])
// Sizes per region
// ~~~~~~~~~~~~~~~~
labelList regionSizes(cellRegion.nRegions(), 0);
labelList regionSizes(nCellRegions, 0);
forAll(cellRegion, cellI)
{
@ -1489,9 +1521,9 @@ int main(int argc, char *argv[])
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Region per zone
labelList regionToZone(cellRegion.nRegions(), -1);
labelList regionToZone(nCellRegions, -1);
// Name of region
wordList regionNames(cellRegion.nRegions());
wordList regionNames(nCellRegions);
// Zone to region
labelList zoneToRegion(cellZones.size(), -1);
@ -1506,6 +1538,7 @@ int main(int argc, char *argv[])
(
zoneID,
cellRegion,
nCellRegions,
zoneI,
label(0.5*zoneSizes[zoneI]) // minimum overlap
);
@ -1532,6 +1565,7 @@ int main(int argc, char *argv[])
(
zoneID,
cellRegion,
nCellRegions,
zoneI,
1 // minimum overlap
);
@ -1660,7 +1694,7 @@ int main(int argc, char *argv[])
mesh.clearOut();
if (cellRegion.nRegions() == 1)
if (nCellRegions == 1)
{
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.
for (label regionI = 0; regionI < cellRegion.nRegions(); regionI++)
for (label regionI = 0; regionI < nCellRegions; regionI++)
{
label zoneI = regionToZone[regionI];
@ -1759,6 +1793,7 @@ int main(int argc, char *argv[])
(
mesh,
cellRegion,
nCellRegions,
interfaces,
interfaceSizes,
regionNames
@ -1837,7 +1872,7 @@ int main(int argc, char *argv[])
else
{
// Split all
for (label regionI = 0; regionI < cellRegion.nRegions(); regionI++)
for (label regionI = 0; regionI < nCellRegions; regionI++)
{
Info<< nl
<< "Region " << regionI << nl