GIT: Initial state after latest Foundation merge

This commit is contained in:
Andrew Heather
2016-09-20 14:49:08 +01:00
4571 changed files with 115696 additions and 74609 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -123,16 +123,16 @@ int main(int argc, char *argv[])
//
// Current patch number.
label newPatchI = bMesh.patches().size();
label newPatchi = bMesh.patches().size();
label suffix = 0;
while (true)
{
// Find first unset face.
label unsetFaceI = findIndex(patchIDs, -1);
label unsetFacei = findIndex(patchIDs, -1);
if (unsetFaceI == -1)
if (unsetFacei == -1)
{
// All faces have patchID set. Exit.
break;
@ -151,29 +151,29 @@ int main(int argc, char *argv[])
bMesh.changePatchType(patchName, "patch");
// Fill visited with all faces reachable from unsetFaceI.
// Fill visited with all faces reachable from unsetFacei.
boolList visited(bMesh.mesh().size());
bMesh.markFaces(markedEdges, unsetFaceI, visited);
bMesh.markFaces(markedEdges, unsetFacei, visited);
// Assign all visited faces to current patch
label nVisited = 0;
forAll(visited, faceI)
forAll(visited, facei)
{
if (visited[faceI])
if (visited[facei])
{
nVisited++;
patchIDs[faceI] = newPatchI;
patchIDs[facei] = newPatchi;
}
}
Info<< "Assigned " << nVisited << " faces to patch " << patchName
<< endl << endl;
newPatchI++;
newPatchi++;
}
@ -183,41 +183,41 @@ int main(int argc, char *argv[])
// Create new list of patches with old ones first
List<polyPatch*> newPatchPtrList(patches.size());
newPatchI = 0;
newPatchi = 0;
// Copy old patches
forAll(mesh.boundaryMesh(), patchI)
forAll(mesh.boundaryMesh(), patchi)
{
const polyPatch& patch = mesh.boundaryMesh()[patchI];
const polyPatch& patch = mesh.boundaryMesh()[patchi];
newPatchPtrList[newPatchI] =
newPatchPtrList[newPatchi] =
patch.clone
(
mesh.boundaryMesh(),
newPatchI,
newPatchi,
patch.size(),
patch.start()
).ptr();
newPatchI++;
newPatchi++;
}
// Add new ones with empty size.
for (label patchI = newPatchI; patchI < patches.size(); patchI++)
for (label patchi = newPatchi; patchi < patches.size(); patchi++)
{
const boundaryPatch& bp = patches[patchI];
const boundaryPatch& bp = patches[patchi];
newPatchPtrList[newPatchI] = polyPatch::New
newPatchPtrList[newPatchi] = polyPatch::New
(
polyPatch::typeName,
bp.name(),
0,
mesh.nFaces(),
newPatchI,
newPatchi,
mesh.boundaryMesh()
).ptr();
newPatchI++;
newPatchi++;
}
if (!overwrite)
@ -237,11 +237,11 @@ int main(int argc, char *argv[])
// have to do the geometric stuff.
const labelList& meshFace = bMesh.meshFace();
forAll(patchIDs, faceI)
forAll(patchIDs, facei)
{
label meshFaceI = meshFace[faceI];
label meshFacei = meshFace[facei];
polyMeshRepatcher.changePatchID(meshFaceI, patchIDs[faceI]);
polyMeshRepatcher.changePatchID(meshFacei, patchIDs[facei]);
}
polyMeshRepatcher.repatch();

View File

@ -1,5 +1,6 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \

View File

@ -1,3 +1,4 @@
#include "PatchTools.H"
#include "checkGeometry.H"
#include "polyMesh.H"
#include "cellSet.H"
@ -10,6 +11,12 @@
#include "surfaceWriter.H"
#include "checkTools.H"
#include "vtkSurfaceWriter.H"
#include "writer.H"
#include "checkTools.H"
#include "cyclicAMIPolyPatch.H"
#include "Time.H"
// Find wedge with opposite orientation. Note: does not actually check that
// it is opposite, only that it has opposite normal and same axis
@ -23,17 +30,17 @@ Foam::label Foam::findOppositeWedge
scalar wppCosAngle = wpp.cosAngle();
forAll(patches, patchI)
forAll(patches, patchi)
{
if
(
patchI != wpp.index()
&& patches[patchI].size()
&& isA<wedgePolyPatch>(patches[patchI])
patchi != wpp.index()
&& patches[patchi].size()
&& isA<wedgePolyPatch>(patches[patchi])
)
{
const wedgePolyPatch& pp =
refCast<const wedgePolyPatch>(patches[patchI]);
refCast<const wedgePolyPatch>(patches[patchi]);
// Calculate (cos of) angle to wpp (not pp!) centre normal
scalar ppCosAngle = wpp.centreNormal() & pp.n();
@ -45,7 +52,7 @@ Foam::label Foam::findOppositeWedge
&& mag(ppCosAngle - wppCosAngle) >= 1e-3
)
{
return patchI;
return patchi;
}
}
}
@ -69,12 +76,12 @@ bool Foam::checkWedges
const polyBoundaryMesh& patches = mesh.boundaryMesh();
forAll(patches, patchI)
forAll(patches, patchi)
{
if (patches[patchI].size() && isA<wedgePolyPatch>(patches[patchI]))
if (patches[patchi].size() && isA<wedgePolyPatch>(patches[patchi]))
{
const wedgePolyPatch& pp =
refCast<const wedgePolyPatch>(patches[patchI]);
refCast<const wedgePolyPatch>(patches[patchi]);
scalar wedgeAngle = acos(pp.cosAngle());
@ -86,9 +93,9 @@ bool Foam::checkWedges
}
// Find opposite
label oppositePatchI = findOppositeWedge(mesh, pp);
label oppositePatchi = findOppositeWedge(mesh, pp);
if (oppositePatchI == -1)
if (oppositePatchi == -1)
{
if (report)
{
@ -99,7 +106,7 @@ bool Foam::checkWedges
}
const wedgePolyPatch& opp =
refCast<const wedgePolyPatch>(patches[oppositePatchI]);
refCast<const wedgePolyPatch>(patches[oppositePatchi]);
if (mag(opp.axis() & pp.axis()) < (1-1e-3))
@ -158,9 +165,9 @@ bool Foam::checkWedges
// Check all non-wedge faces
label nEdgesInError = 0;
forAll(fcs, faceI)
forAll(fcs, facei)
{
const face& f = fcs[faceI];
const face& f = fcs[facei];
forAll(f, fp)
{
@ -202,7 +209,7 @@ bool Foam::checkWedges
// Ok if purely in empty directions.
if (nNonEmptyDirs > 0)
{
if (edgesInError.insert(edge(p0, p1), faceI))
if (edgesInError.insert(edge(p0, p1), facei))
{
nEdgesInError++;
}
@ -211,7 +218,7 @@ bool Foam::checkWedges
else if (nEmptyDirs > 1)
{
// Always an error
if (edgesInError.insert(edge(p0, p1), faceI))
if (edgesInError.insert(edge(p0, p1), facei))
{
nEdgesInError++;
}
@ -276,9 +283,9 @@ namespace Foam
// lists of size cpp to transform.
List<pointField> newPts(pts.size());
forAll(pts, faceI)
forAll(pts, facei)
{
newPts[faceI].setSize(pts[faceI].size());
newPts[facei].setSize(pts[facei].size());
}
label index = 0;
@ -288,12 +295,12 @@ namespace Foam
// Extract for every face the i'th position
pointField ptsAtIndex(pts.size(), Zero);
forAll(cpp, faceI)
forAll(cpp, facei)
{
const pointField& facePts = pts[faceI];
const pointField& facePts = pts[facei];
if (facePts.size() > index)
{
ptsAtIndex[faceI] = facePts[index];
ptsAtIndex[facei] = facePts[index];
n++;
}
}
@ -308,12 +315,12 @@ namespace Foam
cpp.transformPosition(ptsAtIndex);
// Extract back from ptsAtIndex into newPts
forAll(cpp, faceI)
forAll(cpp, facei)
{
pointField& facePts = newPts[faceI];
pointField& facePts = newPts[facei];
if (facePts.size() > index)
{
facePts[index] = ptsAtIndex[faceI];
facePts[index] = ptsAtIndex[facei];
}
}
@ -342,24 +349,24 @@ bool Foam::checkCoupledPoints
List<pointField> nbrPoints(fcs.size() - mesh.nInternalFaces());
// Exchange zero point
forAll(patches, patchI)
forAll(patches, patchi)
{
if (patches[patchI].coupled())
if (patches[patchi].coupled())
{
const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>
(
patches[patchI]
patches[patchi]
);
forAll(cpp, i)
{
label bFaceI = cpp.start() + i - mesh.nInternalFaces();
label bFacei = cpp.start() + i - mesh.nInternalFaces();
const face& f = cpp[i];
nbrPoints[bFaceI].setSize(f.size());
nbrPoints[bFacei].setSize(f.size());
forAll(f, fp)
{
const point& p0 = p[f[fp]];
nbrPoints[bFaceI][fp] = p0;
nbrPoints[bFacei][fp] = p0;
}
}
}
@ -377,12 +384,12 @@ bool Foam::checkCoupledPoints
scalar avgMismatch = 0;
label nCoupledPoints = 0;
forAll(patches, patchI)
forAll(patches, patchi)
{
if (patches[patchI].coupled())
if (patches[patchi].coupled())
{
const coupledPolyPatch& cpp =
refCast<const coupledPolyPatch>(patches[patchI]);
refCast<const coupledPolyPatch>(patches[patchi]);
if (cpp.owner())
{
@ -399,15 +406,15 @@ bool Foam::checkCoupledPoints
forAll(cpp, i)
{
label bFaceI = cpp.start() + i - mesh.nInternalFaces();
label bFacei = cpp.start() + i - mesh.nInternalFaces();
const face& f = cpp[i];
if (f.size() != nbrPoints[bFaceI].size())
if (f.size() != nbrPoints[bFacei].size())
{
FatalErrorInFunction
<< "Local face size : " << f.size()
<< " does not equal neighbour face size : "
<< nbrPoints[bFaceI].size()
<< nbrPoints[bFacei].size()
<< abort(FatalError);
}
@ -415,7 +422,7 @@ bool Foam::checkCoupledPoints
forAll(f, j)
{
const point& p0 = p[f[fp]];
scalar d = mag(p0 - nbrPoints[bFaceI][j]);
scalar d = mag(p0 - nbrPoints[bFacei][j]);
if (d > smallDist[i])
{
@ -478,7 +485,8 @@ Foam::label Foam::checkGeometry
(
const polyMesh& mesh,
const bool allGeometry,
const autoPtr<surfaceWriter>& writer
const autoPtr<surfaceWriter>& surfWriter,
const autoPtr<writer<scalar>>& setWriter
)
{
label noFailedChecks = 0;
@ -535,6 +543,10 @@ Foam::label Foam::checkGeometry
<< nonAlignedPoints.name() << endl;
nonAlignedPoints.instance() = mesh.pointsInstance();
nonAlignedPoints.write();
if (setWriter.valid())
{
mergeAndWrite(setWriter, nonAlignedPoints);
}
}
}
}
@ -565,9 +577,9 @@ Foam::label Foam::checkGeometry
<< " non closed cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance();
cells.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), cells);
mergeAndWrite(surfWriter(), cells);
}
}
}
@ -581,9 +593,9 @@ Foam::label Foam::checkGeometry
<< aspectCells.name() << endl;
aspectCells.instance() = mesh.pointsInstance();
aspectCells.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), aspectCells);
mergeAndWrite(surfWriter(), aspectCells);
}
}
}
@ -602,9 +614,9 @@ Foam::label Foam::checkGeometry
<< " zero area faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), faces);
mergeAndWrite(surfWriter(), faces);
}
}
}
@ -624,9 +636,9 @@ Foam::label Foam::checkGeometry
<< " zero volume cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance();
cells.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), cells);
mergeAndWrite(surfWriter(), cells);
}
}
}
@ -647,9 +659,9 @@ Foam::label Foam::checkGeometry
<< " non-orthogonal faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), faces);
mergeAndWrite(surfWriter(), faces);
}
}
}
@ -669,9 +681,9 @@ Foam::label Foam::checkGeometry
<< faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), faces);
mergeAndWrite(surfWriter(), faces);
}
}
}
@ -691,9 +703,9 @@ Foam::label Foam::checkGeometry
<< " skew faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), faces);
mergeAndWrite(surfWriter(), faces);
}
}
}
@ -715,9 +727,9 @@ Foam::label Foam::checkGeometry
<< faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), faces);
mergeAndWrite(surfWriter(), faces);
}
}
}
@ -748,9 +760,9 @@ Foam::label Foam::checkGeometry
<< "decomposition tets to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), faces);
mergeAndWrite(surfWriter(), faces);
}
}
}
@ -773,6 +785,10 @@ Foam::label Foam::checkGeometry
<< endl;
points.instance() = mesh.pointsInstance();
points.write();
if (setWriter.valid())
{
mergeAndWrite(setWriter, points);
}
}
}
@ -792,6 +808,10 @@ Foam::label Foam::checkGeometry
<< " apart) points to set " << nearPoints.name() << endl;
nearPoints.instance() = mesh.pointsInstance();
nearPoints.write();
if (setWriter.valid())
{
mergeAndWrite(setWriter, nearPoints);
}
}
}
}
@ -812,9 +832,9 @@ Foam::label Foam::checkGeometry
<< endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), faces);
mergeAndWrite(surfWriter(), faces);
}
}
}
@ -835,9 +855,9 @@ Foam::label Foam::checkGeometry
<< " warped faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), faces);
mergeAndWrite(surfWriter(), faces);
}
}
}
@ -856,9 +876,9 @@ Foam::label Foam::checkGeometry
<< " under-determined cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance();
cells.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), cells);
mergeAndWrite(surfWriter(), cells);
}
}
}
@ -876,9 +896,9 @@ Foam::label Foam::checkGeometry
<< " concave cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance();
cells.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), cells);
mergeAndWrite(surfWriter(), cells);
}
}
}
@ -897,9 +917,9 @@ Foam::label Foam::checkGeometry
<< faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), faces);
mergeAndWrite(surfWriter(), faces);
}
}
}
@ -918,9 +938,143 @@ Foam::label Foam::checkGeometry
<< faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), faces);
mergeAndWrite(surfWriter(), faces);
}
}
}
if (allGeometry)
{
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
const word tmName(mesh.time().timeName());
const word procAndTime(Foam::name(Pstream::myProcNo()) + "_" + tmName);
autoPtr<surfaceWriter> patchWriter;
if (!surfWriter.valid())
{
patchWriter.reset(new vtkSurfaceWriter());
}
const surfaceWriter& wr =
(
surfWriter.valid()
? surfWriter()
: patchWriter()
);
forAll(pbm, patchi)
{
if (isA<cyclicAMIPolyPatch>(pbm[patchi]))
{
const cyclicAMIPolyPatch& cpp =
refCast<const cyclicAMIPolyPatch>(pbm[patchi]);
if (cpp.owner())
{
Info<< "Calculating AMI weights between owner patch: "
<< cpp.name() << " and neighbour patch: "
<< cpp.neighbPatch().name() << endl;
const AMIPatchToPatchInterpolation& ami =
cpp.AMI();
{
// Collect geometry
labelList pointToGlobal;
labelList uniqueMeshPointLabels;
autoPtr<globalIndex> globalPoints;
autoPtr<globalIndex> globalFaces;
faceList mergedFaces;
pointField mergedPoints;
Foam::PatchTools::gatherAndMerge
(
mesh,
cpp.localFaces(),
cpp.meshPoints(),
cpp.meshPointMap(),
pointToGlobal,
uniqueMeshPointLabels,
globalPoints,
globalFaces,
mergedFaces,
mergedPoints
);
// Collect field
scalarField mergedWeights;
globalFaces().gather
(
UPstream::worldComm,
labelList(UPstream::procID(UPstream::worldComm)),
ami.srcWeightsSum(),
mergedWeights
);
if (Pstream::master())
{
wr.write
(
"postProcessing",
"src_" + tmName,
mergedPoints,
mergedFaces,
"weightsSum",
mergedWeights,
false
);
}
}
{
// Collect geometry
labelList pointToGlobal;
labelList uniqueMeshPointLabels;
autoPtr<globalIndex> globalPoints;
autoPtr<globalIndex> globalFaces;
faceList mergedFaces;
pointField mergedPoints;
Foam::PatchTools::gatherAndMerge
(
mesh,
cpp.neighbPatch().localFaces(),
cpp.neighbPatch().meshPoints(),
cpp.neighbPatch().meshPointMap(),
pointToGlobal,
uniqueMeshPointLabels,
globalPoints,
globalFaces,
mergedFaces,
mergedPoints
);
// Collect field
scalarField mergedWeights;
globalFaces().gather
(
UPstream::worldComm,
labelList(UPstream::procID(UPstream::worldComm)),
ami.tgtWeightsSum(),
mergedWeights
);
if (Pstream::master())
{
wr.write
(
"postProcessing",
"tgt_" + tmName,
mergedPoints,
mergedFaces,
"weightsSum",
mergedWeights,
false
);
}
}
}
}
}
}

View File

@ -1,6 +1,7 @@
#include "label.H"
#include "HashSet.H"
#include "labelVector.H"
#include "writer.H"
namespace Foam
{
@ -26,6 +27,7 @@ namespace Foam
(
const polyMesh& mesh,
const bool allGeometry,
const autoPtr<surfaceWriter>&
const autoPtr<surfaceWriter>&,
const autoPtr<writer<scalar>>&
);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
@ -31,19 +31,27 @@ Description
Checks validity of a mesh.
Usage
- checkMesh [OPTION]
\b checkMesh [OPTION]
\param -allGeometry \n
Checks all (including non finite-volume specific) geometry
Options:
- \par -allGeometry
Checks all (including non finite-volume specific) geometry
\param -allTopology \n
Checks all (including non finite-volume specific) addressing
- \par -allTopology
Checks all (including non finite-volume specific) addressing
\param -meshQuality \n
Checks against user defined (in \a system/meshQualityDict) quality settings
- \par -meshQuality
Checks against user defined (in \a system/meshQualityDict) quality
settings
\param -region \<name\> \n
Specify an alternative mesh region.
- \par -region \<name\>
Specify an alternative mesh region.
- \par -writeSets \<surfaceFormat\>
Reconstruct all cellSets and faceSets geometry and write to
postProcessing directory according to surfaceFormat
(e.g. vtk or ensight). Additionally reconstructs all pointSets and
writes as vtk format.
\param -writeSets \<surfaceFormat\> \n
Reconstruct all cellSets and faceSets geometry and write to postProcessing/
@ -56,7 +64,8 @@ Usage
#include "Time.H"
#include "polyMesh.H"
#include "globalMeshData.H"
#include "vtkSurfaceWriter.H"
#include "surfaceWriter.H"
#include "vtkSetWriter.H"
#include "checkTools.H"
#include "checkTopology.H"
@ -94,7 +103,7 @@ int main(int argc, char *argv[])
argList::addOption
(
"writeSets",
"surfaceFormat"
"surfaceFormat",
"reconstruct and write all faceSets and cellSets in selected format"
);
@ -156,10 +165,12 @@ int main(int argc, char *argv[])
}
autoPtr<surfaceWriter> writer;
autoPtr<surfaceWriter> surfWriter;
autoPtr<writer<scalar>> setWriter;
if (writeSets)
{
writer = surfaceWriter::New(surfaceFormat);
surfWriter = surfaceWriter::New(surfaceFormat);
setWriter = writer<scalar>::New(vtkSetWriter<scalar>::typeName);
}
@ -192,15 +203,22 @@ int main(int argc, char *argv[])
mesh,
allTopology,
allGeometry,
writer
surfWriter,
setWriter
);
}
nFailedChecks += checkGeometry(mesh, allGeometry, writer);
nFailedChecks += checkGeometry
(
mesh,
allGeometry,
surfWriter,
setWriter
);
if (meshQuality)
{
nFailedChecks += checkMeshQuality(mesh, qualDict(), writer);
nFailedChecks += checkMeshQuality(mesh, qualDict(), surfWriter);
}
@ -221,11 +239,17 @@ int main(int argc, char *argv[])
{
Info<< "Time = " << runTime.timeName() << nl << endl;
label nFailedChecks = checkGeometry(mesh, allGeometry, writer);
label nFailedChecks = checkGeometry
(
mesh,
allGeometry,
surfWriter,
setWriter
);
if (meshQuality)
{
nFailedChecks += checkMeshQuality(mesh, qualDict(), writer);
nFailedChecks += checkMeshQuality(mesh, qualDict(), surfWriter);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
@ -33,13 +33,14 @@ License
#include "tetWedgeMatcher.H"
#include "tetMatcher.H"
#include "IOmanip.H"
#include "pointSet.H"
#include "faceSet.H"
#include "cellSet.H"
#include "PatchTools.H"
#include "Time.H"
#include "surfaceWriter.H"
#include "sampledSurfaces.H"
#include "syncTools.H"
#include "globalIndex.H"
#include "PatchTools.H"
void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
@ -128,36 +129,36 @@ void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
Map<label> polyhedralFaces;
for (label cellI = 0; cellI < mesh.nCells(); cellI++)
for (label celli = 0; celli < mesh.nCells(); celli++)
{
if (hex.isA(mesh, cellI))
if (hex.isA(mesh, celli))
{
nHex++;
}
else if (tet.isA(mesh, cellI))
else if (tet.isA(mesh, celli))
{
nTet++;
}
else if (pyr.isA(mesh, cellI))
else if (pyr.isA(mesh, celli))
{
nPyr++;
}
else if (prism.isA(mesh, cellI))
else if (prism.isA(mesh, celli))
{
nPrism++;
}
else if (wedge.isA(mesh, cellI))
else if (wedge.isA(mesh, celli))
{
nWedge++;
}
else if (tetWedge.isA(mesh, cellI))
else if (tetWedge.isA(mesh, celli))
{
nTetWedge++;
}
else
{
nUnknown++;
polyhedralFaces(mesh.cells()[cellI].size())++;
polyhedralFaces(mesh.cells()[celli].size())++;
}
}
@ -188,9 +189,9 @@ void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
const labelList sortedKeys = polyhedralFaces.sortedToc();
forAll(sortedKeys, keyI)
forAll(sortedKeys, keyi)
{
const label nFaces = sortedKeys[keyI];
const label nFaces = sortedKeys[keyi];
Info<< setf(std::ios::right) << setw(13)
<< nFaces << " " << polyhedralFaces[nFaces] << nl;
@ -201,6 +202,58 @@ void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
}
void Foam::mergeAndWrite
(
const polyMesh& mesh,
const surfaceWriter& writer,
const word& name,
const indirectPrimitivePatch setPatch,
const fileName& outputDir
)
{
if (Pstream::parRun())
{
labelList pointToGlobal;
labelList uniqueMeshPointLabels;
autoPtr<globalIndex> globalPoints;
autoPtr<globalIndex> globalFaces;
faceList mergedFaces;
pointField mergedPoints;
Foam::PatchTools::gatherAndMerge
(
mesh,
setPatch.localFaces(),
setPatch.meshPoints(),
setPatch.meshPointMap(),
pointToGlobal,
uniqueMeshPointLabels,
globalPoints,
globalFaces,
mergedFaces,
mergedPoints
);
// Write
if (Pstream::master())
{
writer.write(outputDir, name, mergedPoints, mergedFaces);
}
}
else
{
writer.write
(
outputDir,
name,
setPatch.localPoints(),
setPatch.localFaces()
);
}
}
void Foam::mergeAndWrite
(
const surfaceWriter& writer,
@ -224,48 +277,7 @@ void Foam::mergeAndWrite
/ set.name()
);
if (Pstream::parRun())
{
// Use tolerance from sampling (since we're doing exactly the same
// when parallel merging)
const scalar tol = sampledSurfaces::mergeTol();
// dimension as fraction of mesh bounding box
scalar mergeDim = tol * mesh.bounds().mag();
pointField mergedPoints;
faceList mergedFaces;
labelList pointMergeMap;
PatchTools::gatherAndMerge
(
mergeDim,
setPatch,
mergedPoints,
mergedFaces,
pointMergeMap
);
if (Pstream::master())
{
writer.write
(
outputDir,
set.name(),
mergedPoints,
mergedFaces
);
}
}
else
{
writer.write
(
outputDir,
set.name(),
setPatch.localPoints(),
setPatch.localFaces()
);
}
mergeAndWrite(mesh, writer, set.name(), setPatch, outputDir);
}
@ -288,9 +300,9 @@ void Foam::mergeAndWrite
boolList bndInSet(mesh.nFaces()-mesh.nInternalFaces());
forAll(pbm, patchI)
forAll(pbm, patchi)
{
const polyPatch& pp = pbm[patchI];
const polyPatch& pp = pbm[patchi];
const labelList& fc = pp.faceCells();
forAll(fc, i)
{
@ -301,32 +313,32 @@ void Foam::mergeAndWrite
DynamicList<label> outsideFaces(3*set.size());
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
{
bool ownVal = isInSet[mesh.faceOwner()[faceI]];
bool neiVal = isInSet[mesh.faceNeighbour()[faceI]];
bool ownVal = isInSet[mesh.faceOwner()[facei]];
bool neiVal = isInSet[mesh.faceNeighbour()[facei]];
if (ownVal != neiVal)
{
outsideFaces.append(faceI);
outsideFaces.append(facei);
}
}
forAll(pbm, patchI)
forAll(pbm, patchi)
{
const polyPatch& pp = pbm[patchI];
const polyPatch& pp = pbm[patchi];
const labelList& fc = pp.faceCells();
if (pp.coupled())
{
forAll(fc, i)
{
label faceI = pp.start()+i;
label facei = pp.start()+i;
bool neiVal = bndInSet[faceI-mesh.nInternalFaces()];
bool neiVal = bndInSet[facei-mesh.nInternalFaces()];
if (isInSet[fc[i]] && !neiVal)
{
outsideFaces.append(faceI);
outsideFaces.append(facei);
}
}
}
@ -358,46 +370,118 @@ void Foam::mergeAndWrite
/ set.name()
);
mergeAndWrite(mesh, writer, set.name(), setPatch, outputDir);
}
void Foam::mergeAndWrite
(
const writer<scalar>& writer,
const pointSet& set
)
{
const polyMesh& mesh = refCast<const polyMesh>(set.db());
pointField mergedPts;
labelList mergedIDs;
if (Pstream::parRun())
{
// Use tolerance from sampling (since we're doing exactly the same
// when parallel merging)
const scalar tol = sampledSurfaces::mergeTol();
// dimension as fraction of mesh bounding box
scalar mergeDim = tol * mesh.bounds().mag();
// Note: we explicitly do not merge the points
// (mesh.globalData().mergePoints etc) since this might
// hide any synchronisation problem
pointField mergedPoints;
faceList mergedFaces;
labelList pointMergeMap;
globalIndex globalNumbering(mesh.nPoints());
mergedPts.setSize(returnReduce(set.size(), sumOp<label>()));
mergedIDs.setSize(mergedPts.size());
labelList setPointIDs(set.sortedToc());
// Get renumbered local data
pointField myPoints(mesh.points(), setPointIDs);
labelList myIDs(setPointIDs.size());
forAll(setPointIDs, i)
{
myIDs[i] = globalNumbering.toGlobal(setPointIDs[i]);
}
PatchTools::gatherAndMerge
(
mergeDim,
setPatch,
mergedPoints,
mergedFaces,
pointMergeMap
);
if (Pstream::master())
{
writer.write
// Insert master data first
label pOffset = 0;
SubList<point>(mergedPts, myPoints.size(), pOffset) = myPoints;
SubList<label>(mergedIDs, myIDs.size(), pOffset) = myIDs;
pOffset += myPoints.size();
// Receive slave ones
for (int slave=1; slave<Pstream::nProcs(); slave++)
{
IPstream fromSlave(Pstream::scheduled, slave);
pointField slavePts(fromSlave);
labelList slaveIDs(fromSlave);
SubList<point>(mergedPts, slavePts.size(), pOffset) = slavePts;
SubList<label>(mergedIDs, slaveIDs.size(), pOffset) = slaveIDs;
pOffset += slaveIDs.size();
}
}
else
{
// Construct processor stream with estimate of size. Could
// be improved.
OPstream toMaster
(
outputDir,
set.name(),
mergedPoints,
mergedFaces
Pstream::scheduled,
Pstream::masterNo(),
myPoints.byteSize() + myIDs.byteSize()
);
toMaster << myPoints << myIDs;
}
}
else
{
writer.write
mergedIDs = set.sortedToc();
mergedPts = pointField(mesh.points(), mergedIDs);
}
// Write with scalar pointID
if (Pstream::master())
{
scalarField scalarPointIDs(mergedIDs.size());
forAll(mergedIDs, i)
{
scalarPointIDs[i] = 1.0*mergedIDs[i];
}
coordSet points(set.name(), "distance", mergedPts, mag(mergedPts));
List<const scalarField*> flds(1, &scalarPointIDs);
wordList fldNames(1, "pointID");
// Output e.g. pointSet p0 to
// postProcessing/<time>/p0.vtk
const fileName outputDir
(
outputDir,
set.name(),
setPatch.localPoints(),
setPatch.localFaces()
set.time().path()
/ (Pstream::parRun() ? ".." : "")
/ "postProcessing"
/ mesh.pointsInstance()
// set.name()
);
mkDir(outputDir);
fileName outputFile(outputDir/writer.getFileName(points, wordList()));
//fileName outputFile(outputDir/set.name());
OFstream os(outputFile);
writer.write(points, fldNames, flds, os);
}
}
// ************************************************************************* //

View File

@ -1,19 +1,42 @@
#include "scalar.H"
#include "indirectPrimitivePatch.H"
#include "writer.H"
namespace Foam
{
class polyMesh;
class surfaceWriter;
class pointSet;
class faceSet;
class cellSet;
class fileName;
class polyMesh;
void printMeshStats(const polyMesh& mesh, const bool allTopology);
//- Write vtk representation of (assembled) faceSet to vtk file in
//- Generate merged surface on master and write. Needs input patch
// to be of mesh faces.
void mergeAndWrite
(
const polyMesh& mesh,
const surfaceWriter& writer,
const word& name,
const indirectPrimitivePatch setPatch,
const fileName& outputDir
);
//- Write vtk representation of (assembled) faceSet to surface file in
// postProcessing/ directory
void mergeAndWrite(const surfaceWriter&, const faceSet&);
//- Write vtk representation of (assembled) cellSet to vtk file in
//- Write vtk representation of (assembled) cellSet to surface file in
// postProcessing/ directory
void mergeAndWrite(const surfaceWriter&, const cellSet&);
//- Write vtk representation of (assembled) pointSet to 'set' file in
// postProcessing/ directory
void mergeAndWrite(const writer<scalar>&, const pointSet&);
}
// ************************************************************************* //

View File

@ -43,7 +43,8 @@ Foam::label Foam::checkTopology
const polyMesh& mesh,
const bool allTopology,
const bool allGeometry,
const autoPtr<surfaceWriter>& writer
const autoPtr<surfaceWriter>& surfWriter,
const autoPtr<writer<scalar>>& setWriter
)
{
label noFailedChecks = 0;
@ -56,11 +57,11 @@ Foam::label Foam::checkTopology
// Check that empty patches cover all sides of the mesh
{
label nEmpty = 0;
forAll(mesh.boundaryMesh(), patchI)
forAll(mesh.boundaryMesh(), patchi)
{
if (isA<emptyPolyPatch>(mesh.boundaryMesh()[patchI]))
if (isA<emptyPolyPatch>(mesh.boundaryMesh()[patchi]))
{
nEmpty += mesh.boundaryMesh()[patchI].size();
nEmpty += mesh.boundaryMesh()[patchi].size();
}
}
reduce(nEmpty, sumOp<label>());
@ -100,19 +101,19 @@ Foam::label Foam::checkTopology
{
cellSet cells(mesh, "illegalCells", mesh.nCells()/100);
forAll(mesh.cells(), cellI)
forAll(mesh.cells(), celli)
{
const cell& cFaces = mesh.cells()[cellI];
const cell& cFaces = mesh.cells()[celli];
if (cFaces.size() <= 3)
{
cells.insert(cellI);
cells.insert(celli);
}
forAll(cFaces, i)
{
if (cFaces[i] < 0 || cFaces[i] >= mesh.nFaces())
{
cells.insert(cellI);
cells.insert(celli);
break;
}
}
@ -129,9 +130,9 @@ Foam::label Foam::checkTopology
<< " illegal cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance();
cells.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), cells);
mergeAndWrite(surfWriter(), cells);
}
}
@ -154,6 +155,10 @@ Foam::label Foam::checkTopology
<< " unused points to set " << points.name() << endl;
points.instance() = mesh.pointsInstance();
points.write();
if (setWriter.valid())
{
mergeAndWrite(setWriter, points);
}
}
}
@ -172,9 +177,9 @@ Foam::label Foam::checkTopology
<< " unordered faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), faces);
mergeAndWrite(surfWriter(), faces);
}
}
}
@ -192,9 +197,9 @@ Foam::label Foam::checkTopology
<< faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), faces);
mergeAndWrite(surfWriter(), faces);
}
}
}
@ -213,9 +218,9 @@ Foam::label Foam::checkTopology
<< endl;
cells.instance() = mesh.pointsInstance();
cells.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), cells);
mergeAndWrite(surfWriter(), cells);
}
}
@ -237,9 +242,9 @@ Foam::label Foam::checkTopology
<< faces.name() << endl;
faces.instance() = mesh.pointsInstance();
faces.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), faces);
mergeAndWrite(surfWriter(), faces);
}
}
}
@ -248,17 +253,17 @@ Foam::label Foam::checkTopology
{
labelList nInternalFaces(mesh.nCells(), 0);
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
{
nInternalFaces[mesh.faceOwner()[faceI]]++;
nInternalFaces[mesh.faceNeighbour()[faceI]]++;
nInternalFaces[mesh.faceOwner()[facei]]++;
nInternalFaces[mesh.faceNeighbour()[facei]]++;
}
const polyBoundaryMesh& patches = mesh.boundaryMesh();
forAll(patches, patchI)
forAll(patches, patchi)
{
if (patches[patchI].coupled())
if (patches[patchi].coupled())
{
const labelUList& owners = patches[patchI].faceCells();
const labelUList& owners = patches[patchi].faceCells();
forAll(owners, i)
{
@ -270,15 +275,15 @@ Foam::label Foam::checkTopology
cellSet oneCells(mesh, "oneInternalFaceCells", mesh.nCells()/100);
cellSet twoCells(mesh, "twoInternalFacesCells", mesh.nCells()/100);
forAll(nInternalFaces, cellI)
forAll(nInternalFaces, celli)
{
if (nInternalFaces[cellI] <= 1)
if (nInternalFaces[celli] <= 1)
{
oneCells.insert(cellI);
oneCells.insert(celli);
}
else if (nInternalFaces[cellI] == 2)
else if (nInternalFaces[celli] == 2)
{
twoCells.insert(cellI);
twoCells.insert(celli);
}
}
@ -292,9 +297,9 @@ Foam::label Foam::checkTopology
<< endl;
oneCells.instance() = mesh.pointsInstance();
oneCells.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), oneCells);
mergeAndWrite(surfWriter(), oneCells);
}
}
@ -308,9 +313,9 @@ Foam::label Foam::checkTopology
<< endl;
twoCells.instance() = mesh.pointsInstance();
twoCells.write();
if (writer.valid())
if (surfWriter.valid())
{
mergeAndWrite(writer(), twoCells);
mergeAndWrite(surfWriter(), twoCells);
}
}
}
@ -349,6 +354,13 @@ Foam::label Foam::checkTopology
ctr.write();
// Points in multiple regions
pointSet points
(
mesh,
"multiRegionPoints",
mesh.nPoints()/1000
);
// Is region disconnected
boolList regionDisconnected(rs.nRegions(), true);
@ -361,31 +373,32 @@ Foam::label Foam::checkTopology
for
(
label faceI = mesh.nInternalFaces();
faceI < mesh.nFaces();
faceI++
label facei = mesh.nInternalFaces();
facei < mesh.nFaces();
facei++
)
{
label regionI = rs[mesh.faceOwner()[faceI]];
const face& f = mesh.faces()[faceI];
label regioni = rs[mesh.faceOwner()[facei]];
const face& f = mesh.faces()[facei];
forAll(f, fp)
{
label& pRegion = pointToRegion[f[fp]];
if (pRegion == -1)
{
pRegion = regionI;
pRegion = regioni;
}
else if (pRegion == -2)
{
// Already marked
regionDisconnected[regionI] = false;
regionDisconnected[regioni] = false;
}
else if (pRegion != regionI)
{
// Multiple regions
regionDisconnected[regionI] = false;
regionDisconnected[regioni] = false;
regionDisconnected[pRegion] = false;
pRegion = -2;
points.insert(f[fp]);
}
}
}
@ -437,6 +450,19 @@ Foam::label Foam::checkTopology
cellRegions[i].write();
}
label nPoints = returnReduce(points.size(), sumOp<label>());
if (nPoints)
{
Info<< " <<Writing " << nPoints
<< " points that are in multiple regions to set "
<< points.name() << endl;
points.write();
if (setWriter.valid())
{
mergeAndWrite(setWriter, points);
}
}
}
}
@ -479,9 +505,9 @@ Foam::label Foam::checkTopology
}
Info<< endl;
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
if (!isA<processorPolyPatch>(pp))
{

View File

@ -1,5 +1,6 @@
#include "label.H"
#include "autoPtr.H"
#include "writer.H"
namespace Foam
{
@ -11,6 +12,7 @@ namespace Foam
const polyMesh&,
const bool,
const bool,
const autoPtr<surfaceWriter>&
const autoPtr<surfaceWriter>&,
const autoPtr<writer<scalar>>&
);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -37,6 +37,7 @@ Description
- if the patch already exists will not override it nor its fields
- if the patch does not exist it will be created together with 'calculated'
patchfields unless the field is mentioned in the patchFields section.
- any 0-sized patches (since faces have been moved out) will get removed
\*---------------------------------------------------------------------------*/
@ -109,21 +110,90 @@ label addPatch
}
// Filter out the empty patches.
void filterPatches(fvMesh& mesh, const HashSet<word>& addedPatchNames)
{
// Remove any zero-sized ones. Assumes
// - processor patches are already only there if needed
// - all other patches are available on all processors
// - but coupled ones might still be needed, even if zero-size
// (e.g. processorCyclic)
// See also logic in createPatch.
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
labelList oldToNew(pbm.size(), -1);
label newPatchi = 0;
forAll(pbm, patchi)
{
const polyPatch& pp = pbm[patchi];
if (!isA<processorPolyPatch>(pp))
{
if
(
isA<coupledPolyPatch>(pp)
|| returnReduce(pp.size(), sumOp<label>())
|| addedPatchNames.found(pp.name())
)
{
// Coupled (and unknown size) or uncoupled and used
oldToNew[patchi] = newPatchi++;
}
}
}
forAll(pbm, patchi)
{
const polyPatch& pp = pbm[patchi];
if (isA<processorPolyPatch>(pp))
{
oldToNew[patchi] = newPatchi++;
}
}
const label nKeepPatches = newPatchi;
// Shuffle unused ones to end
if (nKeepPatches != pbm.size())
{
Info<< endl
<< "Removing zero-sized patches:" << endl << incrIndent;
forAll(oldToNew, patchi)
{
if (oldToNew[patchi] == -1)
{
Info<< indent << pbm[patchi].name()
<< " type " << pbm[patchi].type()
<< " at position " << patchi << endl;
oldToNew[patchi] = newPatchi++;
}
}
Info<< decrIndent;
fvMeshTools::reorderPatches(mesh, oldToNew, nKeepPatches, true);
Info<< endl;
}
}
void modifyOrAddFace
(
polyTopoChange& meshMod,
const face& f,
const label faceI,
const label facei,
const label own,
const bool flipFaceFlux,
const label newPatchI,
const label newPatchi,
const label zoneID,
const bool zoneFlip,
PackedBoolList& modifiedFace
)
{
if (!modifiedFace[faceI])
if (!modifiedFace[facei])
{
// First usage of face. Modify.
meshMod.setAction
@ -131,17 +201,17 @@ void modifyOrAddFace
polyModifyFace
(
f, // modified face
faceI, // label of face
facei, // label of face
own, // owner
-1, // neighbour
flipFaceFlux, // face flip
newPatchI, // patch for face
newPatchi, // patch for face
false, // remove from zone
zoneID, // zone for face
zoneFlip // face flip in zone
)
);
modifiedFace[faceI] = 1;
modifiedFace[facei] = 1;
}
else
{
@ -155,9 +225,9 @@ void modifyOrAddFace
-1, // neighbour
-1, // master point
-1, // master edge
faceI, // master face
facei, // master face
flipFaceFlux, // face flip
newPatchI, // patch for face
newPatchi, // patch for face
zoneID, // zone for face
zoneFlip // face flip in zone
)
@ -187,21 +257,21 @@ void createFaces
// Pass 1. Do selected side of zone
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
{
label zoneFaceI = fZone.whichFace(faceI);
label zoneFacei = fZone.whichFace(facei);
if (zoneFaceI != -1)
if (zoneFacei != -1)
{
if (!fZone.flipMap()[zoneFaceI])
if (!fZone.flipMap()[zoneFacei])
{
// Use owner side of face
modifyOrAddFace
(
meshMod,
mesh.faces()[faceI], // modified face
faceI, // label of face
mesh.faceOwner()[faceI],// owner
mesh.faces()[facei], // modified face
facei, // label of face
mesh.faceOwner()[facei],// owner
false, // face flip
newMasterPatches[i], // patch for face
fZone.index(), // zone for face
@ -218,9 +288,9 @@ void createFaces
modifyOrAddFace
(
meshMod,
mesh.faces()[faceI].reverseFace(), // modified face
faceI, // label of face
mesh.faceNeighbour()[faceI],// owner
mesh.faces()[facei].reverseFace(), // modified face
facei, // label of face
mesh.faceNeighbour()[facei],// owner
true, // face flip
newMasterPatches[i], // patch for face
fZone.index(), // zone for face
@ -237,21 +307,21 @@ void createFaces
// Pass 2. Do other side of zone
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
{
label zoneFaceI = fZone.whichFace(faceI);
label zoneFacei = fZone.whichFace(facei);
if (zoneFaceI != -1)
if (zoneFacei != -1)
{
if (!fZone.flipMap()[zoneFaceI])
if (!fZone.flipMap()[zoneFacei])
{
// Use neighbour side of face
modifyOrAddFace
(
meshMod,
mesh.faces()[faceI].reverseFace(), // modified face
faceI, // label of face
mesh.faceNeighbour()[faceI], // owner
mesh.faces()[facei].reverseFace(), // modified face
facei, // label of face
mesh.faceNeighbour()[facei], // owner
true, // face flip
newSlavePatches[i], // patch for face
fZone.index(), // zone for face
@ -265,9 +335,9 @@ void createFaces
modifyOrAddFace
(
meshMod,
mesh.faces()[faceI], // modified face
faceI, // label of face
mesh.faceOwner()[faceI],// owner
mesh.faces()[facei], // modified face
facei, // label of face
mesh.faceOwner()[facei],// owner
false, // face flip
newSlavePatches[i], // patch for face
fZone.index(), // zone for face
@ -293,13 +363,13 @@ void createFaces
// For warning once per patch.
labelHashSet patchWarned;
forAll(pbm, patchI)
forAll(pbm, patchi)
{
const polyPatch& pp = pbm[patchI];
const polyPatch& pp = pbm[patchi];
label newPatchI = newMasterPatches[i];
label newPatchi = newMasterPatches[i];
if (pp.coupled() && pbm[newPatchI].coupled())
if (pp.coupled() && pbm[newPatchi].coupled())
{
// Do not allow coupled faces to be moved to different
// coupled patches.
@ -308,20 +378,20 @@ void createFaces
{
forAll(pp, i)
{
label faceI = pp.start()+i;
label facei = pp.start()+i;
label zoneFaceI = fZone.whichFace(faceI);
label zoneFacei = fZone.whichFace(facei);
if (zoneFaceI != -1)
if (zoneFacei != -1)
{
if (patchWarned.insert(patchI))
if (patchWarned.insert(patchi))
{
WarningInFunction
<< "Found boundary face (in patch "
<< pp.name()
<< ") in faceZone " << fZone.name()
<< " to convert to baffle patch "
<< pbm[newPatchI].name()
<< pbm[newPatchi].name()
<< endl
<< " Run with -internalFacesOnly option"
<< " if you don't wish to convert"
@ -331,13 +401,13 @@ void createFaces
modifyOrAddFace
(
meshMod,
mesh.faces()[faceI], // modified face
faceI, // label of face
mesh.faceOwner()[faceI], // owner
mesh.faces()[facei], // modified face
facei, // label of face
mesh.faceOwner()[facei], // owner
false, // face flip
newPatchI, // patch for face
newPatchi, // patch for face
fZone.index(), // zone for face
fZone.flipMap()[zoneFaceI], // face flip in zone
fZone.flipMap()[zoneFacei], // face flip in zone
modifiedFace // modify or add
);
nModified++;
@ -497,9 +567,9 @@ int main(int argc, char *argv[])
// Add faces to faceZones
labelList nFaces(mesh.faceZones().size(), 0);
forAll(faceToZoneID, faceI)
forAll(faceToZoneID, facei)
{
label zoneID = faceToZoneID[faceI];
label zoneID = faceToZoneID[facei];
if (zoneID != -1)
{
nFaces[zoneID]++;
@ -515,13 +585,13 @@ int main(int argc, char *argv[])
labelList addr(n);
boolList flip(n);
n = 0;
forAll(faceToZoneID, faceI)
forAll(faceToZoneID, facei)
{
label zone = faceToZoneID[faceI];
label zone = faceToZoneID[facei];
if (zone == zoneID)
{
addr[n] = faceI;
flip[n] = faceToFlip[faceI];
addr[n] = facei;
flip[n] = faceToFlip[facei];
n++;
}
}
@ -702,14 +772,14 @@ int main(int argc, char *argv[])
forAllConstIter(dictionary, patchSources, iter)
{
const word patchName(iter().dict()["name"]);
label patchI = pbm.findPatchID(patchName);
label patchi = pbm.findPatchID(patchName);
if (master)
{
newMasterPatches.append(patchI);
newMasterPatches.append(patchi);
}
else
{
newSlavePatches.append(patchI);
newSlavePatches.append(patchi);
}
master = !master;
}
@ -764,9 +834,9 @@ int main(int argc, char *argv[])
forAllConstIter(HashSet<word>, bafflePatches, iter)
{
label patchI = mesh.boundaryMesh().findPatchID(iter.key());
label patchi = mesh.boundaryMesh().findPatchID(iter.key());
const fvPatchMapper& pm = mapper.boundaryMap()[patchI];
const fvPatchMapper& pm = mapper.boundaryMap()[patchi];
if (pm.sizeBeforeMapping() == 0)
{
@ -778,7 +848,7 @@ int main(int argc, char *argv[])
<< "You might have to edit these fields." << endl;
}
fvMeshTools::zeroPatchFields(mesh, patchI);
fvMeshTools::zeroPatchFields(mesh, patchi);
}
}
}
@ -799,7 +869,7 @@ int main(int argc, char *argv[])
forAllConstIter(dictionary, patchSources, iter)
{
const word patchName(iter().dict()["name"]);
label patchI = pbm.findPatchID(patchName);
label patchi = pbm.findPatchID(patchName);
if (iter().dict().found("patchFields"))
{
@ -812,7 +882,7 @@ int main(int argc, char *argv[])
fvMeshTools::setPatchFields
(
mesh,
patchI,
patchi,
patchFieldsDict
);
}
@ -866,20 +936,20 @@ int main(int argc, char *argv[])
const word masterPatchName(groupName + "_master");
const word slavePatchName(groupName + "_slave");
label patchIMaster = pbm.findPatchID(masterPatchName);
label patchISlave = pbm.findPatchID(slavePatchName);
label patchiMaster = pbm.findPatchID(masterPatchName);
label patchiSlave = pbm.findPatchID(slavePatchName);
fvMeshTools::setPatchFields
(
mesh,
patchIMaster,
patchiMaster,
patchFieldsDict
);
fvMeshTools::setPatchFields
(
mesh,
patchISlave,
patchiSlave,
patchFieldsDict
);
}
@ -895,6 +965,11 @@ int main(int argc, char *argv[])
mesh.movePoints(map().preMotionPoints());
}
// Remove any now zero-sized patches
filterPatches(mesh, bafflePatches);
if (overwrite)
{
mesh.setInstance(oldInstance);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -94,11 +94,11 @@ void Foam::faceSelection::select
{
if (flip_)
{
forAll(faceToZoneID, faceI)
forAll(faceToZoneID, facei)
{
if (faceToZoneID[faceI] == zoneID)
if (faceToZoneID[facei] == zoneID)
{
faceToFlip[faceI] = !faceToFlip[faceI];
faceToFlip[facei] = !faceToFlip[facei];
}
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -109,7 +109,7 @@ public:
autoPtr<faceSelection> clone() const
{
NotImplemented;
return autoPtr<faceSelection>(NULL);
return autoPtr<faceSelection>(nullptr);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -81,18 +81,18 @@ void Foam::faceSelections::faceZoneSelection::select
forAll(fZone, i)
{
label faceI = fZone[i];
label facei = fZone[i];
if (faceToZoneID[faceI] == -1)
if (faceToZoneID[facei] == -1)
{
faceToZoneID[faceI] = zoneID;
faceToFlip[faceI] = fZone.flipMap()[i];
faceToZoneID[facei] = zoneID;
faceToFlip[facei] = fZone.flipMap()[i];
}
else if (faceToZoneID[faceI] != zoneID)
else if (faceToZoneID[facei] != zoneID)
{
FatalErrorInFunction
<< "Face " << faceI << " already in faceZone "
<< faceToZoneID[faceI]
<< "Face " << facei << " already in faceZone "
<< faceToZoneID[facei]
<< exit(FatalError);
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -86,7 +86,7 @@ public:
autoPtr<faceSelection> clone() const
{
NotImplemented;
return autoPtr<faceSelection>(NULL);
return autoPtr<faceSelection>(nullptr);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -98,10 +98,10 @@ void Foam::faceSelections::searchableSurfaceSelection::select
pointField end(mesh_.nFaces());
// Internal faces
for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
{
start[faceI] = mesh_.cellCentres()[mesh_.faceOwner()[faceI]];
end[faceI] = mesh_.cellCentres()[mesh_.faceNeighbour()[faceI]];
start[facei] = mesh_.cellCentres()[mesh_.faceOwner()[facei]];
end[facei] = mesh_.cellCentres()[mesh_.faceNeighbour()[facei]];
}
// Boundary faces
@ -115,26 +115,26 @@ void Foam::faceSelections::searchableSurfaceSelection::select
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
forAll(pbm, patchI)
forAll(pbm, patchi)
{
const polyPatch& pp = pbm[patchI];
const polyPatch& pp = pbm[patchi];
if (pp.coupled())
{
forAll(pp, i)
{
label faceI = pp.start()+i;
start[faceI] = mesh_.cellCentres()[mesh_.faceOwner()[faceI]];
end[faceI] = neighbourCellCentres[faceI-mesh_.nInternalFaces()];
label facei = pp.start()+i;
start[facei] = mesh_.cellCentres()[mesh_.faceOwner()[facei]];
end[facei] = neighbourCellCentres[facei-mesh_.nInternalFaces()];
}
}
else
{
forAll(pp, i)
{
label faceI = pp.start()+i;
start[faceI] = mesh_.cellCentres()[mesh_.faceOwner()[faceI]];
end[faceI] = mesh_.faceCentres()[faceI];
label facei = pp.start()+i;
start[facei] = mesh_.cellCentres()[mesh_.faceOwner()[facei]];
end[facei] = mesh_.faceCentres()[facei];
}
}
}
@ -146,29 +146,29 @@ void Foam::faceSelections::searchableSurfaceSelection::select
//- Note: do not select boundary faces.
for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
{
if (hits[faceI].hit())
if (hits[facei].hit())
{
faceToZoneID[faceI] = zoneID;
vector d = end[faceI]-start[faceI];
faceToFlip[faceI] = ((normals[faceI] & d) < 0);
faceToZoneID[facei] = zoneID;
vector d = end[facei]-start[facei];
faceToFlip[facei] = ((normals[facei] & d) < 0);
}
}
forAll(pbm, patchI)
forAll(pbm, patchi)
{
const polyPatch& pp = pbm[patchI];
const polyPatch& pp = pbm[patchi];
if (pp.coupled())
{
forAll(pp, i)
{
label faceI = pp.start()+i;
if (hits[faceI].hit())
label facei = pp.start()+i;
if (hits[facei].hit())
{
faceToZoneID[faceI] = zoneID;
vector d = end[faceI]-start[faceI];
faceToFlip[faceI] = ((normals[faceI] & d) < 0);
faceToZoneID[facei] = zoneID;
vector d = end[facei]-start[facei];
faceToFlip[facei] = ((normals[facei] & d) < 0);
}
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -79,7 +79,7 @@ public:
autoPtr<faceSelection> clone() const
{
NotImplemented;
return autoPtr<faceSelection>(NULL);
return autoPtr<faceSelection>(nullptr);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -110,9 +110,9 @@ void filterPatches(polyMesh& mesh, const HashSet<word>& addedPatchNames)
label nOldPatches = returnReduce(patches.size(), sumOp<label>());
// Copy old patches.
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
// Note: reduce possible since non-proc patches guaranteed in same order
if (!isA<processorPolyPatch>(pp))
@ -146,14 +146,14 @@ void filterPatches(polyMesh& mesh, const HashSet<word>& addedPatchNames)
{
Info<< "Removing zero-sized patch " << pp.name()
<< " type " << pp.type()
<< " at position " << patchI << endl;
<< " at position " << patchi << endl;
}
}
}
// Copy non-empty processor patches
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
if (isA<processorPolyPatch>(pp))
{
@ -173,7 +173,7 @@ void filterPatches(polyMesh& mesh, const HashSet<word>& addedPatchNames)
else
{
Info<< "Removing empty processor patch " << pp.name()
<< " at position " << patchI << endl;
<< " at position " << patchi << endl;
}
}
}
@ -202,16 +202,16 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
forAll(patches, patchI)
forAll(patches, patchi)
{
if
(
isA<cyclicPolyPatch>(patches[patchI])
&& refCast<const cyclicPolyPatch>(patches[patchI]).owner()
isA<cyclicPolyPatch>(patches[patchi])
&& refCast<const cyclicPolyPatch>(patches[patchi]).owner()
)
{
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(patches[patchI]);
refCast<const cyclicPolyPatch>(patches[patchi]);
// Dump patches
{
@ -247,12 +247,12 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
Pout<< "Dumping cyclic match as lines between face centres to "
<< str.name() << endl;
forAll(cycPatch, faceI)
forAll(cycPatch, facei)
{
const point& fc0 = mesh.faceCentres()[cycPatch.start()+faceI];
const point& fc0 = mesh.faceCentres()[cycPatch.start()+facei];
meshTools::writeOBJ(str, fc0);
vertI++;
const point& fc1 = mesh.faceCentres()[nbrPatch.start()+faceI];
const point& fc1 = mesh.faceCentres()[nbrPatch.start()+facei];
meshTools::writeOBJ(str, fc1);
vertI++;
@ -322,9 +322,9 @@ void syncPoints
{
// Send
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
if
(
@ -342,12 +342,12 @@ void syncPoints
const labelList& meshPts = procPatch.meshPoints();
const labelList& nbrPts = procPatch.neighbPoints();
forAll(nbrPts, pointI)
forAll(nbrPts, pointi)
{
label nbrPointI = nbrPts[pointI];
if (nbrPointI >= 0 && nbrPointI < patchInfo.size())
label nbrPointi = nbrPts[pointi];
if (nbrPointi >= 0 && nbrPointi < patchInfo.size())
{
patchInfo[nbrPointI] = points[meshPts[pointI]];
patchInfo[nbrPointi] = points[meshPts[pointi]];
}
}
@ -359,9 +359,9 @@ void syncPoints
// Receive and set.
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
if
(
@ -400,19 +400,19 @@ void syncPoints
const labelList& meshPts = procPatch.meshPoints();
forAll(meshPts, pointI)
forAll(meshPts, pointi)
{
label meshPointI = meshPts[pointI];
points[meshPointI] = nbrPatchInfo[pointI];
label meshPointi = meshPts[pointi];
points[meshPointi] = nbrPatchInfo[pointi];
}
}
}
}
// Do the cyclics.
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
if
(
@ -481,9 +481,9 @@ void syncPoints
forAll(pd.sharedPointLabels(), i)
{
label meshPointI = pd.sharedPointLabels()[i];
label meshPointi = pd.sharedPointLabels()[i];
// Fill my entries in the shared points
sharedPts[pd.sharedPointAddr()[i]] = points[meshPointI];
sharedPts[pd.sharedPointAddr()[i]] = points[meshPointi];
}
// Combine on master.
@ -494,8 +494,8 @@ void syncPoints
// my local information.
forAll(pd.sharedPointLabels(), i)
{
label meshPointI = pd.sharedPointLabels()[i];
points[meshPointI] = sharedPts[pd.sharedPointAddr()[i]];
label meshPointi = pd.sharedPointLabels()[i];
points[meshPointi] = sharedPts[pd.sharedPointAddr()[i]];
}
}
}
@ -567,12 +567,12 @@ int main(int argc, char *argv[])
// Old and new patches.
DynamicList<polyPatch*> allPatches(patches.size()+patchSources.size());
label startFaceI = mesh.nInternalFaces();
label startFacei = mesh.nInternalFaces();
// Copy old patches.
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
if (!isA<processorPolyPatch>(pp))
{
@ -581,12 +581,12 @@ int main(int argc, char *argv[])
pp.clone
(
patches,
patchI,
patchi,
pp.size(),
startFaceI
startFacei
).ptr()
);
startFaceI += pp.size();
startFacei += pp.size();
}
}
@ -596,20 +596,20 @@ int main(int argc, char *argv[])
word patchName(dict.lookup("name"));
label destPatchI = patches.findPatchID(patchName);
label destPatchi = patches.findPatchID(patchName);
if (destPatchI == -1)
if (destPatchi == -1)
{
dictionary patchDict(dict.subDict("patchInfo"));
destPatchI = allPatches.size();
destPatchi = allPatches.size();
Info<< "Adding new patch " << patchName
<< " as patch " << destPatchI
<< " as patch " << destPatchi
<< " from " << patchDict << endl;
patchDict.set("nFaces", 0);
patchDict.set("startFace", startFaceI);
patchDict.set("startFace", startFacei);
// Add an empty patch.
allPatches.append
@ -618,7 +618,7 @@ int main(int argc, char *argv[])
(
patchName,
patchDict,
destPatchI,
destPatchi,
patches
).ptr()
);
@ -631,9 +631,9 @@ int main(int argc, char *argv[])
}
// Copy old patches.
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
if (isA<processorPolyPatch>(pp))
{
@ -642,12 +642,12 @@ int main(int argc, char *argv[])
pp.clone
(
patches,
patchI,
patchi,
pp.size(),
startFaceI
startFacei
).ptr()
);
startFaceI += pp.size();
startFacei += pp.size();
}
}
@ -671,9 +671,9 @@ int main(int argc, char *argv[])
const dictionary& dict = patchSources[addedI];
const word patchName(dict.lookup("name"));
label destPatchI = patches.findPatchID(patchName);
label destPatchi = patches.findPatchID(patchName);
if (destPatchI == -1)
if (destPatchi == -1)
{
FatalErrorInFunction
<< "patch " << patchName << " not added. Problem."
@ -698,7 +698,7 @@ int main(int argc, char *argv[])
const polyPatch& pp = patches[iter.key()];
Info<< "Moving faces from patch " << pp.name()
<< " to patch " << destPatchI << endl;
<< " to patch " << destPatchi << endl;
forAll(pp, i)
{
@ -706,7 +706,7 @@ int main(int argc, char *argv[])
(
mesh,
pp.start() + i,
destPatchI,
destPatchi,
meshMod
);
}
@ -728,12 +728,12 @@ int main(int argc, char *argv[])
forAll(patchFaces, i)
{
label faceI = patchFaces[i];
label facei = patchFaces[i];
if (mesh.isInternalFace(faceI))
if (mesh.isInternalFace(facei))
{
FatalErrorInFunction
<< "Face " << faceI << " specified in set "
<< "Face " << facei << " specified in set "
<< faces.name()
<< " is not an external face of the mesh." << endl
<< "This application can only repatch existing boundary"
@ -743,8 +743,8 @@ int main(int argc, char *argv[])
changePatchID
(
mesh,
faceI,
destPatchI,
facei,
destPatchi,
meshMod
);
}
@ -786,9 +786,9 @@ int main(int argc, char *argv[])
// For cyclic patches:
// - for separated ones use user specified offset vector
forAll(mesh.boundaryMesh(), patchI)
forAll(mesh.boundaryMesh(), patchi)
{
const polyPatch& pp = mesh.boundaryMesh()[patchI];
const polyPatch& pp = mesh.boundaryMesh()[patchi];
if (pp.size() && isA<coupledPolyPatch>(pp))
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -85,7 +85,7 @@ int main(int argc, char *argv[])
pointField newPoints
(
zeroPoints
+ scaleFactor*pInterp.interpolate(U)().internalField()
+ scaleFactor*pInterp.interpolate(U)().primitiveField()
);
mesh.polyMesh::movePoints(newPoints);

View File

@ -79,15 +79,15 @@ int main(int argc, char *argv[])
scalar minCmptVal = bb.min()[planeNormalCmpt];
scalar maxCmptVal = bb.max()[planeNormalCmpt];
forAll(points, pointI)
forAll(points, pointi)
{
if (points[pointI][planeNormalCmpt] < midCmptVal)
if (points[pointi][planeNormalCmpt] < midCmptVal)
{
points[pointI][planeNormalCmpt] = minCmptVal;
points[pointi][planeNormalCmpt] = minCmptVal;
}
else
{
points[pointI][planeNormalCmpt] = maxCmptVal;
points[pointi][planeNormalCmpt] = maxCmptVal;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
@ -78,11 +78,11 @@ int main(int argc, char *argv[])
boolList inside(querySurf.calcInside(mesh.cellCentres()));
forAll(inside, cellI)
forAll(inside, celli)
{
if (inside[cellI])
if (inside[celli])
{
insideCells.insert(cellI);
insideCells.insert(celli);
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -50,14 +50,14 @@ Foam::label Foam::mergePolyMesh::patchIndex(const polyPatch& p)
bool nameFound = false;
forAll(patchNames_, patchI)
forAll(patchNames_, patchi)
{
if (patchNames_[patchI] == pName)
if (patchNames_[patchi] == pName)
{
if (word(patchDicts_[patchI]["type"]) == pType)
if (word(patchDicts_[patchi]["type"]) == pType)
{
// Found name and types match
return patchI;
return patchi;
}
else
{
@ -134,12 +134,12 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
// Insert the original patches into the list
wordList curPatchNames = boundaryMesh().names();
forAll(boundaryMesh(), patchI)
forAll(boundaryMesh(), patchi)
{
patchNames_.append(boundaryMesh()[patchI].name());
patchNames_.append(boundaryMesh()[patchi].name());
OStringStream os;
boundaryMesh()[patchI].write(os);
boundaryMesh()[patchi].write(os);
patchDicts_.append(dictionary(IStringStream(os.str())()));
}
@ -207,10 +207,10 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
pointZoneIndices[zoneI] = zoneIndex(pointZoneNames_, pz[zoneI].name());
}
forAll(p, pointI)
forAll(p, pointi)
{
// Grab zone ID. If a point is not in a zone, it will return -1
zoneID = pz.whichZone(pointI);
zoneID = pz.whichZone(pointi);
if (zoneID >= 0)
{
@ -218,15 +218,15 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
zoneID = pointZoneIndices[zoneID];
}
renumberPoints[pointI] =
renumberPoints[pointi] =
meshMod_.setAction
(
polyAddPoint
(
p[pointI], // Point to add
p[pointi], // Point to add
-1, // Master point (straight addition)
zoneID, // Zone for point
pointI < m.nPoints() // Is in cell?
pointi < m.nPoints() // Is in cell?
)
);
}
@ -244,10 +244,10 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
cellZoneIndices[zoneI] = zoneIndex(cellZoneNames_, cz[zoneI].name());
}
forAll(c, cellI)
forAll(c, celli)
{
// Grab zone ID. If a cell is not in a zone, it will return -1
zoneID = cz.whichZone(cellI);
zoneID = cz.whichZone(celli);
if (zoneID >= 0)
{
@ -255,7 +255,7 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
zoneID = cellZoneIndices[zoneID];
}
renumberCells[cellI] =
renumberCells[celli] =
meshMod_.setAction
(
polyAddCell
@ -275,9 +275,9 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
// Gather the patch indices
labelList patchIndices(bm.size());
forAll(patchIndices, patchI)
forAll(patchIndices, patchi)
{
patchIndices[patchI] = patchIndex(bm[patchI]);
patchIndices[patchi] = patchIndex(bm[patchi]);
}
// Temporary: update number of allowable patches. This should be
@ -303,15 +303,15 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
label newOwn, newNei, newPatch, newZone;
bool newZoneFlip;
forAll(f, faceI)
forAll(f, facei)
{
const face& curFace = f[faceI];
const face& curFace = f[facei];
face newFace(curFace.size());
forAll(curFace, pointI)
forAll(curFace, pointi)
{
newFace[pointI] = renumberPoints[curFace[pointI]];
newFace[pointi] = renumberPoints[curFace[pointi]];
}
if (debug)
@ -320,22 +320,22 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
if (min(newFace) < 0)
{
FatalErrorInFunction
<< "Error in point mapping for face " << faceI
<< "Error in point mapping for face " << facei
<< ". Old face: " << curFace << " New face: " << newFace
<< abort(FatalError);
}
}
if (faceI < m.nInternalFaces() || faceI >= m.nFaces())
if (facei < m.nInternalFaces() || facei >= m.nFaces())
{
newPatch = -1;
}
else
{
newPatch = patchIndices[bm.whichPatch(faceI)];
newPatch = patchIndices[bm.whichPatch(facei)];
}
newOwn = own[faceI];
newOwn = own[facei];
if (newOwn > -1) newOwn = renumberCells[newOwn];
if (newPatch > -1)
@ -344,23 +344,23 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
}
else
{
newNei = nei[faceI];
newNei = nei[facei];
newNei = renumberCells[newNei];
}
newZone = fz.whichZone(faceI);
newZone = fz.whichZone(facei);
newZoneFlip = false;
if (newZone >= 0)
{
newZoneFlip = fz[newZone].flipMap()[fz[newZone].whichFace(faceI)];
newZoneFlip = fz[newZone].flipMap()[fz[newZone].whichFace(facei)];
// Grab the new zone
newZone = faceZoneIndices[newZone];
}
renumberFaces[faceI] =
renumberFaces[facei] =
meshMod_.setAction
(
polyAddFace
@ -400,32 +400,32 @@ void Foam::mergePolyMesh::merge()
const polyBoundaryMesh& oldPatches = boundaryMesh();
// Note. Re-using counter in two for loops
label patchI = 0;
label patchi = 0;
for (patchI = 0; patchI < oldPatches.size(); patchI++)
for (patchi = 0; patchi < oldPatches.size(); patchi++)
{
newPatches[patchI] = oldPatches[patchI].clone(oldPatches).ptr();
newPatches[patchi] = oldPatches[patchi].clone(oldPatches).ptr();
}
Info<< "Adding new patches. " << endl;
label endOfLastPatch =
oldPatches[patchI - 1].start() + oldPatches[patchI - 1].size();
oldPatches[patchi - 1].start() + oldPatches[patchi - 1].size();
for (; patchI < patchNames_.size(); patchI++)
for (; patchi < patchNames_.size(); patchi++)
{
// Add a patch
dictionary dict(patchDicts_[patchI]);
dictionary dict(patchDicts_[patchi]);
dict.set("nFaces", 0);
dict.set("startFace", endOfLastPatch);
newPatches[patchI] =
newPatches[patchi] =
(
polyPatch::New
(
patchNames_[patchI],
patchNames_[patchi],
dict,
patchI,
patchi,
oldPatches
).ptr()
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -79,16 +79,16 @@ void insertDuplicateMerge
const labelList& faceOwner = mesh.faceOwner();
const faceZoneMesh& faceZones = mesh.faceZones();
forAll(duplicates, bFaceI)
forAll(duplicates, bFacei)
{
label otherFaceI = duplicates[bFaceI];
label otherFacei = duplicates[bFacei];
if (otherFaceI != -1 && otherFaceI > bFaceI)
if (otherFacei != -1 && otherFacei > bFacei)
{
// Two duplicate faces. Merge.
label face0 = mesh.nInternalFaces() + bFaceI;
label face1 = mesh.nInternalFaces() + otherFaceI;
label face0 = mesh.nInternalFaces() + bFacei;
label face1 = mesh.nInternalFaces() + otherFacei;
label own0 = faceOwner[face0];
label own1 = faceOwner[face1];
@ -169,21 +169,21 @@ labelList findBaffles(const polyMesh& mesh, const labelList& boundaryFaces)
// Check that none are on processor patches
const polyBoundaryMesh& patches = mesh.boundaryMesh();
forAll(duplicates, bFaceI)
forAll(duplicates, bFacei)
{
if (duplicates[bFaceI] != -1)
if (duplicates[bFacei] != -1)
{
label faceI = mesh.nInternalFaces() + bFaceI;
label patchI = patches.whichPatch(faceI);
label facei = mesh.nInternalFaces() + bFacei;
label patchi = patches.whichPatch(facei);
if (isA<processorPolyPatch>(patches[patchI]))
if (isA<processorPolyPatch>(patches[patchi]))
{
FatalErrorInFunction
<< "Duplicate face " << faceI
<< "Duplicate face " << facei
<< " is on a processorPolyPatch."
<< "This is not allowed." << nl
<< "Face:" << faceI
<< " is on patch:" << patches[patchI].name()
<< "Face:" << facei
<< " is on patch:" << patches[patchi].name()
<< abort(FatalError);
}
}
@ -199,14 +199,14 @@ labelList findBaffles(const polyMesh& mesh, const labelList& boundaryFaces)
(mesh.nFaces() - mesh.nInternalFaces())/256
);
forAll(duplicates, bFaceI)
forAll(duplicates, bFacei)
{
label otherFaceI = duplicates[bFaceI];
label otherFacei = duplicates[bFacei];
if (otherFaceI != -1 && otherFaceI > bFaceI)
if (otherFacei != -1 && otherFacei > bFacei)
{
duplicateSet.insert(mesh.nInternalFaces() + bFaceI);
duplicateSet.insert(mesh.nInternalFaces() + otherFaceI);
duplicateSet.insert(mesh.nInternalFaces() + bFacei);
duplicateSet.insert(mesh.nInternalFaces() + otherFacei);
}
}
@ -372,16 +372,16 @@ int main(int argc, char *argv[])
pointSet dupPoints(mesh, "duplicatedPoints", 100);
forAll(pointMap, pointI)
forAll(pointMap, pointi)
{
label oldPointI = pointMap[pointI];
label oldPointi = pointMap[pointi];
nDupPerPoint[oldPointI]++;
nDupPerPoint[oldPointi]++;
if (nDupPerPoint[oldPointI] > 1)
if (nDupPerPoint[oldPointi] > 1)
{
dupPoints.insert(map().reversePointMap()[oldPointI]);
dupPoints.insert(pointI);
dupPoints.insert(map().reversePointMap()[oldPointi]);
dupPoints.insert(pointi);
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -43,7 +43,7 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
IOobject::NO_WRITE
)
),
mirrorMeshPtr_(NULL)
mirrorMeshPtr_(nullptr)
{
plane mirrorPlane(mirrorMeshDict_);
@ -67,18 +67,18 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
labelList mirrorPointLookup(oldPoints.size(), -1);
// Grab the old points
forAll(oldPoints, pointI)
forAll(oldPoints, pointi)
{
newPoints[nNewPoints] = oldPoints[pointI];
newPoints[nNewPoints] = oldPoints[pointi];
nNewPoints++;
}
forAll(oldPoints, pointI)
forAll(oldPoints, pointi)
{
scalar alpha =
mirrorPlane.normalIntersect
(
oldPoints[pointI],
oldPoints[pointi],
mirrorPlane.normal()
);
@ -87,10 +87,10 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
{
// The point gets mirrored
newPoints[nNewPoints] =
oldPoints[pointI] + 2.0*alpha*mirrorPlane.normal();
oldPoints[pointi] + 2.0*alpha*mirrorPlane.normal();
// remember the point correspondence
mirrorPointLookup[pointI] = nNewPoints;
mirrorPointLookup[pointi] = nNewPoints;
nNewPoints++;
}
else
@ -98,9 +98,9 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
// The point is on the plane and does not get mirrored
// Adjust plane location
newPoints[nNewPoints] =
oldPoints[pointI] + alpha*mirrorPlane.normal();
oldPoints[pointi] + alpha*mirrorPlane.normal();
mirrorPointLookup[pointI] = pointI;
mirrorPointLookup[pointi] = pointi;
}
}
@ -130,12 +130,12 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
const labelUList& oldOwnerStart = lduAddr().ownerStartAddr();
forAll(newCellFaces, cellI)
forAll(newCellFaces, celli)
{
labelList& curFaces = newCellFaces[cellI];
labelList& curFaces = newCellFaces[celli];
const label s = oldOwnerStart[cellI];
const label e = oldOwnerStart[cellI + 1];
const label s = oldOwnerStart[celli];
const label e = oldOwnerStart[celli + 1];
curFaces.setSize(e - s);
@ -149,9 +149,9 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
// as internal
boolListList insertedBouFace(oldPatches.size());
forAll(oldPatches, patchI)
forAll(oldPatches, patchi)
{
const polyPatch& curPatch = oldPatches[patchI];
const polyPatch& curPatch = oldPatches[patchi];
if (curPatch.coupled())
{
@ -162,7 +162,7 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
<< " createPatch afterwards." << endl;
}
boolList& curInsBouFace = insertedBouFace[patchI];
boolList& curInsBouFace = insertedBouFace[patchi];
curInsBouFace.setSize(curPatch.size());
curInsBouFace = false;
@ -171,29 +171,29 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
const labelUList& curFaceCells = curPatch.faceCells();
const label curStart = curPatch.start();
forAll(curPatch, faceI)
forAll(curPatch, facei)
{
// Find out if the mirrored face is identical to the
// original. If so, the face needs to become internal and
// added to its owner cell
const face& origFace = curPatch[faceI];
const face& origFace = curPatch[facei];
face mirrorFace(origFace.size());
forAll(mirrorFace, pointI)
forAll(mirrorFace, pointi)
{
mirrorFace[pointI] = mirrorPointLookup[origFace[pointI]];
mirrorFace[pointi] = mirrorPointLookup[origFace[pointi]];
}
if (origFace == mirrorFace)
{
// The mirror is identical to current face. This will
// become an internal face
const label oldSize = newCellFaces[curFaceCells[faceI]].size();
const label oldSize = newCellFaces[curFaceCells[facei]].size();
newCellFaces[curFaceCells[faceI]].setSize(oldSize + 1);
newCellFaces[curFaceCells[faceI]][oldSize] = curStart + faceI;
newCellFaces[curFaceCells[facei]].setSize(oldSize + 1);
newCellFaces[curFaceCells[facei]][oldSize] = curStart + facei;
curInsBouFace[faceI] = true;
curInsBouFace[facei] = true;
}
}
}
@ -210,9 +210,9 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
label nNewFaces = 0;
// Insert original (internal) faces
forAll(newCellFaces, cellI)
forAll(newCellFaces, celli)
{
const labelList& curCellFaces = newCellFaces[cellI];
const labelList& curCellFaces = newCellFaces[celli];
forAll(curCellFaces, cfI)
{
@ -224,9 +224,9 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
}
// Mirror internal faces
for (label faceI = 0; faceI < nOldInternalFaces; faceI++)
for (label facei = 0; facei < nOldInternalFaces; facei++)
{
const face& oldFace = oldFaces[faceI];
const face& oldFace = oldFaces[facei];
face& nf = newFaces[nNewFaces];
nf.setSize(oldFace.size());
@ -237,7 +237,7 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
nf[i] = mirrorPointLookup[oldFace[oldFace.size() - i]];
}
mirrorFaceLookup[faceI] = nNewFaces;
mirrorFaceLookup[facei] = nNewFaces;
nNewFaces++;
}
@ -247,36 +247,36 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
labelList newPatchStarts(boundary().size(), -1);
label nNewPatches = 0;
forAll(boundaryMesh(), patchI)
forAll(boundaryMesh(), patchi)
{
const label curPatchSize = boundaryMesh()[patchI].size();
const label curPatchStart = boundaryMesh()[patchI].start();
const boolList& curInserted = insertedBouFace[patchI];
const label curPatchSize = boundaryMesh()[patchi].size();
const label curPatchStart = boundaryMesh()[patchi].start();
const boolList& curInserted = insertedBouFace[patchi];
newPatchStarts[nNewPatches] = nNewFaces;
// Master side
for (label faceI = 0; faceI < curPatchSize; faceI++)
for (label facei = 0; facei < curPatchSize; facei++)
{
// Check if the face has already been added. If not, add it and
// insert the numbering details.
if (!curInserted[faceI])
if (!curInserted[facei])
{
newFaces[nNewFaces] = oldFaces[curPatchStart + faceI];
newFaces[nNewFaces] = oldFaces[curPatchStart + facei];
masterFaceLookup[curPatchStart + faceI] = nNewFaces;
masterFaceLookup[curPatchStart + facei] = nNewFaces;
nNewFaces++;
}
}
// Mirror side
for (label faceI = 0; faceI < curPatchSize; faceI++)
for (label facei = 0; facei < curPatchSize; facei++)
{
// Check if the face has already been added. If not, add it and
// insert the numbering details.
if (!curInserted[faceI])
if (!curInserted[facei])
{
const face& oldFace = oldFaces[curPatchStart + faceI];
const face& oldFace = oldFaces[curPatchStart + facei];
face& nf = newFaces[nNewFaces];
nf.setSize(oldFace.size());
@ -287,21 +287,21 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
nf[i] = mirrorPointLookup[oldFace[oldFace.size() - i]];
}
mirrorFaceLookup[curPatchStart + faceI] = nNewFaces;
mirrorFaceLookup[curPatchStart + facei] = nNewFaces;
nNewFaces++;
}
else
{
// Grab the index of the master face for the mirror side
mirrorFaceLookup[curPatchStart + faceI] =
masterFaceLookup[curPatchStart + faceI];
mirrorFaceLookup[curPatchStart + facei] =
masterFaceLookup[curPatchStart + facei];
}
}
// If patch exists, grab the name and type of the original patch
if (nNewFaces > newPatchStarts[nNewPatches])
{
newToOldPatch[nNewPatches] = patchI;
newToOldPatch[nNewPatches] = patchi;
newPatchSizes[nNewPatches] =
nNewFaces - newPatchStarts[nNewPatches];
@ -328,9 +328,9 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
label nNewCells = 0;
// Grab the original cells. Take care of face renumbering.
forAll(oldCells, cellI)
forAll(oldCells, celli)
{
const cell& oc = oldCells[cellI];
const cell& oc = oldCells[celli];
cell& nc = newCells[nNewCells];
nc.setSize(oc.size());
@ -344,9 +344,9 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
}
// Mirror the cells
forAll(oldCells, cellI)
forAll(oldCells, celli)
{
const cell& oc = oldCells[cellI];
const cell& oc = oldCells[celli];
cell& nc = newCells[nNewCells];
nc.setSize(oc.size());
@ -376,14 +376,14 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
// Add the boundary patches
List<polyPatch*> p(newPatchSizes.size());
forAll(p, patchI)
forAll(p, patchi)
{
p[patchI] = boundaryMesh()[newToOldPatch[patchI]].clone
p[patchi] = boundaryMesh()[newToOldPatch[patchi]].clone
(
pMesh.boundaryMesh(),
patchI,
newPatchSizes[patchI],
newPatchStarts[patchI]
patchi,
newPatchSizes[patchi],
newPatchStarts[patchi]
).ptr();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -38,6 +38,7 @@ Description
#include "pimpleControl.H"
#include "vtkSurfaceWriter.H"
#include "cyclicAMIPolyPatch.H"
#include "PatchTools.H"
using namespace Foam;
@ -46,6 +47,7 @@ using namespace Foam;
// Dump patch + weights to vtk file
void writeWeights
(
const polyMesh& mesh,
const scalarField& wghtSum,
const primitivePatch& patch,
const fileName& directory,
@ -55,16 +57,51 @@ void writeWeights
{
vtkSurfaceWriter writer;
writer.write
// Collect geometry
labelList pointToGlobal;
labelList uniqueMeshPointLabels;
autoPtr<globalIndex> globalPoints;
autoPtr<globalIndex> globalFaces;
faceList mergedFaces;
pointField mergedPoints;
Foam::PatchTools::gatherAndMerge
(
directory,
prefix + "_proc" + Foam::name(Pstream::myProcNo()) + "_" + timeName,
patch.localPoints(),
mesh,
patch.localFaces(),
"weightsSum",
wghtSum,
false
patch.meshPoints(),
patch.meshPointMap(),
pointToGlobal,
uniqueMeshPointLabels,
globalPoints,
globalFaces,
mergedFaces,
mergedPoints
);
// Collect field
scalarField mergedWeights;
globalFaces().gather
(
UPstream::worldComm,
labelList(UPstream::procID(UPstream::worldComm)),
wghtSum,
mergedWeights
);
if (Pstream::master())
{
writer.write
(
directory,
prefix + "_" + timeName,
mergedPoints,
mergedFaces,
"weightsSum",
mergedWeights,
false
);
}
}
@ -74,12 +111,12 @@ void writeWeights(const polyMesh& mesh)
const word tmName(mesh.time().timeName());
forAll(pbm, patchI)
forAll(pbm, patchi)
{
if (isA<cyclicAMIPolyPatch>(pbm[patchI]))
if (isA<cyclicAMIPolyPatch>(pbm[patchi]))
{
const cyclicAMIPolyPatch& cpp =
refCast<const cyclicAMIPolyPatch>(pbm[patchI]);
refCast<const cyclicAMIPolyPatch>(pbm[patchi]);
if (cpp.owner())
{
@ -92,6 +129,7 @@ void writeWeights(const polyMesh& mesh)
writeWeights
(
mesh,
ami.tgtWeightsSum(),
cpp.neighbPatch(),
"postProcessing",
@ -100,6 +138,7 @@ void writeWeights(const polyMesh& mesh)
);
writeWeights
(
mesh,
ami.srcWeightsSum(),
cpp,
"postProcessing",

View File

@ -102,20 +102,20 @@ int main(int argc, char *argv[])
label nProtected = 0;
forAll(faceLabels, faceI)
forAll(faceLabels, facei)
{
const label meshFaceI = faceLabels[faceI];
const label patchI = bm.whichPatch(meshFaceI);
const label meshFacei = faceLabels[facei];
const label patchi = bm.whichPatch(meshFacei);
if
(
patchI != -1
&& bm[patchI].coupled()
&& !isMasterFace[meshFaceI]
patchi != -1
&& bm[patchi].coupled()
&& !isMasterFace[meshFacei]
)
{
// Slave side. Mark so doesn't get visited.
allFaceInfo[faceI] = orientedSurface::NOFLIP;
allFaceInfo[facei] = orientedSurface::NOFLIP;
nProtected++;
}
}
@ -128,13 +128,13 @@ int main(int argc, char *argv[])
// Number of (master)faces per edge
labelList nMasterFaces(patch.nEdges(), 0);
forAll(faceLabels, faceI)
forAll(faceLabels, facei)
{
const label meshFaceI = faceLabels[faceI];
const label meshFacei = faceLabels[facei];
if (isMasterFace[meshFaceI])
if (isMasterFace[meshFacei])
{
const labelList& fEdges = patch.faceEdges()[faceI];
const labelList& fEdges = patch.faceEdges()[facei];
forAll(fEdges, fEdgeI)
{
nMasterFaces[fEdges[fEdgeI]]++;
@ -186,59 +186,59 @@ int main(int argc, char *argv[])
while (true)
{
// Pick an unset face
label unsetFaceI = labelMax;
forAll(allFaceInfo, faceI)
label unsetFacei = labelMax;
forAll(allFaceInfo, facei)
{
if (allFaceInfo[faceI] == orientedSurface::UNVISITED)
if (allFaceInfo[facei] == orientedSurface::UNVISITED)
{
unsetFaceI = globalFaces.toGlobal(faceI);
unsetFacei = globalFaces.toGlobal(facei);
break;
}
}
reduce(unsetFaceI, minOp<label>());
reduce(unsetFacei, minOp<label>());
if (unsetFaceI == labelMax)
if (unsetFacei == labelMax)
{
break;
}
label procI = globalFaces.whichProcID(unsetFaceI);
label seedFaceI = globalFaces.toLocal(procI, unsetFaceI);
Info<< "Seeding from processor " << procI << " face " << seedFaceI
label proci = globalFaces.whichProcID(unsetFacei);
label seedFacei = globalFaces.toLocal(proci, unsetFacei);
Info<< "Seeding from processor " << proci << " face " << seedFacei
<< endl;
if (procI == Pstream::myProcNo())
if (proci == Pstream::myProcNo())
{
// Determine orientation of seedFace
vector d = outsidePoint-patch.faceCentres()[seedFaceI];
const vector& fn = patch.faceNormals()[seedFaceI];
vector d = outsidePoint-patch.faceCentres()[seedFacei];
const vector& fn = patch.faceNormals()[seedFacei];
// Set information to correct orientation
patchFaceOrientation& faceInfo = allFaceInfo[seedFaceI];
patchFaceOrientation& faceInfo = allFaceInfo[seedFacei];
faceInfo = orientedSurface::NOFLIP;
if ((fn&d) < 0)
{
faceInfo.flip();
Pout<< "Face " << seedFaceI << " at "
<< patch.faceCentres()[seedFaceI]
Pout<< "Face " << seedFacei << " at "
<< patch.faceCentres()[seedFacei]
<< " with normal " << fn
<< " needs to be flipped." << endl;
}
else
{
Pout<< "Face " << seedFaceI << " at "
<< patch.faceCentres()[seedFaceI]
Pout<< "Face " << seedFacei << " at "
<< patch.faceCentres()[seedFacei]
<< " with normal " << fn
<< " points in positive direction (cos = " << (fn&d)/mag(d)
<< ")" << endl;
}
const labelList& fEdges = patch.faceEdges()[seedFaceI];
const labelList& fEdges = patch.faceEdges()[seedFacei];
forAll(fEdges, fEdgeI)
{
label edgeI = fEdges[fEdgeI];
@ -252,7 +252,7 @@ int main(int argc, char *argv[])
mesh,
patch,
edgeI,
seedFaceI,
seedFacei,
faceInfo,
tol,
dummyTrackData
@ -303,10 +303,10 @@ int main(int argc, char *argv[])
forAll(faceLabels, i)
{
const label meshFaceI = faceLabels[i];
if (!mesh.isInternalFace(meshFaceI))
const label meshFacei = faceLabels[i];
if (!mesh.isInternalFace(meshFacei))
{
neiStatus[meshFaceI-mesh.nInternalFaces()] =
neiStatus[meshFacei-mesh.nInternalFaces()] =
allFaceInfo[i].flipStatus();
}
}
@ -314,31 +314,31 @@ int main(int argc, char *argv[])
forAll(faceLabels, i)
{
const label meshFaceI = faceLabels[i];
const label patchI = bm.whichPatch(meshFaceI);
const label meshFacei = faceLabels[i];
const label patchi = bm.whichPatch(meshFacei);
if
(
patchI != -1
&& bm[patchI].coupled()
&& !isMasterFace[meshFaceI]
patchi != -1
&& bm[patchi].coupled()
&& !isMasterFace[meshFacei]
)
{
// Slave side. Take flipped from neighbour
label bFaceI = meshFaceI-mesh.nInternalFaces();
label bFacei = meshFacei-mesh.nInternalFaces();
if (neiStatus[bFaceI] == orientedSurface::NOFLIP)
if (neiStatus[bFacei] == orientedSurface::NOFLIP)
{
allFaceInfo[i] = orientedSurface::FLIP;
}
else if (neiStatus[bFaceI] == orientedSurface::FLIP)
else if (neiStatus[bFacei] == orientedSurface::FLIP)
{
allFaceInfo[i] = orientedSurface::NOFLIP;
}
else
{
FatalErrorInFunction
<< "Incorrect status for face " << meshFaceI
<< "Incorrect status for face " << meshFacei
<< abort(FatalError);
}
}
@ -350,25 +350,25 @@ int main(int argc, char *argv[])
boolList newFlipMap(allFaceInfo.size(), false);
label nChanged = 0;
forAll(allFaceInfo, faceI)
forAll(allFaceInfo, facei)
{
if (allFaceInfo[faceI] == orientedSurface::NOFLIP)
if (allFaceInfo[facei] == orientedSurface::NOFLIP)
{
newFlipMap[faceI] = false;
newFlipMap[facei] = false;
}
else if (allFaceInfo[faceI] == orientedSurface::FLIP)
else if (allFaceInfo[facei] == orientedSurface::FLIP)
{
newFlipMap[faceI] = true;
newFlipMap[facei] = true;
}
else
{
FatalErrorInFunction
<< "Problem : unvisited face " << faceI
<< " centre:" << mesh.faceCentres()[faceLabels[faceI]]
<< "Problem : unvisited face " << facei
<< " centre:" << mesh.faceCentres()[faceLabels[facei]]
<< abort(FatalError);
}
if (fZone.flipMap()[faceI] != newFlipMap[faceI])
if (fZone.flipMap()[facei] != newFlipMap[facei])
{
nChanged++;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -94,30 +94,30 @@ class meshDualiser
static void dumpPolyTopoChange(const polyTopoChange&, const fileName&);
//- Find dual cell given point and cell
label findDualCell(const label cellI, const label pointI) const;
label findDualCell(const label celli, const label pointi) const;
//- Helper function to generate dualpoints on all boundary edges
// emanating from (boundary & feature) point
void generateDualBoundaryEdges
(
const PackedBoolList&,
const label pointI,
const label pointi,
polyTopoChange&
);
//- Check that owner and neighbour of face have same dual cell
bool sameDualCell
(
const label faceI,
const label pointI
const label facei,
const label pointi
) const;
//- Add internal face
label addInternalFace
(
const label masterPointI,
const label masterPointi,
const label masterEdgeI,
const label masterFaceI,
const label masterFacei,
const bool edgeOrder,
const label dualCell0,
@ -129,12 +129,12 @@ class meshDualiser
//- Add boundary face
label addBoundaryFace
(
const label masterPointI,
const label masterPointi,
const label masterEdgeI,
const label masterFaceI,
const label masterFacei,
const label dualCellI,
const label patchI,
const label dualCelli,
const label patchi,
const DynamicList<label>& verts,
polyTopoChange& meshMod
) const;
@ -145,7 +145,7 @@ class meshDualiser
const bool splitFace,
const PackedBoolList&,
const label edgeI,
const label startFaceI,
const label startFacei,
polyTopoChange&,
boolList& doneEFaces
) const;
@ -153,17 +153,17 @@ class meshDualiser
//- Create single internal face from internal face
void createFaceFromInternalFace
(
const label faceI,
const label facei,
label& fp,
polyTopoChange&
) const;
//- Creates boundary faces walking around point on patchI.
//- Creates boundary faces walking around point on patchi.
void createFacesAroundBoundaryPoint
(
const label patchI,
const label patchPointI,
const label startFaceI,
const label patchi,
const label patchPointi,
const label startFacei,
polyTopoChange&,
boolList& donePFaces // pFaces visited
) const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -32,31 +32,32 @@ Description
edges.
Usage
- polyDualMesh featureAngle
\b polyDualMesh featureAngle
Detects any boundary edge > angle and creates multiple boundary faces
for it. Normal behaviour is to have each point become a cell
(1.5 behaviour)
\param -concaveMultiCells
Creates multiple cells for each point on a concave edge. Might limit
the amount of distortion on some meshes.
Options:
- \par -concaveMultiCells
Creates multiple cells for each point on a concave edge. Might limit
the amount of distortion on some meshes.
\param -splitAllFaces
Normally only constructs a single face between two cells. This single face
might be too distorted. splitAllFaces will create a single face for every
original cell the face passes through. The mesh will thus have
multiple faces inbetween two cells! (so is not strictly upper-triangular
anymore - checkMesh will complain)
- \par -splitAllFaces
Normally only constructs a single face between two cells. This single
face might be too distorted. splitAllFaces will create a single face for
every original cell the face passes through. The mesh will thus have
multiple faces inbetween two cells! (so is not strictly upper-triangular
anymore - checkMesh will complain)
\param -doNotPreserveFaceZones:
By default all faceZones are preserved by marking all faces, edges and
points on them as features. The -doNotPreserveFaceZones disables this
behaviour.
- \par -doNotPreserveFaceZones:
By default all faceZones are preserved by marking all faces, edges and
points on them as features. The -doNotPreserveFaceZones disables this
behaviour.
Note: is just a driver for meshDualiser. Substitute your own
simpleMarkFeatures to have different behaviour.
Note
It is just a driver for meshDualiser. Substitute your own simpleMarkFeatures
to have different behaviour.
\*---------------------------------------------------------------------------*/
@ -108,9 +109,9 @@ void simpleMarkFeatures
// 1. Mark all edges between patches
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
const labelList& meshEdges = pp.meshEdges();
// All patch corner edges. These need to be feature points & edges!
@ -237,9 +238,9 @@ void simpleMarkFeatures
// Face centres that need inclusion in the dual mesh
labelHashSet featureFaceSet(mesh.nFaces()-mesh.nInternalFaces());
// A. boundary faces.
for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
for (label facei = mesh.nInternalFaces(); facei < mesh.nFaces(); facei++)
{
featureFaceSet.insert(faceI);
featureFaceSet.insert(facei);
}
// B. face zones.
@ -273,11 +274,11 @@ void simpleMarkFeatures
forAll(fz, i)
{
label faceI = fz[i];
const face& f = mesh.faces()[faceI];
const labelList& fEdges = mesh.faceEdges()[faceI];
label facei = fz[i];
const face& f = mesh.faces()[facei];
const labelList& fEdges = mesh.faceEdges()[facei];
featureFaceSet.insert(faceI);
featureFaceSet.insert(facei);
forAll(f, fp)
{
// Mark point as multi cell point (since both sides of
@ -388,9 +389,9 @@ int main(int argc, char *argv[])
// (Note: in 1.4.2 we can use the built-in mesh point ordering
// facility instead)
PackedBoolList isBoundaryEdge(mesh.nEdges());
for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
for (label facei = mesh.nInternalFaces(); facei < mesh.nFaces(); facei++)
{
const labelList& fEdges = mesh.faceEdges()[faceI];
const labelList& fEdges = mesh.faceEdges()[facei];
forAll(fEdges, i)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -243,9 +243,9 @@ int main(int argc, char *argv[])
// Select all cells
refCells.setSize(mesh.nCells());
forAll(mesh.cells(), cellI)
forAll(mesh.cells(), celli)
{
refCells[cellI] = cellI;
refCells[celli] = celli;
}
if (mesh.nGeometricD() == 3)
@ -332,9 +332,9 @@ int main(int argc, char *argv[])
// Create cellSet with added cells for easy inspection
cellSet newCells(mesh, "refinedCells", refCells.size());
forAll(oldToNew, oldCellI)
forAll(oldToNew, oldCelli)
{
const labelList& added = oldToNew[oldCellI];
const labelList& added = oldToNew[oldCelli];
forAll(added, i)
{
@ -375,21 +375,21 @@ int main(int argc, char *argv[])
+ oldTimeName;
forAll(oldToNew, oldCellI)
forAll(oldToNew, oldCelli)
{
const labelList& added = oldToNew[oldCellI];
const labelList& added = oldToNew[oldCelli];
if (added.size())
{
forAll(added, i)
{
newToOld[added[i]] = oldCellI;
newToOld[added[i]] = oldCelli;
}
}
else
{
// Unrefined cell
newToOld[oldCellI] = oldCellI;
newToOld[oldCelli] = oldCelli;
}
}

View File

@ -21,6 +21,6 @@ then
export LINK_FLAGS="${LINK_FLAGS} -lzoltanRenumber -L${ZOLTAN_ARCH_PATH}/lib -lzoltan"
fi
wmake
wmake $targetType
#------------------------------------------------------------------------------

View File

@ -89,9 +89,9 @@ tmp<volScalarField> createScalarField
);
volScalarField& fld = tfld.ref();
forAll(fld, cellI)
forAll(fld, celli)
{
fld[cellI] = elems[cellI];
fld[celli] = elems[celli];
}
return tfld;
@ -103,9 +103,9 @@ label getBand(const labelList& owner, const labelList& neighbour)
{
label band = 0;
forAll(neighbour, faceI)
forAll(neighbour, facei)
{
label diff = neighbour[faceI] - owner[faceI];
label diff = neighbour[facei] - owner[facei];
if (diff > band)
{
@ -131,10 +131,10 @@ void getBand
labelList cellBandwidth(nCells, 0);
scalarField nIntersect(nCells, 0.0);
forAll(neighbour, faceI)
forAll(neighbour, facei)
{
label own = owner[faceI];
label nei = neighbour[faceI];
label own = owner[facei];
label nei = neighbour[facei];
// Note: mag not necessary for correct (upper-triangular) ordering.
label diff = nei-own;
@ -145,17 +145,17 @@ void getBand
// Do not use field algebra because of conversion label to scalar
profile = 0.0;
forAll(cellBandwidth, cellI)
forAll(cellBandwidth, celli)
{
profile += 1.0*cellBandwidth[cellI];
profile += 1.0*cellBandwidth[celli];
}
sumSqrIntersect = 0.0;
if (calculateIntersect)
{
forAll(nIntersect, cellI)
forAll(nIntersect, celli)
{
for (label colI = cellI-cellBandwidth[cellI]; colI <= cellI; colI++)
for (label colI = celli-cellBandwidth[celli]; colI <= celli; colI++)
{
nIntersect[colI] += 1.0;
}
@ -177,37 +177,37 @@ labelList getFaceOrder
labelList oldToNewFace(mesh.nFaces(), -1);
label newFaceI = 0;
label newFacei = 0;
labelList nbr;
labelList order;
forAll(cellOrder, newCellI)
forAll(cellOrder, newCelli)
{
label oldCellI = cellOrder[newCellI];
label oldCelli = cellOrder[newCelli];
const cell& cFaces = mesh.cells()[oldCellI];
const cell& cFaces = mesh.cells()[oldCelli];
// Neighbouring cells
nbr.setSize(cFaces.size());
forAll(cFaces, i)
{
label faceI = cFaces[i];
label facei = cFaces[i];
if (mesh.isInternalFace(faceI))
if (mesh.isInternalFace(facei))
{
// Internal face. Get cell on other side.
label nbrCellI = reverseCellOrder[mesh.faceNeighbour()[faceI]];
if (nbrCellI == newCellI)
label nbrCelli = reverseCellOrder[mesh.faceNeighbour()[facei]];
if (nbrCelli == newCelli)
{
nbrCellI = reverseCellOrder[mesh.faceOwner()[faceI]];
nbrCelli = reverseCellOrder[mesh.faceOwner()[facei]];
}
if (newCellI < nbrCellI)
if (newCelli < nbrCelli)
{
// CellI is master
nbr[i] = nbrCellI;
// Celli is master
nbr[i] = nbrCelli;
}
else
{
@ -230,25 +230,25 @@ labelList getFaceOrder
label index = order[i];
if (nbr[index] != -1)
{
oldToNewFace[cFaces[index]] = newFaceI++;
oldToNewFace[cFaces[index]] = newFacei++;
}
}
}
// Leave patch faces intact.
for (label faceI = newFaceI; faceI < mesh.nFaces(); faceI++)
for (label facei = newFacei; facei < mesh.nFaces(); facei++)
{
oldToNewFace[faceI] = faceI;
oldToNewFace[facei] = facei;
}
// Check done all faces.
forAll(oldToNewFace, faceI)
forAll(oldToNewFace, facei)
{
if (oldToNewFace[faceI] == -1)
if (oldToNewFace[facei] == -1)
{
FatalErrorInFunction
<< "Did not determine new position" << " for face " << faceI
<< "Did not determine new position" << " for face " << facei
<< abort(FatalError);
}
}
@ -270,45 +270,45 @@ labelList getRegionFaceOrder
labelList oldToNewFace(mesh.nFaces(), -1);
label newFaceI = 0;
label newFacei = 0;
label prevRegion = -1;
forAll(cellOrder, newCellI)
forAll(cellOrder, newCelli)
{
label oldCellI = cellOrder[newCellI];
label oldCelli = cellOrder[newCelli];
if (cellToRegion[oldCellI] != prevRegion)
if (cellToRegion[oldCelli] != prevRegion)
{
prevRegion = cellToRegion[oldCellI];
prevRegion = cellToRegion[oldCelli];
}
const cell& cFaces = mesh.cells()[oldCellI];
const cell& cFaces = mesh.cells()[oldCelli];
SortableList<label> nbr(cFaces.size());
forAll(cFaces, i)
{
label faceI = cFaces[i];
label facei = cFaces[i];
if (mesh.isInternalFace(faceI))
if (mesh.isInternalFace(facei))
{
// Internal face. Get cell on other side.
label nbrCellI = reverseCellOrder[mesh.faceNeighbour()[faceI]];
if (nbrCellI == newCellI)
label nbrCelli = reverseCellOrder[mesh.faceNeighbour()[facei]];
if (nbrCelli == newCelli)
{
nbrCellI = reverseCellOrder[mesh.faceOwner()[faceI]];
nbrCelli = reverseCellOrder[mesh.faceOwner()[facei]];
}
if (cellToRegion[oldCellI] != cellToRegion[cellOrder[nbrCellI]])
if (cellToRegion[oldCelli] != cellToRegion[cellOrder[nbrCelli]])
{
// Treat like external face. Do later.
nbr[i] = -1;
}
else if (newCellI < nbrCellI)
else if (newCelli < nbrCelli)
{
// CellI is master
nbr[i] = nbrCellI;
// Celli is master
nbr[i] = nbrCelli;
}
else
{
@ -329,7 +329,7 @@ labelList getRegionFaceOrder
{
if (nbr[i] != -1)
{
oldToNewFace[cFaces[nbr.indices()[i]]] = newFaceI++;
oldToNewFace[cFaces[nbr.indices()[i]]] = newFacei++;
}
}
}
@ -340,14 +340,14 @@ labelList getRegionFaceOrder
// Sort in increasing region
SortableList<label> sortKey(mesh.nFaces(), labelMax);
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
{
label ownRegion = cellToRegion[mesh.faceOwner()[faceI]];
label neiRegion = cellToRegion[mesh.faceNeighbour()[faceI]];
label ownRegion = cellToRegion[mesh.faceOwner()[facei]];
label neiRegion = cellToRegion[mesh.faceNeighbour()[facei]];
if (ownRegion != neiRegion)
{
sortKey[faceI] =
sortKey[facei] =
min(ownRegion, neiRegion)*nRegions
+max(ownRegion, neiRegion);
}
@ -370,25 +370,25 @@ labelList getRegionFaceOrder
prevKey = key;
}
oldToNewFace[sortKey.indices()[i]] = newFaceI++;
oldToNewFace[sortKey.indices()[i]] = newFacei++;
}
}
// Leave patch faces intact.
for (label faceI = newFaceI; faceI < mesh.nFaces(); faceI++)
for (label facei = newFacei; facei < mesh.nFaces(); facei++)
{
oldToNewFace[faceI] = faceI;
oldToNewFace[facei] = facei;
}
// Check done all faces.
forAll(oldToNewFace, faceI)
forAll(oldToNewFace, facei)
{
if (oldToNewFace[faceI] == -1)
if (oldToNewFace[facei] == -1)
{
FatalErrorInFunction
<< "Did not determine new position"
<< " for face " << faceI
<< " for face " << facei
<< abort(FatalError);
}
}
@ -430,16 +430,16 @@ autoPtr<mapPolyMesh> reorderMesh
// Check if any faces need swapping.
labelHashSet flipFaceFlux(newOwner.size());
forAll(newNeighbour, faceI)
forAll(newNeighbour, facei)
{
label own = newOwner[faceI];
label nei = newNeighbour[faceI];
label own = newOwner[facei];
label nei = newNeighbour[facei];
if (nei < own)
{
newFaces[faceI].flip();
Swap(newOwner[faceI], newNeighbour[faceI]);
flipFaceFlux.insert(faceI);
newFaces[facei].flip();
Swap(newOwner[facei], newNeighbour[facei]);
flipFaceFlux.insert(facei);
}
}
@ -449,12 +449,12 @@ autoPtr<mapPolyMesh> reorderMesh
labelList oldPatchNMeshPoints(patches.size());
labelListList patchPointMap(patches.size());
forAll(patches, patchI)
forAll(patches, patchi)
{
patchSizes[patchI] = patches[patchI].size();
patchStarts[patchI] = patches[patchI].start();
oldPatchNMeshPoints[patchI] = patches[patchI].nPoints();
patchPointMap[patchI] = identity(patches[patchI].nPoints());
patchSizes[patchi] = patches[patchi].size();
patchStarts[patchi] = patches[patchi].start();
oldPatchNMeshPoints[patchi] = patches[patchi].nPoints();
patchPointMap[patchi] = identity(patches[patchi].nPoints());
}
mesh.resetPrimitives
@ -480,8 +480,8 @@ autoPtr<mapPolyMesh> reorderMesh
boolList newFlipMap(fZone.size());
forAll(fZone, i)
{
label oldFaceI = fZone[i];
newAddressing[i] = reverseFaceOrder[oldFaceI];
label oldFacei = fZone[i];
newAddressing[i] = reverseFaceOrder[oldFacei];
if (flipFaceFlux.found(newAddressing[i]))
{
newFlipMap[i] = !fZone.flipMap()[i];
@ -569,11 +569,11 @@ labelList regionRenumber
labelListList regionToCells(invertOneToMany(nRegions, cellToRegion));
label cellI = 0;
label celli = 0;
forAll(regionToCells, regionI)
{
Info<< " region " << regionI << " starts at " << cellI << endl;
Info<< " region " << regionI << " starts at " << celli << endl;
// Make sure no parallel comms
bool oldParRun = UPstream::parRun();
@ -598,7 +598,7 @@ labelList regionRenumber
forAll(subCellOrder, i)
{
cellOrder[cellI++] = cellMap[subCellOrder[i]];
cellOrder[celli++] = cellMap[subCellOrder[i]];
}
}
Info<< endl;
@ -1005,11 +1005,11 @@ int main(int argc, char *argv[])
// Collect all boundary cells on coupled patches
label nBndCells = 0;
forAll(pbm, patchI)
forAll(pbm, patchi)
{
if (pbm[patchI].coupled())
if (pbm[patchi].coupled())
{
nBndCells += pbm[patchI].size();
nBndCells += pbm[patchi].size();
}
}
@ -1018,20 +1018,20 @@ int main(int argc, char *argv[])
labelList bndCells(nBndCells);
labelList bndCellMap(nBndCells);
nBndCells = 0;
forAll(pbm, patchI)
forAll(pbm, patchi)
{
if (pbm[patchI].coupled())
if (pbm[patchi].coupled())
{
const labelUList& faceCells = pbm[patchI].faceCells();
const labelUList& faceCells = pbm[patchi].faceCells();
forAll(faceCells, i)
{
label cellI = faceCells[i];
label celli = faceCells[i];
if (reverseCellOrder[cellI] != -1)
if (reverseCellOrder[celli] != -1)
{
bndCells[nBndCells] = cellI;
bndCellMap[nBndCells++] = reverseCellOrder[cellI];
reverseCellOrder[cellI] = -1;
bndCells[nBndCells] = celli;
bndCellMap[nBndCells++] = reverseCellOrder[celli];
reverseCellOrder[celli] = -1;
}
}
}
@ -1049,8 +1049,8 @@ int main(int argc, char *argv[])
label sortedI = mesh.nCells();
forAllReverse(order, i)
{
label origCellI = bndCells[order[i]];
newReverseCellOrder[origCellI] = --sortedI;
label origCelli = bndCells[order[i]];
newReverseCellOrder[origCelli] = --sortedI;
}
Info<< "Ordered all " << nBndCells << " cells with a coupled face"
@ -1059,12 +1059,12 @@ int main(int argc, char *argv[])
// Compact
sortedI = 0;
forAll(cellOrder, newCellI)
forAll(cellOrder, newCelli)
{
label origCellI = cellOrder[newCellI];
if (newReverseCellOrder[origCellI] == -1)
label origCelli = cellOrder[newCelli];
if (newReverseCellOrder[origCelli] == -1)
{
newReverseCellOrder[origCellI] = sortedI++;
newReverseCellOrder[origCelli] = sortedI++;
}
}
@ -1155,15 +1155,15 @@ int main(int argc, char *argv[])
const labelHashSet& fff = map().flipFaceFlux();
forAllConstIter(labelHashSet, fff, iter)
{
label faceI = iter.key();
label masterFaceI = faceProcAddressing[faceI];
label facei = iter.key();
label masterFacei = faceProcAddressing[facei];
faceProcAddressing[faceI] = -masterFaceI;
faceProcAddressing[facei] = -masterFacei;
if (masterFaceI == 0)
if (masterFacei == 0)
{
FatalErrorInFunction
<< " masterFaceI:" << masterFaceI << exit(FatalError);
<< " masterFacei:" << masterFacei << exit(FatalError);
}
}
}

View File

@ -16,6 +16,6 @@ then
export LINK_FLAGS="-lreadline"
fi
wmake
wmake $targetType
#------------------------------------------------------------------------------

View File

@ -84,13 +84,13 @@ void writeVTK
faceList setFaces(currentSet.size());
labelList faceValues(currentSet.size());
label setFaceI = 0;
label setFacei = 0;
forAllConstIter(topoSet, currentSet, iter)
{
setFaces[setFaceI] = mesh.faces()[iter.key()];
faceValues[setFaceI] = iter.key();
setFaceI++;
setFaces[setFacei] = mesh.faces()[iter.key()];
faceValues[setFacei] = iter.key();
setFacei++;
}
primitiveFacePatch fp(setFaces, mesh.points());
@ -113,44 +113,44 @@ void writeVTK
forAllConstIter(cellSet, currentSet, iter)
{
label cellI = iter.key();
label celli = iter.key();
const cell& cFaces = mesh.cells()[cellI];
const cell& cFaces = mesh.cells()[celli];
forAll(cFaces, i)
{
label faceI = cFaces[i];
label facei = cFaces[i];
if (mesh.isInternalFace(faceI))
if (mesh.isInternalFace(facei))
{
label otherCellI = mesh.faceOwner()[faceI];
label otherCelli = mesh.faceOwner()[facei];
if (otherCellI == cellI)
if (otherCelli == celli)
{
otherCellI = mesh.faceNeighbour()[faceI];
otherCelli = mesh.faceNeighbour()[facei];
}
if (!currentSet.found(otherCellI))
if (!currentSet.found(otherCelli))
{
cellFaces.insert(faceI, cellI);
cellFaces.insert(facei, celli);
}
}
else
{
cellFaces.insert(faceI, cellI);
cellFaces.insert(facei, celli);
}
}
}
faceList setFaces(cellFaces.size());
labelList faceValues(cellFaces.size());
label setFaceI = 0;
label setFacei = 0;
forAllConstIter(Map<label>, cellFaces, iter)
{
setFaces[setFaceI] = mesh.faces()[iter.key()];
faceValues[setFaceI] = iter(); // Cell ID
setFaceI++;
setFaces[setFacei] = mesh.faces()[iter.key()];
faceValues[setFacei] = iter(); // Cell ID
setFacei++;
}
primitiveFacePatch fp(setFaces, mesh.points());
@ -874,7 +874,7 @@ int main(int argc, char *argv[])
// Main command read & execute loop
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
autoPtr<IFstream> fileStreamPtr(NULL);
autoPtr<IFstream> fileStreamPtr(nullptr);
if (batch)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -81,9 +81,9 @@ void writePatch
label nFaceVerts = 0;
forAll(fp.localFaces(), faceI)
forAll(fp.localFaces(), facei)
{
nFaceVerts += fp.localFaces()[faceI].size() + 1;
nFaceVerts += fp.localFaces()[facei].size() + 1;
}
pStream << "POLYGONS " << fp.size() << ' ' << nFaceVerts
<< std::endl;
@ -91,9 +91,9 @@ void writePatch
DynamicList<label> vertLabels(nFaceVerts);
forAll(fp.localFaces(), faceI)
forAll(fp.localFaces(), facei)
{
const face& f = fp.localFaces()[faceI];
const face& f = fp.localFaces()[facei];
vertLabels.append(f.size());

View File

@ -166,8 +166,8 @@ int main(int argc, char *argv[])
// No flip map.
forAll(faceLabels, i)
{
label faceI = faceLabels[i];
addressing.append(faceI);
label facei = faceLabels[i];
addressing.append(facei);
flipMap.append(false);
}
}
@ -190,24 +190,24 @@ int main(int argc, char *argv[])
forAll(faceLabels, i)
{
label faceI = faceLabels[i];
label facei = faceLabels[i];
bool flip = false;
if (mesh.isInternalFace(faceI))
if (mesh.isInternalFace(facei))
{
if
(
cells.found(mesh.faceOwner()[faceI])
&& !cells.found(mesh.faceNeighbour()[faceI])
cells.found(mesh.faceOwner()[facei])
&& !cells.found(mesh.faceNeighbour()[facei])
)
{
flip = false;
}
else if
(
!cells.found(mesh.faceOwner()[faceI])
&& cells.found(mesh.faceNeighbour()[faceI])
!cells.found(mesh.faceOwner()[facei])
&& cells.found(mesh.faceNeighbour()[facei])
)
{
flip = true;
@ -216,21 +216,21 @@ int main(int argc, char *argv[])
{
FatalErrorInFunction
<< "One of owner or neighbour of internal face "
<< faceI << " should be in cellSet " << cells.name()
<< facei << " should be in cellSet " << cells.name()
<< " to be able to determine orientation." << endl
<< "Face:" << faceI
<< " own:" << mesh.faceOwner()[faceI]
<< "Face:" << facei
<< " own:" << mesh.faceOwner()[facei]
<< " OwnInCellSet:"
<< cells.found(mesh.faceOwner()[faceI])
<< " nei:" << mesh.faceNeighbour()[faceI]
<< cells.found(mesh.faceOwner()[facei])
<< " nei:" << mesh.faceNeighbour()[facei]
<< " NeiInCellSet:"
<< cells.found(mesh.faceNeighbour()[faceI])
<< cells.found(mesh.faceNeighbour()[facei])
<< abort(FatalError);
}
}
else
{
if (cells.found(mesh.faceOwner()[faceI]))
if (cells.found(mesh.faceOwner()[facei]))
{
flip = false;
}
@ -240,7 +240,7 @@ int main(int argc, char *argv[])
}
}
addressing.append(faceI);
addressing.append(facei);
flipMap.append(flip);
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -43,16 +43,16 @@ defineTypeNameAndDebug(regionSide, 0);
Foam::label Foam::regionSide::otherFace
(
const primitiveMesh& mesh,
const label cellI,
const label faceI,
const label celli,
const label facei,
const label edgeI
)
{
label f0I, f1I;
meshTools::getEdgeFaces(mesh, cellI, edgeI, f0I, f1I);
meshTools::getEdgeFaces(mesh, celli, edgeI, f0I, f1I);
if (f0I == faceI)
if (f0I == facei)
{
return f1I;
}
@ -67,17 +67,17 @@ Foam::label Foam::regionSide::otherFace
Foam::label Foam::regionSide::otherEdge
(
const primitiveMesh& mesh,
const label faceI,
const label facei,
const label edgeI,
const label pointI
const label pointi
)
{
const edge& e = mesh.edges()[edgeI];
// Get other point on edge.
label freePointI = e.otherVertex(pointI);
label freePointi = e.otherVertex(pointi);
const labelList& fEdges = mesh.faceEdges()[faceI];
const labelList& fEdges = mesh.faceEdges()[facei];
forAll(fEdges, fEdgeI)
{
@ -87,12 +87,12 @@ Foam::label Foam::regionSide::otherEdge
if
(
(
otherE.start() == pointI
&& otherE.end() != freePointI
otherE.start() == pointi
&& otherE.end() != freePointi
)
|| (
otherE.end() == pointI
&& otherE.start() != freePointI
otherE.end() == pointi
&& otherE.start() != freePointi
)
)
{
@ -102,52 +102,52 @@ Foam::label Foam::regionSide::otherEdge
}
FatalErrorInFunction
<< "Cannot find other edge on face " << faceI << " that uses point "
<< pointI << " but not point " << freePointI << endl
<< "Cannot find other edge on face " << facei << " that uses point "
<< pointi << " but not point " << freePointi << endl
<< "Edges on face:" << fEdges
<< " verts:" << UIndirectList<edge>(mesh.edges(), fEdges)()
<< " Vertices on face:"
<< mesh.faces()[faceI]
<< mesh.faces()[facei]
<< " Vertices on original edge:" << e << abort(FatalError);
return -1;
}
// Step from faceI (on side cellI) to connected face & cell without crossing
// Step from facei (on side celli) to connected face & cell without crossing
// fenceEdges.
void Foam::regionSide::visitConnectedFaces
(
const primitiveMesh& mesh,
const labelHashSet& region,
const labelHashSet& fenceEdges,
const label cellI,
const label faceI,
const label celli,
const label facei,
labelHashSet& visitedFace
)
{
if (!visitedFace.found(faceI))
if (!visitedFace.found(facei))
{
if (debug)
{
Info<< "visitConnectedFaces : cellI:" << cellI << " faceI:"
<< faceI << " isOwner:" << (cellI == mesh.faceOwner()[faceI])
Info<< "visitConnectedFaces : celli:" << celli << " facei:"
<< facei << " isOwner:" << (celli == mesh.faceOwner()[facei])
<< endl;
}
// Mark as visited
visitedFace.insert(faceI);
visitedFace.insert(facei);
// Mark which side of face was visited.
if (cellI == mesh.faceOwner()[faceI])
if (celli == mesh.faceOwner()[facei])
{
sideOwner_.insert(faceI);
sideOwner_.insert(facei);
}
// Visit all neighbouring faces on faceSet. Stay on this 'side' of
// face by doing edge-face-cell walk.
const labelList& fEdges = mesh.faceEdges()[faceI];
const labelList& fEdges = mesh.faceEdges()[facei];
forAll(fEdges, fEdgeI)
{
@ -159,41 +159,41 @@ void Foam::regionSide::visitConnectedFaces
// we hit face on faceSet.
// Find face reachable from edge
label otherFaceI = otherFace(mesh, cellI, faceI, edgeI);
label otherFacei = otherFace(mesh, celli, facei, edgeI);
if (mesh.isInternalFace(otherFaceI))
if (mesh.isInternalFace(otherFacei))
{
label otherCellI = cellI;
label otherCelli = celli;
// Keep on crossing faces/cells until back on face on
// surface
while (!region.found(otherFaceI))
while (!region.found(otherFacei))
{
visitedFace.insert(otherFaceI);
visitedFace.insert(otherFacei);
if (debug)
{
Info<< "visitConnectedFaces : cellI:" << cellI
<< " found insideEdgeFace:" << otherFaceI
Info<< "visitConnectedFaces : celli:" << celli
<< " found insideEdgeFace:" << otherFacei
<< endl;
}
// Cross otherFaceI into neighbouring cell
otherCellI =
// Cross otherFacei into neighbouring cell
otherCelli =
meshTools::otherCell
(
mesh,
otherCellI,
otherFaceI
otherCelli,
otherFacei
);
otherFaceI =
otherFacei =
otherFace
(
mesh,
otherCellI,
otherFaceI,
otherCelli,
otherFacei,
edgeI
);
}
@ -203,8 +203,8 @@ void Foam::regionSide::visitConnectedFaces
mesh,
region,
fenceEdges,
otherCellI,
otherFaceI,
otherCelli,
otherFacei,
visitedFace
);
}
@ -214,7 +214,7 @@ void Foam::regionSide::visitConnectedFaces
}
// From edge on face connected to point on region (regionPointI) cross
// From edge on face connected to point on region (regionPointi) cross
// to all other edges using this point by walking across faces
// Does not cross regionEdges so stays on one side
// of region
@ -222,26 +222,26 @@ void Foam::regionSide::walkPointConnectedFaces
(
const primitiveMesh& mesh,
const labelHashSet& regionEdges,
const label regionPointI,
const label startFaceI,
const label regionPointi,
const label startFacei,
const label startEdgeI,
labelHashSet& visitedEdges
)
{
// Mark as visited
insidePointFaces_.insert(startFaceI);
insidePointFaces_.insert(startFacei);
if (debug)
{
Info<< "walkPointConnectedFaces : regionPointI:" << regionPointI
<< " faceI:" << startFaceI
Info<< "walkPointConnectedFaces : regionPointi:" << regionPointi
<< " facei:" << startFacei
<< " edgeI:" << startEdgeI << " verts:"
<< mesh.edges()[startEdgeI]
<< endl;
}
// Cross faceI i.e. get edge not startEdgeI which uses regionPointI
label edgeI = otherEdge(mesh, startFaceI, startEdgeI, regionPointI);
// Cross facei i.e. get edge not startEdgeI which uses regionPointi
label edgeI = otherEdge(mesh, startFacei, startEdgeI, regionPointi);
if (!regionEdges.found(edgeI))
{
@ -263,16 +263,16 @@ void Foam::regionSide::walkPointConnectedFaces
const labelList& eFaces = mesh.edgeFaces()[edgeI];
forAll(eFaces, eFaceI)
forAll(eFaces, eFacei)
{
label faceI = eFaces[eFaceI];
label facei = eFaces[eFacei];
walkPointConnectedFaces
(
mesh,
regionEdges,
regionPointI,
faceI,
regionPointi,
facei,
edgeI,
visitedEdges
);
@ -298,8 +298,8 @@ void Foam::regionSide::walkAllPointConnectedFaces
forAllConstIter(labelHashSet, regionFaces, iter)
{
const label faceI = iter.key();
const labelList& fEdges = mesh.faceEdges()[faceI];
const label facei = iter.key();
const labelList& fEdges = mesh.faceEdges()[facei];
forAll(fEdges, fEdgeI)
{
@ -331,29 +331,29 @@ void Foam::regionSide::walkAllPointConnectedFaces
forAllConstIter(labelHashSet, regionFaces, iter)
{
const label faceI = iter.key();
const label facei = iter.key();
// Get side of face.
label cellI;
label celli;
if (sideOwner_.found(faceI))
if (sideOwner_.found(facei))
{
cellI = mesh.faceOwner()[faceI];
celli = mesh.faceOwner()[facei];
}
else
{
cellI = mesh.faceNeighbour()[faceI];
celli = mesh.faceNeighbour()[facei];
}
// Find starting point and edge on face.
const labelList& fEdges = mesh.faceEdges()[faceI];
const labelList& fEdges = mesh.faceEdges()[facei];
forAll(fEdges, fEdgeI)
{
label edgeI = fEdges[fEdgeI];
// Get the face 'perpendicular' to faceI on region.
label otherFaceI = otherFace(mesh, cellI, faceI, edgeI);
// Get the face 'perpendicular' to facei on region.
label otherFacei = otherFace(mesh, celli, facei, edgeI);
// Edge
const edge& e = mesh.edges()[edgeI];
@ -365,14 +365,14 @@ void Foam::regionSide::walkAllPointConnectedFaces
visitedPoint.insert(e.start());
//edgeI = otherEdge(mesh, otherFaceI, edgeI, e.start());
//edgeI = otherEdge(mesh, otherFacei, edgeI, e.start());
walkPointConnectedFaces
(
mesh,
regionEdges,
e.start(),
otherFaceI,
otherFacei,
edgeI,
visitedEdges
);
@ -384,14 +384,14 @@ void Foam::regionSide::walkAllPointConnectedFaces
visitedPoint.insert(e.end());
//edgeI = otherEdge(mesh, otherFaceI, edgeI, e.end());
//edgeI = otherEdge(mesh, otherFacei, edgeI, e.end());
walkPointConnectedFaces
(
mesh,
regionEdges,
e.end(),
otherFaceI,
otherFacei,
edgeI,
visitedEdges
);
@ -409,8 +409,8 @@ Foam::regionSide::regionSide
const primitiveMesh& mesh,
const labelHashSet& region, // faces of region
const labelHashSet& fenceEdges, // outside edges
const label startCellI,
const label startFaceI
const label startCelli,
const label startFacei
)
:
sideOwner_(region.size()),
@ -427,8 +427,8 @@ Foam::regionSide::regionSide
mesh,
region,
fenceEdges,
startCellI,
startFaceI,
startCelli,
startFacei,
visitedFace
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -77,32 +77,32 @@ class regionSide
static label otherEdge
(
const primitiveMesh& mesh,
const label faceI,
const label facei,
const label edgeI,
const label pointI
const label pointi
);
//- From faceI, side cellI, cross to other faces/cells by
//- From facei, side celli, cross to other faces/cells by
// face-cell walking and store visited faces and update sideOwner_.
void visitConnectedFaces
(
const primitiveMesh& mesh,
const labelHashSet& region,
const labelHashSet& fenceEdges,
const label cellI,
const label faceI,
const label celli,
const label facei,
labelHashSet& visitedFace
);
//- From edge on face connected to point on region (regionPointI) cross
//- From edge on face connected to point on region (regionPointi) cross
// to all other edges using this point by walking across faces
// Does not cross regionEdges so stays on one side of region
void walkPointConnectedFaces
(
const primitiveMesh& mesh,
const labelHashSet& regionEdges,
const label regionPointI,
const label startFaceI,
const label regionPointi,
const label startFacei,
const label startEdgeI,
labelHashSet& visitedEdges
);
@ -127,8 +127,8 @@ public:
static label otherFace
(
const primitiveMesh& mesh,
const label cellI,
const label excludeFaceI,
const label celli,
const label excludeFacei,
const label edgeI
);

View File

@ -89,9 +89,9 @@ label findEdge(const primitiveMesh& mesh, const label v0, const label v1)
// Checks whether patch present
void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
{
const label patchI = bMesh.findPatchID(name);
const label patchi = bMesh.findPatchID(name);
if (patchI == -1)
if (patchi == -1)
{
FatalErrorInFunction
<< "Cannot find patch " << name << nl
@ -100,7 +100,7 @@ void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
<< exit(FatalError);
}
if (bMesh[patchI].size())
if (bMesh[patchi].size())
{
FatalErrorInFunction
<< "Patch " << name << " is present but non-zero size"
@ -203,15 +203,15 @@ int main(int argc, char *argv[])
}
// Find sides reachable from 0th face of faceSet
label startFaceI = faces[0];
label startFacei = faces[0];
regionSide regionInfo
(
mesh,
facesSet,
fenceEdges,
mesh.faceOwner()[startFaceI],
startFaceI
mesh.faceOwner()[startFacei],
startFacei
);
// Determine flip state for all faces in faceSet

View File

@ -124,8 +124,8 @@ void renamePatches
const_cast<polyBoundaryMesh&>(mesh.boundaryMesh());
forAll(patchesToRename, i)
{
label patchI = patchesToRename[i];
polyPatch& pp = polyPatches[patchI];
label patchi = patchesToRename[i];
polyPatch& pp = polyPatches[patchi];
if (isA<coupledPolyPatch>(pp))
{
@ -180,11 +180,11 @@ void subsetVolFields
// Hack: set value to 0 for introduced patches (since don't
// get initialised.
forAll(tSubFld().boundaryField(), patchI)
forAll(tSubFld().boundaryField(), patchi)
{
if (addedPatches.found(patchI))
if (addedPatches.found(patchi))
{
tSubFld.ref().boundaryField()[patchI] ==
tSubFld.ref().boundaryFieldRef()[patchi] ==
typename GeoField::value_type(Zero);
}
}
@ -234,11 +234,11 @@ void subsetSurfaceFields
// Hack: set value to 0 for introduced patches (since don't
// get initialised.
forAll(tSubFld().boundaryField(), patchI)
forAll(tSubFld().boundaryField(), patchi)
{
if (addedPatches.found(patchI))
if (addedPatches.found(patchi))
{
tSubFld.ref().boundaryField()[patchI] ==
tSubFld.ref().boundaryFieldRef()[patchi] ==
typename GeoField::value_type(Zero);
}
}
@ -255,11 +255,11 @@ void subsetSurfaceFields
labelList getNonRegionCells(const labelList& cellRegion, const label regionI)
{
DynamicList<label> nonRegionCells(cellRegion.size());
forAll(cellRegion, cellI)
forAll(cellRegion, celli)
{
if (cellRegion[cellI] != regionI)
if (cellRegion[celli] != regionI)
{
nonRegionCells.append(cellI);
nonRegionCells.append(celli);
}
}
return nonRegionCells.shrink();
@ -334,17 +334,17 @@ void getInterfaceSizes
// Internal faces
// ~~~~~~~~~~~~~~
forAll(mesh.faceNeighbour(), faceI)
forAll(mesh.faceNeighbour(), facei)
{
label ownRegion = cellRegion[mesh.faceOwner()[faceI]];
label neiRegion = cellRegion[mesh.faceNeighbour()[faceI]];
label ownRegion = cellRegion[mesh.faceOwner()[facei]];
label neiRegion = cellRegion[mesh.faceNeighbour()[facei]];
if (ownRegion != neiRegion)
{
addToInterface
(
mesh,
(useFaceZones ? mesh.faceZones().whichZone(faceI) : -1),
(useFaceZones ? mesh.faceZones().whichZone(facei) : -1),
ownRegion,
neiRegion,
regionsToSize
@ -360,15 +360,15 @@ void getInterfaceSizes
forAll(coupledRegion, i)
{
label cellI = mesh.faceOwner()[i+mesh.nInternalFaces()];
coupledRegion[i] = cellRegion[cellI];
label celli = mesh.faceOwner()[i+mesh.nInternalFaces()];
coupledRegion[i] = cellRegion[celli];
}
syncTools::swapBoundaryFaceList(mesh, coupledRegion);
forAll(coupledRegion, i)
{
label faceI = i+mesh.nInternalFaces();
label ownRegion = cellRegion[mesh.faceOwner()[faceI]];
label facei = i+mesh.nInternalFaces();
label ownRegion = cellRegion[mesh.faceOwner()[facei]];
label neiRegion = coupledRegion[i];
if (ownRegion != neiRegion)
@ -376,7 +376,7 @@ void getInterfaceSizes
addToInterface
(
mesh,
(useFaceZones ? mesh.faceZones().whichZone(faceI) : -1),
(useFaceZones ? mesh.faceZones().whichZone(facei) : -1),
ownRegion,
neiRegion,
regionsToSize
@ -524,17 +524,17 @@ void getInterfaceSizes
// Mark all inter-region faces.
faceToInterface.setSize(mesh.nFaces(), -1);
forAll(mesh.faceNeighbour(), faceI)
forAll(mesh.faceNeighbour(), facei)
{
label ownRegion = cellRegion[mesh.faceOwner()[faceI]];
label neiRegion = cellRegion[mesh.faceNeighbour()[faceI]];
label ownRegion = cellRegion[mesh.faceOwner()[facei]];
label neiRegion = cellRegion[mesh.faceNeighbour()[facei]];
if (ownRegion != neiRegion)
{
label zoneID = -1;
if (useFaceZones)
{
zoneID = mesh.faceZones().whichZone(faceI);
zoneID = mesh.faceZones().whichZone(facei);
}
edge interface
@ -543,13 +543,13 @@ void getInterfaceSizes
max(ownRegion, neiRegion)
);
faceToInterface[faceI] = regionsToInterface[interface][zoneID];
faceToInterface[facei] = regionsToInterface[interface][zoneID];
}
}
forAll(coupledRegion, i)
{
label faceI = i+mesh.nInternalFaces();
label ownRegion = cellRegion[mesh.faceOwner()[faceI]];
label facei = i+mesh.nInternalFaces();
label ownRegion = cellRegion[mesh.faceOwner()[facei]];
label neiRegion = coupledRegion[i];
if (ownRegion != neiRegion)
@ -557,7 +557,7 @@ void getInterfaceSizes
label zoneID = -1;
if (useFaceZones)
{
zoneID = mesh.faceZones().whichZone(faceI);
zoneID = mesh.faceZones().whichZone(facei);
}
edge interface
@ -566,7 +566,7 @@ void getInterfaceSizes
max(ownRegion, neiRegion)
);
faceToInterface[faceI] = regionsToInterface[interface][zoneID];
faceToInterface[facei] = regionsToInterface[interface][zoneID];
}
}
}
@ -644,8 +644,8 @@ autoPtr<mapPolyMesh> createRegionMesh
forAll(coupledRegion, i)
{
label cellI = mesh.faceOwner()[i+mesh.nInternalFaces()];
coupledRegion[i] = cellRegion[cellI];
label celli = mesh.faceOwner()[i+mesh.nInternalFaces()];
coupledRegion[i] = cellRegion[celli];
}
syncTools::swapBoundaryFaceList(mesh, coupledRegion);
@ -667,19 +667,19 @@ autoPtr<mapPolyMesh> createRegionMesh
labelList exposedPatchIDs(exposedFaces.size());
forAll(exposedFaces, i)
{
label faceI = exposedFaces[i];
label interfaceI = faceToInterface[faceI];
label facei = exposedFaces[i];
label interfacei = faceToInterface[facei];
label ownRegion = cellRegion[mesh.faceOwner()[faceI]];
label ownRegion = cellRegion[mesh.faceOwner()[facei]];
label neiRegion = -1;
if (mesh.isInternalFace(faceI))
if (mesh.isInternalFace(facei))
{
neiRegion = cellRegion[mesh.faceNeighbour()[faceI]];
neiRegion = cellRegion[mesh.faceNeighbour()[facei]];
}
else
{
neiRegion = coupledRegion[faceI-mesh.nInternalFaces()];
neiRegion = coupledRegion[facei-mesh.nInternalFaces()];
}
@ -699,8 +699,8 @@ autoPtr<mapPolyMesh> createRegionMesh
else
{
FatalErrorInFunction
<< "Exposed face:" << faceI
<< " fc:" << mesh.faceCentres()[faceI]
<< "Exposed face:" << facei
<< " fc:" << mesh.faceCentres()[facei]
<< " has owner region " << ownRegion
<< " and neighbour region " << neiRegion
<< " when handling region:" << regionI
@ -710,11 +710,11 @@ autoPtr<mapPolyMesh> createRegionMesh
// Find the patch.
if (regionI < otherRegion)
{
exposedPatchIDs[i] = interfacePatches[interfaceI];
exposedPatchIDs[i] = interfacePatches[interfacei];
}
else
{
exposedPatchIDs[i] = interfacePatches[interfaceI]+1;
exposedPatchIDs[i] = interfacePatches[interfacei]+1;
}
}
@ -775,10 +775,10 @@ void createAndWriteRegion
// Make map of all added patches
labelHashSet addedPatches(2*interfacePatches.size());
forAll(interfacePatches, interfaceI)
forAll(interfacePatches, interfacei)
{
addedPatches.insert(interfacePatches[interfaceI]);
addedPatches.insert(interfacePatches[interfaceI]+1);
addedPatches.insert(interfacePatches[interfacei]);
addedPatches.insert(interfacePatches[interfacei]+1);
}
@ -885,16 +885,16 @@ void createAndWriteRegion
Info<< "Deleting empty patches" << endl;
// Assumes all non-proc boundaries are on all processors!
forAll(newPatches, patchI)
forAll(newPatches, patchi)
{
const polyPatch& pp = newPatches[patchI];
const polyPatch& pp = newPatches[patchi];
if (!isA<processorPolyPatch>(pp))
{
if (returnReduce(pp.size(), sumOp<label>()) > 0)
{
oldToNew[patchI] = newI;
if (!addedPatches.found(patchI))
oldToNew[patchi] = newI;
if (!addedPatches.found(patchi))
{
sharedPatches.append(newI);
}
@ -904,24 +904,24 @@ void createAndWriteRegion
}
// Same for processor patches (but need no reduction)
forAll(newPatches, patchI)
forAll(newPatches, patchi)
{
const polyPatch& pp = newPatches[patchI];
const polyPatch& pp = newPatches[patchi];
if (isA<processorPolyPatch>(pp) && pp.size())
{
oldToNew[patchI] = newI++;
oldToNew[patchi] = newI++;
}
}
const label nNewPatches = newI;
// Move all deleteable patches to the end
forAll(oldToNew, patchI)
forAll(oldToNew, patchi)
{
if (oldToNew[patchI] == -1)
if (oldToNew[patchi] == -1)
{
oldToNew[patchI] = newI++;
oldToNew[patchi] = newI++;
}
}
@ -978,23 +978,23 @@ void createAndWriteRegion
),
newMesh().nFaces()
);
forAll(faceProcAddressing, faceI)
forAll(faceProcAddressing, facei)
{
// face + turning index. (see decomposePar)
// Is the face pointing in the same direction?
label oldFaceI = map().faceMap()[faceI];
label oldFacei = map().faceMap()[facei];
if
(
map().cellMap()[newMesh().faceOwner()[faceI]]
== mesh.faceOwner()[oldFaceI]
map().cellMap()[newMesh().faceOwner()[facei]]
== mesh.faceOwner()[oldFacei]
)
{
faceProcAddressing[faceI] = oldFaceI+1;
faceProcAddressing[facei] = oldFacei+1;
}
else
{
faceProcAddressing[faceI] = -(oldFaceI+1);
faceProcAddressing[facei] = -(oldFacei+1);
}
}
Info<< "Writing map " << faceProcAddressing.name()
@ -1148,11 +1148,11 @@ label findCorrespondingRegion
// Per region the number of cells in zoneI
labelList cellsInZone(nCellRegions, 0);
forAll(cellRegion, cellI)
forAll(cellRegion, celli)
{
if (existingZoneID[cellI] == zoneI)
if (existingZoneID[celli] == zoneI)
{
cellsInZone[cellRegion[cellI]]++;
cellsInZone[cellRegion[celli]]++;
}
}
@ -1171,11 +1171,11 @@ label findCorrespondingRegion
else
{
// Check that region contains no cells that aren't in cellZone.
forAll(cellRegion, cellI)
forAll(cellRegion, celli)
{
if (cellRegion[cellI] == regionI && existingZoneID[cellI] != zoneI)
if (cellRegion[celli] == regionI && existingZoneID[celli] != zoneI)
{
// cellI in regionI but not in zoneI
// celli in regionI but not in zoneI
regionI = -1;
break;
}
@ -1210,18 +1210,18 @@ void getZoneID
forAll(cz, i)
{
label cellI = cz[i];
if (zoneID[cellI] == -1)
label celli = cz[i];
if (zoneID[celli] == -1)
{
zoneID[cellI] = zoneI;
zoneID[celli] = zoneI;
}
else
{
FatalErrorInFunction
<< "Cell " << cellI << " with cell centre "
<< mesh.cellCentres()[cellI]
<< "Cell " << celli << " with cell centre "
<< mesh.cellCentres()[celli]
<< " is multiple zones. This is not allowed." << endl
<< "It is in zone " << cellZones[zoneID[cellI]].name()
<< "It is in zone " << cellZones[zoneID[celli]].name()
<< " and in zone " << cellZones[zoneI].name()
<< exit(FatalError);
}
@ -1271,15 +1271,15 @@ void matchRegions
Pstream::gatherList(zoneNames);
Pstream::scatterList(zoneNames);
forAll(zoneNames, procI)
forAll(zoneNames, proci)
{
if (zoneNames[procI] != zoneNames[0])
if (zoneNames[proci] != zoneNames[0])
{
FatalErrorInFunction
<< "cellZones not synchronised across processors." << endl
<< "Master has cellZones " << zoneNames[0] << endl
<< "Processor " << procI
<< " has cellZones " << zoneNames[procI]
<< "Processor " << proci
<< " has cellZones " << zoneNames[proci]
<< exit(FatalError);
}
}
@ -1396,9 +1396,9 @@ void writeCellToRegion(const fvMesh& mesh, const labelList& cellRegion)
dimensionedScalar("zero", dimless, 0),
zeroGradientFvPatchScalarField::typeName
);
forAll(cellRegion, cellI)
forAll(cellRegion, celli)
{
cellToRegion[cellI] = cellRegion[cellI];
cellToRegion[celli] = cellRegion[celli];
}
cellToRegion.write();
@ -1571,14 +1571,14 @@ int main(int argc, char *argv[])
<< " This requires all"
<< " cells to be in one and only one cellZone." << nl << endl;
label unzonedCellI = findIndex(zoneID, -1);
if (unzonedCellI != -1)
label unzonedCelli = findIndex(zoneID, -1);
if (unzonedCelli != -1)
{
FatalErrorInFunction
<< "For the cellZonesOnly option all cells "
<< "have to be in a cellZone." << endl
<< "Cell " << unzonedCellI
<< " at" << mesh.cellCentres()[unzonedCellI]
<< "Cell " << unzonedCelli
<< " at" << mesh.cellCentres()[unzonedCelli]
<< " is not in a cellZone. There might be more unzoned cells."
<< exit(FatalError);
}
@ -1620,14 +1620,14 @@ int main(int argc, char *argv[])
labelList newNeiZoneID(mesh.nFaces()-mesh.nInternalFaces());
getZoneID(mesh, newCellZones, newZoneID, newNeiZoneID);
label unzonedCellI = findIndex(newZoneID, -1);
if (unzonedCellI != -1)
label unzonedCelli = findIndex(newZoneID, -1);
if (unzonedCelli != -1)
{
FatalErrorInFunction
<< "For the cellZonesFileOnly option all cells "
<< "have to be in a cellZone." << endl
<< "Cell " << unzonedCellI
<< " at" << mesh.cellCentres()[unzonedCellI]
<< "Cell " << unzonedCelli
<< " at" << mesh.cellCentres()[unzonedCelli]
<< " is not in a cellZone. There might be more unzoned cells."
<< exit(FatalError);
}
@ -1672,25 +1672,25 @@ int main(int argc, char *argv[])
{
blockedFace.setSize(mesh.nFaces(), false);
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
{
label own = mesh.faceOwner()[faceI];
label nei = mesh.faceNeighbour()[faceI];
label own = mesh.faceOwner()[facei];
label nei = mesh.faceNeighbour()[facei];
if (zoneID[own] != zoneID[nei])
{
blockedFace[faceI] = true;
blockedFace[facei] = true;
}
}
// Different cellZones on either side of processor patch.
forAll(neiZoneID, i)
{
label faceI = i+mesh.nInternalFaces();
label facei = i+mesh.nInternalFaces();
if (zoneID[mesh.faceOwner()[faceI]] != neiZoneID[i])
if (zoneID[mesh.faceOwner()[facei]] != neiZoneID[i])
{
blockedFace[faceI] = true;
blockedFace[facei] = true;
}
}
}
@ -1750,9 +1750,9 @@ int main(int argc, char *argv[])
labelList regionSizes(nCellRegions, 0);
forAll(cellRegion, cellI)
forAll(cellRegion, celli)
{
regionSizes[cellRegion[cellI]]++;
regionSizes[cellRegion[celli]]++;
}
forAll(regionSizes, regionI)
{
@ -2004,14 +2004,14 @@ int main(int argc, char *argv[])
(void)mesh.tetBasePtIs();
label cellI = mesh.findCell(insidePoint);
label celli = mesh.findCell(insidePoint);
Info<< nl << "Found point " << insidePoint << " in cell " << cellI
Info<< nl << "Found point " << insidePoint << " in cell " << celli
<< endl;
if (cellI != -1)
if (celli != -1)
{
regionI = cellRegion[cellI];
regionI = cellRegion[celli];
}
reduce(regionI, maxOp<label>());

View File

@ -177,9 +177,9 @@ label addCellZone(const polyMesh& mesh, const word& name)
// Checks whether patch present
void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
{
const label patchI = bMesh.findPatchID(name);
const label patchi = bMesh.findPatchID(name);
if (patchI == -1)
if (patchi == -1)
{
FatalErrorInFunction
<< "Cannot find patch " << name << endl
@ -188,7 +188,7 @@ void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
<< exit(FatalError);
}
if (bMesh[patchI].empty())
if (bMesh[patchi].empty())
{
FatalErrorInFunction
<< "Patch " << name << " is present but zero size"
@ -480,7 +480,7 @@ int main(int argc, char *argv[])
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
// Bypass runTime write (since only writes at outputTime)
// Bypass runTime write (since only writes at writeTime)
if
(
!runTime.objectRegistry::writeObject

View File

@ -4,7 +4,6 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools \
-ldynamicMesh \
-ldynamicMesh \
-lgenericPatchFields

View File

@ -326,7 +326,7 @@ int main(int argc, char *argv[])
// Create mesh subsetting engine
fvMeshSubset subsetter(mesh);
labelList exposedPatchIDs;
label patchi = -1;
if (args.optionFound("patch"))
{
@ -523,17 +523,17 @@ int main(int argc, char *argv[])
// Read dimensioned fields and subset
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
typedef volScalarField::DimensionedInternalField dimScalType;
typedef volScalarField::Internal dimScalType;
wordList scalarDimNames(objects.names(dimScalType::typeName));
PtrList<dimScalType> scalarDimFlds(scalarDimNames.size());
subsetDimensionedFields(subsetter, scalarDimNames, scalarDimFlds);
typedef volVectorField::DimensionedInternalField dimVecType;
typedef volVectorField::Internal dimVecType;
wordList vectorDimNames(objects.names(dimVecType::typeName));
PtrList<dimVecType> vectorDimFlds(vectorDimNames.size());
subsetDimensionedFields(subsetter, vectorDimNames, vectorDimFlds);
typedef volSphericalTensorField::DimensionedInternalField dimSphereType;
typedef volSphericalTensorField::Internal dimSphereType;
wordList sphericalTensorDimNames(objects.names(dimSphereType::typeName));
PtrList<dimSphereType> sphericalTensorDimFlds
(
@ -546,12 +546,12 @@ int main(int argc, char *argv[])
sphericalTensorDimFlds
);
typedef volSymmTensorField::DimensionedInternalField dimSymmTensorType;
typedef volSymmTensorField::Internal dimSymmTensorType;
wordList symmTensorDimNames(objects.names(dimSymmTensorType::typeName));
PtrList<dimSymmTensorType> symmTensorDimFlds(symmTensorDimNames.size());
subsetDimensionedFields(subsetter, symmTensorDimNames, symmTensorDimFlds);
typedef volTensorField::DimensionedInternalField dimTensorType;
typedef volTensorField::Internal dimTensorType;
wordList tensorDimNames(objects.names(dimTensorType::typeName));
PtrList<dimTensorType> tensorDimFlds(tensorDimNames.size());
subsetDimensionedFields(subsetter, tensorDimNames, tensorDimFlds);