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

@ -1,7 +1,6 @@
probes/probes.C
probes/patchProbes.C
probes/probesGrouping.C
probes/probesFunctionObject/probesFunctionObject.C
sampledSet/circle/circleSet.C
sampledSet/cloud/cloudSet.C
@ -14,7 +13,6 @@ sampledSet/patchSeed/patchSeedSet.C
sampledSet/sampledSet/sampledSet.C
sampledSet/sampledSets/sampledSets.C
sampledSet/sampledSets/sampledSetsGrouping.C
sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C
sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.C
sampledSet/uniform/uniformSet.C
sampledSet/array/arraySet.C
@ -33,7 +31,6 @@ sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C
sampledSurface/sampledSurface/sampledSurface.C
sampledSurface/sampledSurfaces/sampledSurfaces.C
sampledSurface/sampledSurfaces/sampledSurfacesGrouping.C
sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C
sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C
sampledSurface/thresholdCellFaces/thresholdCellFaces.C
sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C
@ -43,7 +40,7 @@ surfWriters = sampledSurface/writers
$(surfWriters)/surfaceWriter.C
$(surfWriters)/dx/dxSurfaceWriter.C
$(surfWriters)/ensight/ensightSurfaceWriter.C
$(surfWriters)/foamFile/foamFileSurfaceWriter.C
$(surfWriters)/foam/foamSurfaceWriter.C
$(surfWriters)/nastran/nastranSurfaceWriter.C
$(surfWriters)/proxy/proxySurfaceWriter.C
$(surfWriters)/raw/rawSurfaceWriter.C

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
@ -56,20 +56,20 @@ void Foam::cuttingPlane::calcCutCells
}
cutCells_.setSize(listSize);
label cutcellI(0);
label cutcelli(0);
// Find the cut cells by detecting any cell that uses points with
// opposing dotProducts.
for (label listI = 0; listI < listSize; ++listI)
{
label cellI = listI;
label celli = listI;
if (notNull(cellIdLabels))
{
cellI = cellIdLabels[listI];
celli = cellIdLabels[listI];
}
const labelList& cEdges = cellEdges[cellI];
const labelList& cEdges = cellEdges[celli];
label nCutEdges = 0;
@ -87,7 +87,7 @@ void Foam::cuttingPlane::calcCutCells
if (nCutEdges > 2)
{
cutCells_[cutcellI++] = cellI;
cutCells_[cutcelli++] = celli;
break;
}
@ -96,7 +96,7 @@ void Foam::cuttingPlane::calcCutCells
}
// Set correct list size
cutCells_.setSize(cutcellI);
cutCells_.setSize(cutcelli);
}
@ -161,12 +161,12 @@ bool Foam::cuttingPlane::walkCell
(
const primitiveMesh& mesh,
const labelUList& edgePoint,
const label cellI,
const label celli,
const label startEdgeI,
DynamicList<label>& faceVerts
)
{
label faceI = -1;
label facei = -1;
label edgeI = startEdgeI;
label nIter = 0;
@ -177,10 +177,10 @@ bool Foam::cuttingPlane::walkCell
faceVerts.append(edgePoint[edgeI]);
// Cross edge to other face
faceI = meshTools::otherFace(mesh, cellI, faceI, edgeI);
facei = meshTools::otherFace(mesh, celli, facei, edgeI);
// Find next cut edge on face.
const labelList& fEdges = mesh.faceEdges()[faceI];
const labelList& fEdges = mesh.faceEdges()[facei];
label nextEdgeI = -1;
@ -202,9 +202,9 @@ bool Foam::cuttingPlane::walkCell
if (nextEdgeI == -1)
{
// Did not find another cut edge on faceI. Do what?
// Did not find another cut edge on facei. Do what?
WarningInFunction
<< "Did not find closed walk along surface of cell " << cellI
<< "Did not find closed walk along surface of cell " << celli
<< " starting from edge " << startEdgeI
<< " in " << nIter << " iterations." << nl
<< "Collected cutPoints so far:" << faceVerts
@ -220,7 +220,7 @@ bool Foam::cuttingPlane::walkCell
if (nIter > 1000)
{
WarningInFunction
<< "Did not find closed walk along surface of cell " << cellI
<< "Did not find closed walk along surface of cell " << celli
<< " starting from edge " << startEdgeI
<< " in " << nIter << " iterations." << nl
<< "Collected cutPoints so far:" << faceVerts
@ -238,7 +238,7 @@ bool Foam::cuttingPlane::walkCell
else
{
WarningInFunction
<< "Did not find closed walk along surface of cell " << cellI
<< "Did not find closed walk along surface of cell " << celli
<< " starting from edge " << startEdgeI << nl
<< "Collected cutPoints so far:" << faceVerts
<< endl;
@ -266,10 +266,10 @@ void Foam::cuttingPlane::walkCellCuts
forAll(cutCells_, i)
{
label cellI = cutCells_[i];
label celli = cutCells_[i];
// Find the starting edge to walk from.
const labelList& cEdges = mesh.cellEdges()[cellI];
const labelList& cEdges = mesh.cellEdges()[celli];
label startEdgeI = -1;
@ -288,7 +288,7 @@ void Foam::cuttingPlane::walkCellCuts
if (startEdgeI == -1)
{
FatalErrorInFunction
<< "Cannot find cut edge for cut cell " << cellI
<< "Cannot find cut edge for cut cell " << celli
<< abort(FatalError);
}
@ -297,7 +297,7 @@ void Foam::cuttingPlane::walkCellCuts
(
mesh,
edgePoint,
cellI,
celli,
startEdgeI,
faceVerts
);
@ -318,13 +318,13 @@ void Foam::cuttingPlane::walkCellCuts
label nTri = f.triangles(cutPoints, dynCutFaces);
while (nTri--)
{
dynCutCells.append(cellI);
dynCutCells.append(celli);
}
}
else
{
dynCutFaces.append(f);
dynCutCells.append(cellI);
dynCutCells.append(celli);
}
}
}
@ -397,9 +397,9 @@ void Foam::cuttingPlane::remapFaces
MeshStorage::remapFaces(faceMap);
List<label> newCutCells(faceMap.size());
forAll(faceMap, faceI)
forAll(faceMap, facei)
{
newCutCells[faceI] = cutCells_[faceMap[faceI]];
newCutCells[facei] = cutCells_[faceMap[facei]];
}
cutCells_.transfer(newCutCells);
}

View File

@ -97,7 +97,7 @@ class cuttingPlane
(
const primitiveMesh&,
const labelUList& edgePoint,
const label cellI,
const label celli,
const label startEdgeI,
DynamicList<label>& faceVerts
);
@ -118,6 +118,7 @@ protected:
//- Construct plane description without cutting
cuttingPlane(const plane&);
// Protected Member Functions
//- Recut mesh with existing planeDesc, restricted to a list of cells

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
@ -68,7 +68,7 @@ void makeGraph
makeGraph
(
x,
vsf.internalField(),
vsf.primitiveField(),
name,
path,
graphFormat

View File

@ -24,8 +24,8 @@ void writeCellGraph
vsf.name(),
"x",
vsf.name(),
vsf.mesh().C().internalField().component(vector::X),
vsf.internalField()
vsf.mesh().C().primitiveField().component(vector::X),
vsf.primitiveField()
).write(path/vsf.name(), graphFormat);
}

View File

@ -103,8 +103,8 @@ void Foam::cellVolumeWeightMethod::calculateAddressing
label& startSeedI
)
{
label srcCellI = srcSeedI;
label tgtCellI = tgtSeedI;
label srcCelli = srcSeedI;
label tgtCelli = tgtSeedI;
List<DynamicList<label>> srcToTgtAddr(src_.nCells());
List<DynamicList<scalar>> srcToTgtWght(src_.nCells());
@ -115,12 +115,12 @@ void Foam::cellVolumeWeightMethod::calculateAddressing
// list of tgt cell neighbour cells
DynamicList<label> nbrTgtCells(10);
// list of tgt cells currently visited for srcCellI to avoid multiple hits
// list of tgt cells currently visited for srcCelli to avoid multiple hits
DynamicList<label> visitedTgtCells(10);
// list to keep track of tgt cells used to seed src cells
labelList seedCells(src_.nCells(), -1);
seedCells[srcCellI] = tgtCellI;
seedCells[srcCelli] = tgtCelli;
const scalarField& srcVol = src_.cellVolumes();
@ -130,27 +130,27 @@ void Foam::cellVolumeWeightMethod::calculateAddressing
visitedTgtCells.clear();
// append initial target cell and neighbours
nbrTgtCells.append(tgtCellI);
appendNbrCells(tgtCellI, tgt_, visitedTgtCells, nbrTgtCells);
nbrTgtCells.append(tgtCelli);
appendNbrCells(tgtCelli, tgt_, visitedTgtCells, nbrTgtCells);
do
{
tgtCellI = nbrTgtCells.remove();
visitedTgtCells.append(tgtCellI);
tgtCelli = nbrTgtCells.remove();
visitedTgtCells.append(tgtCelli);
scalar vol = interVol(srcCellI, tgtCellI);
scalar vol = interVol(srcCelli, tgtCelli);
// accumulate addressing and weights for valid intersection
if (vol/srcVol[srcCellI] > tolerance_)
if (vol/srcVol[srcCelli] > tolerance_)
{
// store src/tgt cell pair
srcToTgtAddr[srcCellI].append(tgtCellI);
srcToTgtWght[srcCellI].append(vol);
srcToTgtAddr[srcCelli].append(tgtCelli);
srcToTgtWght[srcCelli].append(vol);
tgtToSrcAddr[tgtCellI].append(srcCellI);
tgtToSrcWght[tgtCellI].append(vol);
tgtToSrcAddr[tgtCelli].append(srcCelli);
tgtToSrcWght[tgtCelli].append(vol);
appendNbrCells(tgtCellI, tgt_, visitedTgtCells, nbrTgtCells);
appendNbrCells(tgtCelli, tgt_, visitedTgtCells, nbrTgtCells);
// accumulate intersection volume
V_ += vol;
@ -158,21 +158,21 @@ void Foam::cellVolumeWeightMethod::calculateAddressing
}
while (!nbrTgtCells.empty());
mapFlag[srcCellI] = false;
mapFlag[srcCelli] = false;
// find new source seed cell
setNextCells
(
startSeedI,
srcCellI,
tgtCellI,
srcCelli,
tgtCelli,
srcCellIDs,
mapFlag,
visitedTgtCells,
seedCells
);
}
while (srcCellI != -1);
while (srcCelli != -1);
// transfer addressing into persistent storage
forAll(srcToTgtCellAddr, i)
@ -230,15 +230,15 @@ void Foam::cellVolumeWeightMethod::calculateAddressing
void Foam::cellVolumeWeightMethod::setNextCells
(
label& startSeedI,
label& srcCellI,
label& tgtCellI,
label& srcCelli,
label& tgtCelli,
const labelList& srcCellIDs,
const boolList& mapFlag,
const DynamicList<label>& visitedCells,
labelList& seedCells
) const
{
const labelList& srcNbrCells = src_.cellCells()[srcCellI];
const labelList& srcNbrCells = src_.cellCells()[srcCelli];
// set possible seeds for later use by querying all src cell neighbours
// with all visited target cells
@ -259,8 +259,8 @@ void Foam::cellVolumeWeightMethod::setNextCells
if (!valuesSet)
{
srcCellI = cellS;
tgtCellI = cellT;
srcCelli = cellS;
tgtCelli = cellT;
valuesSet = true;
}
}
@ -291,8 +291,8 @@ void Foam::cellVolumeWeightMethod::setNextCells
if (seedCells[cellS] != -1)
{
srcCellI = cellS;
tgtCellI = seedCells[cellS];
srcCelli = cellS;
tgtCelli = seedCells[cellS];
return;
}
@ -312,8 +312,8 @@ void Foam::cellVolumeWeightMethod::setNextCells
srcCellIDs,
mapFlag,
startSeedI,
srcCellI,
tgtCellI
srcCelli,
tgtCelli
);
if (restart)
@ -324,8 +324,8 @@ void Foam::cellVolumeWeightMethod::setNextCells
}
// if we have got to here, there are no more src/tgt cell intersections
srcCellI = -1;
tgtCellI = -1;
srcCelli = -1;
tgtCelli = -1;
}

View File

@ -85,8 +85,8 @@ protected:
void setNextCells
(
label& startSeedI,
label& srcCellI,
label& tgtCellI,
label& srcCelli,
label& tgtCelli,
const labelList& srcCellIDs,
const boolList& mapFlag,
const DynamicList<label>& visitedCells,

View File

@ -40,14 +40,14 @@ namespace Foam
bool Foam::directMethod::intersect
(
const label srcCellI,
const label tgtCellI
const label srcCelli,
const label tgtCelli
) const
{
return tgt_.pointInCell
(
src_.cellCentres()[srcCellI],
tgtCellI,
src_.cellCentres()[srcCelli],
tgtCelli,
polyMesh::FACE_PLANES
);
}
@ -118,20 +118,20 @@ void Foam::directMethod::calculateAddressing
const scalarField& srcVc = src_.cellVolumes();
const scalarField& tgtVc = tgt_.cellVolumes();
label srcCellI = srcSeedI;
label tgtCellI = tgtSeedI;
label srcCelli = srcSeedI;
label tgtCelli = tgtSeedI;
do
{
// store src/tgt cell pair
srcToTgt[srcCellI].append(tgtCellI);
tgtToSrc[tgtCellI].append(srcCellI);
srcToTgt[srcCelli].append(tgtCelli);
tgtToSrc[tgtCelli].append(srcCelli);
// mark source cell srcSeedI as matched
mapFlag[srcCellI] = false;
mapFlag[srcCelli] = false;
// accumulate intersection volume
V_ += srcVc[srcCellI];
V_ += srcVc[srcCelli];
// find new source seed cell
appendToDirectSeeds
@ -139,11 +139,11 @@ void Foam::directMethod::calculateAddressing
mapFlag,
srcTgtSeed,
srcSeeds,
srcCellI,
tgtCellI
srcCelli,
tgtCelli
);
}
while (srcCellI >= 0);
while (srcCelli >= 0);
// transfer addressing into persistent storage
forAll(srcToTgtCellAddr, i)

View File

@ -59,8 +59,8 @@ protected:
//- Return the true if cells intersect
virtual bool intersect
(
const label srcCellI,
const label tgtCellI
const label srcCelli,
const label tgtCelli
) const;
//- Find indices of overlapping cells in src and tgt meshes - returns

View File

@ -109,35 +109,35 @@ void Foam::mapNearestMethod::calculateAddressing
const scalarField& tgtVc = tgt_.cellVolumes();
{
label srcCellI = srcSeedI;
label tgtCellI = tgtSeedI;
label srcCelli = srcSeedI;
label tgtCelli = tgtSeedI;
do
{
// find nearest tgt cell
findNearestCell(src_, tgt_, srcCellI, tgtCellI);
findNearestCell(src_, tgt_, srcCelli, tgtCelli);
// store src/tgt cell pair
srcToTgt[srcCellI].append(tgtCellI);
tgtToSrc[tgtCellI].append(srcCellI);
srcToTgt[srcCelli].append(tgtCelli);
tgtToSrc[tgtCelli].append(srcCelli);
// mark source cell srcCellI and tgtCellI as matched
mapFlag[srcCellI] = false;
// mark source cell srcCelli and tgtCelli as matched
mapFlag[srcCelli] = false;
// accumulate intersection volume
V_ += srcVc[srcCellI];
V_ += srcVc[srcCelli];
// find new source cell
setNextNearestCells
(
startSeedI,
srcCellI,
tgtCellI,
srcCelli,
tgtCelli,
mapFlag,
srcCellIDs
);
}
while (srcCellI >= 0);
while (srcCelli >= 0);
}
// for the case of multiple source cells per target cell, select the
@ -145,16 +145,16 @@ void Foam::mapNearestMethod::calculateAddressing
const vectorField& srcCc = src_.cellCentres();
const vectorField& tgtCc = tgt_.cellCentres();
forAll(tgtToSrc, targetCellI)
forAll(tgtToSrc, targetCelli)
{
if (tgtToSrc[targetCellI].size() > 1)
if (tgtToSrc[targetCelli].size() > 1)
{
const vector& tgtC = tgtCc[targetCellI];
const vector& tgtC = tgtCc[targetCelli];
DynamicList<label>& srcCells = tgtToSrc[targetCellI];
DynamicList<label>& srcCells = tgtToSrc[targetCelli];
label srcCellI = srcCells[0];
scalar d = magSqr(tgtC - srcCc[srcCellI]);
label srcCelli = srcCells[0];
scalar d = magSqr(tgtC - srcCc[srcCelli]);
for (label i = 1; i < srcCells.size(); i++)
{
@ -163,26 +163,26 @@ void Foam::mapNearestMethod::calculateAddressing
if (dNew < d)
{
d = dNew;
srcCellI = srcI;
srcCelli = srcI;
}
}
srcCells.clear();
srcCells.append(srcCellI);
srcCells.append(srcCelli);
}
}
// If there are more target cells than source cells, some target cells
// might not yet be mapped
forAll(tgtToSrc, tgtCellI)
forAll(tgtToSrc, tgtCelli)
{
if (tgtToSrc[tgtCellI].empty())
if (tgtToSrc[tgtCelli].empty())
{
label srcCellI = findMappedSrcCell(tgtCellI, tgtToSrc);
label srcCelli = findMappedSrcCell(tgtCelli, tgtToSrc);
findNearestCell(tgt_, src_, tgtCellI, srcCellI);
findNearestCell(tgt_, src_, tgtCelli, srcCelli);
tgtToSrc[tgtCellI].append(srcCellI);
tgtToSrc[tgtCelli].append(srcCelli);
}
}
@ -241,29 +241,29 @@ void Foam::mapNearestMethod::findNearestCell
void Foam::mapNearestMethod::setNextNearestCells
(
label& startSeedI,
label& srcCellI,
label& tgtCellI,
label& srcCelli,
label& tgtCelli,
boolList& mapFlag,
const labelList& srcCellIDs
) const
{
const labelList& srcNbr = src_.cellCells()[srcCellI];
const labelList& srcNbr = src_.cellCells()[srcCelli];
srcCellI = -1;
srcCelli = -1;
forAll(srcNbr, i)
{
label cellI = srcNbr[i];
if (mapFlag[cellI])
label celli = srcNbr[i];
if (mapFlag[celli])
{
srcCellI = cellI;
srcCelli = celli;
return;
}
}
for (label i = startSeedI; i < srcCellIDs.size(); i++)
{
label cellI = srcCellIDs[i];
if (mapFlag[cellI])
label celli = srcCellIDs[i];
if (mapFlag[celli])
{
startSeedI = i;
break;
@ -275,26 +275,26 @@ void Foam::mapNearestMethod::setNextNearestCells
srcCellIDs,
mapFlag,
startSeedI,
srcCellI,
tgtCellI
srcCelli,
tgtCelli
);
}
Foam::label Foam::mapNearestMethod::findMappedSrcCell
(
const label tgtCellI,
const label tgtCelli,
const List<DynamicList<label>>& tgtToSrc
) const
{
DynamicList<label> testCells(10);
DynamicList<label> visitedCells(10);
testCells.append(tgtCellI);
testCells.append(tgtCelli);
do
{
// search target tgtCellI neighbours for match with source cell
// search target tgtCelli neighbours for match with source cell
label tgtI = testCells.remove();
if (findIndex(visitedCells, tgtI) == -1)

View File

@ -98,16 +98,16 @@ protected:
virtual void setNextNearestCells
(
label& startSeedI,
label& srcCellI,
label& tgtCellI,
label& srcCelli,
label& tgtCelli,
boolList& mapFlag,
const labelList& srcCellIDs
) const;
//- Find a source cell mapped to target cell tgtCellI
//- Find a source cell mapped to target cell tgtCelli
virtual label findMappedSrcCell
(
const label tgtCellI,
const label tgtCelli,
const List<DynamicList<label>>& tgtToSrc
) const;

View File

@ -76,22 +76,22 @@ Foam::labelList Foam::meshToMeshMethod::maskCells() const
bool Foam::meshToMeshMethod::intersect
(
const label srcCellI,
const label tgtCellI
const label srcCelli,
const label tgtCelli
) const
{
scalar threshold = tolerance_*src_.cellVolumes()[srcCellI];
scalar threshold = tolerance_*src_.cellVolumes()[srcCelli];
tetOverlapVolume overlapEngine;
treeBoundBox bbTgtCell(tgt_.points(), tgt_.cellPoints()[tgtCellI]);
treeBoundBox bbTgtCell(tgt_.points(), tgt_.cellPoints()[tgtCelli]);
return overlapEngine.cellCellOverlapMinDecomp
(
src_,
srcCellI,
srcCelli,
tgt_,
tgtCellI,
tgtCelli,
bbTgtCell,
threshold
);
@ -100,20 +100,20 @@ bool Foam::meshToMeshMethod::intersect
Foam::scalar Foam::meshToMeshMethod::interVol
(
const label srcCellI,
const label tgtCellI
const label srcCelli,
const label tgtCelli
) const
{
tetOverlapVolume overlapEngine;
treeBoundBox bbTgtCell(tgt_.points(), tgt_.cellPoints()[tgtCellI]);
treeBoundBox bbTgtCell(tgt_.points(), tgt_.cellPoints()[tgtCelli]);
scalar vol = overlapEngine.cellCellOverlapVolumeMinDecomp
(
src_,
srcCellI,
srcCelli,
tgt_,
tgtCellI,
tgtCelli,
bbTgtCell
);
@ -159,26 +159,26 @@ Foam::meshToMeshMethod::interVolAndCentroid
void Foam::meshToMeshMethod::appendNbrCells
(
const label cellI,
const label celli,
const polyMesh& mesh,
const DynamicList<label>& visitedCells,
DynamicList<label>& nbrCellIDs
) const
{
const labelList& nbrCells = mesh.cellCells()[cellI];
const labelList& nbrCells = mesh.cellCells()[celli];
// filter out cells already visited from cell neighbours
forAll(nbrCells, i)
{
label nbrCellI = nbrCells[i];
label nbrCelli = nbrCells[i];
if
(
(findIndex(visitedCells, nbrCellI) == -1)
&& (findIndex(nbrCellIDs, nbrCellI) == -1)
(findIndex(visitedCells, nbrCelli) == -1)
&& (findIndex(nbrCellIDs, nbrCelli) == -1)
)
{
nbrCellIDs.append(nbrCellI);
nbrCellIDs.append(nbrCelli);
}
}
}
@ -273,10 +273,10 @@ void Foam::meshToMeshMethod::writeConnectivity
const labelList& addr = mesh1ToMesh2Addr[i];
forAll(addr, j)
{
label cellI = addr[j];
label celli = addr[j];
const vector& c0 = mesh1.cellCentres()[i];
const cell& c = mesh2.cells()[cellI];
const cell& c = mesh2.cells()[celli];
const pointField pts(c.points(mesh2.faces(), mesh2.points()));
forAll(pts, j)
{

View File

@ -74,15 +74,15 @@ protected:
//- Return the true if cells intersect
virtual bool intersect
(
const label srcCellI,
const label tgtCellI
const label srcCelli,
const label tgtCelli
) const;
//- Return the intersection volume between two cells
virtual scalar interVol
(
const label srcCellI,
const label tgtCellI
const label srcCelli,
const label tgtCelli
) const;
//- Return the intersection volume and centroid between two cells
@ -95,7 +95,7 @@ protected:
//- Append target cell neihgbour cells to cellIDs list
virtual void appendNbrCells
(
const label tgtCellI,
const label tgtCelli,
const polyMesh& mesh,
const DynamicList<label>& visitedTgtCells,
DynamicList<label>& nbrTgtCellIDs

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
@ -85,13 +85,13 @@ public:
}
}
if ((singlePatchProc_ == -1) != (distMapPtr_ != NULL))
if ((singlePatchProc_ == -1) != (distMapPtr_ != nullptr))
{
FatalErrorInFunction
<< "Supply a mapDistributeBase if and only if "
<< "singlePatchProc is -1"
<< " singlePatchProc_:" << singlePatchProc_
<< " distMapPtr_:" << (distMapPtr_ != NULL)
<< " distMapPtr_:" << (distMapPtr_ != nullptr)
<< exit(FatalError);
}
}

View File

@ -368,9 +368,9 @@ void Foam::meshToMesh::normaliseWeights
if (nCell > 0)
{
forAll(wght, cellI)
forAll(wght, celli)
{
scalarList& w = wght[cellI];
scalarList& w = wght[celli];
scalar s = sum(w);
forAll(w, i)
@ -663,11 +663,11 @@ void Foam::meshToMesh::calculatePatchAMIs(const word& AMIMethodName)
forAll(srcPatchID_, i)
{
label srcPatchI = srcPatchID_[i];
label tgtPatchI = tgtPatchID_[i];
label srcPatchi = srcPatchID_[i];
label tgtPatchi = tgtPatchID_[i];
const polyPatch& srcPP = srcRegion_.boundaryMesh()[srcPatchI];
const polyPatch& tgtPP = tgtRegion_.boundaryMesh()[tgtPatchI];
const polyPatch& srcPP = srcRegion_.boundaryMesh()[srcPatchi];
const polyPatch& tgtPP = tgtRegion_.boundaryMesh()[tgtPatchi];
Info<< "Creating AMI between source patch " << srcPP.name()
<< " and target patch " << tgtPP.name()
@ -710,9 +710,9 @@ void Foam::meshToMesh::constructNoCuttingPatches
DynamicList<label> srcPatchID(srcBM.size());
DynamicList<label> tgtPatchID(tgtBM.size());
forAll(srcBM, patchI)
forAll(srcBM, patchi)
{
const polyPatch& pp = srcBM[patchI];
const polyPatch& pp = srcBM[patchi];
// We want to map all the global patches, including constraint
// patches (since they might have mappable properties, e.g.
@ -721,11 +721,11 @@ void Foam::meshToMesh::constructNoCuttingPatches
{
srcPatchID.append(pp.index());
label tgtPatchI = tgtBM.findPatchID(pp.name());
label tgtPatchi = tgtBM.findPatchID(pp.name());
if (tgtPatchI != -1)
if (tgtPatchi != -1)
{
tgtPatchID.append(tgtPatchI);
tgtPatchID.append(tgtPatchi);
}
else
{
@ -823,8 +823,8 @@ Foam::meshToMesh::meshToMesh
tgtToSrcCellVec_(),
V_(0.0),
singleMeshProc_(-1),
srcMapPtr_(NULL),
tgtMapPtr_(NULL)
srcMapPtr_(nullptr),
tgtMapPtr_(nullptr)
{
constructNoCuttingPatches
(
@ -861,8 +861,8 @@ Foam::meshToMesh::meshToMesh
tgtToSrcCellVec_(),
V_(0.0),
singleMeshProc_(-1),
srcMapPtr_(NULL),
tgtMapPtr_(NULL)
srcMapPtr_(nullptr),
tgtMapPtr_(nullptr)
{
constructNoCuttingPatches(methodName, AMIMethodName, interpAllPatches);
}
@ -889,8 +889,8 @@ Foam::meshToMesh::meshToMesh
tgtToSrcCellWght_(),
V_(0.0),
singleMeshProc_(-1),
srcMapPtr_(NULL),
tgtMapPtr_(NULL)
srcMapPtr_(nullptr),
tgtMapPtr_(nullptr)
{
constructFromCuttingPatches
(
@ -927,8 +927,8 @@ Foam::meshToMesh::meshToMesh
tgtToSrcCellWght_(),
V_(0.0),
singleMeshProc_(-1),
srcMapPtr_(NULL),
tgtMapPtr_(NULL)
srcMapPtr_(nullptr),
tgtMapPtr_(nullptr)
{
constructFromCuttingPatches
(

View File

@ -40,7 +40,7 @@ Foam::label Foam::meshToMesh::calcDistribution
const polyMesh& tgt
) const
{
label procI = 0;
label proci = 0;
if (Pstream::parRun())
{
@ -61,7 +61,7 @@ Foam::label Foam::meshToMesh::calcDistribution
if (nHaveCells > 1)
{
procI = -1;
proci = -1;
if (debug)
{
InfoInFunction
@ -70,16 +70,16 @@ Foam::label Foam::meshToMesh::calcDistribution
}
else if (nHaveCells == 1)
{
procI = findIndex(cellsPresentOnProc, 1);
proci = findIndex(cellsPresentOnProc, 1);
if (debug)
{
InfoInFunction
<< "Meshes local to processor" << procI << endl;
<< "Meshes local to processor" << proci << endl;
}
}
}
return procI;
return proci;
}
@ -94,15 +94,15 @@ Foam::label Foam::meshToMesh::calcOverlappingProcs
label nOverlaps = 0;
forAll(procBb, procI)
forAll(procBb, proci)
{
const treeBoundBoxList& bbp = procBb[procI];
const treeBoundBoxList& bbp = procBb[proci];
forAll(bbp, bbI)
forAll(bbp, bbi)
{
if (bbp[bbI].overlaps(bb))
if (bbp[bbi].overlaps(bb))
{
overlaps[procI] = true;
overlaps[proci] = true;
nOverlaps++;
break;
}
@ -146,9 +146,9 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
InfoInFunction
<< "Determining extent of src mesh per processor:" << nl
<< "\tproc\tbb" << endl;
forAll(procBb, procI)
forAll(procBb, proci)
{
Info<< '\t' << procI << '\t' << procBb[procI] << endl;
Info<< '\t' << proci << '\t' << procBb[proci] << endl;
}
}
@ -165,22 +165,22 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
List<DynamicList<label>> dynSendMap(Pstream::nProcs());
label iniSize = floor(tgt.nCells()/Pstream::nProcs());
forAll(dynSendMap, procI)
forAll(dynSendMap, proci)
{
dynSendMap[procI].setCapacity(iniSize);
dynSendMap[proci].setCapacity(iniSize);
}
// work array - whether src processor bb overlaps the tgt cell bounds
boolList procBbOverlaps(Pstream::nProcs());
forAll(cells, cellI)
forAll(cells, celli)
{
const cell& c = cells[cellI];
const cell& c = cells[celli];
// determine bounding box of tgt cell
boundBox cellBb(point::max, point::min);
forAll(c, faceI)
forAll(c, facei)
{
const face& f = faces[c[faceI]];
const face& f = faces[c[facei]];
forAll(f, fp)
{
cellBb.min() = min(cellBb.min(), points[f[fp]]);
@ -191,20 +191,20 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
// find the overlapping tgt cells on each src processor
(void)calcOverlappingProcs(procBb, cellBb, procBbOverlaps);
forAll(procBbOverlaps, procI)
forAll(procBbOverlaps, proci)
{
if (procBbOverlaps[procI])
if (procBbOverlaps[proci])
{
dynSendMap[procI].append(cellI);
dynSendMap[proci].append(celli);
}
}
}
// convert dynamicList to labelList
sendMap.setSize(Pstream::nProcs());
forAll(sendMap, procI)
forAll(sendMap, proci)
{
sendMap[procI].transfer(dynSendMap[procI]);
sendMap[proci].transfer(dynSendMap[proci]);
}
}
@ -213,9 +213,9 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
{
Pout<< "Of my " << cells.size() << " target cells I need to send to:"
<< nl << "\tproc\tcells" << endl;
forAll(sendMap, procI)
forAll(sendMap, proci)
{
Pout<< '\t' << procI << '\t' << sendMap[procI].size() << endl;
Pout<< '\t' << proci << '\t' << sendMap[proci].size() << endl;
}
}
@ -223,9 +223,9 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
// send over how many tgt cells I need to receive from each processor
labelListList sendSizes(Pstream::nProcs());
sendSizes[Pstream::myProcNo()].setSize(Pstream::nProcs());
forAll(sendMap, procI)
forAll(sendMap, proci)
{
sendSizes[Pstream::myProcNo()][procI] = sendMap[procI].size();
sendSizes[Pstream::myProcNo()][proci] = sendMap[proci].size();
}
Pstream::gatherList(sendSizes);
Pstream::scatterList(sendSizes);
@ -235,15 +235,15 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
labelListList constructMap(Pstream::nProcs());
label segmentI = 0;
forAll(constructMap, procI)
forAll(constructMap, proci)
{
// what I need to receive is what other processor is sending to me
label nRecv = sendSizes[procI][Pstream::myProcNo()];
constructMap[procI].setSize(nRecv);
label nRecv = sendSizes[proci][Pstream::myProcNo()];
constructMap[proci].setSize(nRecv);
for (label i = 0; i < nRecv; i++)
{
constructMap[procI][i] = segmentI++;
constructMap[proci][i] = segmentI++;
}
}
@ -297,9 +297,9 @@ void Foam::meshToMesh::distributeCells
{
// reverse cell map
labelList reverseCellMap(tgtMesh.nCells(), -1);
forAll(sendElems, subCellI)
forAll(sendElems, subCelli)
{
reverseCellMap[sendElems[subCellI]] = subCellI;
reverseCellMap[sendElems[subCelli]] = subCelli;
}
DynamicList<face> subFaces(tgtMesh.nFaces());
@ -312,10 +312,10 @@ void Foam::meshToMesh::distributeCells
label nInternal = 0;
// internal faces
forAll(tgtMesh.faceNeighbour(), faceI)
forAll(tgtMesh.faceNeighbour(), facei)
{
label own = tgtMesh.faceOwner()[faceI];
label nbr = tgtMesh.faceNeighbour()[faceI];
label own = tgtMesh.faceOwner()[facei];
label nbr = tgtMesh.faceNeighbour()[facei];
label subOwn = reverseCellMap[own];
label subNbr = reverseCellMap[nbr];
@ -325,7 +325,7 @@ void Foam::meshToMesh::distributeCells
if (subOwn < subNbr)
{
subFaces.append(tgtMesh.faces()[faceI]);
subFaces.append(tgtMesh.faces()[facei]);
subFaceOwner.append(subOwn);
subFaceNeighbour.append(subNbr);
subNbrProcIDs.append(-1);
@ -333,7 +333,7 @@ void Foam::meshToMesh::distributeCells
}
else
{
subFaces.append(tgtMesh.faces()[faceI].reverseFace());
subFaces.append(tgtMesh.faces()[facei].reverseFace());
subFaceOwner.append(subNbr);
subFaceNeighbour.append(subOwn);
subNbrProcIDs.append(-1);
@ -343,16 +343,16 @@ void Foam::meshToMesh::distributeCells
}
// boundary faces for new region
forAll(tgtMesh.faceNeighbour(), faceI)
forAll(tgtMesh.faceNeighbour(), facei)
{
label own = tgtMesh.faceOwner()[faceI];
label nbr = tgtMesh.faceNeighbour()[faceI];
label own = tgtMesh.faceOwner()[facei];
label nbr = tgtMesh.faceNeighbour()[facei];
label subOwn = reverseCellMap[own];
label subNbr = reverseCellMap[nbr];
if (subOwn != -1 && subNbr == -1)
{
subFaces.append(tgtMesh.faces()[faceI]);
subFaces.append(tgtMesh.faces()[facei]);
subFaceOwner.append(subOwn);
subFaceNeighbour.append(subNbr);
subNbrProcIDs.append(-1);
@ -360,7 +360,7 @@ void Foam::meshToMesh::distributeCells
}
else if (subOwn == -1 && subNbr != -1)
{
subFaces.append(tgtMesh.faces()[faceI].reverseFace());
subFaces.append(tgtMesh.faces()[facei].reverseFace());
subFaceOwner.append(subNbr);
subFaceNeighbour.append(subOwn);
subNbrProcIDs.append(-1);
@ -369,11 +369,11 @@ void Foam::meshToMesh::distributeCells
}
// boundary faces of existing region
forAll(tgtMesh.boundaryMesh(), patchI)
forAll(tgtMesh.boundaryMesh(), patchi)
{
const polyPatch& pp = tgtMesh.boundaryMesh()[patchI];
const polyPatch& pp = tgtMesh.boundaryMesh()[patchi];
label nbrProcI = -1;
label nbrProci = -1;
// store info for faces on processor patches
if (isA<processorPolyPatch>(pp))
@ -381,20 +381,20 @@ void Foam::meshToMesh::distributeCells
const processorPolyPatch& ppp =
dynamic_cast<const processorPolyPatch&>(pp);
nbrProcI = ppp.neighbProcNo();
nbrProci = ppp.neighbProcNo();
}
forAll(pp, i)
{
label faceI = pp.start() + i;
label own = tgtMesh.faceOwner()[faceI];
label facei = pp.start() + i;
label own = tgtMesh.faceOwner()[facei];
if (reverseCellMap[own] != -1)
{
subFaces.append(tgtMesh.faces()[faceI]);
subFaces.append(tgtMesh.faces()[facei]);
subFaceOwner.append(reverseCellMap[own]);
subFaceNeighbour.append(-1);
subNbrProcIDs.append(nbrProcI);
subNbrProcIDs.append(nbrProci);
subProcLocalFaceIDs.append(i);
}
}
@ -403,19 +403,19 @@ void Foam::meshToMesh::distributeCells
// reverse point map
labelList reversePointMap(tgtMesh.nPoints(), -1);
DynamicList<point> subPoints(tgtMesh.nPoints());
forAll(subFaces, subFaceI)
forAll(subFaces, subFacei)
{
face& f = subFaces[subFaceI];
face& f = subFaces[subFacei];
forAll(f, fp)
{
label pointI = f[fp];
if (reversePointMap[pointI] == -1)
label pointi = f[fp];
if (reversePointMap[pointi] == -1)
{
reversePointMap[pointI] = subPoints.size();
subPoints.append(tgtMesh.points()[pointI]);
reversePointMap[pointi] = subPoints.size();
subPoints.append(tgtMesh.points()[pointi]);
}
f[fp] = reversePointMap[pointI];
f[fp] = reversePointMap[pointi];
}
}
@ -568,19 +568,19 @@ void Foam::meshToMesh::distributeAndMergeCells
// Starting offset for points
label nPoints = 0;
labelList pointOffset(Pstream::nProcs(), 0);
forAll(allPoints, procI)
forAll(allPoints, proci)
{
pointOffset[procI] = nPoints;
nPoints += allPoints[procI].size();
pointOffset[proci] = nPoints;
nPoints += allPoints[proci].size();
}
// Starting offset for cells
label nCells = 0;
labelList cellOffset(Pstream::nProcs(), 0);
forAll(allTgtCellIDs, procI)
forAll(allTgtCellIDs, proci)
{
cellOffset[procI] = nCells;
nCells += allTgtCellIDs[procI].size();
cellOffset[proci] = nCells;
nCells += allTgtCellIDs[proci].size();
}
// Count any coupled faces
@ -588,19 +588,19 @@ void Foam::meshToMesh::distributeAndMergeCells
typedef HashTable<label, label3, label3::Hash<>> procCoupleInfo;
procCoupleInfo procFaceToGlobalCell;
forAll(allNbrProcIDs, procI)
forAll(allNbrProcIDs, proci)
{
const labelList& nbrProcI = allNbrProcIDs[procI];
const labelList& localFaceI = allProcLocalFaceIDs[procI];
const labelList& nbrProci = allNbrProcIDs[proci];
const labelList& localFacei = allProcLocalFaceIDs[proci];
forAll(nbrProcI, i)
forAll(nbrProci, i)
{
if (nbrProcI[i] != -1 && localFaceI[i] != -1)
if (nbrProci[i] != -1 && localFacei[i] != -1)
{
label3 key;
key[0] = min(procI, nbrProcI[i]);
key[1] = max(procI, nbrProcI[i]);
key[2] = localFaceI[i];
key[0] = min(proci, nbrProci[i]);
key[1] = max(proci, nbrProci[i]);
key[2] = localFacei[i];
procCoupleInfo::const_iterator fnd =
procFaceToGlobalCell.find(key);
@ -618,7 +618,7 @@ void Foam::meshToMesh::distributeAndMergeCells
<< " across local face " << key[2] << endl;
}
allNIntCoupledFaces[procI]++;
allNIntCoupledFaces[proci]++;
}
}
}
@ -629,14 +629,14 @@ void Foam::meshToMesh::distributeAndMergeCells
label nIntFaces = 0;
label nFacesTotal = 0;
labelList internalFaceOffset(Pstream::nProcs(), 0);
forAll(allNIntCoupledFaces, procI)
forAll(allNIntCoupledFaces, proci)
{
label nCoupledFaces =
allNIntCoupledFaces[procI] - allNInternalFaces[procI];
allNIntCoupledFaces[proci] - allNInternalFaces[proci];
internalFaceOffset[procI] = nIntFaces;
nIntFaces += allNIntCoupledFaces[procI];
nFacesTotal += allFaceOwners[procI].size() - nCoupledFaces;
internalFaceOffset[proci] = nIntFaces;
nIntFaces += allNIntCoupledFaces[proci];
nFacesTotal += allFaceOwners[proci].size() - nCoupledFaces;
}
tgtPoints.setSize(nPoints);
@ -646,99 +646,99 @@ void Foam::meshToMesh::distributeAndMergeCells
tgtCellIDs.setSize(nCells);
// Insert points
forAll(allPoints, procI)
forAll(allPoints, proci)
{
const pointField& pts = allPoints[procI];
SubList<point>(tgtPoints, pts.size(), pointOffset[procI]) = pts;
const pointField& pts = allPoints[proci];
SubList<point>(tgtPoints, pts.size(), pointOffset[proci]) = pts;
}
// Insert cellIDs
forAll(allTgtCellIDs, procI)
forAll(allTgtCellIDs, proci)
{
const labelList& cellIDs = allTgtCellIDs[procI];
SubList<label>(tgtCellIDs, cellIDs.size(), cellOffset[procI]) = cellIDs;
const labelList& cellIDs = allTgtCellIDs[proci];
SubList<label>(tgtCellIDs, cellIDs.size(), cellOffset[proci]) = cellIDs;
}
// Insert internal faces (from internal faces)
forAll(allFaces, procI)
forAll(allFaces, proci)
{
const faceList& fcs = allFaces[procI];
const labelList& faceOs = allFaceOwners[procI];
const labelList& faceNs = allFaceNeighbours[procI];
const faceList& fcs = allFaces[proci];
const labelList& faceOs = allFaceOwners[proci];
const labelList& faceNs = allFaceNeighbours[proci];
SubList<face> slice
(
tgtFaces,
allNInternalFaces[procI],
internalFaceOffset[procI]
allNInternalFaces[proci],
internalFaceOffset[proci]
);
slice = SubList<face>(fcs, allNInternalFaces[procI]);
slice = SubList<face>(fcs, allNInternalFaces[proci]);
forAll(slice, i)
{
add(slice[i], pointOffset[procI]);
add(slice[i], pointOffset[proci]);
}
SubField<label> ownSlice
(
tgtFaceOwners,
allNInternalFaces[procI],
internalFaceOffset[procI]
allNInternalFaces[proci],
internalFaceOffset[proci]
);
ownSlice = SubField<label>(faceOs, allNInternalFaces[procI]);
add(ownSlice, cellOffset[procI]);
ownSlice = SubField<label>(faceOs, allNInternalFaces[proci]);
add(ownSlice, cellOffset[proci]);
SubField<label> nbrSlice
(
tgtFaceNeighbours,
allNInternalFaces[procI],
internalFaceOffset[procI]
allNInternalFaces[proci],
internalFaceOffset[proci]
);
nbrSlice = SubField<label>(faceNs, allNInternalFaces[procI]);
add(nbrSlice, cellOffset[procI]);
nbrSlice = SubField<label>(faceNs, allNInternalFaces[proci]);
add(nbrSlice, cellOffset[proci]);
internalFaceOffset[procI] += allNInternalFaces[procI];
internalFaceOffset[proci] += allNInternalFaces[proci];
}
// Insert internal faces (from coupled face-pairs)
forAll(allNbrProcIDs, procI)
forAll(allNbrProcIDs, proci)
{
const labelList& nbrProcI = allNbrProcIDs[procI];
const labelList& localFaceI = allProcLocalFaceIDs[procI];
const labelList& faceOs = allFaceOwners[procI];
const faceList& fcs = allFaces[procI];
const labelList& nbrProci = allNbrProcIDs[proci];
const labelList& localFacei = allProcLocalFaceIDs[proci];
const labelList& faceOs = allFaceOwners[proci];
const faceList& fcs = allFaces[proci];
forAll(nbrProcI, i)
forAll(nbrProci, i)
{
if (nbrProcI[i] != -1 && localFaceI[i] != -1)
if (nbrProci[i] != -1 && localFacei[i] != -1)
{
label3 key;
key[0] = min(procI, nbrProcI[i]);
key[1] = max(procI, nbrProcI[i]);
key[2] = localFaceI[i];
key[0] = min(proci, nbrProci[i]);
key[1] = max(proci, nbrProci[i]);
key[2] = localFacei[i];
procCoupleInfo::iterator fnd = procFaceToGlobalCell.find(key);
if (fnd != procFaceToGlobalCell.end())
{
label tgtFaceI = fnd();
if (tgtFaceI == -1)
label tgtFacei = fnd();
if (tgtFacei == -1)
{
// on first visit store the new cell on this side
fnd() = cellOffset[procI] + faceOs[i];
fnd() = cellOffset[proci] + faceOs[i];
}
else
{
// get owner and neighbour in new cell numbering
label newOwn = cellOffset[procI] + faceOs[i];
label newOwn = cellOffset[proci] + faceOs[i];
label newNbr = fnd();
label tgtFaceI = internalFaceOffset[procI]++;
label tgtFacei = internalFaceOffset[proci]++;
if (debug > 1)
{
Pout<< " proc " << procI
<< "\tinserting face:" << tgtFaceI
Pout<< " proc " << proci
<< "\tinserting face:" << tgtFacei
<< " connection between owner " << newOwn
<< " and neighbour " << newNbr
<< endl;
@ -747,19 +747,19 @@ void Foam::meshToMesh::distributeAndMergeCells
if (newOwn < newNbr)
{
// we have correct orientation
tgtFaces[tgtFaceI] = fcs[i];
tgtFaceOwners[tgtFaceI] = newOwn;
tgtFaceNeighbours[tgtFaceI] = newNbr;
tgtFaces[tgtFacei] = fcs[i];
tgtFaceOwners[tgtFacei] = newOwn;
tgtFaceNeighbours[tgtFacei] = newNbr;
}
else
{
// reverse orientation
tgtFaces[tgtFaceI] = fcs[i].reverseFace();
tgtFaceOwners[tgtFaceI] = newNbr;
tgtFaceNeighbours[tgtFaceI] = newOwn;
tgtFaces[tgtFacei] = fcs[i].reverseFace();
tgtFaceOwners[tgtFacei] = newNbr;
tgtFaceNeighbours[tgtFacei] = newOwn;
}
add(tgtFaces[tgtFaceI], pointOffset[procI]);
add(tgtFaces[tgtFacei], pointOffset[proci]);
// mark with unique value
fnd() = -2;
@ -770,50 +770,50 @@ void Foam::meshToMesh::distributeAndMergeCells
}
forAll(allNbrProcIDs, procI)
forAll(allNbrProcIDs, proci)
{
const labelList& nbrProcI = allNbrProcIDs[procI];
const labelList& localFaceI = allProcLocalFaceIDs[procI];
const labelList& faceOs = allFaceOwners[procI];
const labelList& faceNs = allFaceNeighbours[procI];
const faceList& fcs = allFaces[procI];
const labelList& nbrProci = allNbrProcIDs[proci];
const labelList& localFacei = allProcLocalFaceIDs[proci];
const labelList& faceOs = allFaceOwners[proci];
const labelList& faceNs = allFaceNeighbours[proci];
const faceList& fcs = allFaces[proci];
forAll(nbrProcI, i)
forAll(nbrProci, i)
{
// coupled boundary face
if (nbrProcI[i] != -1 && localFaceI[i] != -1)
if (nbrProci[i] != -1 && localFacei[i] != -1)
{
label3 key;
key[0] = min(procI, nbrProcI[i]);
key[1] = max(procI, nbrProcI[i]);
key[2] = localFaceI[i];
key[0] = min(proci, nbrProci[i]);
key[1] = max(proci, nbrProci[i]);
key[2] = localFacei[i];
label tgtFaceI = procFaceToGlobalCell[key];
label tgtFacei = procFaceToGlobalCell[key];
if (tgtFaceI == -1)
if (tgtFacei == -1)
{
FatalErrorInFunction
<< "Unvisited " << key
<< abort(FatalError);
}
else if (tgtFaceI != -2)
else if (tgtFacei != -2)
{
label newOwn = cellOffset[procI] + faceOs[i];
label tgtFaceI = nIntFaces++;
label newOwn = cellOffset[proci] + faceOs[i];
label tgtFacei = nIntFaces++;
if (debug > 1)
{
Pout<< " proc " << procI
<< "\tinserting boundary face:" << tgtFaceI
Pout<< " proc " << proci
<< "\tinserting boundary face:" << tgtFacei
<< " from coupled face " << key
<< endl;
}
tgtFaces[tgtFaceI] = fcs[i];
add(tgtFaces[tgtFaceI], pointOffset[procI]);
tgtFaces[tgtFacei] = fcs[i];
add(tgtFaces[tgtFacei], pointOffset[proci]);
tgtFaceOwners[tgtFaceI] = newOwn;
tgtFaceNeighbours[tgtFaceI] = -1;
tgtFaceOwners[tgtFacei] = newOwn;
tgtFaceNeighbours[tgtFacei] = -1;
}
}
// normal boundary face
@ -823,14 +823,14 @@ void Foam::meshToMesh::distributeAndMergeCells
label nbr = faceNs[i];
if ((own != -1) && (nbr == -1))
{
label newOwn = cellOffset[procI] + faceOs[i];
label tgtFaceI = nIntFaces++;
label newOwn = cellOffset[proci] + faceOs[i];
label tgtFacei = nIntFaces++;
tgtFaces[tgtFaceI] = fcs[i];
add(tgtFaces[tgtFaceI], pointOffset[procI]);
tgtFaces[tgtFacei] = fcs[i];
add(tgtFaces[tgtFacei], pointOffset[proci]);
tgtFaceOwners[tgtFaceI] = newOwn;
tgtFaceNeighbours[tgtFaceI] = -1;
tgtFaceOwners[tgtFacei] = newOwn;
tgtFaceNeighbours[tgtFacei] = -1;
}
}
}

View File

@ -105,40 +105,40 @@ void Foam::meshToMesh::mapSrcToTgt
List<Type> work(srcField);
map.distribute(work);
forAll(result, cellI)
forAll(result, celli)
{
const labelList& srcAddress = tgtToSrcCellAddr_[cellI];
const scalarList& srcWeight = tgtToSrcCellWght_[cellI];
const labelList& srcAddress = tgtToSrcCellAddr_[celli];
const scalarList& srcWeight = tgtToSrcCellWght_[celli];
if (srcAddress.size())
{
// result[cellI] = Zero;
result[cellI] *= (1.0 - sum(srcWeight));
// result[celli] = Zero;
result[celli] *= (1.0 - sum(srcWeight));
forAll(srcAddress, i)
{
label srcI = srcAddress[i];
scalar w = srcWeight[i];
cbop(result[cellI], cellI, work[srcI], w);
cbop(result[celli], celli, work[srcI], w);
}
}
}
}
else
{
forAll(result, cellI)
forAll(result, celli)
{
const labelList& srcAddress = tgtToSrcCellAddr_[cellI];
const scalarList& srcWeight = tgtToSrcCellWght_[cellI];
const labelList& srcAddress = tgtToSrcCellAddr_[celli];
const scalarList& srcWeight = tgtToSrcCellWght_[celli];
if (srcAddress.size())
{
// result[cellI] = Zero;
result[cellI] *= (1.0 - sum(srcWeight));
// result[celli] = Zero;
result[celli] *= (1.0 - sum(srcWeight));
forAll(srcAddress, i)
{
label srcI = srcAddress[i];
scalar w = srcWeight[i];
cbop(result[cellI], cellI, srcField[srcI], w);
cbop(result[celli], celli, srcField[srcI], w);
}
}
}
@ -320,38 +320,38 @@ void Foam::meshToMesh::mapTgtToSrc
List<Type> work(tgtField);
map.distribute(work);
forAll(result, cellI)
forAll(result, celli)
{
const labelList& tgtAddress = srcToTgtCellAddr_[cellI];
const scalarList& tgtWeight = srcToTgtCellWght_[cellI];
const labelList& tgtAddress = srcToTgtCellAddr_[celli];
const scalarList& tgtWeight = srcToTgtCellWght_[celli];
if (tgtAddress.size())
{
result[cellI] *= (1.0 - sum(tgtWeight));
result[celli] *= (1.0 - sum(tgtWeight));
forAll(tgtAddress, i)
{
label tgtI = tgtAddress[i];
scalar w = tgtWeight[i];
cbop(result[cellI], cellI, work[tgtI], w);
cbop(result[celli], celli, work[tgtI], w);
}
}
}
}
else
{
forAll(result, cellI)
forAll(result, celli)
{
const labelList& tgtAddress = srcToTgtCellAddr_[cellI];
const scalarList& tgtWeight = srcToTgtCellWght_[cellI];
const labelList& tgtAddress = srcToTgtCellAddr_[celli];
const scalarList& tgtWeight = srcToTgtCellWght_[celli];
if (tgtAddress.size())
{
result[cellI] *= (1.0 - sum(tgtWeight));
result[celli] *= (1.0 - sum(tgtWeight));
forAll(tgtAddress, i)
{
label tgtI = tgtAddress[i];
scalar w = tgtWeight[i];
cbop(result[cellI], cellI, tgtField[tgtI], w);
cbop(result[celli], celli, tgtField[tgtI], w);
}
}
}
@ -512,14 +512,14 @@ void Foam::meshToMesh::mapInternalSrcToTgt
mapSrcToTgt
(
field,
fvc::grad(field)().internalField(),
fvc::grad(field)().primitiveField(),
cop,
result.internalField()
result.primitiveFieldRef()
);
}
else
{
mapSrcToTgt(field, cop, result.internalField());
mapSrcToTgt(field, cop, result.primitiveFieldRef());
}
}
@ -554,19 +554,20 @@ void Foam::meshToMesh::mapSrcToTgt
const bool secondOrder
) const
{
mapInternalSrcToTgt(field, cop, result, secondOrder);
mapInternalSrcToTgt(field, cop, result.primitiveFieldRef(), secondOrder);
const PtrList<AMIPatchToPatchInterpolation>& AMIList = patchAMIs();
typename GeometricField<Type, fvPatchField, volMesh>::
Boundary& resultBf = result.boundaryFieldRef();
forAll(AMIList, i)
{
label srcPatchI = srcPatchID_[i];
label tgtPatchI = tgtPatchID_[i];
const fvPatchField<Type>& srcField = field.boundaryField()[srcPatchI];
fvPatchField<Type>& tgtField = result.boundaryField()[tgtPatchI];
label srcPatchi = srcPatchID_[i];
label tgtPatchi = tgtPatchID_[i];
const fvPatchField<Type>& srcField = field.boundaryField()[srcPatchi];
fvPatchField<Type>& tgtField = resultBf[tgtPatchi];
// Clone and map (since rmap does not do general mapping)
tmp<fvPatchField<Type>> tnewTgt
@ -575,14 +576,14 @@ void Foam::meshToMesh::mapSrcToTgt
(
srcField,
tgtField.patch(),
result.dimensionedInternalField(),
result(),
distributedWeightedFvPatchFieldMapper
(
AMIList[i].singlePatchProc(),
(
AMIList[i].singlePatchProc() == -1
? &AMIList[i].srcMap()
: NULL
: nullptr
),
AMIList[i].tgtAddress(),
AMIList[i].tgtWeights()
@ -591,7 +592,7 @@ void Foam::meshToMesh::mapSrcToTgt
);
// Transfer all mapped quantities (value and e.g. gradient) onto
// tgtField
// tgtField. Value will get overwritten below.
tgtField.rmap(tnewTgt(), identity(tgtField.size()));
// Override value to account for CombineOp (note: is dummy template
@ -601,8 +602,8 @@ void Foam::meshToMesh::mapSrcToTgt
forAll(cuttingPatches_, i)
{
label patchI = cuttingPatches_[i];
fvPatchField<Type>& pf = result.boundaryField()[patchI];
label patchi = cuttingPatches_[i];
fvPatchField<Type>& pf = resultBf[patchi];
pf == pf.patchInternalField();
}
}
@ -622,32 +623,32 @@ Foam::meshToMesh::mapSrcToTgt
const fvMesh& tgtMesh = static_cast<const fvMesh&>(tgtRegion_);
const fvBoundaryMesh& tgtBm = tgtMesh.boundary();
const typename fieldType::GeometricBoundaryField& srcBfld =
const typename fieldType::Boundary& srcBfld =
field.boundaryField();
PtrList<fvPatchField<Type>> tgtPatchFields(tgtBm.size());
// constuct tgt boundary patch types as copy of 'field' boundary types
// construct tgt boundary patch types as copy of 'field' boundary types
// note: this will provide place holders for fields with additional
// entries, but these values will need to be reset
forAll(tgtPatchID_, i)
{
label srcPatchI = srcPatchID_[i];
label tgtPatchI = tgtPatchID_[i];
label srcPatchi = srcPatchID_[i];
label tgtPatchi = tgtPatchID_[i];
if (!tgtPatchFields.set(tgtPatchI))
if (!tgtPatchFields.set(tgtPatchi))
{
tgtPatchFields.set
(
tgtPatchI,
tgtPatchi,
fvPatchField<Type>::New
(
srcBfld[srcPatchI],
tgtMesh.boundary()[tgtPatchI],
srcBfld[srcPatchi],
tgtMesh.boundary()[tgtPatchi],
DimensionedField<Type, volMesh>::null(),
directFvPatchFieldMapper
(
labelList(tgtMesh.boundary()[tgtPatchI].size(), -1)
labelList(tgtMesh.boundary()[tgtPatchi].size(), -1)
)
)
);
@ -655,19 +656,19 @@ Foam::meshToMesh::mapSrcToTgt
}
// Any unset tgtPatchFields become calculated
forAll(tgtPatchFields, tgtPatchI)
forAll(tgtPatchFields, tgtPatchi)
{
if (!tgtPatchFields.set(tgtPatchI))
if (!tgtPatchFields.set(tgtPatchi))
{
// Note: use factory New method instead of direct generation of
// calculated so we keep constraints
tgtPatchFields.set
(
tgtPatchI,
tgtPatchi,
fvPatchField<Type>::New
(
calculatedFvPatchField<Type>::typeName,
tgtMesh.boundary()[tgtPatchI],
tgtMesh.boundary()[tgtPatchi],
DimensionedField<Type, volMesh>::null()
)
);
@ -783,6 +784,27 @@ void Foam::meshToMesh::mapAndOpTgtToSrc
}
template<class Type, class CombineOp>
void Foam::meshToMesh::mapAndOpTgtToSrc
(
const AMIPatchToPatchInterpolation& AMI,
Field<Type>& srcField,
const Field<Type>& tgtField,
const CombineOp& cop
) const
{
srcField = pTraits<Type>::zero;
AMI.interpolateToSource
(
tgtField,
multiplyWeightedOp<Type, CombineOp>(cop),
srcField,
UList<Type>::null()
);
}
template<class Type, class CombineOp>
void Foam::meshToMesh::mapTgtToSrc
(
@ -792,18 +814,18 @@ void Foam::meshToMesh::mapTgtToSrc
const bool secondOrder
) const
{
mapInternalTgtToSrc(field, cop, result, secondOrder);
mapInternalTgtToSrc(field, cop, result.primitiveFieldRef(), secondOrder);
const PtrList<AMIPatchToPatchInterpolation>& AMIList = patchAMIs();
forAll(AMIList, i)
{
label srcPatchI = srcPatchID_[i];
label tgtPatchI = tgtPatchID_[i];
label srcPatchi = srcPatchID_[i];
label tgtPatchi = tgtPatchID_[i];
fvPatchField<Type>& srcField = result.boundaryFieldRef()[srcPatchi];
const fvPatchField<Type>& tgtField = field.boundaryField()[tgtPatchi];
fvPatchField<Type>& srcField = result.boundaryField()[srcPatchI];
const fvPatchField<Type>& tgtField = field.boundaryField()[tgtPatchI];
// Clone and map (since rmap does not do general mapping)
tmp<fvPatchField<Type>> tnewSrc
@ -812,23 +834,22 @@ void Foam::meshToMesh::mapTgtToSrc
(
tgtField,
srcField.patch(),
result.dimensionedInternalField(),
result(),
distributedWeightedFvPatchFieldMapper
(
AMIList[i].singlePatchProc(),
(
AMIList[i].singlePatchProc() == -1
? &AMIList[i].tgtMap()
: NULL
: nullptr
),
AMIList[i].srcAddress(),
AMIList[i].srcWeights()
)
)
);
// Transfer all mapped quantities (value and e.g. gradient) onto
// tgtField
// srcField. Value will get overwritten below
srcField.rmap(tnewSrc(), identity(srcField.size()));
// Override value to account for CombineOp (could be dummy for
@ -838,8 +859,8 @@ void Foam::meshToMesh::mapTgtToSrc
forAll(cuttingPatches_, i)
{
label patchI = cuttingPatches_[i];
fvPatchField<Type>& pf = result.boundaryField()[patchI];
label patchi = cuttingPatches_[i];
fvPatchField<Type>& pf = result.boundaryFieldRef()[patchi];
pf == pf.patchInternalField();
}
}
@ -859,7 +880,7 @@ Foam::meshToMesh::mapTgtToSrc
const fvMesh& srcMesh = static_cast<const fvMesh&>(srcRegion_);
const fvBoundaryMesh& srcBm = srcMesh.boundary();
const typename fieldType::GeometricBoundaryField& tgtBfld =
const typename fieldType::Boundary& tgtBfld =
field.boundaryField();
PtrList<fvPatchField<Type>> srcPatchFields(srcBm.size());
@ -869,22 +890,22 @@ Foam::meshToMesh::mapTgtToSrc
// entries, but these values will need to be reset
forAll(srcPatchID_, i)
{
label srcPatchI = srcPatchID_[i];
label tgtPatchI = tgtPatchID_[i];
label srcPatchi = srcPatchID_[i];
label tgtPatchi = tgtPatchID_[i];
if (!srcPatchFields.set(tgtPatchI))
if (!srcPatchFields.set(tgtPatchi))
{
srcPatchFields.set
(
srcPatchI,
srcPatchi,
fvPatchField<Type>::New
(
tgtBfld[srcPatchI],
srcMesh.boundary()[tgtPatchI],
tgtBfld[srcPatchi],
srcMesh.boundary()[tgtPatchi],
DimensionedField<Type, volMesh>::null(),
directFvPatchFieldMapper
(
labelList(srcMesh.boundary()[srcPatchI].size(), -1)
labelList(srcMesh.boundary()[srcPatchi].size(), -1)
)
)
);
@ -892,19 +913,19 @@ Foam::meshToMesh::mapTgtToSrc
}
// Any unset srcPatchFields become calculated
forAll(srcPatchFields, srcPatchI)
forAll(srcPatchFields, srcPatchi)
{
if (!srcPatchFields.set(srcPatchI))
if (!srcPatchFields.set(srcPatchi))
{
// Note: use factory New method instead of direct generation of
// calculated so we keep constraints
srcPatchFields.set
(
srcPatchI,
srcPatchi,
fvPatchField<Type>::New
(
calculatedFvPatchField<Type>::typeName,
srcMesh.boundary()[srcPatchI],
srcMesh.boundary()[srcPatchi],
DimensionedField<Type, volMesh>::null()
)
);

View File

@ -70,14 +70,14 @@ void Foam::meshToMesh0::calcAddressing()
// set reference to boundary
const polyPatchList& patchesFrom = fromMesh_.boundaryMesh();
forAll(patchesFrom, patchI)
forAll(patchesFrom, patchi)
{
// get reference to cells next to the boundary
const labelUList& bCells = patchesFrom[patchI].faceCells();
const labelUList& bCells = patchesFrom[patchi].faceCells();
forAll(bCells, faceI)
forAll(bCells, facei)
{
boundaryCell[bCells[faceI]] = true;
boundaryCell[bCells[facei]] = true;
}
}

View File

@ -51,8 +51,8 @@ void Foam::meshToMesh0::calculateInverseDistanceWeights() const
// get reference to source mesh data
const labelListList& cc = fromMesh_.cellCells();
const vectorField& centreFrom = fromMesh_.C().internalField();
const vectorField& centreTo = toMesh_.C().internalField();
const vectorField& centreFrom = fromMesh_.C();
const vectorField& centreTo = toMesh_.C();
forAll(cellAddressing_, 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
@ -52,9 +52,9 @@ Foam::meshToMesh0::meshToMesh0
patchMap_(patchMap),
cellAddressing_(toMesh_.nCells()),
boundaryAddressing_(toMesh_.boundaryMesh().size()),
inverseDistanceWeightsPtr_(NULL),
inverseVolumeWeightsPtr_(NULL),
cellToCellAddressingPtr_(NULL),
inverseDistanceWeightsPtr_(nullptr),
inverseVolumeWeightsPtr_(nullptr),
cellToCellAddressingPtr_(nullptr),
V_(0.0)
{
forAll(fromMesh_.boundaryMesh(), patchi)
@ -120,9 +120,9 @@ Foam::meshToMesh0::meshToMesh0
toMesh_(meshTo),
cellAddressing_(toMesh_.nCells()),
boundaryAddressing_(toMesh_.boundaryMesh().size()),
inverseDistanceWeightsPtr_(NULL),
inverseVolumeWeightsPtr_(NULL),
cellToCellAddressingPtr_(NULL),
inverseDistanceWeightsPtr_(nullptr),
inverseVolumeWeightsPtr_(nullptr),
cellToCellAddressingPtr_(nullptr),
V_(0.0)
{
// check whether both meshes have got the same number

View File

@ -253,6 +253,9 @@ void Foam::meshToMesh0::interpolate
{
interpolateInternalField(toVf, fromVf, ord, cop);
typename GeometricField<Type, fvPatchField, volMesh>::
Boundary& toVfBf = toVf.boundaryFieldRef();
forAll(toMesh_.boundaryMesh(), patchi)
{
const fvPatch& toPatch = toMesh_.boundary()[patchi];
@ -265,7 +268,7 @@ void Foam::meshToMesh0::interpolate
{
mapField
(
toVf.boundaryField()[patchi],
toVfBf[patchi],
fromVf,
boundaryAddressing_[patchi],
cop
@ -277,7 +280,7 @@ void Foam::meshToMesh0::interpolate
{
interpolateField
(
toVf.boundaryField()[patchi],
toVfBf[patchi],
fromVf,
boundaryAddressing_[patchi],
toPatch.Cf(),
@ -290,7 +293,7 @@ void Foam::meshToMesh0::interpolate
{
interpolateField
(
toVf.boundaryField()[patchi],
toVfBf[patchi],
fromVf,
boundaryAddressing_[patchi],
toPatch.Cf(),
@ -300,7 +303,6 @@ void Foam::meshToMesh0::interpolate
}
case CELL_VOLUME_WEIGHT:
{
// Do nothing
break;
}
@ -310,12 +312,12 @@ void Foam::meshToMesh0::interpolate
<< exit(FatalError);
}
if (isA<mixedFvPatchField<Type>>(toVf.boundaryField()[patchi]))
if (isA<mixedFvPatchField<Type>>(toVfBf[patchi]))
{
refCast<mixedFvPatchField<Type>>
(
toVf.boundaryField()[patchi]
).refValue() = toVf.boundaryField()[patchi];
toVfBf[patchi]
).refValue() = toVfBf[patchi];
}
}
else if
@ -324,20 +326,9 @@ void Foam::meshToMesh0::interpolate
&& fromMeshPatches_.found(patchMap_.find(toPatch.name())())
)
{
/*
toVf.boundaryField()[patchi].map
(
fromVf.boundaryField()
[
fromMeshPatches_.find(patchMap_.find(toPatch.name())())()
],
boundaryAddressing_[patchi]
);
*/
mapField
(
toVf.boundaryField()[patchi],
toVfBf[patchi],
fromVf.boundaryField()
[
fromMeshPatches_.find(patchMap_.find(toPatch.name())())()
@ -393,19 +384,19 @@ Foam::meshToMesh0::interpolate
boundaryAddressing_.size()
);
forAll(boundaryAddressing_, patchI)
forAll(boundaryAddressing_, patchi)
{
patchFields.set
(
patchI,
patchi,
fvPatchField<Type>::New
(
fromVf.boundaryField()[patchI],
toMesh_.boundary()[patchI],
fromVf.boundaryField()[patchi],
toMesh_.boundary()[patchi],
DimensionedField<Type, volMesh>::null(),
patchFieldInterpolator
(
boundaryAddressing_[patchI]
boundaryAddressing_[patchi]
)
)
);

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,12 +29,21 @@ License
#include "mappedPatchBase.H"
#include "treeBoundBox.H"
#include "treeDataFace.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(patchProbes, 0);
addToRunTimeSelectionTable
(
functionObject,
patchProbes,
dictionary
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -99,9 +108,9 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
);
forAll(probeLocations(), probeI)
forAll(probeLocations(), probei)
{
const point sample = probeLocations()[probeI];
const point sample = probeLocations()[probei];
scalar span = boundaryTree.bb().mag();
@ -116,9 +125,9 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
info = boundaryTree.findNearest(sample, Foam::sqr(GREAT));
}
label faceI = boundaryTree.shapes().faceLabels()[info.index()];
label facei = boundaryTree.shapes().faceLabels()[info.index()];
const label patchi = bm.whichPatch(faceI);
const label patchi = bm.whichPatch(facei);
if (isA<emptyPolyPatch>(bm[patchi]))
{
@ -151,7 +160,7 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
sampleInfo.second().first() = magSqr(facePt-sample);
sampleInfo.second().second() = Pstream::myProcNo();
nearest[probeI]= sampleInfo;
nearest[probei]= sampleInfo;
}
}
}
@ -174,7 +183,7 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
InfoInFunction << endl;
forAll(nearest, sampleI)
{
label procI = nearest[sampleI].second().second();
label proci = nearest[sampleI].second().second();
label localI = nearest[sampleI].first().index();
Info<< " " << sampleI << " coord:"<< operator[](sampleI)
@ -205,37 +214,46 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
void Foam::patchProbes::readDict(const dictionary& dict)
{
if (!dict.readIfPresent("patches", patchNames_))
{
word patchName(dict.lookup("patchName"));
patchNames_ = wordReList(1, wordRe(patchName));
}
probes::readDict(dict);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::patchProbes::patchProbes
(
const word& name,
const Time& t,
const dictionary& dict
)
:
probes(name, t, dict)
{
// When constructing probes above it will have called the
// probes::findElements (since the virtual mechanism not yet operating).
// Not easy to workaround (apart from feeding through flag into constructor)
// so clear out any cells found for now.
elementList_.clear();
faceList_.clear();
read(dict);
}
Foam::patchProbes::patchProbes
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles,
const bool doFindElements
) const bool readFields
)
:
probes(name, obr, dict, loadFromFiles, false)
{
readDict(dict);
if (doFindElements)
if (readFields)
{
// Find the elements
findElements(mesh_);
// Open the probe streams
prepare();
read(dict);
}
}
@ -246,7 +264,7 @@ Foam::patchProbes::~patchProbes()
{}
void Foam::patchProbes::write()
bool Foam::patchProbes::write()
{
if (this->size() && prepare())
{
@ -262,18 +280,19 @@ void Foam::patchProbes::write()
sampleAndWriteSurfaceFields(surfaceSymmTensorFields_);
sampleAndWriteSurfaceFields(surfaceTensorFields_);
}
return true;
}
void Foam::patchProbes::read(const dictionary& dict)
bool Foam::patchProbes::read(const dictionary& dict)
{
readDict(dict);
// Find the elements
findElements(mesh_);
// Open the probe streams
prepare();
if (!dict.readIfPresent("patches", patchNames_))
{
word patchName(dict.lookup("patchName"));
patchNames_ = wordReList(1, wordRe(patchName));
}
return probes::read(dict);
}

View File

@ -168,6 +168,14 @@ public:
// Constructors
//- Construct from Time and dictionary
patchProbes
(
const word& name,
const Time& time,
const dictionary& dict
);
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
patchProbes
@ -183,15 +191,17 @@ public:
//- Destructor
virtual ~patchProbes();
//- Public members
//- Sample and write
virtual void write();
virtual bool write();
//- Read
virtual void read(const dictionary&);
virtual bool read(const dictionary&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -47,9 +47,9 @@ void Foam::patchProbes::sampleAndWrite
<< setw(w)
<< vField.time().timeToUserTime(vField.time().value());
forAll(values, probeI)
forAll(values, probei)
{
probeStream << ' ' << setw(w) << values[probeI];
probeStream << ' ' << setw(w) << values[probei];
}
probeStream << endl;
}
@ -73,9 +73,9 @@ void Foam::patchProbes::sampleAndWrite
<< setw(w)
<< sField.time().timeToUserTime(sField.time().value());
forAll(values, probeI)
forAll(values, probei)
{
probeStream << ' ' << setw(w) << values[probeI];
probeStream << ' ' << setw(w) << values[probei];
}
probeStream << endl;
}
@ -88,7 +88,7 @@ void Foam::patchProbes::sampleAndWrite
const fieldGroup<Type>& fields
)
{
forAll(fields, fieldI)
forAll(fields, fieldi)
{
if (loadFromFiles_)
{
@ -98,7 +98,7 @@ void Foam::patchProbes::sampleAndWrite
(
IOobject
(
fields[fieldI],
fields[fieldi],
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
@ -111,7 +111,7 @@ void Foam::patchProbes::sampleAndWrite
}
else
{
objectRegistry::const_iterator iter = mesh_.find(fields[fieldI]);
objectRegistry::const_iterator iter = mesh_.find(fields[fieldi]);
if
(
@ -125,7 +125,7 @@ void Foam::patchProbes::sampleAndWrite
mesh_.lookupObject
<GeometricField<Type, fvPatchField, volMesh>>
(
fields[fieldI]
fields[fieldi]
)
);
}
@ -140,7 +140,7 @@ void Foam::patchProbes::sampleAndWriteSurfaceFields
const fieldGroup<Type>& fields
)
{
forAll(fields, fieldI)
forAll(fields, fieldi)
{
if (loadFromFiles_)
{
@ -150,7 +150,7 @@ void Foam::patchProbes::sampleAndWriteSurfaceFields
(
IOobject
(
fields[fieldI],
fields[fieldi],
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
@ -163,7 +163,7 @@ void Foam::patchProbes::sampleAndWriteSurfaceFields
}
else
{
objectRegistry::const_iterator iter = mesh_.find(fields[fieldI]);
objectRegistry::const_iterator iter = mesh_.find(fields[fieldi]);
if
(
@ -177,7 +177,7 @@ void Foam::patchProbes::sampleAndWriteSurfaceFields
mesh_.lookupObject
<GeometricField<Type, fvsPatchField, surfaceMesh>>
(
fields[fieldI]
fields[fieldi]
)
);
}
@ -206,15 +206,19 @@ Foam::patchProbes::sample
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
forAll(*this, probeI)
forAll(*this, probei)
{
<<<<<<< HEAD
label faceI = faceList_[probeI];
=======
label facei = elementList_[probei];
>>>>>>> foundation-github
if (faceI >= 0)
if (facei >= 0)
{
label patchI = patches.whichPatch(faceI);
label localFaceI = patches[patchI].whichFace(faceI);
values[probeI] = vField.boundaryField()[patchI][localFaceI];
label patchi = patches.whichPatch(facei);
label localFacei = patches[patchi].whichFace(facei);
values[probei] = vField.boundaryField()[patchi][localFacei];
}
}
@ -257,15 +261,19 @@ Foam::patchProbes::sample
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
forAll(*this, probeI)
forAll(*this, probei)
{
<<<<<<< HEAD
label faceI = faceList_[probeI];
=======
label facei = elementList_[probei];
>>>>>>> foundation-github
if (faceI >= 0)
if (facei >= 0)
{
label patchI = patches.whichPatch(faceI);
label localFaceI = patches[patchI].whichFace(faceI);
values[probeI] = sField.boundaryField()[patchI][localFaceI];
label patchi = patches.whichPatch(facei);
label localFacei = patches[patchi].whichFace(facei);
values[probei] = sField.boundaryField()[patchi][localFacei];
}
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,12 +29,20 @@ License
#include "Time.H"
#include "IOmanip.H"
#include "mapPolyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(probes, 0);
addToRunTimeSelectionTable
(
functionObject,
probes,
dictionary
);
}
@ -42,10 +50,7 @@ namespace Foam
void Foam::probes::findElements(const fvMesh& mesh)
{
if (debug)
{
Info<< "probes: resetting sample locations" << endl;
}
DebugInfo<< "probes: resetting sample locations" << endl;
elementList_.clear();
elementList_.setSize(size());
@ -53,58 +58,58 @@ void Foam::probes::findElements(const fvMesh& mesh)
faceList_.clear();
faceList_.setSize(size());
forAll(*this, probeI)
forAll(*this, probei)
{
const vector& location = operator[](probeI);
const vector& location = operator[](probei);
const label cellI = mesh.findCell(location);
const label celli = mesh.findCell(location);
elementList_[probeI] = cellI;
elementList_[probei] = celli;
if (cellI != -1)
if (celli != -1)
{
const labelList& cellFaces = mesh.cells()[cellI];
const vector& cellCentre = mesh.cellCentres()[cellI];
const labelList& cellFaces = mesh.cells()[celli];
const vector& cellCentre = mesh.cellCentres()[celli];
scalar minDistance = GREAT;
label minFaceID = -1;
forAll(cellFaces, i)
{
label faceI = cellFaces[i];
vector dist = mesh.faceCentres()[faceI] - cellCentre;
label facei = cellFaces[i];
vector dist = mesh.faceCentres()[facei] - cellCentre;
if (mag(dist) < minDistance)
{
minDistance = mag(dist);
minFaceID = faceI;
minFaceID = facei;
}
}
faceList_[probeI] = minFaceID;
faceList_[probei] = minFaceID;
}
else
{
faceList_[probeI] = -1;
faceList_[probei] = -1;
}
if (debug && (elementList_[probeI] != -1 || faceList_[probeI] != -1))
if (debug && (elementList_[probei] != -1 || faceList_[probei] != -1))
{
Pout<< "probes : found point " << location
<< " in cell " << elementList_[probeI]
<< " and face " << faceList_[probeI] << endl;
<< " in cell " << elementList_[probei]
<< " and face " << faceList_[probei] << endl;
}
}
// Check if all probes have been found.
forAll(elementList_, probeI)
forAll(elementList_, probei)
{
const vector& location = operator[](probeI);
label cellI = elementList_[probeI];
label faceI = faceList_[probeI];
const vector& location = operator[](probei);
label celli = elementList_[probei];
label facei = faceList_[probei];
// Check at least one processor with cell.
reduce(cellI, maxOp<label>());
reduce(faceI, maxOp<label>());
reduce(celli, maxOp<label>());
reduce(facei, maxOp<label>());
if (cellI == -1)
if (celli == -1)
{
if (Pstream::master())
{
@ -113,7 +118,7 @@ void Foam::probes::findElements(const fvMesh& mesh)
<< " in any cell. Skipping location." << endl;
}
}
else if (faceI == -1)
else if (facei == -1)
{
if (Pstream::master())
{
@ -125,27 +130,29 @@ void Foam::probes::findElements(const fvMesh& mesh)
else
{
// Make sure location not on two domains.
if (elementList_[probeI] != -1 && elementList_[probeI] != cellI)
if (elementList_[probei] != -1 && elementList_[probei] != celli)
{
WarningInFunction
<< "Location " << location
<< " seems to be on multiple domains:"
<< " cell " << elementList_[probeI]
<< " cell " << elementList_[probei]
<< " on my domain " << Pstream::myProcNo()
<< " and cell " << cellI << " on some other domain." << endl
<< " and cell " << celli << " on some other domain."
<< nl
<< "This might happen if the probe location is on"
<< " a processor patch. Change the location slightly"
<< " to prevent this." << endl;
}
if (faceList_[probeI] != -1 && faceList_[probeI] != faceI)
if (faceList_[probei] != -1 && faceList_[probei] != facei)
{
WarningInFunction
<< "Location " << location
<< " seems to be on multiple domains:"
<< " cell " << faceList_[probeI]
<< " cell " << faceList_[probei]
<< " on my domain " << Pstream::myProcNo()
<< " and face " << faceI << " on some other domain." << endl
<< " and face " << facei << " on some other domain."
<< nl
<< "This might happen if the probe location is on"
<< " a processor patch. Change the location slightly"
<< " to prevent this." << endl;
@ -176,16 +183,14 @@ Foam::label Foam::probes::prepare()
currentFields.insert(surfaceSymmTensorFields_);
currentFields.insert(surfaceTensorFields_);
if (debug)
{
Info<< "Probing fields: " << currentFields << nl
<< "Probing locations: " << *this << nl
<< endl;
}
DebugInfo
<< "Probing fields: " << currentFields << nl
<< "Probing locations: " << *this << nl
<< endl;
fileName probeDir;
fileName probeSubDir = name_;
fileName probeSubDir = name();
if (mesh_.name() != polyMesh::defaultRegion)
{
@ -209,10 +214,7 @@ Foam::label Foam::probes::prepare()
{
if (!currentFields.erase(iter.key()))
{
if (debug)
{
Info<< "close probe stream: " << iter()->name() << endl;
}
DdebugInfo<< "close probe stream: " << iter()->name() << endl;
delete probeFilePtrs_.remove(iter);
}
@ -230,27 +232,24 @@ Foam::label Foam::probes::prepare()
OFstream& fout = *fPtr;
if (debug)
{
Info<< "open probe stream: " << fout.name() << endl;
}
DebugInfo<< "open probe stream: " << fout.name() << endl;
probeFilePtrs_.insert(fieldName, fPtr);
unsigned int w = IOstream::defaultPrecision() + 7;
forAll(*this, probeI)
forAll(*this, probei)
{
fout<< "# Probe " << probeI << ' ' << operator[](probeI)
fout<< "# Probe " << probei << ' ' << operator[](probei)
<< endl;
}
fout<< '#' << setw(IOstream::defaultPrecision() + 6)
<< "Probe";
forAll(*this, probeI)
forAll(*this, probei)
{
fout<< ' ' << setw(w) << probeI;
fout<< ' ' << setw(w) << probei;
}
fout<< endl;
@ -263,55 +262,45 @@ Foam::label Foam::probes::prepare()
}
void Foam::probes::readDict(const dictionary& dict)
{
dict.lookup("probeLocations") >> *this;
dict.lookup("fields") >> fieldSelection_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
dict.readIfPresent("fixedLocations", fixedLocations_);
if (dict.readIfPresent("interpolationScheme", interpolationScheme_))
{
if (!fixedLocations_ && interpolationScheme_ != "cell")
{
WarningInFunction
<< "Only cell interpolation can be applied when "
<< "not using fixedLocations. InterpolationScheme "
<< "entry will be ignored";
}
}
Foam::probes::probes
(
const word& name,
const Time& t,
const dictionary& dict
)
:
fvMeshFunctionObject(t, name),
pointField(0),
loadFromFiles_(false),
fieldSelection_(),
fixedLocations_(true),
interpolationScheme_("cell")
{
read(dict);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::probes::probes
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles,
const bool doFindElements
const bool readFields
)
:
fvMeshFunctionObject(obr, name),
pointField(0),
name_(name),
mesh_(refCast<const fvMesh>(obr)),
loadFromFiles_(loadFromFiles),
fieldSelection_(),
fixedLocations_(true),
interpolationScheme_("cell")
{
// Read dictionary (but do not search for elements)
readDict(dict);
// Optionally find elements in constructor
if (doFindElements)
if (readFields)
{
// Find the elements
findElements(mesh_);
// Open the probe streams
prepare();
read(dict);
}
}
@ -324,48 +313,11 @@ Foam::probes::~probes()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::probes::execute()
bool Foam::probes::read(const dictionary& dict)
{
// Do nothing - only valid on write
}
dict.lookup("probeLocations") >> *this;
dict.lookup("fields") >> fieldSelection_;
void Foam::probes::end()
{
// Do nothing - only valid on write
}
void Foam::probes::timeSet()
{
// Do nothing - only valid on write
}
void Foam::probes::write()
{
if (size() && prepare())
{
sampleAndWrite(scalarFields_);
sampleAndWrite(vectorFields_);
sampleAndWrite(sphericalTensorFields_);
sampleAndWrite(symmTensorFields_);
sampleAndWrite(tensorFields_);
sampleAndWriteSurfaceFields(surfaceScalarFields_);
sampleAndWriteSurfaceFields(surfaceVectorFields_);
sampleAndWriteSurfaceFields(surfaceSphericalTensorFields_);
sampleAndWriteSurfaceFields(surfaceSymmTensorFields_);
sampleAndWriteSurfaceFields(surfaceTensorFields_);
}
}
void Foam::probes::read(const dictionary& dict)
{
readDict(dict);
// Find the elements
dict.readIfPresent("fixedLocations", fixedLocations_);
if (dict.readIfPresent("interpolationScheme", interpolationScheme_))
{
@ -381,16 +333,46 @@ void Foam::probes::read(const dictionary& dict)
// Initialise cells to sample from supplied locations
findElements(mesh_);
// Open the probe streams
prepare();
return true;
}
bool Foam::probes::execute()
{
return true;
}
bool Foam::probes::write()
{
if (size() && prepare())
{
sampleAndWrite(scalarFields_);
sampleAndWrite(vectorFields_);
sampleAndWrite(sphericalTensorFields_);
sampleAndWrite(symmTensorFields_);
sampleAndWrite(tensorFields_);
sampleAndWriteSurfaceFields(surfaceScalarFields_);
sampleAndWriteSurfaceFields(surfaceVectorFields_);
sampleAndWriteSurfaceFields(surfaceSphericalTensorFields_);
sampleAndWriteSurfaceFields(surfaceSymmTensorFields_);
sampleAndWriteSurfaceFields(surfaceTensorFields_);
}
return true;
}
void Foam::probes::updateMesh(const mapPolyMesh& mpm)
{
if (debug)
DebugInfo<< "probes: updateMesh" << endl;
if (&mpm.mesh() != &mesh_)
{
Info<< "probes: updateMesh" << endl;
return;
}
if (fixedLocations_)
@ -399,10 +381,7 @@ void Foam::probes::updateMesh(const mapPolyMesh& mpm)
}
else
{
if (debug)
{
Info<< "probes: remapping sample locations" << endl;
}
DebugInfo<< "probes: remapping sample locations" << endl;
// 1. Update cells
{
@ -411,23 +390,23 @@ void Foam::probes::updateMesh(const mapPolyMesh& mpm)
const labelList& reverseMap = mpm.reverseCellMap();
forAll(elementList_, i)
{
label cellI = elementList_[i];
if (cellI != -1)
label celli = elementList_[i];
if (celli != -1)
{
label newCellI = reverseMap[cellI];
if (newCellI == -1)
label newCelli = reverseMap[cellI];
if (newCelli == -1)
{
// cell removed
}
else if (newCellI < -1)
else if (newCelli < -1)
{
// cell merged
elems.append(-newCellI - 2);
elems.append(-newCelli - 2);
}
else
{
// valid new cell
elems.append(newCellI);
elems.append(newCelli);
}
}
else
@ -447,23 +426,23 @@ void Foam::probes::updateMesh(const mapPolyMesh& mpm)
const labelList& reverseMap = mpm.reverseFaceMap();
forAll(faceList_, i)
{
label faceI = faceList_[i];
if (faceI != -1)
label facei = faceList_[i];
if (facei != -1)
{
label newFaceI = reverseMap[faceI];
if (newFaceI == -1)
label newFacei = reverseMap[facei];
if (newFacei == -1)
{
// face removed
}
else if (newFaceI < -1)
else if (newFacei < -1)
{
// face merged
elems.append(-newFaceI - 2);
elems.append(-newFacei - 2);
}
else
{
// valid new face
elems.append(newFaceI);
elems.append(newFacei);
}
}
else
@ -479,14 +458,11 @@ void Foam::probes::updateMesh(const mapPolyMesh& mpm)
}
void Foam::probes::movePoints(const polyMesh&)
void Foam::probes::movePoints(const polyMesh& mesh)
{
if (debug)
{
Info<< "probes: movePoints" << endl;
}
DebugInfo<< "probes: movePoints" << endl;
if (fixedLocations_)
if (fixedLocations_ && &mesh == &mesh_)
{
findElements(mesh_);
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,7 +25,7 @@ Class
Foam::probes
Group
grpFunctionObjects
grpUtilitiesFunctionObjects
Description
Set of locations to sample.
@ -76,6 +76,7 @@ SourceFiles
#ifndef probes_H
#define probes_H
#include "fvMeshFunctionObject.H"
#include "HashPtrTable.H"
#include "OFstream.H"
#include "polyMesh.H"
@ -91,6 +92,7 @@ namespace Foam
{
// Forward declaration of classes
class Time;
class objectRegistry;
class dictionary;
class fvMesh;
@ -102,6 +104,7 @@ class mapPolyMesh;
class probes
:
public fvMeshFunctionObject,
public pointField
{
protected:
@ -123,18 +126,10 @@ protected:
};
// Private data
//- Name of this set of probes,
// Also used as the name of the probes directory.
const word name_;
//- Const reference to fvMesh
const fvMesh& mesh_;
// Protected data
//- Load fields from files (not from objectRegistry)
const bool loadFromFiles_;
bool loadFromFiles_;
// Read from dictonary
@ -195,8 +190,6 @@ protected:
// returns number of fields to sample
label prepare();
//- Read dictionary settings
void readDict(const dictionary& dict);
private:
@ -238,15 +231,23 @@ public:
// Constructors
//- Construct from Time and dictionary
probes
(
const word& name,
const Time& runTime,
const dictionary& dict
);
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
probes
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false,
const bool findElements = true
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles = false
const bool readFields = true
);
@ -256,12 +257,6 @@ public:
// Member Functions
//- Return name of the set of probes
virtual const word& name() const
{
return name_;
}
//- Return names of fields to probe
virtual const wordReList& fieldNames() const
{
@ -286,20 +281,14 @@ public:
return elementList_;
}
//- Read the probes
virtual bool read(const dictionary&);
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Called when time was set at the end of the Time::operator++
virtual void timeSet();
virtual bool execute();
//- Sample and write
virtual void write();
//- Read the probes
virtual void read(const dictionary&);
virtual bool write();
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh&);

View File

@ -1,49 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "probesFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(probesFunctionObject, 0);
defineNamedTemplateTypeNameAndDebug(patchProbesFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
probesFunctionObject,
dictionary
);
addToRunTimeSelectionTable
(
functionObject,
patchProbesFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -1,55 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Typedef
Foam::probesFunctionObject
Description
FunctionObject wrapper around probes to allow them to be created via the
functions entry within controlDict.
SourceFiles
probesFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef probesFunctionObject_H
#define probesFunctionObject_H
#include "probes.H"
#include "patchProbes.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<probes> probesFunctionObject;
typedef OutputFilterFunctionObject<patchProbes> patchProbesFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

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
@ -121,9 +121,9 @@ Foam::label Foam::probes::classifyFields()
labelList indices = findStrings(fieldSelection_, allFields);
forAll(indices, fieldI)
forAll(indices, fieldi)
{
const word& fieldName = allFields[indices[fieldI]];
const word& fieldName = allFields[indices[fieldi]];
nFields += appendFieldGroup
(
@ -138,9 +138,9 @@ Foam::label Foam::probes::classifyFields()
wordList allFields = mesh_.sortedNames();
labelList indices = findStrings(fieldSelection_, allFields);
forAll(indices, fieldI)
forAll(indices, fieldi)
{
const word& fieldName = allFields[indices[fieldI]];
const word& fieldName = allFields[indices[fieldi]];
nFields += appendFieldGroup
(

View File

@ -78,9 +78,9 @@ void Foam::probes::sampleAndWrite
os << setw(w) << vField.time().timeToUserTime(vField.time().value());
forAll(values, probeI)
forAll(values, probei)
{
os << ' ' << setw(w) << values[probeI];
os << ' ' << setw(w) << values[probei];
}
os << endl;
}
@ -102,9 +102,9 @@ void Foam::probes::sampleAndWrite
os << setw(w) << sField.time().timeToUserTime(sField.time().value());
forAll(values, probeI)
forAll(values, probei)
{
os << ' ' << setw(w) << values[probeI];
os << ' ' << setw(w) << values[probei];
}
os << endl;
}
@ -114,7 +114,7 @@ void Foam::probes::sampleAndWrite
template<class Type>
void Foam::probes::sampleAndWrite(const fieldGroup<Type>& fields)
{
forAll(fields, fieldI)
forAll(fields, fieldi)
{
if (loadFromFiles_)
{
@ -124,7 +124,7 @@ void Foam::probes::sampleAndWrite(const fieldGroup<Type>& fields)
(
IOobject
(
fields[fieldI],
fields[fieldi],
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
@ -137,7 +137,7 @@ void Foam::probes::sampleAndWrite(const fieldGroup<Type>& fields)
}
else
{
objectRegistry::const_iterator iter = mesh_.find(fields[fieldI]);
objectRegistry::const_iterator iter = mesh_.find(fields[fieldi]);
if
(
@ -151,7 +151,7 @@ void Foam::probes::sampleAndWrite(const fieldGroup<Type>& fields)
mesh_.lookupObject
<GeometricField<Type, fvPatchField, volMesh>>
(
fields[fieldI]
fields[fieldi]
)
);
}
@ -163,7 +163,7 @@ void Foam::probes::sampleAndWrite(const fieldGroup<Type>& fields)
template<class Type>
void Foam::probes::sampleAndWriteSurfaceFields(const fieldGroup<Type>& fields)
{
forAll(fields, fieldI)
forAll(fields, fieldi)
{
if (loadFromFiles_)
{
@ -173,7 +173,7 @@ void Foam::probes::sampleAndWriteSurfaceFields(const fieldGroup<Type>& fields)
(
IOobject
(
fields[fieldI],
fields[fieldi],
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
@ -186,7 +186,7 @@ void Foam::probes::sampleAndWriteSurfaceFields(const fieldGroup<Type>& fields)
}
else
{
objectRegistry::const_iterator iter = mesh_.find(fields[fieldI]);
objectRegistry::const_iterator iter = mesh_.find(fields[fieldi]);
if
(
@ -200,7 +200,7 @@ void Foam::probes::sampleAndWriteSurfaceFields(const fieldGroup<Type>& fields)
mesh_.lookupObject
<GeometricField<Type, fvsPatchField, surfaceMesh>>
(
fields[fieldI]
fields[fieldi]
)
);
}
@ -233,16 +233,16 @@ Foam::probes::sample
interpolation<Type>::New(interpolationScheme_, vField)
);
forAll(*this, probeI)
forAll(*this, probei)
{
if (elementList_[probeI] >= 0)
if (elementList_[probei] >= 0)
{
const vector& position = operator[](probeI);
const vector& position = operator[](probei);
values[probeI] = interpolator().interpolate
values[probei] = interpolator().interpolate
(
position,
elementList_[probeI],
elementList_[probei],
-1
);
}
@ -250,11 +250,11 @@ Foam::probes::sample
}
else
{
forAll(*this, probeI)
forAll(*this, probei)
{
if (elementList_[probeI] >= 0)
if (elementList_[probei] >= 0)
{
values[probeI] = vField[elementList_[probeI]];
values[probei] = vField[elementList_[probei]];
}
}
}
@ -296,11 +296,11 @@ Foam::probes::sample
Field<Type>& values = tValues.ref();
forAll(*this, probeI)
forAll(*this, probei)
{
if (faceList_[probeI] >= 0)
if (faceList_[probei] >= 0)
{
values[probeI] = sField[faceList_[probeI]];
values[probei] = sField[faceList_[probei]];
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -88,12 +88,12 @@ void Foam::arraySet::calcSamples
forAll(sampleCoords, sampleI)
{
label cellI = queryMesh.findCell(sampleCoords[sampleI]);
label celli = queryMesh.findCell(sampleCoords[sampleI]);
if (cellI != -1)
if (celli != -1)
{
samplingPts.append(sampleCoords[sampleI]);
samplingCells.append(cellI);
samplingCells.append(celli);
samplingFaces.append(-1);
samplingSegments.append(0);
samplingCurveDist.append(1.0 * sampleI);

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
@ -65,11 +65,11 @@ void Foam::circleSet::calcSamples
);
// set start point
label cellI = searchEngine().findCell(startPoint_);
if (cellI != -1)
label celli = searchEngine().findCell(startPoint_);
if (celli != -1)
{
samplingPts.append(startPoint_);
samplingCells.append(cellI);
samplingCells.append(celli);
samplingFaces.append(-1);
samplingSegments.append(0);
samplingCurveDist.append(0.0);
@ -110,12 +110,12 @@ void Foam::circleSet::calcSamples
axis1 /= mag(axis1);
point pt = origin_ + radius*axis1;
label cellI = searchEngine().findCell(pt);
label celli = searchEngine().findCell(pt);
if (cellI != -1)
if (celli != -1)
{
samplingPts.append(pt);
samplingCells.append(cellI);
samplingCells.append(celli);
samplingFaces.append(-1);
samplingSegments.append(nPoint);
samplingCurveDist.append

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -55,12 +55,12 @@ void Foam::cloudSet::calcSamples
forAll(sampleCoords_, sampleI)
{
label cellI = queryMesh.findCell(sampleCoords_[sampleI]);
label celli = queryMesh.findCell(sampleCoords_[sampleI]);
if (cellI != -1)
if (celli != -1)
{
samplingPts.append(sampleCoords_[sampleI]);
samplingCells.append(cellI);
samplingCells.append(celli);
samplingFaces.append(-1);
samplingSegments.append(0);
samplingCurveDist.append(1.0 * sampleI);

View File

@ -124,40 +124,40 @@ void Foam::faceOnlySet::calcSamples
);
point bPoint(GREAT, GREAT, GREAT);
label bFaceI = -1;
label bFacei = -1;
if (bHits.size())
{
bPoint = bHits[0].hitPoint();
bFaceI = bHits[0].index();
bFacei = bHits[0].index();
}
// Get first tracking point. Use bPoint, bFaceI if provided.
// Get first tracking point. Use bPoint, bFacei if provided.
point trackPt;
label trackCellI = -1;
label trackFaceI = -1;
label trackCelli = -1;
label trackFacei = -1;
// Pout<< "before getTrackingPoint : bPoint:" << bPoint
// << " bFaceI:" << bFaceI << endl;
// << " bFacei:" << bFacei << endl;
getTrackingPoint
(
start_,
bPoint,
bFaceI,
bFacei,
smallDist,
trackPt,
trackCellI,
trackFaceI
trackCelli,
trackFacei
);
// Pout<< "after getTrackingPoint : "
// << " trackPt:" << trackPt
// << " trackCellI:" << trackCellI
// << " trackFaceI:" << trackFaceI
// << " trackCelli:" << trackCelli
// << " trackFacei:" << trackFacei
// << endl;
if (trackCellI == -1)
if (trackCelli == -1)
{
// Line start_ - end_ does not intersect domain at all.
// (or is along edge)
@ -169,16 +169,16 @@ void Foam::faceOnlySet::calcSamples
return;
}
if (trackFaceI == -1)
if (trackFacei == -1)
{
// No boundary face. Check for nearish internal face
trackFaceI = findNearFace(trackCellI, trackPt, smallDist);
trackFacei = findNearFace(trackCelli, trackPt, smallDist);
}
// Pout<< "calcSamples : got first point to track from :"
// << " trackPt:" << trackPt
// << " trackCell:" << trackCellI
// << " trackFace:" << trackFaceI
// << " trackCell:" << trackCelli
// << " trackFace:" << trackFacei
// << endl;
//
@ -196,12 +196,12 @@ void Foam::faceOnlySet::calcSamples
while (true)
{
if (trackFaceI != -1)
if (trackFacei != -1)
{
// Pout<< "trackPt:" << trackPt << " on face so use." << endl;
samplingPts.append(trackPt);
samplingCells.append(trackCellI);
samplingFaces.append(trackFaceI);
samplingCells.append(trackCelli);
samplingFaces.append(trackFacei);
samplingCurveDist.append(mag(trackPt - start_));
}
@ -210,7 +210,7 @@ void Foam::faceOnlySet::calcSamples
(
mesh(),
trackPt,
trackCellI
trackCelli
);
bool reachedBoundary = trackToBoundary
@ -271,9 +271,9 @@ void Foam::faceOnlySet::calcSamples
}
// Update starting point for tracking
trackFaceI = bHits[bHitI].index();
trackPt = pushIn(bHits[bHitI].hitPoint(), trackFaceI);
trackCellI = getBoundaryCell(trackFaceI);
trackFacei = bHits[bHitI].index();
trackPt = pushIn(bHits[bHitI].hitPoint(), trackFacei);
trackCelli = getBoundaryCell(trackFacei);
segmentI++;

View File

@ -62,7 +62,7 @@ class faceOnlySet
// Private Member Functions
//- Samples from startTrackPt/CellI. Updates particle/samplePt/sampleI
//- Samples from startTrackPt/Celli. Updates particle/samplePt/sampleI
// and puts
// samples in the DynamicLists. Returns false if end of all samples
// reached

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -201,11 +201,11 @@ void Foam::patchCloudSet::calcSamples
{
if (nearest[sampleI].second().second() == Pstream::myProcNo())
{
label faceI = nearInfo.index();
label facei = nearInfo.index();
samplingPts.append(nearInfo.hitPoint());
samplingCells.append(mesh().faceOwner()[faceI]);
samplingFaces.append(faceI);
samplingCells.append(mesh().faceOwner()[facei]);
samplingFaces.append(facei);
samplingSegments.append(0);
samplingCurveDist.append(1.0 * sampleI);
}

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
@ -259,22 +259,22 @@ void Foam::patchSeedSet::calcSamples
forAll(patchFaces, i)
{
label faceI = patchFaces[i];
label facei = patchFaces[i];
// Slightly shift point in since on warped face face-diagonal
// decomposition might be outside cell for face-centre decomposition!
pointIndexHit info = mappedPatchBase::facePoint
(
mesh(),
faceI,
facei,
polyMesh::FACE_DIAG_TRIS
);
label cellI = mesh().faceOwner()[faceI];
label celli = mesh().faceOwner()[facei];
if (info.hit())
{
// Move the point into the cell
const point& cc = mesh().cellCentres()[cellI];
const point& cc = mesh().cellCentres()[celli];
samplingPts.append
(
info.hitPoint() + 1e-1*(cc-info.hitPoint())
@ -284,8 +284,8 @@ void Foam::patchSeedSet::calcSamples
{
samplingPts.append(info.rawPoint());
}
samplingCells.append(cellI);
samplingFaces.append(faceI);
samplingCells.append(celli);
samplingFaces.append(facei);
samplingSegments.append(0);
samplingCurveDist.append(globalSampleNumbers.toGlobal(i));
}

View File

@ -176,8 +176,8 @@ void Foam::polyLineSet::calcSamples
{
// Get boundary intersection
point trackPt;
label trackCellI = -1;
label trackFaceI = -1;
label trackCelli = -1;
label trackFacei = -1;
do
{
@ -194,12 +194,12 @@ void Foam::polyLineSet::calcSamples
);
point bPoint(GREAT, GREAT, GREAT);
label bFaceI = -1;
label bFacei = -1;
if (bHits.size())
{
bPoint = bHits[0].hitPoint();
bFaceI = bHits[0].index();
bFacei = bHits[0].index();
}
// Get tracking point
@ -209,27 +209,27 @@ void Foam::polyLineSet::calcSamples
(
sampleCoords_[sampleI],
bPoint,
bFaceI,
bFacei,
smallDist,
trackPt,
trackCellI,
trackFaceI
trackCelli,
trackFacei
);
if (isSample && (mag(lastSample - trackPt) > smallDist))
{
//Info<< "calcSamples : getTrackingPoint returned valid sample "
// << " trackPt:" << trackPt
// << " trackFaceI:" << trackFaceI
// << " trackCellI:" << trackCellI
// << " trackFacei:" << trackFacei
// << " trackCelli:" << trackCelli
// << " sampleI:" << sampleI
// << " dist:" << dist
// << endl;
samplingPts.append(trackPt);
samplingCells.append(trackCellI);
samplingFaces.append(trackFaceI);
samplingCells.append(trackCelli);
samplingFaces.append(trackFacei);
// Convert sampling position to unique curve parameter. Get
// fraction of distance between sampleI and sampleI+1.
@ -241,12 +241,12 @@ void Foam::polyLineSet::calcSamples
lastSample = trackPt;
}
if (trackCellI == -1)
if (trackCelli == -1)
{
// No intersection found. Go to next point
sampleI++;
}
} while ((trackCellI == -1) && (sampleI < sampleCoords_.size() - 1));
} while ((trackCelli == -1) && (sampleI < sampleCoords_.size() - 1));
if (sampleI == sampleCoords_.size() - 1)
{
@ -265,7 +265,7 @@ void Foam::polyLineSet::calcSamples
(
mesh(),
trackPt,
trackCellI
trackCelli
);
bool bReached = trackToBoundary

View File

@ -41,21 +41,21 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::label Foam::sampledSet::getBoundaryCell(const label faceI) const
Foam::label Foam::sampledSet::getBoundaryCell(const label facei) const
{
return mesh().faceOwner()[faceI];
return mesh().faceOwner()[facei];
}
Foam::label Foam::sampledSet::getNeighbourCell(const label faceI) const
Foam::label Foam::sampledSet::getNeighbourCell(const label facei) const
{
if (faceI >= mesh().nInternalFaces())
if (facei >= mesh().nInternalFaces())
{
return mesh().faceOwner()[faceI];
return mesh().faceOwner()[facei];
}
else
{
return mesh().faceNeighbour()[faceI];
return mesh().faceNeighbour()[facei];
}
}
@ -134,11 +134,11 @@ Foam::label Foam::sampledSet::pointInCell
Foam::scalar Foam::sampledSet::calcSign
(
const label faceI,
const label facei,
const point& sample
) const
{
vector vec = sample - mesh().faceCentres()[faceI];
vector vec = sample - mesh().faceCentres()[facei];
scalar magVec = mag(vec);
@ -150,7 +150,7 @@ Foam::scalar Foam::sampledSet::calcSign
vec /= magVec;
vector n = mesh().faceAreas()[faceI];
vector n = mesh().faceAreas()[facei];
n /= mag(n) + VSMALL;
@ -160,16 +160,16 @@ Foam::scalar Foam::sampledSet::calcSign
Foam::label Foam::sampledSet::findNearFace
(
const label cellI,
const label celli,
const point& sample,
const scalar smallDist
) const
{
const cell& myFaces = mesh().cells()[cellI];
const cell& myFaces = mesh().cells()[celli];
forAll(myFaces, myFaceI)
forAll(myFaces, myFacei)
{
const face& f = mesh().faces()[myFaces[myFaceI]];
const face& f = mesh().faces()[myFaces[myFacei]];
pointHit inter = f.nearestPoint(sample, mesh().points());
@ -186,7 +186,7 @@ Foam::label Foam::sampledSet::findNearFace
if (dist < smallDist)
{
return myFaces[myFaceI];
return myFaces[myFacei];
}
}
return -1;
@ -196,20 +196,20 @@ Foam::label Foam::sampledSet::findNearFace
Foam::point Foam::sampledSet::pushIn
(
const point& facePt,
const label faceI
const label facei
) const
{
label cellI = mesh().faceOwner()[faceI];
const point& cC = mesh().cellCentres()[cellI];
label celli = mesh().faceOwner()[facei];
const point& cC = mesh().cellCentres()[celli];
point newPosition = facePt;
// Taken from particle::initCellFacePt()
label tetFaceI;
label tetFacei;
label tetPtI;
mesh().findTetFacePt(cellI, facePt, tetFaceI, tetPtI);
mesh().findTetFacePt(celli, facePt, tetFacei, tetPtI);
if (tetFaceI == -1 || tetPtI == -1)
if (tetFacei == -1 || tetPtI == -1)
{
newPosition = facePt;
@ -223,24 +223,24 @@ Foam::point Foam::sampledSet::pushIn
mesh().findTetFacePt
(
cellI,
celli,
newPosition,
tetFaceI,
tetFacei,
tetPtI
);
iterNo++;
} while (tetFaceI < 0 && iterNo <= trap);
} while (tetFacei < 0 && iterNo <= trap);
}
if (tetFaceI == -1)
if (tetFacei == -1)
{
FatalErrorInFunction
<< "After pushing " << facePt << " to " << newPosition
<< " it is still outside face " << faceI
<< " at " << mesh().faceCentres()[faceI]
<< " of cell " << cellI
<< " it is still outside face " << facei
<< " at " << mesh().faceCentres()[facei]
<< " of cell " << celli
<< " at " << cC << endl
<< "Please change your starting point"
<< abort(FatalError);
@ -254,28 +254,28 @@ bool Foam::sampledSet::getTrackingPoint
(
const point& samplePt,
const point& bPoint,
const label bFaceI,
const label bFacei,
const scalar smallDist,
point& trackPt,
label& trackCellI,
label& trackFaceI
label& trackCelli,
label& trackFacei
) const
{
bool isGoodSample = false;
if (bFaceI == -1)
if (bFacei == -1)
{
// No boundary intersection. Try and find cell samplePt is in
trackCellI = mesh().findCell(samplePt, searchEngine_.decompMode());
trackCelli = mesh().findCell(samplePt, searchEngine_.decompMode());
if
(
(trackCellI == -1)
(trackCelli == -1)
|| !mesh().pointInCell
(
samplePt,
trackCellI,
trackCelli,
searchEngine_.decompMode()
)
)
@ -283,8 +283,8 @@ bool Foam::sampledSet::getTrackingPoint
// Line samplePt - end_ does not intersect domain at all.
// (or is along edge)
trackCellI = -1;
trackFaceI = -1;
trackCelli = -1;
trackFacei = -1;
isGoodSample = false;
}
@ -293,7 +293,7 @@ bool Foam::sampledSet::getTrackingPoint
// Start is inside. Use it as tracking point
trackPt = samplePt;
trackFaceI = -1;
trackFacei = -1;
isGoodSample = true;
}
@ -301,31 +301,31 @@ bool Foam::sampledSet::getTrackingPoint
else if (mag(samplePt - bPoint) < smallDist)
{
// samplePt close to bPoint. Snap to it
trackPt = pushIn(bPoint, bFaceI);
trackFaceI = bFaceI;
trackCellI = getBoundaryCell(trackFaceI);
trackPt = pushIn(bPoint, bFacei);
trackFacei = bFacei;
trackCelli = getBoundaryCell(trackFacei);
isGoodSample = true;
}
else
{
scalar sign = calcSign(bFaceI, samplePt);
scalar sign = calcSign(bFacei, samplePt);
if (sign < 0)
{
// samplePt inside or marginally outside.
trackPt = samplePt;
trackFaceI = -1;
trackCellI = mesh().findCell(trackPt, searchEngine_.decompMode());
trackFacei = -1;
trackCelli = mesh().findCell(trackPt, searchEngine_.decompMode());
isGoodSample = true;
}
else
{
// samplePt outside. use bPoint
trackPt = pushIn(bPoint, bFaceI);
trackFaceI = bFaceI;
trackCellI = getBoundaryCell(trackFaceI);
trackPt = pushIn(bPoint, bFacei);
trackFacei = bFacei;
trackCelli = getBoundaryCell(trackFacei);
isGoodSample = false;
}
@ -336,11 +336,11 @@ bool Foam::sampledSet::getTrackingPoint
InfoInFunction
<< " samplePt:" << samplePt
<< " bPoint:" << bPoint
<< " bFaceI:" << bFaceI
<< " bFacei:" << bFacei
<< endl << " Calculated first tracking point :"
<< " trackPt:" << trackPt
<< " trackCellI:" << trackCellI
<< " trackFaceI:" << trackFaceI
<< " trackCelli:" << trackCelli
<< " trackFacei:" << trackFacei
<< " isGoodSample:" << isGoodSample
<< endl;
}
@ -478,7 +478,7 @@ Foam::Ostream& Foam::sampledSet::write(Ostream& os) const
{
coordSet::write(os);
os << endl << "\t(cellI)\t(faceI)" << endl;
os << endl << "\t(celli)\t(facei)" << endl;
forAll(*this, sampleI)
{

View File

@ -25,7 +25,7 @@ Class
Foam::sampledSet
Group
grpFunctionObjects
grpUtilitiesFunctionObjects
Description
Holds list of sampling points which is filled at construction time.
@ -101,38 +101,38 @@ protected:
//- Calculates inproduct of face normal and vector sample-face centre
// <0 if sample inside.
scalar calcSign(const label faceI, const point& sample) const;
scalar calcSign(const label facei, const point& sample) const;
//- Returns face label (or -1) of face which is close to sample
label findNearFace
(
const label cellI,
const label celli,
const point& sample,
const scalar smallDist
) const;
//- Moves sample in direction of -n to it is 'inside' of faceI
//- Moves sample in direction of -n to it is 'inside' of facei
point pushIn
(
const point& sample,
const label faceI
const label facei
) const;
//- Calculates start of tracking given samplePt and first boundary
// intersection
// (bPoint, bFaceI) (bFaceI == -1 if no boundary intersection)
// (bPoint, bFacei) (bFacei == -1 if no boundary intersection)
// Returns true if trackPt is valid sampling point. Sets trackPt,
// trackFaceI, trackCellI (-1 if no tracking point found)
// trackFacei, trackCelli (-1 if no tracking point found)
bool getTrackingPoint
(
const point& samplePt,
const point& bPoint,
const label bFaceI,
const label bFacei,
const scalar smallDist,
point& trackPt,
label& trackCellI,
label& trackFaceI
label& trackCelli,
label& trackFacei
) const;
//- Sets sample data
@ -217,7 +217,7 @@ public:
autoPtr<sampledSet> clone() const
{
NotImplemented;
return autoPtr<sampledSet>(NULL);
return autoPtr<sampledSet>(nullptr);
}

View File

@ -30,15 +30,25 @@ License
#include "ListListOps.H"
#include "SortableList.H"
#include "volPointInterpolation.H"
#include "mapPolyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(sampledSets, 0);
bool sampledSets::verbose_ = false;
addToRunTimeSelectionTable
(
functionObject,
sampledSets,
dictionary
);
}
bool Foam::sampledSets::verbose_ = false;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -128,6 +138,48 @@ void Foam::sampledSets::combineSampledSets
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledSets::sampledSets
(
const word& name,
const Time& t,
const dictionary& dict
)
:
functionObject(name),
PtrList<sampledSet>(),
mesh_
(
refCast<const fvMesh>
(
t.lookupObject<objectRegistry>
(
dict.lookupOrDefault("region", polyMesh::defaultRegion)
)
)
),
loadFromFiles_(false),
outputPath_(fileName::null),
searchEngine_(mesh_),
interpolationScheme_(word::null),
writeFormat_(word::null)
{
if (Pstream::parRun())
{
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name;
}
else
{
outputPath_ = mesh_.time().path()/"postProcessing"/name;
}
if (mesh_.name() != fvMesh::defaultRegion)
{
outputPath_ = outputPath_/mesh_.name();
}
read(dict);
}
Foam::sampledSets::sampledSets
(
const word& name,
@ -136,7 +188,7 @@ Foam::sampledSets::sampledSets
const bool loadFromFiles
)
:
functionObjectState(obr, name),
stateFunctionObject(obr, name),
PtrList<sampledSet>(),
mesh_(refCast<const fvMesh>(obr)),
loadFromFiles_(loadFromFiles),
@ -147,11 +199,11 @@ Foam::sampledSets::sampledSets
{
if (Pstream::parRun())
{
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name_;
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name;
}
else
{
outputPath_ = mesh_.time().path()/"postProcessing"/name_;
outputPath_ = mesh_.time().path()/"postProcessing"/name;
}
if (mesh_.name() != fvMesh::defaultRegion)
{
@ -176,25 +228,13 @@ void Foam::sampledSets::verbose(const bool verbosity)
}
void Foam::sampledSets::execute()
bool Foam::sampledSets::execute()
{
// Do nothing - only valid on write
return true;
}
void Foam::sampledSets::end()
{
// Do nothing - only valid on write
}
void Foam::sampledSets::timeSet()
{
// Do nothing - only valid on write
}
void Foam::sampledSets::write()
bool Foam::sampledSets::write()
{
if (size())
{
@ -218,7 +258,7 @@ void Foam::sampledSets::write()
{
Pout<< "Creating directory "
<< outputPath_/mesh_.time().timeName()
<< nl << endl;
<< nl << endl;
}
mkDir(outputPath_/mesh_.time().timeName());
@ -238,10 +278,12 @@ void Foam::sampledSets::write()
sampleAndWrite(tensorFields_);
}
}
return true;
}
void Foam::sampledSets::read(const dictionary& dict)
bool Foam::sampledSets::read(const dictionary& dict)
{
dict_ = dict;
@ -284,6 +326,8 @@ void Foam::sampledSets::read(const dictionary& dict)
}
Pout<< ")" << endl;
}
return true;
}
@ -305,15 +349,21 @@ void Foam::sampledSets::correct()
}
void Foam::sampledSets::updateMesh(const mapPolyMesh&)
void Foam::sampledSets::updateMesh(const mapPolyMesh& mpm)
{
correct();
if (&mpm.mesh() == &mesh_)
{
correct();
}
}
void Foam::sampledSets::movePoints(const polyMesh&)
void Foam::sampledSets::movePoints(const polyMesh& mesh)
{
correct();
if (&mesh == &mesh_)
{
correct();
}
}

View File

@ -36,7 +36,7 @@ SourceFiles
#ifndef sampledSets_H
#define sampledSets_H
#include "functionObjectState.H"
#include "regionFunctionObject.H"
#include "sampledSet.H"
#include "volFieldsFwd.H"
#include "meshSearch.H"
@ -50,6 +50,8 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
class Time;
class objectRegistry;
class dictionary;
class fvMesh;
@ -60,7 +62,7 @@ class fvMesh;
class sampledSets
:
public functionObjectState,
public regionFunctionObject,
public PtrList<sampledSet>
{
// Private classes
@ -80,7 +82,7 @@ class sampledSets
fieldGroup()
:
DynamicList<word>(0),
formatter(NULL)
formatter(nullptr)
{}
//- Construct for a particular format
@ -255,6 +257,14 @@ public:
// Constructors
//- Construct from Time and dictionary
sampledSets
(
const word& name,
const Time& time,
const dictionary& dict
);
//- Construct for given objectRegistry and dictionary
// allow the possibility to load fields from files
sampledSets
@ -275,20 +285,14 @@ public:
//- Set verbosity level
void verbose(const bool verbosity = true);
//- Read the sampledSets
virtual bool read(const dictionary&);
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Called when time was set at the end of the Time::operator++
virtual void timeSet();
virtual bool execute();
//- Sample and write
virtual void write();
//- Read the sampledSets
virtual void read(const dictionary&);
virtual bool write();
//- Correct for mesh changes
void correct();

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
@ -93,9 +93,9 @@ Foam::label Foam::sampledSets::classifyFields()
if (indices.size())
{
forAll(indices, fieldI)
forAll(indices, fieldi)
{
const word& fieldName = allFields[indices[fieldI]];
const word& fieldName = allFields[indices[fieldi]];
nFields += appendFieldGroup
(
@ -124,9 +124,9 @@ Foam::label Foam::sampledSets::classifyFields()
if (indices.size())
{
forAll(indices, fieldI)
forAll(indices, fieldi)
{
const word& fieldName = allFields[indices[fieldI]];
const word& fieldName = allFields[indices[fieldi]];
nFields += appendFieldGroup
(

View File

@ -54,10 +54,10 @@ Foam::sampledSets::volFieldSampler<Type>::volFieldSampler
forAll(samples, sampleI)
{
const point& samplePt = samples[sampleI];
label cellI = samples.cells()[sampleI];
label faceI = samples.faces()[sampleI];
label celli = samples.cells()[sampleI];
label facei = samples.faces()[sampleI];
if (cellI == -1 && faceI == -1)
if (celli == -1 && facei == -1)
{
// Special condition for illegal sampling points
values[sampleI] = pTraits<Type>::max;
@ -67,8 +67,8 @@ Foam::sampledSets::volFieldSampler<Type>::volFieldSampler
values[sampleI] = interpolator().interpolate
(
samplePt,
cellI,
faceI
celli,
facei
);
}
}
@ -94,15 +94,15 @@ Foam::sampledSets::volFieldSampler<Type>::volFieldSampler
values.setSize(samples.size());
forAll(samples, sampleI)
{
label cellI = samples.cells()[sampleI];
label celli = samples.cells()[sampleI];
if (cellI ==-1)
if (celli ==-1)
{
values[sampleI] = pTraits<Type>::max;
}
else
{
values[sampleI] = field[cellI];
values[sampleI] = field[celli];
}
}
}

View File

@ -1,34 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
functions
{
// Example of sampling on a line
lines
{
type sets;
functionObjectLibs ("libsampling.so");
outputControl outputTime;
setFormat gnuplot;
fields (p U);
interpolationScheme cellPoint;
sets
(
diagonal
{
type midPoint;
axis x;
start (-0.0206 -0.0254 -0.0005);
end (0.29 0.0254 0.0005);
}
);
}
}

View File

@ -1,42 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "sampledSetsFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(sampledSetsFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
sampledSetsFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -1,54 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Typedef
Foam::sampledSetsFunctionObject
Description
FunctionObject wrapper around sets to allow them to be created via the
functions entry within controlDict.
SourceFiles
sampledSetsFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef sampledSetsFunctionObject_H
#define sampledSetsFunctionObject_H
#include "sampledSets.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<sampledSets>
sampledSetsFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -53,12 +53,12 @@ void Foam::triSurfaceMeshPointSet::calcSamples
{
forAll(sampleCoords_, sampleI)
{
label cellI = searchEngine().findCell(sampleCoords_[sampleI]);
label celli = searchEngine().findCell(sampleCoords_[sampleI]);
if (cellI != -1)
if (celli != -1)
{
samplingPts.append(sampleCoords_[sampleI]);
samplingCells.append(cellI);
samplingCells.append(celli);
samplingFaces.append(-1);
samplingSegments.append(0);
samplingCurveDist.append(1.0 * sampleI);

View File

@ -149,7 +149,7 @@ bool Foam::uniformSet::trackToBoundary
{
Pout<< "Searching along trajectory from "
<< " trackPt:" << trackPt
<< " trackCellI:" << singleParticle.cell()
<< " trackCelli:" << singleParticle.cell()
<< " to:" << samplePt << endl;
}
@ -164,8 +164,8 @@ bool Foam::uniformSet::trackToBoundary
{
Pout<< "Result of tracking "
<< " trackPt:" << trackPt
<< " trackCellI:" << singleParticle.cell()
<< " trackFaceI:" << singleParticle.face()
<< " trackCelli:" << singleParticle.cell()
<< " trackFacei:" << singleParticle.face()
<< " onBoundary:" << singleParticle.onBoundary()
<< " samplePt:" << samplePt
<< " smallDist:" << smallDist
@ -245,34 +245,34 @@ void Foam::uniformSet::calcSamples
);
point bPoint(GREAT, GREAT, GREAT);
label bFaceI = -1;
label bFacei = -1;
if (bHits.size())
{
bPoint = bHits[0].hitPoint();
bFaceI = bHits[0].index();
bFacei = bHits[0].index();
}
// Get first tracking point. Use bPoint, bFaceI if provided.
// Get first tracking point. Use bPoint, bFacei if provided.
point trackPt;
label trackCellI = -1;
label trackFaceI = -1;
label trackCelli = -1;
label trackFacei = -1;
bool isSample =
getTrackingPoint
(
start_,
bPoint,
bFaceI,
bFacei,
smallDist,
trackPt,
trackCellI,
trackFaceI
trackCelli,
trackFacei
);
if (trackCellI == -1)
if (trackCelli == -1)
{
// Line start_ - end_ does not intersect domain at all.
// (or is along edge)
@ -286,8 +286,8 @@ void Foam::uniformSet::calcSamples
if (isSample)
{
samplingPts.append(start_);
samplingCells.append(trackCellI);
samplingFaces.append(trackFaceI);
samplingCells.append(trackCelli);
samplingFaces.append(trackFacei);
samplingCurveDist.append(0.0);
}
@ -310,7 +310,7 @@ void Foam::uniformSet::calcSamples
while(true)
{
// Initialize tracking starting from trackPt
passiveParticle singleParticle(mesh(), trackPt, trackCellI);
passiveParticle singleParticle(mesh(), trackPt, trackCelli);
bool reachedBoundary = trackToBoundary
(
@ -380,9 +380,9 @@ void Foam::uniformSet::calcSamples
}
// Update starting point for tracking
trackFaceI = bFaceI;
trackPt = pushIn(bPoint, trackFaceI);
trackCellI = getBoundaryCell(trackFaceI);
trackFacei = bFacei;
trackPt = pushIn(bPoint, trackFacei);
trackCelli = getBoundaryCell(trackFacei);
segmentI++;

View File

@ -76,7 +76,7 @@ class uniformSet
label& sampleI
) const;
//- Samples from startTrackPt/CellI. Updates particle/samplePt/sampleI
//- Samples from startTrackPt/Celli. Updates particle/samplePt/sampleI
// and puts
// samples in the DynamicLists. Returns false if end of all samples
// reached

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
@ -83,7 +83,7 @@ void Foam::distanceSurface::createGeometry()
// Internal field
{
const pointField& cc = fvm.C();
scalarField& fld = cellDistance.internalField();
scalarField& fld = cellDistance.primitiveFieldRef();
List<pointIndexHit> nearest;
surfPtr_().findNearest
@ -128,12 +128,15 @@ void Foam::distanceSurface::createGeometry()
}
}
volScalarField::Boundary& cellDistanceBf =
cellDistance.boundaryFieldRef();
// Patch fields
{
forAll(fvm.C().boundaryField(), patchI)
forAll(fvm.C().boundaryField(), patchi)
{
const pointField& cc = fvm.C().boundaryField()[patchI];
fvPatchScalarField& fld = cellDistance.boundaryField()[patchI];
const pointField& cc = fvm.C().boundaryField()[patchi];
fvPatchScalarField& fld = cellDistanceBf[patchi];
List<pointIndexHit> nearest;
surfPtr_().findNearest
@ -254,7 +257,7 @@ void Foam::distanceSurface::createGeometry()
pointMesh::New(fvm),
dimensionedScalar("zero", dimLength, 0)
);
pDist.internalField() = pointDistance_;
pDist.primitiveFieldRef() = pointDistance_;
Pout<< "Writing point distance:" << pDist.objectPath() << endl;
pDist.write();
@ -335,9 +338,9 @@ Foam::distanceSurface::distanceSurface
bounds_(dict.lookupOrDefault("bounds", boundBox::greatBox)),
zoneKey_(keyType::null),
needsUpdate_(true),
isoSurfCellPtr_(NULL),
isoSurfPtr_(NULL),
facesPtr_(NULL)
isoSurfCellPtr_(nullptr),
isoSurfPtr_(nullptr),
facesPtr_(nullptr)
{
// dict.readIfPresent("zone", zoneKey_);
//
@ -391,9 +394,9 @@ Foam::distanceSurface::distanceSurface
bounds_(bounds),
zoneKey_(keyType::null),
needsUpdate_(true),
isoSurfCellPtr_(NULL),
isoSurfPtr_(NULL),
facesPtr_(NULL)
isoSurfCellPtr_(nullptr),
isoSurfPtr_(nullptr),
facesPtr_(nullptr)
{}

View File

@ -139,27 +139,27 @@ void Foam::isoSurface::syncUnseparatedPoints
if (Pstream::parRun())
{
// Send
forAll(patches, patchI)
forAll(patches, patchi)
{
if
(
isA<processorPolyPatch>(patches[patchI])
&& patches[patchI].nPoints() > 0
&& collocatedPatch(patches[patchI])
isA<processorPolyPatch>(patches[patchi])
&& patches[patchi].nPoints() > 0
&& collocatedPatch(patches[patchi])
)
{
const processorPolyPatch& pp =
refCast<const processorPolyPatch>(patches[patchI]);
refCast<const processorPolyPatch>(patches[patchi]);
const labelList& meshPts = pp.meshPoints();
const labelList& nbrPts = pp.neighbPoints();
pointField patchInfo(meshPts.size());
forAll(nbrPts, pointI)
forAll(nbrPts, pointi)
{
label nbrPointI = nbrPts[pointI];
patchInfo[nbrPointI] = pointValues[meshPts[pointI]];
label nbrPointi = nbrPts[pointi];
patchInfo[nbrPointi] = pointValues[meshPts[pointi]];
}
OPstream toNbr(Pstream::blocking, pp.neighbProcNo());
@ -169,17 +169,17 @@ void Foam::isoSurface::syncUnseparatedPoints
// Receive and combine.
forAll(patches, patchI)
forAll(patches, patchi)
{
if
(
isA<processorPolyPatch>(patches[patchI])
&& patches[patchI].nPoints() > 0
&& collocatedPatch(patches[patchI])
isA<processorPolyPatch>(patches[patchi])
&& patches[patchi].nPoints() > 0
&& collocatedPatch(patches[patchi])
)
{
const processorPolyPatch& pp =
refCast<const processorPolyPatch>(patches[patchI]);
refCast<const processorPolyPatch>(patches[patchi]);
pointField nbrPatchInfo(pp.nPoints());
{
@ -191,13 +191,13 @@ void Foam::isoSurface::syncUnseparatedPoints
const labelList& meshPts = pp.meshPoints();
forAll(meshPts, pointI)
forAll(meshPts, pointi)
{
label meshPointI = meshPts[pointI];
label meshPointi = meshPts[pointi];
minEqOp<point>()
(
pointValues[meshPointI],
nbrPatchInfo[pointI]
pointValues[meshPointi],
nbrPatchInfo[pointi]
);
}
}
@ -205,12 +205,12 @@ void Foam::isoSurface::syncUnseparatedPoints
}
// Do the cyclics.
forAll(patches, patchI)
forAll(patches, patchi)
{
if (isA<cyclicPolyPatch>(patches[patchI]))
if (isA<cyclicPolyPatch>(patches[patchi]))
{
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(patches[patchI]);
refCast<const cyclicPolyPatch>(patches[patchi]);
if (cycPatch.owner() && collocatedPatch(cycPatch))
{
@ -254,9 +254,9 @@ void Foam::isoSurface::syncUnseparatedPoints
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]] = pointValues[meshPointI];
sharedPts[pd.sharedPointAddr()[i]] = pointValues[meshPointi];
}
// Combine on master.
@ -267,8 +267,8 @@ void Foam::isoSurface::syncUnseparatedPoints
// my local information.
forAll(pd.sharedPointLabels(), i)
{
label meshPointI = pd.sharedPointLabels()[i];
pointValues[meshPointI] = sharedPts[pd.sharedPointAddr()[i]];
label meshPointi = pd.sharedPointLabels()[i];
pointValues[meshPointi] = sharedPts[pd.sharedPointAddr()[i]];
}
}
}
@ -323,8 +323,8 @@ void Foam::isoSurface::getNeighbour
const labelList& boundaryRegion,
const volVectorField& meshC,
const volScalarField& cVals,
const label cellI,
const label faceI,
const label celli,
const label facei,
scalar& nbrValue,
point& nbrPoint
) const
@ -332,21 +332,21 @@ void Foam::isoSurface::getNeighbour
const labelList& own = mesh_.faceOwner();
const labelList& nei = mesh_.faceNeighbour();
if (mesh_.isInternalFace(faceI))
if (mesh_.isInternalFace(facei))
{
label nbr = (own[faceI] == cellI ? nei[faceI] : own[faceI]);
label nbr = (own[facei] == celli ? nei[facei] : own[facei]);
nbrValue = cVals[nbr];
nbrPoint = meshC[nbr];
}
else
{
label bFaceI = faceI-mesh_.nInternalFaces();
label patchI = boundaryRegion[bFaceI];
const polyPatch& pp = mesh_.boundaryMesh()[patchI];
label patchFaceI = faceI-pp.start();
label bFacei = facei-mesh_.nInternalFaces();
label patchi = boundaryRegion[bFacei];
const polyPatch& pp = mesh_.boundaryMesh()[patchi];
label patchFacei = facei-pp.start();
nbrValue = cVals.boundaryField()[patchI][patchFaceI];
nbrPoint = meshC.boundaryField()[patchI][patchFaceI];
nbrValue = cVals.boundaryField()[patchi][patchFacei];
nbrPoint = meshC.boundaryField()[patchi][patchFacei];
}
}
@ -366,10 +366,10 @@ void Foam::isoSurface::calcCutTypes
faceCutType_.setSize(mesh_.nFaces());
faceCutType_ = NOTCUT;
for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
{
// CC edge.
bool ownLower = (cVals[own[faceI]] < iso_);
bool ownLower = (cVals[own[facei]] < iso_);
scalar nbrValue;
point nbrPoint;
@ -378,8 +378,8 @@ void Foam::isoSurface::calcCutTypes
boundaryRegion,
meshC,
cVals,
own[faceI],
faceI,
own[facei],
facei,
nbrValue,
nbrPoint
);
@ -388,30 +388,30 @@ void Foam::isoSurface::calcCutTypes
if (ownLower != neiLower)
{
faceCutType_[faceI] = CUT;
faceCutType_[facei] = CUT;
}
else
{
// See if any mesh edge is cut by looping over all the edges of the
// face.
const face f = mesh_.faces()[faceI];
const face f = mesh_.faces()[facei];
if (isEdgeOfFaceCut(pVals, f, ownLower, neiLower))
{
faceCutType_[faceI] = CUT;
faceCutType_[facei] = CUT;
}
}
}
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
label faceI = pp.start();
label facei = pp.start();
forAll(pp, i)
{
bool ownLower = (cVals[own[faceI]] < iso_);
bool ownLower = (cVals[own[facei]] < iso_);
scalar nbrValue;
point nbrPoint;
@ -420,8 +420,8 @@ void Foam::isoSurface::calcCutTypes
boundaryRegion,
meshC,
cVals,
own[faceI],
faceI,
own[facei],
facei,
nbrValue,
nbrPoint
);
@ -430,20 +430,20 @@ void Foam::isoSurface::calcCutTypes
if (ownLower != neiLower)
{
faceCutType_[faceI] = CUT;
faceCutType_[facei] = CUT;
}
else
{
// Mesh edge.
const face f = mesh_.faces()[faceI];
const face f = mesh_.faces()[facei];
if (isEdgeOfFaceCut(pVals, f, ownLower, neiLower))
{
faceCutType_[faceI] = CUT;
faceCutType_[facei] = CUT;
}
}
faceI++;
facei++;
}
}
@ -453,29 +453,29 @@ void Foam::isoSurface::calcCutTypes
cellCutType_.setSize(mesh_.nCells());
cellCutType_ = NOTCUT;
for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
{
if (faceCutType_[faceI] != NOTCUT)
if (faceCutType_[facei] != NOTCUT)
{
if (cellCutType_[own[faceI]] == NOTCUT)
if (cellCutType_[own[facei]] == NOTCUT)
{
cellCutType_[own[faceI]] = CUT;
cellCutType_[own[facei]] = CUT;
nCutCells_++;
}
if (cellCutType_[nei[faceI]] == NOTCUT)
if (cellCutType_[nei[facei]] == NOTCUT)
{
cellCutType_[nei[faceI]] = CUT;
cellCutType_[nei[facei]] = CUT;
nCutCells_++;
}
}
}
for (label faceI = mesh_.nInternalFaces(); faceI < mesh_.nFaces(); faceI++)
for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
{
if (faceCutType_[faceI] != NOTCUT)
if (faceCutType_[facei] != NOTCUT)
{
if (cellCutType_[own[faceI]] == NOTCUT)
if (cellCutType_[own[facei]] == NOTCUT)
{
cellCutType_[own[faceI]] = CUT;
cellCutType_[own[facei]] = CUT;
nCutCells_++;
}
}
@ -492,6 +492,8 @@ void Foam::isoSurface::calcCutTypes
Foam::point Foam::isoSurface::calcCentre(const triSurface& s)
{
// Caculate centre of surface.
vector sum = Zero;
forAll(s, i)
@ -522,13 +524,13 @@ void Foam::isoSurface::calcSnappedCc
// Work arrays
DynamicList<point, 64> localTriPoints(64);
forAll(mesh_.cells(), cellI)
forAll(mesh_.cells(), celli)
{
if (cellCutType_[cellI] == CUT)
if (cellCutType_[celli] == CUT)
{
scalar cVal = cVals[cellI];
scalar cVal = cVals[celli];
const cell& cFaces = mesh_.cells()[cellI];
const cell& cFaces = mesh_.cells()[celli];
localTriPoints.clear();
label nOther = 0;
@ -537,9 +539,9 @@ void Foam::isoSurface::calcSnappedCc
// Create points for all intersections close to cell centre
// (i.e. from pyramid edges)
forAll(cFaces, cFaceI)
forAll(cFaces, cFacei)
{
label faceI = cFaces[cFaceI];
label facei = cFaces[cFacei];
scalar nbrValue;
point nbrPoint;
@ -548,8 +550,8 @@ void Foam::isoSurface::calcSnappedCc
boundaryRegion,
meshC,
cVals,
cellI,
faceI,
celli,
facei,
nbrValue,
nbrPoint
);
@ -560,21 +562,21 @@ void Foam::isoSurface::calcSnappedCc
// From cc to neighbour cc.
s[2] = isoFraction(cVal, nbrValue);
pt[2] = (1.0-s[2])*cc[cellI] + s[2]*nbrPoint;
pt[2] = (1.0-s[2])*cc[celli] + s[2]*nbrPoint;
const face& f = mesh_.faces()[cFaces[cFaceI]];
const face& f = mesh_.faces()[cFaces[cFacei]];
forAll(f, fp)
{
// From cc to fp
label p0 = f[fp];
s[0] = isoFraction(cVal, pVals[p0]);
pt[0] = (1.0-s[0])*cc[cellI] + s[0]*pts[p0];
pt[0] = (1.0-s[0])*cc[celli] + s[0]*pts[p0];
// From cc to fp+1
label p1 = f[f.fcIndex(fp)];
s[1] = isoFraction(cVal, pVals[p1]);
pt[1] = (1.0-s[1])*cc[cellI] + s[1]*pts[p1];
pt[1] = (1.0-s[1])*cc[celli] + s[1]*pts[p1];
if
(
@ -608,12 +610,12 @@ void Foam::isoSurface::calcSnappedCc
// points.
if (nOther > 0)
{
snappedCc[cellI] = snappedPoints.size();
snappedCc[celli] = snappedPoints.size();
snappedPoints.append(otherPointSum/nOther);
//Pout<< " point:" << pointI
// << " replacing coord:" << mesh_.points()[pointI]
// << " by average:" << collapsedPoint[pointI] << endl;
//Pout<< " point:" << pointi
// << " replacing coord:" << mesh_.points()[pointi]
// << " by average:" << collapsedPoint[pointi] << endl;
}
}
else if (localTriPoints.size() == 3)
@ -621,12 +623,12 @@ void Foam::isoSurface::calcSnappedCc
// Single triangle. No need for any analysis. Average points.
pointField points;
points.transfer(localTriPoints);
snappedCc[cellI] = snappedPoints.size();
snappedCc[celli] = snappedPoints.size();
snappedPoints.append(sum(points)/points.size());
//Pout<< " point:" << pointI
// << " replacing coord:" << mesh_.points()[pointI]
// << " by average:" << collapsedPoint[pointI] << endl;
//Pout<< " point:" << pointi
// << " replacing coord:" << mesh_.points()[pointi]
// << " by average:" << collapsedPoint[pointi] << endl;
}
else
{
@ -655,11 +657,11 @@ void Foam::isoSurface::calcSnappedCc
if (nZones == 1)
{
snappedCc[cellI] = snappedPoints.size();
snappedCc[celli] = snappedPoints.size();
snappedPoints.append(calcCentre(surf));
//Pout<< " point:" << pointI << " nZones:" << nZones
// << " replacing coord:" << mesh_.points()[pointI]
// << " by average:" << collapsedPoint[pointI] << endl;
//Pout<< " point:" << pointi << " nZones:" << nZones
// << " replacing coord:" << mesh_.points()[pointi]
// << " by average:" << collapsedPoint[pointi] << endl;
}
}
}
@ -688,22 +690,22 @@ void Foam::isoSurface::calcSnappedPoint
// Work arrays
DynamicList<point, 64> localTriPoints(100);
forAll(mesh_.pointFaces(), pointI)
forAll(mesh_.pointFaces(), pointi)
{
if (isBoundaryPoint.get(pointI) == 1)
if (isBoundaryPoint.get(pointi) == 1)
{
continue;
}
const labelList& pFaces = mesh_.pointFaces()[pointI];
const labelList& pFaces = mesh_.pointFaces()[pointi];
bool anyCut = false;
forAll(pFaces, i)
{
label faceI = pFaces[i];
label facei = pFaces[i];
if (faceCutType_[faceI] == CUT)
if (faceCutType_[facei] == CUT)
{
anyCut = true;
break;
@ -720,14 +722,14 @@ void Foam::isoSurface::calcSnappedPoint
label nOther = 0;
point otherPointSum = Zero;
forAll(pFaces, pFaceI)
forAll(pFaces, pFacei)
{
// Create points for all intersections close to point
// (i.e. from pyramid edges)
label faceI = pFaces[pFaceI];
const face& f = mesh_.faces()[faceI];
label own = mesh_.faceOwner()[faceI];
label facei = pFaces[pFacei];
const face& f = mesh_.faces()[facei];
label own = mesh_.faceOwner()[facei];
// Get neighbour value
scalar nbrValue;
@ -738,7 +740,7 @@ void Foam::isoSurface::calcSnappedPoint
meshC,
cVals,
own,
faceI,
facei,
nbrValue,
nbrPoint
);
@ -747,20 +749,20 @@ void Foam::isoSurface::calcSnappedPoint
FixedList<scalar, 4> s;
FixedList<point, 4> pt;
label fp = findIndex(f, pointI);
s[0] = isoFraction(pVals[pointI], cVals[own]);
pt[0] = (1.0-s[0])*pts[pointI] + s[0]*cc[own];
label fp = findIndex(f, pointi);
s[0] = isoFraction(pVals[pointi], cVals[own]);
pt[0] = (1.0-s[0])*pts[pointi] + s[0]*cc[own];
s[1] = isoFraction(pVals[pointI], nbrValue);
pt[1] = (1.0-s[1])*pts[pointI] + s[1]*nbrPoint;
s[1] = isoFraction(pVals[pointi], nbrValue);
pt[1] = (1.0-s[1])*pts[pointi] + s[1]*nbrPoint;
label nextPointI = f[f.fcIndex(fp)];
s[2] = isoFraction(pVals[pointI], pVals[nextPointI]);
pt[2] = (1.0-s[2])*pts[pointI] + s[2]*pts[nextPointI];
label nextPointi = f[f.fcIndex(fp)];
s[2] = isoFraction(pVals[pointi], pVals[nextPointi]);
pt[2] = (1.0-s[2])*pts[pointi] + s[2]*pts[nextPointi];
label prevPointI = f[f.rcIndex(fp)];
s[3] = isoFraction(pVals[pointI], pVals[prevPointI]);
pt[3] = (1.0-s[3])*pts[pointI] + s[3]*pts[prevPointI];
label prevPointi = f[f.rcIndex(fp)];
s[3] = isoFraction(pVals[pointi], pVals[prevPointi]);
pt[3] = (1.0-s[3])*pts[pointi] + s[3]*pts[prevPointi];
if
(
@ -802,7 +804,7 @@ void Foam::isoSurface::calcSnappedPoint
// points.
if (nOther > 0)
{
collapsedPoint[pointI] = otherPointSum/nOther;
collapsedPoint[pointi] = otherPointSum/nOther;
}
}
else if (localTriPoints.size() == 3)
@ -810,7 +812,7 @@ void Foam::isoSurface::calcSnappedPoint
// Single triangle. No need for any analysis. Average points.
pointField points;
points.transfer(localTriPoints);
collapsedPoint[pointI] = sum(points)/points.size();
collapsedPoint[pointi] = sum(points)/points.size();
}
else
{
@ -839,7 +841,7 @@ void Foam::isoSurface::calcSnappedPoint
if (nZones == 1)
{
collapsedPoint[pointI] = calcCentre(surf);
collapsedPoint[pointi] = calcCentre(surf);
}
}
}
@ -852,12 +854,12 @@ void Foam::isoSurface::calcSnappedPoint
snappedPoint.setSize(mesh_.nPoints());
snappedPoint = -1;
forAll(collapsedPoint, pointI)
forAll(collapsedPoint, pointi)
{
if (collapsedPoint[pointI] != point::max)
if (collapsedPoint[pointi] != point::max)
{
snappedPoint[pointI] = snappedPoints.size();
snappedPoints.append(collapsedPoint[pointI]);
snappedPoint[pointi] = snappedPoints.size();
snappedPoints.append(collapsedPoint[pointi]);
}
}
}
@ -919,19 +921,19 @@ Foam::triSurface Foam::isoSurface::stitchTriPoints
List<labelledTri> tris;
{
DynamicList<labelledTri> dynTris(nTris);
label rawPointI = 0;
label rawPointi = 0;
DynamicList<label> newToOldTri(nTris);
for (label oldTriI = 0; oldTriI < nTris; oldTriI++)
{
labelledTri tri
(
triPointReverseMap[rawPointI],
triPointReverseMap[rawPointI+1],
triPointReverseMap[rawPointI+2],
triPointReverseMap[rawPointi],
triPointReverseMap[rawPointi+1],
triPointReverseMap[rawPointi+2],
0
);
rawPointI += 3;
rawPointi += 3;
if ((tri[0] != tri[1]) && (tri[0] != tri[2]) && (tri[1] != tri[2]))
{
@ -1004,30 +1006,30 @@ Foam::triSurface Foam::isoSurface::stitchTriPoints
{
triSurface surf(tris, geometricSurfacePatchList(0), newPoints);
forAll(surf, faceI)
forAll(surf, facei)
{
const labelledTri& f = surf[faceI];
const labelList& fFaces = surf.faceFaces()[faceI];
const labelledTri& f = surf[facei];
const labelList& fFaces = surf.faceFaces()[facei];
forAll(fFaces, i)
{
label nbrFaceI = fFaces[i];
label nbrFacei = fFaces[i];
if (nbrFaceI <= faceI)
if (nbrFacei <= facei)
{
// lower numbered faces already checked
continue;
}
const labelledTri& nbrF = surf[nbrFaceI];
const labelledTri& nbrF = surf[nbrFacei];
if (f == nbrF)
{
FatalErrorInFunction
<< "Check : "
<< " triangle " << faceI << " vertices " << f
<< " triangle " << facei << " vertices " << f
<< " fc:" << f.centre(surf.points())
<< " has the same vertices as triangle " << nbrFaceI
<< " has the same vertices as triangle " << nbrFacei
<< " vertices " << nbrF
<< " fc:" << nbrF.centre(surf.points())
<< abort(FatalError);
@ -1259,7 +1261,7 @@ bool Foam::isoSurface::validTri(const triSurface& surf, const label faceI)
{
// Simple check on indices ok.
const labelledTri& f = surf[faceI];
const labelledTri& f = surf[facei];
if
(
@ -1269,7 +1271,7 @@ bool Foam::isoSurface::validTri(const triSurface& surf, const label faceI)
)
{
WarningInFunction
<< "triangle " << faceI << " vertices " << f
<< "triangle " << facei << " vertices " << f
<< " uses point indices outside point range 0.."
<< surf.points().size()-1 << endl;
@ -1279,7 +1281,7 @@ bool Foam::isoSurface::validTri(const triSurface& surf, const label faceI)
if ((f[0] == f[1]) || (f[0] == f[2]) || (f[1] == f[2]))
{
WarningInFunction
<< "triangle " << faceI
<< "triangle " << facei
<< " uses non-unique vertices " << f
<< endl;
return false;
@ -1287,21 +1289,21 @@ bool Foam::isoSurface::validTri(const triSurface& surf, const label faceI)
// duplicate triangle check
const labelList& fFaces = surf.faceFaces()[faceI];
const labelList& fFaces = surf.faceFaces()[facei];
// Check if faceNeighbours use same points as this face.
// Note: discards normal information - sides of baffle are merged.
forAll(fFaces, i)
{
label nbrFaceI = fFaces[i];
label nbrFacei = fFaces[i];
if (nbrFaceI <= faceI)
if (nbrFacei <= facei)
{
// lower numbered faces already checked
continue;
}
const labelledTri& nbrF = surf[nbrFaceI];
const labelledTri& nbrF = surf[nbrFacei];
if
(
@ -1311,9 +1313,9 @@ bool Foam::isoSurface::validTri(const triSurface& surf, const label faceI)
)
{
WarningInFunction
<< "triangle " << faceI << " vertices " << f
<< "triangle " << facei << " vertices " << f
<< " fc:" << f.centre(surf.points())
<< " has the same vertices as triangle " << nbrFaceI
<< " has the same vertices as triangle " << nbrFacei
<< " vertices " << nbrF
<< " fc:" << nbrF.centre(surf.points())
<< endl;
@ -1348,7 +1350,7 @@ Foam::triSurface Foam::isoSurface::subsetMesh
oldToNewPoints.setSize(s.points().size());
oldToNewPoints = -1;
{
label pointI = 0;
label pointi = 0;
forAll(include, oldFacei)
{
@ -1359,17 +1361,17 @@ Foam::triSurface Foam::isoSurface::subsetMesh
forAll(tri, fp)
{
label oldPointI = tri[fp];
label oldPointi = tri[fp];
if (oldToNewPoints[oldPointI] == -1)
if (oldToNewPoints[oldPointi] == -1)
{
oldToNewPoints[oldPointI] = pointI;
newToOldPoints[pointI++] = oldPointI;
oldToNewPoints[oldPointi] = pointi;
newToOldPoints[pointi++] = oldPointi;
}
}
}
}
newToOldPoints.setSize(pointI);
newToOldPoints.setSize(pointi);
}
// Extract points
@ -1405,7 +1407,6 @@ Foam::isoSurface::isoSurface
const scalarField& pVals,
const scalar iso,
const bool regularise,
const boundBox& bounds,
const scalar mergeTol
)
:
@ -1413,7 +1414,6 @@ Foam::isoSurface::isoSurface
pVals_(pVals),
iso_(iso),
regularise_(regularise),
bounds_(bounds),
mergeDistance_(mergeTol*mesh_.bounds().mag())
{
if (debug)
@ -1421,8 +1421,8 @@ Foam::isoSurface::isoSurface
Pout<< "isoSurface:" << nl
<< " isoField : " << cVals.name() << nl
<< " cell min/max : "
<< min(cVals.internalField()) << " / "
<< max(cVals.internalField()) << nl
<< min(cVals.primitiveField()) << " / "
<< max(cVals.primitiveField()) << nl
<< " point min/max : "
<< min(pVals_) << " / "
<< max(pVals_) << nl
@ -1465,16 +1465,16 @@ Foam::isoSurface::isoSurface
mesh_.cellCentres(),
mesh_.faceCentres()
);
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
// Adapt separated coupled (proc and cyclic) patches
if (pp.coupled())
{
fvPatchVectorField& pfld = const_cast<fvPatchVectorField&>
(
meshC.boundaryField()[patchI]
meshC.boundaryField()[patchi]
);
PackedBoolList isCollocated
@ -1492,26 +1492,26 @@ Foam::isoSurface::isoSurface
}
else if (isA<emptyPolyPatch>(pp))
{
typedef slicedVolVectorField::GeometricBoundaryField bType;
typedef slicedVolVectorField::Boundary bType;
bType& bfld = const_cast<bType&>(meshC.boundaryField());
// Clear old value. Cannot resize it since is a slice.
bfld.set(patchI, NULL);
bfld.set(patchi, nullptr);
// Set new value we can change
bfld.set
(
patchI,
patchi,
new calculatedFvPatchField<vector>
(
mesh_.boundary()[patchI],
mesh_.boundary()[patchi],
meshC
)
);
// Change to face centres
bfld[patchI] = pp.patchSlice(mesh_.faceCentres());
bfld[patchi] = pp.patchSlice(mesh_.faceCentres());
}
}
@ -1520,16 +1520,16 @@ Foam::isoSurface::isoSurface
// Pre-calculate patch-per-face to avoid whichPatch call.
labelList boundaryRegion(mesh_.nFaces()-mesh_.nInternalFaces());
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
label faceI = pp.start();
label facei = pp.start();
forAll(pp, i)
{
boundaryRegion[faceI-mesh_.nInternalFaces()] = patchI;
faceI++;
boundaryRegion[facei-mesh_.nInternalFaces()] = patchi;
facei++;
}
}
@ -1580,17 +1580,17 @@ Foam::isoSurface::isoSurface
// Determine if point is on boundary.
PackedBoolList isBoundaryPoint(mesh_.nPoints());
forAll(patches, patchI)
forAll(patches, patchi)
{
// Mark all boundary points that are not physically coupled
// (so anything but collocated coupled patches)
if (patches[patchI].coupled())
if (patches[patchi].coupled())
{
const coupledPolyPatch& cpp =
refCast<const coupledPolyPatch>
(
patches[patchI]
patches[patchi]
);
PackedBoolList isCollocated(collocatedFaces(cpp));
@ -1610,7 +1610,7 @@ Foam::isoSurface::isoSurface
}
else
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
forAll(pp, i)
{

View File

@ -192,8 +192,8 @@ class isoSurface
const labelList& boundaryRegion,
const volVectorField& meshC,
const volScalarField& cVals,
const label cellI,
const label faceI,
const label celli,
const label facei,
scalar& nbrValue,
point& nbrPoint
) const;
@ -301,7 +301,7 @@ class isoSurface
const DynamicList<Type>& snappedPoints,
const labelList& snappedCc,
const labelList& snappedPoint,
const label faceI,
const label facei,
const scalar neiVal,
const Type& neiPt,

View File

@ -82,16 +82,16 @@ Foam::isoSurfaceCell::cellCutType Foam::isoSurfaceCell::calcCutType
const PackedBoolList& isTet,
const scalarField& cellValues,
const scalarField& pointValues,
const label cellI
const label celli
) const
{
const cell& cFaces = mesh_.cells()[cellI];
const cell& cFaces = mesh_.cells()[celli];
if (isTet.get(cellI) == 1)
if (isTet.get(celli) == 1)
{
forAll(cFaces, cFaceI)
forAll(cFaces, cFacei)
{
const face& f = mesh_.faces()[cFaces[cFaceI]];
const face& f = mesh_.faces()[cFaces[cFacei]];
for (label fp = 1; fp < f.size() - 1; fp++)
{
@ -107,15 +107,15 @@ Foam::isoSurfaceCell::cellCutType Foam::isoSurfaceCell::calcCutType
}
else
{
bool cellLower = (cellValues[cellI] < iso_);
bool cellLower = (cellValues[celli] < iso_);
// First check if there is any cut in cell
bool edgeCut = false;
forAll(cFaces, cFaceI)
forAll(cFaces, cFacei)
{
label faceI = cFaces[cFaceI];
const face& f = mesh_.faces()[faceI];
label facei = cFaces[cFacei];
const face& f = mesh_.faces()[facei];
// Check pyramids cut
forAll(f, fp)
@ -132,7 +132,7 @@ Foam::isoSurfaceCell::cellCutType Foam::isoSurfaceCell::calcCutType
break;
}
const label fp0 = mesh_.tetBasePtIs()[faceI];
const label fp0 = mesh_.tetBasePtIs()[facei];
label fp = f.fcIndex(fp0);
for (label i = 2; i < f.size(); i++)
{
@ -159,7 +159,7 @@ Foam::isoSurfaceCell::cellCutType Foam::isoSurfaceCell::calcCutType
// Note: not needed if you don't want to preserve maxima/minima
// centred around cellcentre. In that case just always return CUT
const labelList& cPoints = mesh_.cellPoints(cellI);
const labelList& cPoints = mesh_.cellPoints(celli);
label nPyrCuts = 0;
@ -197,11 +197,11 @@ void Foam::isoSurfaceCell::calcCutTypes
{
cellCutType_.setSize(mesh_.nCells());
nCutCells_ = 0;
forAll(mesh_.cells(), cellI)
forAll(mesh_.cells(), celli)
{
cellCutType_[cellI] = calcCutType(isTet, cVals, pVals, cellI);
cellCutType_[celli] = calcCutType(isTet, cVals, pVals, celli);
if (cellCutType_[cellI] == CUT)
if (cellCutType_[celli] == CUT)
{
nCutCells_++;
}
@ -265,7 +265,7 @@ Foam::point Foam::isoSurfaceCell::calcCentre(const triSurface& s)
Foam::pointIndexHit Foam::isoSurfaceCell::collapseSurface
(
const label cellI,
const label celli,
pointField& localPoints,
DynamicList<labelledTri, 64>& localTris
) const
@ -377,13 +377,13 @@ void Foam::isoSurfaceCell::calcSnappedCc
DynamicList<labelledTri, 64> localTris(64);
Map<label> pointToLocal(64);
forAll(mesh_.cells(), cellI)
forAll(mesh_.cells(), celli)
{
if (cellCutType_[cellI] == CUT && isTet.get(cellI) == 0)
if (cellCutType_[celli] == CUT && isTet.get(celli) == 0)
{
scalar cVal = cVals[cellI];
scalar cVal = cVals[celli];
const cell& cFaces = mesh_.cells()[cellI];
const cell& cFaces = mesh_.cells()[celli];
localPoints.clear();
localTris.clear();
@ -392,21 +392,21 @@ void Foam::isoSurfaceCell::calcSnappedCc
// Create points for all intersections close to cell centre
// (i.e. from pyramid edges)
forAll(cFaces, cFaceI)
forAll(cFaces, cFacei)
{
const face& f = mesh_.faces()[cFaces[cFaceI]];
const face& f = mesh_.faces()[cFaces[cFacei]];
forAll(f, fp)
{
label pointI = f[fp];
label pointi = f[fp];
scalar s = isoFraction(cVal, pVals[pointI]);
scalar s = isoFraction(cVal, pVals[pointi]);
if (s >= 0.0 && s <= 0.5)
{
if (pointToLocal.insert(pointI, localPoints.size()))
if (pointToLocal.insert(pointi, localPoints.size()))
{
localPoints.append((1.0-s)*cc[cellI]+s*pts[pointI]);
localPoints.append((1.0-s)*cc[celli]+s*pts[pointi]);
}
}
}
@ -415,40 +415,40 @@ void Foam::isoSurfaceCell::calcSnappedCc
if (localPoints.size() == 1)
{
// No need for any analysis.
snappedCc[cellI] = snappedPoints.size();
snappedCc[celli] = snappedPoints.size();
snappedPoints.append(localPoints[0]);
//Pout<< "cell:" << cellI
// << " at " << mesh_.cellCentres()[cellI]
//Pout<< "cell:" << celli
// << " at " << mesh_.cellCentres()[celli]
// << " collapsing " << localPoints
// << " intersections down to "
// << snappedPoints[snappedCc[cellI]] << endl;
// << snappedPoints[snappedCc[celli]] << endl;
}
else if (localPoints.size() == 2)
{
//? No need for any analysis.???
snappedCc[cellI] = snappedPoints.size();
snappedCc[celli] = snappedPoints.size();
snappedPoints.append(0.5*(localPoints[0]+localPoints[1]));
//Pout<< "cell:" << cellI
// << " at " << mesh_.cellCentres()[cellI]
//Pout<< "cell:" << celli
// << " at " << mesh_.cellCentres()[celli]
// << " collapsing " << localPoints
// << " intersections down to "
// << snappedPoints[snappedCc[cellI]] << endl;
// << snappedPoints[snappedCc[celli]] << endl;
}
else if (localPoints.size())
{
// Need to analyse
forAll(cFaces, cFaceI)
forAll(cFaces, cFacei)
{
label faceI = cFaces[cFaceI];
const face& f = mesh_.faces()[faceI];
label facei = cFaces[cFacei];
const face& f = mesh_.faces()[facei];
// Do a tetrahedralisation. Each face to cc becomes pyr.
// Each pyr gets split into tets by diagonalisation
// of face.
const label fp0 = mesh_.tetBasePtIs()[faceI];
const label fp0 = mesh_.tetBasePtIs()[facei];
label fp = f.fcIndex(fp0);
for (label i = 2; i < f.size(); i++)
{
@ -470,7 +470,7 @@ void Foam::isoSurfaceCell::calcSnappedCc
{
if
(
(mesh_.faceOwner()[faceI] == cellI)
(mesh_.faceOwner()[facei] == celli)
== (cVal >= pVals[tri[0]])
)
{
@ -508,21 +508,21 @@ void Foam::isoSurfaceCell::calcSnappedCc
surfPoints.transfer(localPoints);
pointIndexHit info = collapseSurface
(
cellI,
celli,
surfPoints,
localTris
);
if (info.hit())
{
snappedCc[cellI] = snappedPoints.size();
snappedCc[celli] = snappedPoints.size();
snappedPoints.append(info.hitPoint());
//Pout<< "cell:" << cellI
// << " at " << mesh_.cellCentres()[cellI]
//Pout<< "cell:" << celli
// << " at " << mesh_.cellCentres()[celli]
// << " collapsing " << surfPoints
// << " intersections down to "
// << snappedPoints[snappedCc[cellI]] << endl;
// << snappedPoints[snappedCc[celli]] << endl;
}
}
}
@ -534,24 +534,24 @@ void Foam::isoSurfaceCell::genPointTris
(
const scalarField& cellValues,
const scalarField& pointValues,
const label pointI,
const label faceI,
const label cellI,
const label pointi,
const label facei,
const label celli,
DynamicList<point, 64>& localTriPoints
) const
{
const pointField& cc = mesh_.cellCentres();
const pointField& pts = mesh_.points();
const face& f = mesh_.faces()[faceI];
const face& f = mesh_.faces()[facei];
const label fp0 = mesh_.tetBasePtIs()[faceI];
const label fp0 = mesh_.tetBasePtIs()[facei];
label fp = f.fcIndex(fp0);
for (label i = 2; i < f.size(); i++)
{
label nextFp = f.fcIndex(fp);
triFace tri(f[fp0], f[fp], f[nextFp]);
label index = findIndex(tri, pointI);
label index = findIndex(tri, pointi);
if (index == -1)
{
@ -564,9 +564,9 @@ void Foam::isoSurfaceCell::genPointTris
// Get fractions for the three edges emanating from point
FixedList<scalar, 3> s(3);
s[0] = isoFraction(pointValues[pointI], pointValues[b]);
s[1] = isoFraction(pointValues[pointI], pointValues[c]);
s[2] = isoFraction(pointValues[pointI], cellValues[cellI]);
s[0] = isoFraction(pointValues[pointi], pointValues[b]);
s[1] = isoFraction(pointValues[pointi], pointValues[c]);
s[2] = isoFraction(pointValues[pointi], cellValues[celli]);
if
(
@ -575,14 +575,14 @@ void Foam::isoSurfaceCell::genPointTris
&& (s[2] >= 0.0 && s[2] <= 0.5)
)
{
point p0 = (1.0-s[0])*pts[pointI] + s[0]*pts[b];
point p1 = (1.0-s[1])*pts[pointI] + s[1]*pts[c];
point p2 = (1.0-s[2])*pts[pointI] + s[2]*cc[cellI];
point p0 = (1.0-s[0])*pts[pointi] + s[0]*pts[b];
point p1 = (1.0-s[1])*pts[pointi] + s[1]*pts[c];
point p2 = (1.0-s[2])*pts[pointi] + s[2]*cc[celli];
if
(
(mesh_.faceOwner()[faceI] == cellI)
== (pointValues[pointI] > cellValues[cellI])
(mesh_.faceOwner()[facei] == celli)
== (pointValues[pointi] > cellValues[celli])
)
{
localTriPoints.append(p0);
@ -605,37 +605,37 @@ void Foam::isoSurfaceCell::genPointTris
void Foam::isoSurfaceCell::genPointTris
(
const scalarField& pointValues,
const label pointI,
const label faceI,
const label cellI,
const label pointi,
const label facei,
const label celli,
DynamicList<point, 64>& localTriPoints
) const
{
const pointField& pts = mesh_.points();
const cell& cFaces = mesh_.cells()[cellI];
const cell& cFaces = mesh_.cells()[celli];
FixedList<label, 4> tet;
// Make tet from this face to the 4th point (same as cellcentre in
// non-tet cells)
const face& f = mesh_.faces()[faceI];
const face& f = mesh_.faces()[facei];
// Find 4th point
label ccPointI = -1;
forAll(cFaces, cFaceI)
label ccPointi = -1;
forAll(cFaces, cFacei)
{
const face& f1 = mesh_.faces()[cFaces[cFaceI]];
const face& f1 = mesh_.faces()[cFaces[cFacei]];
forAll(f1, fp)
{
label p1 = f1[fp];
if (findIndex(f, p1) == -1)
{
ccPointI = p1;
ccPointi = p1;
break;
}
}
if (ccPointI != -1)
if (ccPointi != -1)
{
break;
}
@ -643,18 +643,18 @@ void Foam::isoSurfaceCell::genPointTris
// Tet between index..index-1, index..index+1, index..cc
label index = findIndex(f, pointI);
label index = findIndex(f, pointi);
label b = f[f.fcIndex(index)];
label c = f[f.rcIndex(index)];
//Pout<< " p0:" << pointI << " b:" << b << " c:" << c
//<< " d:" << ccPointI << endl;
//Pout<< " p0:" << pointi << " b:" << b << " c:" << c
//<< " d:" << ccPointi << endl;
// Get fractions for the three edges emanating from point
FixedList<scalar, 3> s(3);
s[0] = isoFraction(pointValues[pointI], pointValues[b]);
s[1] = isoFraction(pointValues[pointI], pointValues[c]);
s[2] = isoFraction(pointValues[pointI], pointValues[ccPointI]);
s[0] = isoFraction(pointValues[pointi], pointValues[b]);
s[1] = isoFraction(pointValues[pointi], pointValues[c]);
s[2] = isoFraction(pointValues[pointi], pointValues[ccPointi]);
if
(
@ -663,11 +663,11 @@ void Foam::isoSurfaceCell::genPointTris
&& (s[2] >= 0.0 && s[2] <= 0.5)
)
{
point p0 = (1.0-s[0])*pts[pointI] + s[0]*pts[b];
point p1 = (1.0-s[1])*pts[pointI] + s[1]*pts[c];
point p2 = (1.0-s[2])*pts[pointI] + s[2]*pts[ccPointI];
point p0 = (1.0-s[0])*pts[pointi] + s[0]*pts[b];
point p1 = (1.0-s[1])*pts[pointi] + s[1]*pts[c];
point p2 = (1.0-s[2])*pts[pointi] + s[2]*pts[ccPointi];
if (mesh_.faceOwner()[faceI] != cellI)
if (mesh_.faceOwner()[facei] != celli)
{
localTriPoints.append(p0);
localTriPoints.append(p1);
@ -697,16 +697,16 @@ void Foam::isoSurfaceCell::calcSnappedPoint
// snapped. Coupled boundaries are handled explicitly so not marked here.
PackedBoolList isBoundaryPoint(mesh_.nPoints());
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
if (!pp.coupled())
{
label faceI = pp.start();
label facei = pp.start();
forAll(pp, i)
{
const face& f = mesh_.faces()[faceI++];
const face& f = mesh_.faces()[facei++];
forAll(f, fp)
{
@ -726,27 +726,27 @@ void Foam::isoSurfaceCell::calcSnappedPoint
DynamicList<point, 64> localTriPoints(100);
labelHashSet localPointCells(100);
forAll(mesh_.pointFaces(), pointI)
forAll(mesh_.pointFaces(), pointi)
{
if (isBoundaryPoint.get(pointI) == 1)
if (isBoundaryPoint.get(pointi) == 1)
{
continue;
}
const labelList& pFaces = mesh_.pointFaces()[pointI];
const labelList& pFaces = mesh_.pointFaces()[pointi];
bool anyCut = false;
forAll(pFaces, i)
{
label faceI = pFaces[i];
label facei = pFaces[i];
if
(
cellCutType_[mesh_.faceOwner()[faceI]] == CUT
cellCutType_[mesh_.faceOwner()[facei]] == CUT
|| (
mesh_.isInternalFace(faceI)
&& cellCutType_[mesh_.faceNeighbour()[faceI]] == CUT
mesh_.isInternalFace(facei)
&& cellCutType_[mesh_.faceNeighbour()[facei]] == CUT
)
)
{
@ -766,10 +766,10 @@ void Foam::isoSurfaceCell::calcSnappedPoint
localPointCells.clear();
localTriPoints.clear();
forAll(pFaces, pFaceI)
forAll(pFaces, pFacei)
{
label faceI = pFaces[pFaceI];
label own = mesh_.faceOwner()[faceI];
label facei = pFaces[pFacei];
label own = mesh_.faceOwner()[facei];
if (isTet.get(own) == 1)
{
@ -777,7 +777,7 @@ void Foam::isoSurfaceCell::calcSnappedPoint
// we only generate a triangle once per point.
if (localPointCells.insert(own))
{
genPointTris(pVals, pointI, faceI, own, localTriPoints);
genPointTris(pVals, pointi, facei, own, localTriPoints);
}
}
else
@ -786,22 +786,22 @@ void Foam::isoSurfaceCell::calcSnappedPoint
(
cVals,
pVals,
pointI,
faceI,
pointi,
facei,
own,
localTriPoints
);
}
if (mesh_.isInternalFace(faceI))
if (mesh_.isInternalFace(facei))
{
label nei = mesh_.faceNeighbour()[faceI];
label nei = mesh_.faceNeighbour()[facei];
if (isTet.get(nei) == 1)
{
if (localPointCells.insert(nei))
{
genPointTris(pVals, pointI, faceI, nei, localTriPoints);
genPointTris(pVals, pointi, facei, nei, localTriPoints);
}
}
else
@ -810,8 +810,8 @@ void Foam::isoSurfaceCell::calcSnappedPoint
(
cVals,
pVals,
pointI,
faceI,
pointi,
facei,
nei,
localTriPoints
);
@ -824,11 +824,11 @@ void Foam::isoSurfaceCell::calcSnappedPoint
// Single triangle. No need for any analysis. Average points.
pointField points;
points.transfer(localTriPoints);
collapsedPoint[pointI] = sum(points)/points.size();
collapsedPoint[pointi] = sum(points)/points.size();
//Pout<< " point:" << pointI
// << " replacing coord:" << mesh_.points()[pointI]
// << " by average:" << collapsedPoint[pointI] << endl;
//Pout<< " point:" << pointi
// << " replacing coord:" << mesh_.points()[pointi]
// << " by average:" << collapsedPoint[pointi] << endl;
}
else if (localTriPoints.size())
{
@ -871,7 +871,7 @@ void Foam::isoSurfaceCell::calcSnappedPoint
}
if (minCos > 0)
{
collapsedPoint[pointI] = calcCentre(surf);
collapsedPoint[pointi] = calcCentre(surf);
}
}
}
@ -888,14 +888,14 @@ void Foam::isoSurfaceCell::calcSnappedPoint
snappedPoint.setSize(mesh_.nPoints());
snappedPoint = -1;
forAll(collapsedPoint, pointI)
forAll(collapsedPoint, pointi)
{
// Cannot do == comparison since might be transformed so have
// truncation errors.
if (magSqr(collapsedPoint[pointI]) < 0.5*magSqr(greatPoint))
if (magSqr(collapsedPoint[pointi]) < 0.5*magSqr(greatPoint))
{
snappedPoint[pointI] = snappedPoints.size();
snappedPoints.append(collapsedPoint[pointI]);
snappedPoint[pointi] = snappedPoints.size();
snappedPoints.append(collapsedPoint[pointi]);
}
}
}
@ -960,16 +960,16 @@ Foam::triSurface Foam::isoSurfaceCell::stitchTriPoints
List<labelledTri> tris;
{
DynamicList<labelledTri> dynTris(nTris);
label rawPointI = 0;
label rawPointi = 0;
DynamicList<label> newToOldTri(nTris);
for (label oldTriI = 0; oldTriI < nTris; oldTriI++)
{
labelledTri tri
(
triPointReverseMap[rawPointI],
triPointReverseMap[rawPointI+1],
triPointReverseMap[rawPointI+2],
triPointReverseMap[rawPointi],
triPointReverseMap[rawPointi+1],
triPointReverseMap[rawPointi+2],
0
);
if ((tri[0] != tri[1]) && (tri[0] != tri[2]) && (tri[1] != tri[2]))
@ -978,7 +978,7 @@ Foam::triSurface Foam::isoSurfaceCell::stitchTriPoints
dynTris.append(tri);
}
rawPointI += 3;
rawPointi += 3;
}
triMap.transfer(newToOldTri);
@ -1049,18 +1049,18 @@ Foam::triSurface Foam::isoSurfaceCell::stitchTriPoints
}
bool Foam::isoSurfaceCell::validTri(const triSurface& surf, const label faceI)
bool Foam::isoSurfaceCell::validTri(const triSurface& surf, const label facei)
{
// Simple check on indices ok.
const labelledTri& f = surf[faceI];
const labelledTri& f = surf[facei];
forAll(f, fp)
{
if (f[fp] < 0 || f[fp] >= surf.points().size())
{
WarningInFunction
<< "triangle " << faceI << " vertices " << f
<< "triangle " << facei << " vertices " << f
<< " uses point indices outside point range 0.."
<< surf.points().size()-1 << endl;
@ -1071,7 +1071,7 @@ bool Foam::isoSurfaceCell::validTri(const triSurface& surf, const label faceI)
if ((f[0] == f[1]) || (f[0] == f[2]) || (f[1] == f[2]))
{
WarningInFunction
<< "triangle " << faceI
<< "triangle " << facei
<< " uses non-unique vertices " << f
<< endl;
return false;
@ -1079,21 +1079,21 @@ bool Foam::isoSurfaceCell::validTri(const triSurface& surf, const label faceI)
// duplicate triangle check
const labelList& fFaces = surf.faceFaces()[faceI];
const labelList& fFaces = surf.faceFaces()[facei];
// Check if faceNeighbours use same points as this face.
// Note: discards normal information - sides of baffle are merged.
forAll(fFaces, i)
{
label nbrFaceI = fFaces[i];
label nbrFacei = fFaces[i];
if (nbrFaceI <= faceI)
if (nbrFacei <= facei)
{
// lower numbered faces already checked
continue;
}
const labelledTri& nbrF = surf[nbrFaceI];
const labelledTri& nbrF = surf[nbrFacei];
if
(
@ -1103,9 +1103,9 @@ bool Foam::isoSurfaceCell::validTri(const triSurface& surf, const label faceI)
)
{
WarningInFunction
<< "triangle " << faceI << " vertices " << f
<< "triangle " << facei << " vertices " << f
<< " coords:" << f.points(surf.points())
<< " has the same vertices as triangle " << nbrFaceI
<< " has the same vertices as triangle " << nbrFacei
<< " vertices " << nbrF
<< endl;
@ -1314,7 +1314,7 @@ Foam::triSurface Foam::isoSurfaceCell::subsetMesh
oldToNewPoints.setSize(s.points().size());
oldToNewPoints = -1;
{
label pointI = 0;
label pointi = 0;
forAll(include, oldFacei)
{
@ -1325,17 +1325,17 @@ Foam::triSurface Foam::isoSurfaceCell::subsetMesh
forAll(f, fp)
{
label oldPointI = f[fp];
label oldPointi = f[fp];
if (oldToNewPoints[oldPointI] == -1)
if (oldToNewPoints[oldPointi] == -1)
{
oldToNewPoints[oldPointI] = pointI;
newToOldPoints[pointI++] = oldPointI;
oldToNewPoints[oldPointi] = pointi;
newToOldPoints[pointi++] = oldPointi;
}
}
}
}
newToOldPoints.setSize(pointI);
newToOldPoints.setSize(pointi);
}
// Extract points
@ -1395,11 +1395,11 @@ Foam::isoSurfaceCell::isoSurfaceCell
{
tetMatcher tet;
forAll(isTet, cellI)
forAll(isTet, celli)
{
if (tet.isA(mesh_, cellI))
if (tet.isA(mesh_, celli))
{
isTet.set(cellI, 1);
isTet.set(celli, 1);
}
}
}

View File

@ -167,7 +167,7 @@ class isoSurfaceCell
// Returns point. Destroys arguments.
pointIndexHit collapseSurface
(
const label cellI,
const label celli,
pointField& localPoints,
DynamicList<labelledTri, 64>& localTris
) const;
@ -183,24 +183,24 @@ class isoSurfaceCell
labelList& snappedCc
) const;
//- Generate triangles for face connected to pointI
//- Generate triangles for face connected to pointi
void genPointTris
(
const scalarField& cellValues,
const scalarField& pointValues,
const label pointI,
const label faceI,
const label cellI,
const label pointi,
const label facei,
const label celli,
DynamicList<point, 64>& localTriPoints
) const;
//- Generate triangles for tet connected to pointI
//- Generate triangles for tet connected to pointi
void genPointTris
(
const scalarField& pointValues,
const label pointI,
const label faceI,
const label cellI,
const label pointi,
const label facei,
const label celli,
DynamicList<point, 64>& localTriPoints
) const;

View File

@ -338,15 +338,15 @@ void Foam::isoSurfaceCell::generateTriPoints
tetMatcher tet;
label countNotFoundTets = 0;
forAll(mesh_.cells(), cellI)
forAll(mesh_.cells(), celli)
{
if (cellCutType_[cellI] != NOTCUT)
if (cellCutType_[celli] != NOTCUT)
{
label oldNPoints = triPoints.size();
const cell& cFaces = mesh_.cells()[cellI];
const cell& cFaces = mesh_.cells()[celli];
if (tet.isA(mesh_, cellI))
if (tet.isA(mesh_, celli))
{
// For tets don't do cell-centre decomposition, just use the
// tet points and values
@ -368,7 +368,7 @@ void Foam::isoSurfaceCell::generateTriPoints
// Start off from positive volume tet to make sure we
// generate outwards pointing tets
if (mesh_.faceOwner()[cFaces[0]] == cellI)
if (mesh_.faceOwner()[cFaces[0]] == celli)
{
generateTriPoints
(
@ -421,12 +421,12 @@ void Foam::isoSurfaceCell::generateTriPoints
}
else
{
forAll(cFaces, cFaceI)
forAll(cFaces, cFacei)
{
label faceI = cFaces[cFaceI];
const face& f = mesh_.faces()[faceI];
label facei = cFaces[cFacei];
const face& f = mesh_.faces()[facei];
label fp0 = mesh_.tetBasePtIs()[faceI];
label fp0 = mesh_.tetBasePtIs()[facei];
// Skip undefined tets
if (fp0 < 0)
@ -443,7 +443,7 @@ void Foam::isoSurfaceCell::generateTriPoints
// Start off from positive volume tet to make sure we
// generate outwards pointing tets
if (mesh_.faceOwner()[faceI] == cellI)
if (mesh_.faceOwner()[facei] == celli)
{
generateTriPoints
(
@ -461,9 +461,9 @@ void Foam::isoSurfaceCell::generateTriPoints
pCoords[tri[2]],
snappedPoint[tri[2]],
cVals[cellI],
cCoords[cellI],
snappedCc[cellI],
cVals[celli],
cCoords[celli],
snappedCc[celli],
triPoints
);
@ -486,9 +486,9 @@ void Foam::isoSurfaceCell::generateTriPoints
pCoords[tri[2]],
snappedPoint[tri[2]],
cVals[cellI],
cCoords[cellI],
snappedCc[cellI],
cVals[celli],
cCoords[celli],
snappedCc[celli],
triPoints
);
@ -504,7 +504,7 @@ void Foam::isoSurfaceCell::generateTriPoints
label nCells = (triPoints.size()-oldNPoints)/3;
for (label i = 0; i < nCells; i++)
{
triMeshCells.append(cellI);
triMeshCells.append(celli);
}
}
}

View File

@ -33,16 +33,13 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
Foam::tmp
Foam::tmp<Foam::SlicedGeometricField
<
Foam::SlicedGeometricField
<
Type,
Foam::fvPatchField,
Foam::slicedFvPatchField,
Foam::volMesh
>
>
Type,
Foam::fvPatchField,
Foam::slicedFvPatchField,
Foam::volMesh
>>
Foam::isoSurface::adaptPatchFields
(
const GeometricField<Type, fvPatchField, volMesh>& fld
@ -79,26 +76,29 @@ Foam::isoSurface::adaptPatchFields
const polyBoundaryMesh& patches = mesh.boundaryMesh();
forAll(patches, patchI)
typename FieldType::Boundary& sliceFldBf =
sliceFld.boundaryFieldRef();
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
if
(
isA<emptyPolyPatch>(pp)
&& pp.size() != sliceFld.boundaryField()[patchI].size()
&& pp.size() != sliceFldBf[patchi].size()
)
{
// Clear old value. Cannot resize it since is a slice.
sliceFld.boundaryField().set(patchI, NULL);
sliceFldBf.set(patchi, nullptr);
// Set new value we can change
sliceFld.boundaryField().set
sliceFldBf.set
(
patchI,
patchi,
new calculatedFvPatchField<Type>
(
mesh.boundary()[patchI],
mesh.boundary()[patchi],
sliceFld
)
);
@ -106,9 +106,9 @@ Foam::isoSurface::adaptPatchFields
// Note: cannot use patchInternalField since uses emptyFvPatch::size
// Do our own internalField instead.
const labelUList& faceCells =
mesh.boundary()[patchI].patch().faceCells();
mesh.boundary()[patchi].patch().faceCells();
Field<Type>& pfld = sliceFld.boundaryField()[patchI];
Field<Type>& pfld = sliceFldBf[patchi];
pfld.setSize(faceCells.size());
forAll(faceCells, i)
{
@ -123,10 +123,10 @@ Foam::isoSurface::adaptPatchFields
{
fvPatchField<Type>& pfld = const_cast<fvPatchField<Type>&>
(
sliceFld.boundaryField()[patchI]
sliceFldBf[patchi]
);
const scalarField& w = mesh.weights().boundaryField()[patchI];
const scalarField& w = mesh.weights().boundaryField()[patchi];
tmp<Field<Type>> f =
w*pfld.patchInternalField()
@ -192,8 +192,6 @@ Type Foam::isoSurface::generatePoint
}
// Note: cannot use simpler isoSurfaceCell::generateTriPoints since
// the need here to sometimes pass in remote 'snappedPoints'
template<class Type>
void Foam::isoSurface::generateTriPoints
(
@ -220,6 +218,9 @@ void Foam::isoSurface::generateTriPoints
DynamicList<Type>& points
) const
{
// Note: cannot use simpler isoSurfaceCell::generateTriPoints since
// the need here to sometimes pass in remote 'snappedPoints'
int triIndex = 0;
if (s0 < iso_)
{
@ -443,7 +444,7 @@ Foam::label Foam::isoSurface::generateFaceTriPoints
const DynamicList<Type>& snappedPoints,
const labelList& snappedCc,
const labelList& snappedPoint,
const label faceI,
const label facei,
const scalar neiVal,
const Type& neiPt,
@ -454,34 +455,34 @@ Foam::label Foam::isoSurface::generateFaceTriPoints
DynamicList<label>& triMeshCells
) const
{
label own = mesh_.faceOwner()[faceI];
label own = mesh_.faceOwner()[facei];
label oldNPoints = triPoints.size();
const face& f = mesh_.faces()[faceI];
const face& f = mesh_.faces()[facei];
forAll(f, fp)
{
label pointI = f[fp];
label nextPointI = f[f.fcIndex(fp)];
label pointi = f[fp];
label nextPointi = f[f.fcIndex(fp)];
generateTriPoints
(
pVals[pointI],
pCoords[pointI],
snappedPoint[pointI] != -1,
pVals[pointi],
pCoords[pointi],
snappedPoint[pointi] != -1,
(
snappedPoint[pointI] != -1
? snappedPoints[snappedPoint[pointI]]
snappedPoint[pointi] != -1
? snappedPoints[snappedPoint[pointi]]
: Type(Zero)
),
pVals[nextPointI],
pCoords[nextPointI],
snappedPoint[nextPointI] != -1,
pVals[nextPointi],
pCoords[nextPointi],
snappedPoint[nextPointi] != -1,
(
snappedPoint[nextPointI] != -1
? snappedPoints[snappedPoint[nextPointI]]
snappedPoint[nextPointi] != -1
? snappedPoints[snappedPoint[nextPointi]]
: Type(Zero)
),
@ -564,9 +565,9 @@ void Foam::isoSurface::generateTriPoints
triPoints.clear();
triMeshCells.clear();
for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
{
if (faceCutType_[faceI] != NOTCUT)
if (faceCutType_[facei] != NOTCUT)
{
generateFaceTriPoints
(
@ -579,14 +580,14 @@ void Foam::isoSurface::generateTriPoints
snappedPoints,
snappedCc,
snappedPoint,
faceI,
facei,
cVals[nei[faceI]],
cCoords[nei[faceI]],
snappedCc[nei[faceI]] != -1,
cVals[nei[facei]],
cCoords[nei[facei]],
snappedCc[nei[facei]] != -1,
(
snappedCc[nei[faceI]] != -1
? snappedPoints[snappedCc[nei[faceI]]]
snappedCc[nei[facei]] != -1
? snappedPoints[snappedCc[nei[facei]]]
: Type(Zero)
),
@ -600,24 +601,24 @@ void Foam::isoSurface::generateTriPoints
// Determine neighbouring snap status
boolList neiSnapped(mesh_.nFaces()-mesh_.nInternalFaces(), false);
List<Type> neiSnappedPoint(neiSnapped.size(), Type(Zero));
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
if (pp.coupled())
{
label faceI = pp.start();
label facei = pp.start();
forAll(pp, i)
{
label bFaceI = faceI-mesh_.nInternalFaces();
label snappedIndex = snappedCc[own[faceI]];
label bFacei = facei-mesh_.nInternalFaces();
label snappedIndex = snappedCc[own[facei]];
if (snappedIndex != -1)
{
neiSnapped[bFaceI] = true;
neiSnappedPoint[bFaceI] = snappedPoints[snappedIndex];
neiSnapped[bFacei] = true;
neiSnappedPoint[bFacei] = snappedPoints[snappedIndex];
}
faceI++;
facei++;
}
}
}
@ -626,9 +627,9 @@ void Foam::isoSurface::generateTriPoints
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
if (isA<processorPolyPatch>(pp))
{
@ -639,9 +640,9 @@ void Foam::isoSurface::generateTriPoints
forAll(isCollocated, i)
{
label faceI = pp.start()+i;
label facei = pp.start()+i;
if (faceCutType_[faceI] != NOTCUT)
if (faceCutType_[facei] != NOTCUT)
{
if (isCollocated[i])
{
@ -656,12 +657,12 @@ void Foam::isoSurface::generateTriPoints
snappedPoints,
snappedCc,
snappedPoint,
faceI,
facei,
cVals.boundaryField()[patchI][i],
cCoords.boundaryField()[patchI][i],
neiSnapped[faceI-mesh_.nInternalFaces()],
neiSnappedPoint[faceI-mesh_.nInternalFaces()],
cVals.boundaryField()[patchi][i],
cCoords.boundaryField()[patchi][i],
neiSnapped[facei-mesh_.nInternalFaces()],
neiSnappedPoint[facei-mesh_.nInternalFaces()],
triPoints,
triMeshCells
@ -680,10 +681,10 @@ void Foam::isoSurface::generateTriPoints
snappedPoints,
snappedCc,
snappedPoint,
faceI,
facei,
cVals.boundaryField()[patchI][i],
cCoords.boundaryField()[patchI][i],
cVals.boundaryField()[patchi][i],
cCoords.boundaryField()[patchi][i],
false,
Type(Zero),
@ -696,11 +697,11 @@ void Foam::isoSurface::generateTriPoints
}
else
{
label faceI = pp.start();
label facei = pp.start();
forAll(pp, i)
{
if (faceCutType_[faceI] != NOTCUT)
if (faceCutType_[facei] != NOTCUT)
{
generateFaceTriPoints
(
@ -713,10 +714,10 @@ void Foam::isoSurface::generateTriPoints
snappedPoints,
snappedCc,
snappedPoint,
faceI,
facei,
cVals.boundaryField()[patchI][i],
cCoords.boundaryField()[patchI][i],
cVals.boundaryField()[patchi][i],
cCoords.boundaryField()[patchi][i],
false, // fc not snapped
Type(Zero),
@ -724,7 +725,7 @@ void Foam::isoSurface::generateTriPoints
triMeshCells
);
}
faceI++;
facei++;
}
}
}
@ -757,12 +758,12 @@ Foam::isoSurface::interpolate
forAll(unmergedValues, i)
{
label mergedPointI = triPointMergeMap[i];
label mergedPointi = triPointMergeMap[i];
if (mergedPointI >= 0)
if (mergedPointi >= 0)
{
values[mergedPointI] += unmergedValues[i];
nValues[mergedPointI]++;
values[mergedPointi] += unmergedValues[i];
nValues[mergedPointi]++;
}
}
@ -780,16 +781,16 @@ Foam::isoSurface::interpolate
forAll(interpolatedPoints, i)
{
label pointI = interpolatedPoints[i];
label pointi = interpolatedPoints[i];
const FixedList<label, 3>& oldPoints = interpolatedOldPoints[i];
const FixedList<scalar, 3>& w = interpolationWeights[i];
// Note: zeroing should not be necessary if interpolation only done
// for newly introduced points (i.e. not in triPointMergeMap)
values[pointI] = Type(Zero);
values[pointi] = Type(Zero);
forAll(oldPoints, j)
{
values[pointI] = w[j]*unmergedValues[oldPoints[j]];
values[pointi] = w[j]*unmergedValues[oldPoints[j]];
}
}

View File

@ -220,8 +220,8 @@ void Foam::sampledIsoSurface::getIsoFields() const
<< " max:" << max(*volFieldPtr_).value() << endl;
InfoInFunction
<< "pointField " << pointFieldPtr_->name()
<< " min:" << gMin(pointFieldPtr_->internalField())
<< " max:" << gMax(pointFieldPtr_->internalField()) << endl;
<< " min:" << gMin(pointFieldPtr_->primitiveField())
<< " max:" << gMax(pointFieldPtr_->primitiveField()) << endl;
}
}
else
@ -343,8 +343,8 @@ void Foam::sampledIsoSurface::getIsoFields() const
InfoInFunction
<< "pointSubField "
<< pointSubFieldPtr_->name()
<< " min:" << gMin(pointSubFieldPtr_->internalField())
<< " max:" << gMax(pointSubFieldPtr_->internalField()) << endl;
<< " min:" << gMin(pointSubFieldPtr_->primitiveField())
<< " max:" << gMax(pointSubFieldPtr_->primitiveField()) << endl;
}
}
}
@ -366,14 +366,14 @@ bool Foam::sampledIsoSurface::updateGeometry() const
const polyBoundaryMesh& patches = mesh().boundaryMesh();
// Patch to put exposed internal faces into
const label exposedPatchI = patches.findPatchID(exposedPatchName_);
const label exposedPatchi = patches.findPatchID(exposedPatchName_);
if (debug)
{
Info<< "Allocating subset of size "
<< mesh().cellZones()[zoneID_.index()].size()
<< " with exposed faces into patch "
<< patches[exposedPatchI].name() << endl;
<< patches[exposedPatchi].name() << endl;
}
subMeshPtr_.reset
@ -383,7 +383,7 @@ bool Foam::sampledIsoSurface::updateGeometry() const
subMeshPtr_().setLargeCellSubset
(
labelHashSet(mesh().cellZones()[zoneID_.index()]),
exposedPatchI
exposedPatchi
);
}
@ -475,12 +475,12 @@ Foam::sampledIsoSurface::sampledIsoSurface
average_(dict.lookupOrDefault("average", false)),
zoneID_(dict.lookupOrDefault("zone", word::null), mesh.cellZones()),
exposedPatchName_(word::null),
surfPtr_(NULL),
facesPtr_(NULL),
surfPtr_(nullptr),
facesPtr_(nullptr),
prevTimeIndex_(-1),
storedVolFieldPtr_(NULL),
volFieldPtr_(NULL),
pointFieldPtr_(NULL)
storedVolFieldPtr_(nullptr),
volFieldPtr_(nullptr),
pointFieldPtr_(nullptr)
{
if (!sampledSurface::interpolate())
{

View File

@ -70,7 +70,7 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const
// 1. see if field in database
// 2. see if field can be read
const volScalarField* cellFldPtr = NULL;
const volScalarField* cellFldPtr = nullptr;
if (fvm.foundObject<volScalarField>(isoField_))
{
if (debug)
@ -124,29 +124,29 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const
scalarField cellAvg(fvm.nCells(), scalar(0.0));
labelField nPointCells(fvm.nCells(), 0);
{
for (label pointI = 0; pointI < fvm.nPoints(); pointI++)
for (label pointi = 0; pointi < fvm.nPoints(); pointi++)
{
const labelList& pCells = fvm.pointCells(pointI);
const labelList& pCells = fvm.pointCells(pointi);
forAll(pCells, i)
{
label cellI = pCells[i];
label celli = pCells[i];
cellAvg[cellI] += pointFld().internalField()[pointI];
nPointCells[cellI]++;
cellAvg[celli] += pointFld().primitiveField()[pointi];
nPointCells[celli]++;
}
}
}
forAll(cellAvg, cellI)
forAll(cellAvg, celli)
{
cellAvg[cellI] /= nPointCells[cellI];
cellAvg[celli] /= nPointCells[celli];
}
const isoSurfaceCell iso
(
fvm,
cellAvg,
pointFld().internalField(),
pointFld().primitiveField(),
isoVal_,
regularise_,
bounds_
@ -164,8 +164,8 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const
const isoSurfaceCell iso
(
fvm,
cellFld.internalField(),
pointFld().internalField(),
cellFld.primitiveField(),
pointFld().primitiveField(),
isoVal_,
regularise_,
bounds_
@ -213,7 +213,7 @@ Foam::sampledIsoSurfaceCell::sampledIsoSurfaceCell
regularise_(dict.lookupOrDefault("regularise", true)),
average_(dict.lookupOrDefault("average", true)),
zoneKey_(keyType::null),
facesPtr_(NULL),
facesPtr_(nullptr),
prevTimeIndex_(-1),
meshCells_(0)
{}

View File

@ -61,22 +61,22 @@ Foam::sampledIsoSurfaceCell::interpolateField
boolList pointDone(points().size(), false);
forAll(faces(), cutFaceI)
forAll(faces(), cutFacei)
{
const face& f = faces()[cutFaceI];
const face& f = faces()[cutFacei];
forAll(f, faceVertI)
{
label pointI = f[faceVertI];
label pointi = f[faceVertI];
if (!pointDone[pointI])
if (!pointDone[pointi])
{
values[pointI] = interpolator.interpolate
values[pointi] = interpolator.interpolate
(
points()[pointI],
meshCells_[cutFaceI]
points()[pointi],
meshCells_[cutFacei]
);
pointDone[pointI] = true;
pointDone[pointi] = true;
}
}
}

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
@ -69,15 +69,13 @@ void Foam::sampledCuttingPlane::createGeometry()
const polyBoundaryMesh& patches = mesh().boundaryMesh();
// Patch to put exposed internal faces into
const label exposedPatchI = patches.findPatchID(exposedPatchName_);
const label exposedPatchi = patches.findPatchID(exposedPatchName_);
if (debug)
{
Info<< "Allocating subset of size "
<< mesh().cellZones()[zoneID_.index()].size()
<< " with exposed faces into patch "
<< patches[exposedPatchI].name() << endl;
}
DebugInfo
<< "Allocating subset of size "
<< mesh().cellZones()[zoneID_.index()].size()
<< " with exposed faces into patch "
<< patches[exposedPatchi].name() << endl;
subMeshPtr_.reset
(
@ -86,17 +84,17 @@ void Foam::sampledCuttingPlane::createGeometry()
subMeshPtr_().setLargeCellSubset
(
labelHashSet(mesh().cellZones()[zoneID_.index()]),
exposedPatchI
exposedPatchi
);
}
// Select either the submesh or the underlying mesh
const fvMesh& fvm =
const fvMesh& mesh =
(
subMeshPtr_.valid()
? subMeshPtr_().subMesh()
: static_cast<const fvMesh&>(mesh())
: static_cast<const fvMesh&>(this->mesh())
);
@ -110,13 +108,13 @@ void Foam::sampledCuttingPlane::createGeometry()
IOobject
(
"cellDistance",
fvm.time().timeName(),
fvm.time(),
mesh.time().timeName(),
mesh.time(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
fvm,
mesh,
dimensionedScalar("zero", dimLength, 0)
)
);
@ -124,8 +122,8 @@ void Foam::sampledCuttingPlane::createGeometry()
// Internal field
{
const pointField& cc = fvm.cellCentres();
scalarField& fld = cellDistance.internalField();
const pointField& cc = mesh.cellCentres();
scalarField& fld = cellDistance.primitiveFieldRef();
forAll(cc, i)
{
@ -134,32 +132,35 @@ void Foam::sampledCuttingPlane::createGeometry()
}
}
volScalarField::Boundary& cellDistanceBf =
cellDistance.boundaryFieldRef();
// Patch fields
{
forAll(cellDistance.boundaryField(), patchI)
forAll(cellDistanceBf, patchi)
{
if
(
isA<emptyFvPatchScalarField>
(
cellDistance.boundaryField()[patchI]
cellDistanceBf[patchi]
)
)
{
cellDistance.boundaryField().set
cellDistanceBf.set
(
patchI,
patchi,
new calculatedFvPatchScalarField
(
fvm.boundary()[patchI],
mesh.boundary()[patchi],
cellDistance
)
);
const polyPatch& pp = fvm.boundary()[patchI].patch();
pointField::subField cc = pp.patchSlice(fvm.faceCentres());
const polyPatch& pp = mesh.boundary()[patchi].patch();
pointField::subField cc = pp.patchSlice(mesh.faceCentres());
fvPatchScalarField& fld = cellDistance.boundaryField()[patchI];
fvPatchScalarField& fld = cellDistanceBf[patchi];
fld.setSize(pp.size());
forAll(fld, i)
{
@ -168,8 +169,8 @@ void Foam::sampledCuttingPlane::createGeometry()
}
else
{
const pointField& cc = fvm.C().boundaryField()[patchI];
fvPatchScalarField& fld = cellDistance.boundaryField()[patchI];
const pointField& cc = mesh.C().boundaryField()[patchi];
fvPatchScalarField& fld = cellDistanceBf[patchi];
forAll(fld, i)
{
@ -185,9 +186,9 @@ void Foam::sampledCuttingPlane::createGeometry()
// Distance to points
pointDistance_.setSize(fvm.nPoints());
pointDistance_.setSize(mesh.nPoints());
{
const pointField& pts = fvm.points();
const pointField& pts = mesh.points();
forAll(pointDistance_, i)
{
@ -205,16 +206,16 @@ void Foam::sampledCuttingPlane::createGeometry()
IOobject
(
"pointDistance",
fvm.time().timeName(),
fvm.time(),
mesh.time().timeName(),
mesh.time(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
pointMesh::New(fvm),
pointMesh::New(mesh),
dimensionedScalar("zero", dimLength, 0)
);
pDist.internalField() = pointDistance_;
pDist.primitiveFieldRef() = pointDistance_;
Pout<< "Writing point distance:" << pDist.objectPath() << endl;
pDist.write();
@ -235,7 +236,7 @@ void Foam::sampledCuttingPlane::createGeometry()
)
//new isoSurfaceCell
//(
// fvm,
// mesh,
// cellDistance,
// pointDistance_,
// 0.0,
@ -270,10 +271,10 @@ Foam::sampledCuttingPlane::sampledCuttingPlane
zoneID_(dict.lookupOrDefault("zone", word::null), mesh.cellZones()),
exposedPatchName_(word::null),
needsUpdate_(true),
subMeshPtr_(NULL),
cellDistancePtr_(NULL),
isoSurfPtr_(NULL),
facesPtr_(NULL)
subMeshPtr_(nullptr),
cellDistancePtr_(nullptr),
isoSurfPtr_(nullptr),
facesPtr_(nullptr)
{
if (zoneID_.index() != -1)
{
@ -327,7 +328,7 @@ bool Foam::sampledCuttingPlane::expire()
// Clear derived data
clearGeom();
// already marked as expired
// Already marked as expired
if (needsUpdate_)
{
return false;

View File

@ -25,7 +25,8 @@ Class
Foam::sampledCuttingPlane
Description
A sampledSurface defined by a plane
A sampledSurface defined by a plane using the iso-surface algorithm
to 'cut' the mesh.
SourceFiles
sampledCuttingPlane.C

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
@ -126,8 +126,8 @@ bool Foam::sampledPatch::update()
label sz = 0;
forAll(patchIDs(), i)
{
label patchI = patchIDs()[i];
const polyPatch& pp = mesh().boundaryMesh()[patchI];
label patchi = patchIDs()[i];
const polyPatch& pp = mesh().boundaryMesh()[patchi];
if (isA<emptyPolyPatch>(pp))
{
@ -150,11 +150,11 @@ bool Foam::sampledPatch::update()
forAll(patchIDs(), i)
{
label patchI = patchIDs()[i];
label patchi = patchIDs()[i];
patchStart_[i] = sz;
const polyPatch& pp = mesh().boundaryMesh()[patchI];
const polyPatch& pp = mesh().boundaryMesh()[patchi];
forAll(pp, j)
{

View File

@ -39,8 +39,8 @@ Foam::sampledPatch::sampleField
Field<Type>& values = tvalues.ref();
forAll(patchFaceLabels_, i)
{
label patchI = patchIDs_[patchIndex_[i]];
const Field<Type>& bField = vField.boundaryField()[patchI];
label patchi = patchIDs_[patchIndex_[i]];
const Field<Type>& bField = vField.boundaryField()[patchi];
values[i] = bField[patchFaceLabels_[i]];
}
@ -61,8 +61,8 @@ Foam::sampledPatch::sampleField
forAll(patchFaceLabels_, i)
{
label patchI = patchIDs_[patchIndex_[i]];
values[i] = sField.boundaryField()[patchI][patchFaceLabels_[i]];
label patchi = patchIDs_[patchIndex_[i]];
values[i] = sField.boundaryField()[patchi][patchFaceLabels_[i]];
}
return tvalues;
@ -84,29 +84,29 @@ Foam::sampledPatch::interpolateField
boolList pointDone(points().size(), false);
forAll(faces(), cutFaceI)
forAll(faces(), cutFacei)
{
label patchI = patchIDs_[patchIndex_[cutFaceI]];
const polyPatch& pp = mesh().boundaryMesh()[patchI];
label patchFaceI = patchFaceLabels()[cutFaceI];
const face& f = faces()[cutFaceI];
label patchi = patchIDs_[patchIndex_[cutFacei]];
const polyPatch& pp = mesh().boundaryMesh()[patchi];
label patchFacei = patchFaceLabels()[cutFacei];
const face& f = faces()[cutFacei];
forAll(f, faceVertI)
{
label pointI = f[faceVertI];
label pointi = f[faceVertI];
if (!pointDone[pointI])
if (!pointDone[pointi])
{
label faceI = patchFaceI + pp.start();
label cellI = own[faceI];
label facei = patchFacei + pp.start();
label celli = own[facei];
values[pointI] = interpolator.interpolate
values[pointi] = interpolator.interpolate
(
points()[pointI],
cellI,
faceI
points()[pointi],
celli,
facei
);
pointDone[pointI] = true;
pointDone[pointi] = true;
}
}
}

View File

@ -43,7 +43,7 @@ Foam::sampledPatchInternalField::sampleField
forAll(patchStart(), i)
{
// Get patchface wise data by sampling internal field
Field<Type> interpVals = vField.internalField();
Field<Type> interpVals = vField.primitiveField();
mappers_[i].map().distribute(interpVals);
// Store at correct position in values
@ -93,14 +93,14 @@ Foam::sampledPatchInternalField::interpolateField
Field<Type> patchVals(mesh().nCells());
forAll(samples, cellI)
forAll(samples, celli)
{
if (samples[cellI] != point::max)
if (samples[celli] != point::max)
{
patchVals[cellI] = interpolator.interpolate
patchVals[celli] = interpolator.interpolate
(
samples[cellI],
cellI
samples[celli],
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
@ -71,12 +71,12 @@ Foam::sampledPlane::sampledPlane
)
:
sampledSurface(name, mesh, dict),
cuttingPlane(plane(dict.lookup("basePoint"), dict.lookup("normalVector"))),
cuttingPlane(plane(dict)),
zoneKey_(keyType::null),
triangulate_(dict.lookupOrDefault("triangulate", true)),
needsUpdate_(true)
{
// make plane relative to the coordinateSystem (Cartesian)
// Make plane relative to the coordinateSystem (Cartesian)
// allow lookup from global coordinate systems
if (dict.found("coordinateSystem"))
{
@ -85,7 +85,7 @@ Foam::sampledPlane::sampledPlane
point base = cs.globalPosition(planeDesc().refPoint());
vector norm = cs.globalVector(planeDesc().normal());
// assign the plane description
// Assign the plane description
static_cast<plane&>(*this) = plane(base, norm);
}
@ -115,7 +115,7 @@ bool Foam::sampledPlane::needsUpdate() const
bool Foam::sampledPlane::expire()
{
// already marked as expired
// Already marked as expired
if (needsUpdate_)
{
return false;

View File

@ -25,7 +25,8 @@ Class
Foam::sampledPlane
Description
A sampledSurface defined by a cuttingPlane. Triangulated by default.
A sampledSurface defined by a plane which 'cuts' the mesh using the
cuttingPlane alorithm. The plane is triangulated by default.
Note
Does not actually cut until update() called.

View File

@ -51,22 +51,22 @@ Foam::sampledPlane::interpolateField
boolList pointDone(points().size(), false);
forAll(faces(), cutFaceI)
forAll(faces(), cutFacei)
{
const face& f = faces()[cutFaceI];
const face& f = faces()[cutFacei];
forAll(f, faceVertI)
{
label pointI = f[faceVertI];
label pointi = f[faceVertI];
if (!pointDone[pointI])
if (!pointDone[pointi])
{
values[pointI] = interpolator.interpolate
values[pointi] = interpolator.interpolate
(
points()[pointI],
meshCells()[cutFaceI]
points()[pointi],
meshCells()[cutFacei]
);
pointDone[pointI] = true;
pointDone[pointi] = true;
}
}
}

View File

@ -62,9 +62,9 @@ void Foam::sampledSurface::makeSf() const
SfPtr_ = new vectorField(theFaces.size());
vectorField& values = *SfPtr_;
forAll(theFaces, faceI)
forAll(theFaces, facei)
{
values[faceI] = theFaces[faceI].normal(points());
values[facei] = theFaces[facei].normal(points());
}
}
@ -83,9 +83,9 @@ void Foam::sampledSurface::makeMagSf() const
magSfPtr_ = new scalarField(theFaces.size());
scalarField& values = *magSfPtr_;
forAll(theFaces, faceI)
forAll(theFaces, facei)
{
values[faceI] = theFaces[faceI].mag(points());
values[facei] = theFaces[facei].mag(points());
}
}
@ -104,9 +104,9 @@ void Foam::sampledSurface::makeCf() const
CfPtr_ = new vectorField(theFaces.size());
vectorField& values = *CfPtr_;
forAll(theFaces, faceI)
forAll(theFaces, facei)
{
values[faceI] = theFaces[faceI].centre(points());
values[facei] = theFaces[facei].centre(points());
}
}
@ -156,9 +156,9 @@ Foam::sampledSurface::sampledSurface
name_(name),
mesh_(mesh),
interpolate_(interpolate),
SfPtr_(NULL),
magSfPtr_(NULL),
CfPtr_(NULL),
SfPtr_(nullptr),
magSfPtr_(nullptr),
CfPtr_(nullptr),
area_(-1)
{}
@ -173,9 +173,9 @@ Foam::sampledSurface::sampledSurface
name_(name),
mesh_(mesh),
interpolate_(dict.lookupOrDefault("interpolate", false)),
SfPtr_(NULL),
magSfPtr_(NULL),
CfPtr_(NULL),
SfPtr_(nullptr),
magSfPtr_(nullptr),
CfPtr_(nullptr),
area_(-1)
{
dict.readIfPresent("name", name_);
@ -243,7 +243,7 @@ Foam::tmp<Foam::scalarField> Foam::sampledSurface::sample
) const
{
NotImplemented;
return tmp<scalarField>(NULL);
return tmp<scalarField>(nullptr);
}
@ -253,7 +253,7 @@ Foam::tmp<Foam::vectorField> Foam::sampledSurface::sample
) const
{
NotImplemented;
return tmp<vectorField>(NULL);
return tmp<vectorField>(nullptr);
}
@ -263,7 +263,7 @@ Foam::tmp<Foam::sphericalTensorField> Foam::sampledSurface::sample
) const
{
NotImplemented;
return tmp<sphericalTensorField>(NULL);
return tmp<sphericalTensorField>(nullptr);
}
@ -273,7 +273,7 @@ Foam::tmp<Foam::symmTensorField> Foam::sampledSurface::sample
) const
{
NotImplemented;
return tmp<symmTensorField>(NULL);
return tmp<symmTensorField>(nullptr);
}
@ -283,7 +283,7 @@ Foam::tmp<Foam::tensorField> Foam::sampledSurface::sample
) const
{
NotImplemented;
return tmp<tensorField>(NULL);
return tmp<tensorField>(nullptr);
}
@ -293,9 +293,9 @@ Foam::sampledSurface::project(const Field<scalar>& field) const
tmp<Field<scalar>> tRes(new Field<scalar>(faces().size()));
Field<scalar>& res = tRes.ref();
forAll(faces(), faceI)
forAll(faces(), facei)
{
res[faceI] = field[faceI];
res[facei] = field[facei];
}
return tRes;

View File

@ -25,7 +25,7 @@ Class
Foam::sampledSurface
Group
grpFunctionObjects
grpUtilitiesFunctionObjects
Description
An abstract class for surfaces with sampling.
@ -71,6 +71,13 @@ SourceFiles
namespace Foam
{
// Forward declaration of friend functions and operators
class sampledSurface;
Ostream& operator<<(Ostream&, const sampledSurface&);
/*---------------------------------------------------------------------------*\
Class sampledSurface Declaration
\*---------------------------------------------------------------------------*/
@ -218,7 +225,7 @@ public:
autoPtr<sampledSurface> clone() const
{
NotImplemented;
return autoPtr<sampledSurface>(NULL);
return autoPtr<sampledSurface>(nullptr);
}

View File

@ -114,9 +114,9 @@ void Foam::sampledSurface::project
{
const vectorField& norm = Sf();
forAll(norm, faceI)
forAll(norm, facei)
{
res[faceI] = field[faceI] & (norm[faceI]/mag(norm[faceI]));
res[facei] = field[facei] & (norm[facei]/mag(norm[facei]));
}
}
else
@ -181,22 +181,22 @@ Foam::sampledSurface::pointAverage
labelField nPointCells(mesh.nCells(), 0);
{
for (label pointI = 0; pointI < mesh.nPoints(); pointI++)
for (label pointi = 0; pointi < mesh.nPoints(); pointi++)
{
const labelList& pCells = mesh.pointCells(pointI);
const labelList& pCells = mesh.pointCells(pointi);
forAll(pCells, i)
{
label cellI = pCells[i];
label celli = pCells[i];
cellAvg[cellI] += pfld[pointI];
nPointCells[cellI]++;
cellAvg[celli] += pfld[pointi];
nPointCells[celli]++;
}
}
}
forAll(cellAvg, cellI)
forAll(cellAvg, celli)
{
cellAvg[cellI] /= nPointCells[cellI];
cellAvg[celli] /= nPointCells[celli];
}
// Give value to calculatedFvPatchFields
cellAvg.correctBoundaryConditions();

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,12 +30,21 @@ License
#include "IOmanip.H"
#include "volPointInterpolation.H"
#include "PatchTools.H"
#include "mapPolyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(sampledSurfaces, 0);
addToRunTimeSelectionTable
(
functionObject,
sampledSurfaces,
dictionary
);
}
bool Foam::sampledSurfaces::verbose_ = false;
@ -49,7 +58,7 @@ void Foam::sampledSurfaces::writeGeometry() const
// Write to time directory under outputPath_
// Skip surface without faces (eg, a failed cut-plane)
const fileName outputDir = outputPath_/obr_.time().timeName();
const fileName outputDir = outputPath_/time_.timeName();
forAll(*this, surfI)
{
@ -84,6 +93,35 @@ void Foam::sampledSurfaces::writeGeometry() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledSurfaces::sampledSurfaces
(
const word& name,
const Time& t,
const dictionary& dict
)
:
regionFunctionObject(t, name),
PtrList<sampledSurface>(),
loadFromFiles_(false),
outputPath_(fileName::null),
fieldSelection_(),
interpolationScheme_(word::null),
mergeList_(),
formatter_(nullptr)
{
if (Pstream::parRun())
{
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name;
}
else
{
outputPath_ = mesh_.time().path()/"postProcessing"/name;
}
read(dict);
}
Foam::sampledSurfaces::sampledSurfaces
(
const word& name,
@ -92,29 +130,24 @@ Foam::sampledSurfaces::sampledSurfaces
const bool loadFromFiles
)
:
functionObjectState(obr, name),
regionFunctionObject(obr, name),
PtrList<sampledSurface>(),
obr_(obr),
loadFromFiles_(loadFromFiles),
outputPath_(fileName::null),
fieldSelection_(),
interpolationScheme_(word::null),
mergeList_(),
formatter_(NULL)
formatter_(nullptr)
{
// Only active if a fvMesh is available
if (setActive<fvMesh>())
{
read(dict);
}
read(dict);
if (Pstream::parRun())
{
outputPath_ = obr_.time().path()/".."/"postProcessing"/name_;
outputPath_ = time_.path()/".."/"postProcessing"/name_;
}
else
{
outputPath_ = obr_.time().path()/"postProcessing"/name_;
outputPath_ = time_.path()/"postProcessing"/name_;
}
read(dict);
@ -135,25 +168,13 @@ void Foam::sampledSurfaces::verbose(const bool verbosity)
}
void Foam::sampledSurfaces::execute()
bool Foam::sampledSurfaces::execute()
{
// Do nothing - only valid on write
return true;
}
void Foam::sampledSurfaces::end()
{
// Do nothing - only valid on write
}
void Foam::sampledSurfaces::timeSet()
{
// Do nothing - only valid on write
}
void Foam::sampledSurfaces::write()
bool Foam::sampledSurfaces::write()
{
if (size())
{
@ -183,10 +204,12 @@ void Foam::sampledSurfaces::write()
sampleAndWrite<surfaceSymmTensorField>(objects);
sampleAndWrite<surfaceTensorField>(objects);
}
return true;
}
void Foam::sampledSurfaces::read(const dictionary& dict)
bool Foam::sampledSurfaces::read(const dictionary& dict)
{
bool surfacesFound = dict.found("surfaces");
@ -205,12 +228,10 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
dict.subOrEmptyDict("formatOptions").subOrEmptyDict(writeType)
);
const fvMesh& mesh = refCast<const fvMesh>(obr_);
PtrList<sampledSurface> newList
(
dict.lookup("surfaces"),
sampledSurface::iNew(mesh)
sampledSurface::iNew(mesh_)
);
transfer(newList);
@ -244,20 +265,28 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
}
Pout<< ")" << endl;
}
return true;
}
void Foam::sampledSurfaces::updateMesh(const mapPolyMesh&)
void Foam::sampledSurfaces::updateMesh(const mapPolyMesh& mpm)
{
expire();
if (&mpm.mesh() == &mesh_)
{
expire();
}
// pointMesh and interpolation will have been reset in mesh.update
}
void Foam::sampledSurfaces::movePoints(const polyMesh&)
void Foam::sampledSurfaces::movePoints(const polyMesh& mesh)
{
expire();
if (&mesh == &mesh_)
{
expire();
}
}
@ -330,10 +359,8 @@ bool Foam::sampledSurfaces::update()
return updated;
}
const fvMesh& mesh = refCast<const fvMesh>(obr_);
// Dimension as fraction of mesh bounding box
scalar mergeDim = mergeTol_*mesh.bounds().mag();
scalar mergeDim = mergeTol_*mesh_.bounds().mag();
if (Pstream::master() && debug)
{

View File

@ -37,7 +37,7 @@ SourceFiles
#ifndef sampledSurfaces_H
#define sampledSurfaces_H
#include "functionObjectState.H"
#include "regionFunctionObject.H"
#include "sampledSurface.H"
#include "surfaceWriter.H"
#include "volFieldsFwd.H"
@ -50,6 +50,8 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
class Time;
class fvMesh;
class dictionary;
@ -59,12 +61,11 @@ class dictionary;
class sampledSurfaces
:
public functionObjectState,
public regionFunctionObject,
public PtrList<sampledSurface>
{
// Private classes
//- Class used for surface merging information
class mergeInfo
{
@ -94,9 +95,6 @@ class sampledSurfaces
// Private data
//- Const reference to database
const objectRegistry& obr_;
//- Load fields from files (not from objectRegistry)
const bool loadFromFiles_;
@ -174,6 +172,14 @@ public:
// Constructors
//- Construct from Time and dictionary
sampledSurfaces
(
const word& name,
const Time& time,
const dictionary& dict
);
//- Construct for given objectRegistry and dictionary
// allow the possibility to load fields from files
sampledSurfaces
@ -203,30 +209,17 @@ public:
// Return false if no surfaces required an update.
virtual bool update();
//- Return name of the set of surfaces
virtual const word& name() const
{
return name_;
}
//- Set verbosity level
void verbose(const bool verbosity = true);
//- Read the sampledSurfaces dictionary
virtual bool read(const dictionary&);
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Called when time was set at the end of the Time::operator++
virtual void timeSet();
virtual bool execute();
//- Sample and write
virtual void write();
//- Read the sampledSurfaces dictionary
virtual void read(const dictionary&);
virtual bool write();
//- Update for changes of mesh - expires the surfaces
virtual void updateMesh(const mapPolyMesh&);

View File

@ -184,8 +184,6 @@ template<class GeoField>
void Foam::sampledSurfaces::sampleAndWrite(const IOobjectList& objects)
{
wordList names;
const fvMesh& mesh = refCast<const fvMesh>(obr_);
if (loadFromFiles_)
{
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
@ -193,7 +191,7 @@ void Foam::sampledSurfaces::sampleAndWrite(const IOobjectList& objects)
}
else
{
names = mesh.thisDb().names<GeoField>();
names = mesh_.thisDb().names<GeoField>();
}
labelList nameIDs(findStrings(fieldSelection_, names));
@ -216,11 +214,11 @@ void Foam::sampledSurfaces::sampleAndWrite(const IOobjectList& objects)
IOobject
(
fieldName,
mesh.time().timeName(),
mesh,
time_.timeName(),
mesh_,
IOobject::MUST_READ
),
mesh
mesh_
);
sampleAndWrite(fld);
@ -229,7 +227,7 @@ void Foam::sampledSurfaces::sampleAndWrite(const IOobjectList& objects)
{
sampleAndWrite
(
mesh.thisDb().lookupObject<GeoField>(fieldName)
mesh_.thisDb().lookupObject<GeoField>(fieldName)
);
}
}

View File

@ -1,42 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "sampledSurfacesFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(sampledSurfacesFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
sampledSurfacesFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -1,54 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Typedef
Foam::sampledSurfacesFunctionObject
Description
FunctionObject wrapper around surfaces to allow them to be created via the
functions entry within controlDict.
SourceFiles
sampledSurfacesFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef sampledSurfacesFunctionObject_H
#define sampledSurfacesFunctionObject_H
#include "sampledSurfaces.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<sampledSurfaces>
sampledSurfacesFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

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,9 +94,9 @@ Foam::sampledTriSurfaceMesh::nonCoupledboundaryTree() const
labelList bndFaces(mesh().nFaces()-mesh().nInternalFaces());
label bndI = 0;
forAll(patches, patchI)
forAll(patches, patchi)
{
const polyPatch& pp = patches[patchI];
const polyPatch& pp = patches[patchi];
if (!pp.coupled())
{
forAll(pp, i)
@ -271,28 +271,28 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
labelList reversePointMap(s.points().size(), -1);
{
label newPointI = 0;
label newFaceI = 0;
label newPointi = 0;
label newFacei = 0;
forAll(s, faceI)
forAll(s, facei)
{
if (cellOrFaceLabels[faceI] != -1)
if (cellOrFaceLabels[facei] != -1)
{
faceMap[newFaceI++] = faceI;
faceMap[newFacei++] = facei;
const triSurface::FaceType& f = s[faceI];
const triSurface::FaceType& f = s[facei];
forAll(f, fp)
{
if (reversePointMap[f[fp]] == -1)
{
pointMap[newPointI] = f[fp];
reversePointMap[f[fp]] = newPointI++;
pointMap[newPointi] = f[fp];
reversePointMap[f[fp]] = newPointi++;
}
}
}
}
faceMap.setSize(newFaceI);
pointMap.setSize(newPointI);
faceMap.setSize(newFacei);
pointMap.setSize(newPointi);
}
@ -345,11 +345,11 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
// samplePoints_ : per surface point a location inside the cell
// sampleElements_ : per surface point the cell
forAll(points(), pointI)
forAll(points(), pointi)
{
const point& pt = points()[pointI];
label cellI = cellOrFaceLabels[pointToFace[pointI]];
sampleElements_[pointI] = cellI;
const point& pt = points()[pointi];
label celli = cellOrFaceLabels[pointToFace[pointi]];
sampleElements_[pointi] = celli;
// Check if point inside cell
if
@ -357,17 +357,17 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
mesh().pointInCell
(
pt,
sampleElements_[pointI],
sampleElements_[pointi],
meshSearcher.decompMode()
)
)
{
samplePoints_[pointI] = pt;
samplePoints_[pointi] = pt;
}
else
{
// Find nearest point on faces of cell
const cell& cFaces = mesh().cells()[cellI];
const cell& cFaces = mesh().cells()[celli];
scalar minDistSqr = VGREAT;
@ -378,7 +378,7 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
if (info.distance() < minDistSqr)
{
minDistSqr = info.distance();
samplePoints_[pointI] = info.rawPoint();
samplePoints_[pointi] = info.rawPoint();
}
}
}
@ -389,12 +389,12 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
// samplePoints_ : per surface point a location inside the cell
// sampleElements_ : per surface point the cell
forAll(points(), pointI)
forAll(points(), pointi)
{
const point& pt = points()[pointI];
label cellI = cellOrFaceLabels[pointToFace[pointI]];
sampleElements_[pointI] = cellI;
samplePoints_[pointI] = pt;
const point& pt = points()[pointi];
label celli = cellOrFaceLabels[pointToFace[pointi]];
sampleElements_[pointi] = celli;
samplePoints_[pointi] = pt;
}
}
else
@ -403,12 +403,12 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
// sampleElements_ : per surface point the boundary face containing
// the location
forAll(points(), pointI)
forAll(points(), pointi)
{
const point& pt = points()[pointI];
label faceI = cellOrFaceLabels[pointToFace[pointI]];
sampleElements_[pointI] = faceI;
samplePoints_[pointI] = mesh().faces()[faceI].nearestPoint
const point& pt = points()[pointi];
label facei = cellOrFaceLabels[pointToFace[pointi]];
sampleElements_[pointi] = facei;
samplePoints_[pointi] = mesh().faces()[facei].nearestPoint
(
pt,
mesh().points()
@ -444,16 +444,16 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
{
if (sampleSource_ == cells || sampleSource_ == insideCells)
{
forAll(samplePoints_, pointI)
forAll(samplePoints_, pointi)
{
meshTools::writeOBJ(str, points()[pointI]);
meshTools::writeOBJ(str, points()[pointi]);
vertI++;
meshTools::writeOBJ(str, samplePoints_[pointI]);
meshTools::writeOBJ(str, samplePoints_[pointi]);
vertI++;
label cellI = sampleElements_[pointI];
meshTools::writeOBJ(str, mesh().cellCentres()[cellI]);
label celli = sampleElements_[pointi];
meshTools::writeOBJ(str, mesh().cellCentres()[celli]);
vertI++;
str << "l " << vertI-2 << ' ' << vertI-1 << ' ' << vertI
<< nl;
@ -461,16 +461,16 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
}
else
{
forAll(samplePoints_, pointI)
forAll(samplePoints_, pointi)
{
meshTools::writeOBJ(str, points()[pointI]);
meshTools::writeOBJ(str, points()[pointi]);
vertI++;
meshTools::writeOBJ(str, samplePoints_[pointI]);
meshTools::writeOBJ(str, samplePoints_[pointi]);
vertI++;
label faceI = sampleElements_[pointI];
meshTools::writeOBJ(str, mesh().faceCentres()[faceI]);
label facei = sampleElements_[pointi];
meshTools::writeOBJ(str, mesh().faceCentres()[facei]);
vertI++;
str << "l " << vertI-2 << ' ' << vertI-1 << ' ' << vertI
<< nl;
@ -486,8 +486,8 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
meshTools::writeOBJ(str, faceCentres()[triI]);
vertI++;
label cellI = sampleElements_[triI];
meshTools::writeOBJ(str, mesh().cellCentres()[cellI]);
label celli = sampleElements_[triI];
meshTools::writeOBJ(str, mesh().cellCentres()[celli]);
vertI++;
str << "l " << vertI-1 << ' ' << vertI << nl;
}
@ -499,8 +499,8 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
meshTools::writeOBJ(str, faceCentres()[triI]);
vertI++;
label faceI = sampleElements_[triI];
meshTools::writeOBJ(str, mesh().faceCentres()[faceI]);
label facei = sampleElements_[triI];
meshTools::writeOBJ(str, mesh().faceCentres()[facei]);
vertI++;
str << "l " << vertI-1 << ' ' << vertI << nl;
}

View File

@ -58,24 +58,24 @@ Foam::sampledTriSurfaceMesh::sampleField
Field<Type> bVals(nBnd, Zero);
forAll(vField.boundaryField(), patchI)
forAll(vField.boundaryField(), patchi)
{
label bFaceI = pbm[patchI].start() - mesh().nInternalFaces();
label bFacei = pbm[patchi].start() - mesh().nInternalFaces();
SubList<Type>
(
bVals,
vField.boundaryField()[patchI].size(),
bFaceI
) = vField.boundaryField()[patchI];
vField.boundaryField()[patchi].size(),
bFacei
) = vField.boundaryField()[patchi];
}
// Sample in flat boundary field
forAll(sampleElements_, triI)
{
label faceI = sampleElements_[triI];
values[triI] = bVals[faceI-mesh().nInternalFaces()];
label facei = sampleElements_[triI];
values[triI] = bVals[facei-mesh().nInternalFaces()];
}
}
@ -98,12 +98,12 @@ Foam::sampledTriSurfaceMesh::interpolateField
{
// Sample cells.
forAll(sampleElements_, pointI)
forAll(sampleElements_, pointi)
{
values[pointI] = interpolator.interpolate
values[pointi] = interpolator.interpolate
(
samplePoints_[pointI],
sampleElements_[pointI]
samplePoints_[pointi],
sampleElements_[pointi]
);
}
}
@ -111,15 +111,15 @@ Foam::sampledTriSurfaceMesh::interpolateField
{
// Sample boundary faces.
forAll(samplePoints_, pointI)
forAll(samplePoints_, pointi)
{
label faceI = sampleElements_[pointI];
label facei = sampleElements_[pointi];
values[pointI] = interpolator.interpolate
values[pointi] = interpolator.interpolate
(
samplePoints_[pointI],
mesh().faceOwner()[faceI],
faceI
samplePoints_[pointi],
mesh().faceOwner()[facei],
facei
);
}
}

View File

@ -64,7 +64,7 @@ bool Foam::sampledThresholdCellFaces::updateGeometry() const
// 1. see if field in database
// 2. see if field can be read
const volScalarField* cellFldPtr = NULL;
const volScalarField* cellFldPtr = nullptr;
if (fvm.foundObject<volScalarField>(fieldName_))
{
if (debug)
@ -111,7 +111,7 @@ bool Foam::sampledThresholdCellFaces::updateGeometry() const
thresholdCellFaces surf
(
fvm,
cellFld.internalField(),
cellFld.primitiveField(),
lowerThreshold_,
upperThreshold_,
triangulate_

View File

@ -62,22 +62,22 @@ Foam::sampledThresholdCellFaces::interpolateField
boolList pointDone(points().size(), false);
forAll(faces(), cutFaceI)
forAll(faces(), cutFacei)
{
const face& f = faces()[cutFaceI];
const face& f = faces()[cutFacei];
forAll(f, faceVertI)
{
label pointI = f[faceVertI];
label pointi = f[faceVertI];
if (!pointDone[pointI])
if (!pointDone[pointi])
{
values[pointI] = interpolator.interpolate
values[pointi] = interpolator.interpolate
(
points()[pointI],
meshCells_[cutFaceI]
points()[pointi],
meshCells_[cutFacei]
);
pointDone[pointI] = true;
pointDone[pointi] = true;
}
}
}

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
@ -69,14 +69,14 @@ void Foam::thresholdCellFaces::calculate
0 // index
);
forAll(bMesh, patchI)
forAll(bMesh, patchi)
{
surfZones[patchI+1] = surfZone
surfZones[patchi+1] = surfZone
(
bMesh[patchI].name(),
bMesh[patchi].name(),
0, // size
0, // start
patchI+1 // index
patchi+1 // index
);
}
@ -94,32 +94,32 @@ void Foam::thresholdCellFaces::calculate
// internal faces only
for (label faceI = 0; faceI < mesh_.nInternalFaces(); ++faceI)
for (label facei = 0; facei < mesh_.nInternalFaces(); ++facei)
{
int side = 0;
// check lowerThreshold
if (field[own[faceI]] > lowerThreshold)
if (field[own[facei]] > lowerThreshold)
{
if (field[nei[faceI]] < lowerThreshold)
if (field[nei[facei]] < lowerThreshold)
{
side = +1;
}
}
else if (field[nei[faceI]] > lowerThreshold)
else if (field[nei[facei]] > lowerThreshold)
{
side = -1;
}
// check upperThreshold
if (field[own[faceI]] < upperThreshold)
if (field[own[facei]] < upperThreshold)
{
if (field[nei[faceI]] > upperThreshold)
if (field[nei[facei]] > upperThreshold)
{
side = +1;
}
}
else if (field[nei[faceI]] < upperThreshold)
else if (field[nei[facei]] < upperThreshold)
{
side = -1;
}
@ -127,7 +127,7 @@ void Foam::thresholdCellFaces::calculate
if (side)
{
const face& f = origFaces[faceI];
const face& f = origFaces[facei];
forAll(f, fp)
{
@ -144,12 +144,12 @@ void Foam::thresholdCellFaces::calculate
if (side > 0)
{
surfFace = f;
cellId = own[faceI];
cellId = own[facei];
}
else
{
surfFace = f.reverseFace();
cellId = nei[faceI];
cellId = nei[facei];
}
@ -173,10 +173,10 @@ void Foam::thresholdCellFaces::calculate
// nothing special for processor patches?
forAll(bMesh, patchI)
forAll(bMesh, patchi)
{
const polyPatch& p = bMesh[patchI];
surfZone& zone = surfZones[patchI+1];
const polyPatch& p = bMesh[patchi];
surfZone& zone = surfZones[patchi+1];
zone.start() = nFaces;
@ -189,18 +189,18 @@ void Foam::thresholdCellFaces::calculate
continue;
}
label faceI = p.start();
label facei = p.start();
// patch faces
forAll(p, localFaceI)
forAll(p, localFacei)
{
if
(
field[own[faceI]] > lowerThreshold
&& field[own[faceI]] < upperThreshold
field[own[facei]] > lowerThreshold
&& field[own[facei]] < upperThreshold
)
{
const face& f = origFaces[faceI];
const face& f = origFaces[facei];
forAll(f, fp)
{
if (oldToNewPoints[f[fp]] == -1)
@ -209,7 +209,7 @@ void Foam::thresholdCellFaces::calculate
}
}
label cellId = own[faceI];
label cellId = own[facei];
if (triangulate)
{
@ -226,7 +226,7 @@ void Foam::thresholdCellFaces::calculate
}
}
++faceI;
++facei;
}
zone.size() = surfFaces.size() - zone.start();
@ -237,19 +237,19 @@ void Foam::thresholdCellFaces::calculate
surfCells.shrink();
// renumber
forAll(surfFaces, faceI)
forAll(surfFaces, facei)
{
inplaceRenumber(oldToNewPoints, surfFaces[faceI]);
inplaceRenumber(oldToNewPoints, surfFaces[facei]);
}
pointField surfPoints(nPoints);
nPoints = 0;
forAll(oldToNewPoints, pointI)
forAll(oldToNewPoints, pointi)
{
if (oldToNewPoints[pointI] >= 0)
if (oldToNewPoints[pointi] >= 0)
{
surfPoints[oldToNewPoints[pointI]] = origPoints[pointI];
surfPoints[oldToNewPoints[pointi]] = origPoints[pointi];
nPoints++;
}
}

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
@ -49,9 +49,9 @@ void Foam::dxSurfaceWriter::writeGeometry
<< "object 1 class array type float rank 1 shape 3 items "
<< points.size() << " data follows" << nl;
forAll(points, pointI)
forAll(points, pointi)
{
const point& pt = points[pointI];
const point& pt = points[pointi];
os << float(pt.x()) << ' ' << float(pt.y()) << ' ' << float(pt.z())
<< nl;
@ -63,14 +63,14 @@ void Foam::dxSurfaceWriter::writeGeometry
<< "object 2 class array type int rank 1 shape 3 items "
<< faces.size() << " data follows" << nl;
forAll(faces, faceI)
forAll(faces, facei)
{
const face& f = faces[faceI];
const face& f = faces[facei];
if (f.size() != 3)
{
FatalErrorInFunction
<< "Face " << faceI << " vertices " << f
<< "Face " << facei << " vertices " << f
<< " is not a triangle."
<< exit(FatalError);
}

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -23,20 +23,67 @@ License
\*---------------------------------------------------------------------------*/
#include "foamFileSurfaceWriter.H"
#include "foamSurfaceWriter.H"
#include "OFstream.H"
#include "OSspecific.H"
#include "makeSurfaceWriterMethods.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
makeSurfaceWriterType(foamFileSurfaceWriter);
makeSurfaceWriterType(foamSurfaceWriter);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::foamSurfaceWriter::writeTemplate
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose
) const
{
fileName surfaceDir(outputDir/surfaceName);
if (!isDir(surfaceDir))
{
mkDir(surfaceDir);
}
if (verbose)
{
Info<< "Writing field " << fieldName << " to " << surfaceDir << endl;
}
// geometry should already have been written
// Values to separate directory (e.g. "scalarField/p")
fileName foamName(pTraits<Type>::typeName);
fileName valuesDir(surfaceDir / (foamName + Field<Type>::typeName));
if (!isDir(valuesDir))
{
mkDir(valuesDir);
}
// values
OFstream(valuesDir/fieldName)() << values;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamFileSurfaceWriter::foamFileSurfaceWriter()
Foam::foamSurfaceWriter::foamSurfaceWriter()
:
surfaceWriter()
{}
@ -44,13 +91,13 @@ Foam::foamFileSurfaceWriter::foamFileSurfaceWriter()
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamFileSurfaceWriter::~foamFileSurfaceWriter()
Foam::foamSurfaceWriter::~foamSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName Foam::foamFileSurfaceWriter::write
void Foam::foamSurfaceWriter::write
(
const fileName& outputDir,
const fileName& surfaceName,
@ -80,21 +127,19 @@ Foam::fileName Foam::foamFileSurfaceWriter::write
// Face centers. Not really necessary but very handy when reusing as inputs
// for e.g. timeVaryingMapped bc.
pointField faceCentres(faces.size(), Zero);
pointField faceCentres(faces.size(),point::zero);
forAll(faces, faceI)
forAll(faces, facei)
{
faceCentres[faceI] = faces[faceI].centre(points);
faceCentres[facei] = faces[facei].centre(points);
}
OFstream(surfaceDir/"faceCentres")() << faceCentres;
return surfaceDir;
}
// create write methods
defineSurfaceWriterWriteFields(Foam::foamFileSurfaceWriter);
// Create write methods
defineSurfaceWriterWriteFields(Foam::foamSurfaceWriter);
// ************************************************************************* //

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 | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
@ -22,18 +22,18 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::foamFileSurfaceWriter
Foam::foamSurfaceWriter
Description
A surfaceWriter for foamFiles
A surfaceWriter for foams
SourceFiles
foamFileSurfaceWriter.C
foamSurfaceWriter.C
\*---------------------------------------------------------------------------*/
#ifndef foamFileSurfaceWriter_H
#define foamFileSurfaceWriter_H
#ifndef foamSurfaceWriter_H
#define foamSurfaceWriter_H
#include "surfaceWriter.H"
@ -43,10 +43,10 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class foamFileSurfaceWriter Declaration
Class foamSurfaceWriter Declaration
\*---------------------------------------------------------------------------*/
class foamFileSurfaceWriter
class foamSurfaceWriter
:
public surfaceWriter
{
@ -70,17 +70,17 @@ class foamFileSurfaceWriter
public:
//- Runtime type information
TypeName("foamFile");
TypeName("foam");
// Constructors
//- Construct null
foamFileSurfaceWriter();
foamSurfaceWriter();
//- Destructor
virtual ~foamFileSurfaceWriter();
virtual ~foamSurfaceWriter();
// Member Functions

View File

@ -129,7 +129,7 @@ void Foam::nastranSurfaceWriter::writeKeyword
void Foam::nastranSurfaceWriter::writeCoord
(
const point& p,
const label pointI,
const label pointi,
OFstream& os
) const
{
@ -151,7 +151,7 @@ void Foam::nastranSurfaceWriter::writeCoord
os.setf(ios_base::right);
writeValue(pointI + 1, os);
writeValue(pointi + 1, os);
os << separator_;
writeValue("", os);
os << separator_;
@ -298,9 +298,9 @@ void Foam::nastranSurfaceWriter::writeGeometry
<< "$ Points" << nl
<< "$" << nl;
forAll(points, pointI)
forAll(points, pointi)
{
writeCoord(points[pointI], pointI, os);
writeCoord(points[pointi], pointi, os);
}
@ -312,19 +312,19 @@ void Foam::nastranSurfaceWriter::writeGeometry
label nFace = 1;
forAll(faces, faceI)
forAll(faces, facei)
{
const face& f = faces[faceI];
const face& f = faces[facei];
if (f.size() == 3)
{
writeFace("CTRIA3", faces[faceI], nFace, os);
decomposedFaces[faceI].append(faces[faceI]);
writeFace("CTRIA3", faces[facei], nFace, os);
decomposedFaces[facei].append(faces[facei]);
}
else if (f.size() == 4)
{
writeFace("CQUAD4", faces[faceI], nFace, os);
decomposedFaces[faceI].append(faces[faceI]);
writeFace("CQUAD4", faces[facei], nFace, os);
decomposedFaces[facei].append(faces[facei]);
}
else
{
@ -333,10 +333,10 @@ void Foam::nastranSurfaceWriter::writeGeometry
faceList triFaces;
f.triangles(points, nTri, triFaces);
forAll(triFaces, triI)
forAll(triFaces, trii)
{
writeFace("CTRIA3", triFaces[triI], nFace, os);
decomposedFaces[faceI].append(triFaces[triI]);
writeFace("CTRIA3", triFaces[trii], nFace, os);
decomposedFaces[facei].append(triFaces[trii]);
}
}
}

View File

@ -117,7 +117,7 @@ private:
void writeCoord
(
const point& p,
const label pointI,
const label pointi,
OFstream& os
) const;

View File

@ -208,10 +208,10 @@ Foam::fileName Foam::nastranSurfaceWriter::writeTemplate
forAll(decomposedFaces, i)
{
const DynamicList<face>& dFaces = decomposedFaces[i];
forAll(dFaces, faceI)
forAll(dFaces, facei)
{
Type v = Zero;
const face& f = dFaces[faceI];
const face& f = dFaces[facei];
forAll(f, fptI)
{
@ -231,9 +231,9 @@ Foam::fileName Foam::nastranSurfaceWriter::writeTemplate
{
const DynamicList<face>& dFaces = decomposedFaces[i];
forAll(dFaces, faceI)
forAll(dFaces, facei)
{
writeFaceValue(format, values[faceI], ++n, os);
writeFaceValue(format, values[facei], ++n, os);
}
}
}

View File

@ -41,10 +41,10 @@ inline void Foam::rawSurfaceWriter::writeLocation
(
Ostream& os,
const pointField& points,
const label pointI
const label pointi
)
{
const point& pt = points[pointI];
const point& pt = points[pointi];
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << ' ';
}
@ -54,10 +54,10 @@ inline void Foam::rawSurfaceWriter::writeLocation
Ostream& os,
const pointField& points,
const faceList& faces,
const label faceI
const label facei
)
{
const point& ct = faces[faceI].centre(points);
const point& ct = faces[facei].centre(points);
os << ct.x() << ' ' << ct.y() << ' ' << ct.z() << ' ';
}

View File

@ -63,7 +63,7 @@ class rawSurfaceWriter
(
Ostream&,
const pointField&,
const label pointI
const label pointi
);
static inline void writeLocation
@ -71,7 +71,7 @@ class rawSurfaceWriter
Ostream&,
const pointField&,
const faceList&,
const label faceI
const label facei
);
template<class Type>

View File

@ -53,9 +53,9 @@ void Foam::vtkSurfaceWriter::writeGeometry
// Write vertex coords
os << "POINTS " << points.size() << " double" << nl;
forAll(points, pointI)
forAll(points, pointi)
{
const point& pt = points[pointI];
const point& pt = points[pointi];
os << float(pt.x()) << ' '
<< float(pt.y()) << ' '
<< float(pt.z()) << nl;
@ -65,17 +65,17 @@ void Foam::vtkSurfaceWriter::writeGeometry
// Write faces
label nNodes = 0;
forAll(faces, faceI)
forAll(faces, facei)
{
nNodes += faces[faceI].size();
nNodes += faces[facei].size();
}
os << "POLYGONS " << faces.size() << ' '
<< faces.size() + nNodes << nl;
forAll(faces, faceI)
forAll(faces, facei)
{
const face& f = faces[faceI];
const face& f = faces[facei];
os << f.size();
forAll(f, fp)