ENH: FaceCellWave, localPointRegion: support for local baffles

This commit is contained in:
mattijs
2015-10-13 16:32:52 +01:00
parent d36522e64a
commit aece1c1c4d
7 changed files with 253 additions and 35 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -810,6 +810,79 @@ void Foam::FaceCellWave<Type, TrackingData>::handleAMICyclicPatches()
} }
template<class Type, class TrackingData>
void Foam::FaceCellWave<Type, TrackingData>::handleExplicitConnections()
{
// Collect changed information
DynamicList<label> f0Baffle(explicitConnections_.size());
DynamicList<Type> f0Info(explicitConnections_.size());
DynamicList<label> f1Baffle(explicitConnections_.size());
DynamicList<Type> f1Info(explicitConnections_.size());
forAll(explicitConnections_, connI)
{
const labelPair& baffle = explicitConnections_[connI];
label f0 = baffle[0];
if (changedFace_[f0])
{
f0Baffle.append(connI);
f0Info.append(allFaceInfo_[f0]);
}
label f1 = baffle[1];
if (changedFace_[f1])
{
f1Baffle.append(connI);
f1Info.append(allFaceInfo_[f1]);
}
}
// Update other side with changed information
forAll(f1Info, index)
{
const labelPair& baffle = explicitConnections_[f1Baffle[index]];
label f0 = baffle[0];
Type& currentWallInfo = allFaceInfo_[f0];
if (!currentWallInfo.equal(f1Info[index], td_))
{
updateFace
(
f0,
f1Info[index],
propagationTol_,
currentWallInfo
);
}
}
forAll(f0Info, index)
{
const labelPair& baffle = explicitConnections_[f0Baffle[index]];
label f1 = baffle[1];
Type& currentWallInfo = allFaceInfo_[f1];
if (!currentWallInfo.equal(f0Info[index], td_))
{
updateFace
(
f1,
f0Info[index],
propagationTol_,
currentWallInfo
);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Set up only. Use setFaceInfo and iterate() to do actual calculation. // Set up only. Use setFaceInfo and iterate() to do actual calculation.
@ -823,6 +896,7 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
) )
: :
mesh_(mesh), mesh_(mesh),
explicitConnections_(0),
allFaceInfo_(allFaceInfo), allFaceInfo_(allFaceInfo),
allCellInfo_(allCellInfo), allCellInfo_(allCellInfo),
td_(td), td_(td),
@ -878,6 +952,7 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
) )
: :
mesh_(mesh), mesh_(mesh),
explicitConnections_(0),
allFaceInfo_(allFaceInfo), allFaceInfo_(allFaceInfo),
allCellInfo_(allCellInfo), allCellInfo_(allCellInfo),
td_(td), td_(td),
@ -939,6 +1014,87 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
} }
// Iterate, propagating changedFacesInfo across mesh, until no change (or
// maxIter reached). Initial cell values specified.
template<class Type, class TrackingData>
Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
(
const polyMesh& mesh,
const List<labelPair>& explicitConnections,
const bool handleCyclicAMI,
const labelList& changedFaces,
const List<Type>& changedFacesInfo,
UList<Type>& allFaceInfo,
UList<Type>& allCellInfo,
const label maxIter,
TrackingData& td
)
:
mesh_(mesh),
explicitConnections_(explicitConnections),
allFaceInfo_(allFaceInfo),
allCellInfo_(allCellInfo),
td_(td),
changedFace_(mesh_.nFaces(), false),
changedFaces_(mesh_.nFaces()),
nChangedFaces_(0),
changedCell_(mesh_.nCells(), false),
changedCells_(mesh_.nCells()),
nChangedCells_(0),
hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
hasCyclicAMIPatches_
(
handleCyclicAMI
&& returnReduce(hasPatch<cyclicAMIPolyPatch>(), orOp<bool>())
),
nEvals_(0),
nUnvisitedCells_(mesh_.nCells()),
nUnvisitedFaces_(mesh_.nFaces())
{
if
(
allFaceInfo.size() != mesh_.nFaces()
|| allCellInfo.size() != mesh_.nCells()
)
{
FatalErrorIn
(
"FaceCellWave<Type, TrackingData>::FaceCellWave"
"(const polyMesh&, const List<labelPair>&, const labelList&"
", const List<Type>,"
" UList<Type>&, UList<Type>&, const label maxIter)"
) << "face and cell storage not the size of mesh faces, cells:"
<< endl
<< " allFaceInfo :" << allFaceInfo.size() << endl
<< " mesh_.nFaces():" << mesh_.nFaces() << endl
<< " allCellInfo :" << allCellInfo.size() << endl
<< " mesh_.nCells():" << mesh_.nCells()
<< exit(FatalError);
}
// Copy initial changed faces data
setFaceInfo(changedFaces, changedFacesInfo);
// Iterate until nothing changes
label iter = iterate(maxIter);
if ((maxIter > 0) && (iter >= maxIter))
{
FatalErrorIn
(
"FaceCellWave<Type, TrackingData>::FaceCellWave"
"(const polyMesh&, const List<labelPair>&, const labelList&"
", const List<Type>, UList<Type>&, UList<Type>&"
", const label maxIter)"
) << "Maximum number of iterations reached. Increase maxIter." << endl
<< " maxIter:" << maxIter << endl
<< " nChangedCells:" << nChangedCells_ << endl
<< " nChangedFaces:" << nChangedFaces_ << endl
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -1093,6 +1249,10 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::cellToFace()
// Handled all changed cells by now // Handled all changed cells by now
nChangedCells_ = 0; nChangedCells_ = 0;
// Transfer across any explicitly provided internal connections
handleExplicitConnections();
if (hasCyclicPatches_) if (hasCyclicPatches_)
{ {
// Transfer changed faces across cyclic halves // Transfer changed faces across cyclic halves

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -50,6 +50,7 @@ SourceFiles
#include "boolList.H" #include "boolList.H"
#include "labelList.H" #include "labelList.H"
#include "primitiveFieldsFwd.H" #include "primitiveFieldsFwd.H"
#include "labelPair.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -81,6 +82,9 @@ class FaceCellWave
//- Reference to mesh //- Reference to mesh
const polyMesh& mesh_; const polyMesh& mesh_;
//- Optional boundary faces that information should travel through
const List<labelPair> explicitConnections_;
//- Information for all faces //- Information for all faces
UList<Type>& allFaceInfo_; UList<Type>& allFaceInfo_;
@ -232,6 +236,10 @@ class FaceCellWave
//- Merge data from across AMI cyclics //- Merge data from across AMI cyclics
void handleAMICyclicPatches(); void handleAMICyclicPatches();
//- Merge data across explicitly provided local connections (usually
// baffles)
void handleExplicitConnections();
// Private static data // Private static data
@ -286,6 +294,23 @@ public:
TrackingData& td = dummyTrackData_ TrackingData& td = dummyTrackData_
); );
//- Construct from mesh and explicitly connected boundary faces
// and list of changed faces with the Type
// for these faces. Iterates until nothing changes or maxIter reached.
// (maxIter can be 0)
FaceCellWave
(
const polyMesh&,
const List<labelPair>& explicitConnections,
const bool handleCyclicAMI,
const labelList& initialChangedFaces,
const List<Type>& changedFacesInfo,
UList<Type>& allFaceInfo,
UList<Type>& allCellInfo,
const label maxIter,
TrackingData& td = dummyTrackData_
);
// Member Functions // Member Functions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -188,8 +188,10 @@ Foam::volumeType Foam::treeDataPrimitivePatch<PatchType>::getVolumeType
<< " nearest face:" << faceI; << " nearest face:" << faceI;
} }
const pointField& points = patch_.localPoints(); const typename PatchType::FaceType& localF = patch_.localFaces()[faceI];
const typename PatchType::FaceType& f = patch_.localFaces()[faceI]; const typename PatchType::FaceType& f = patch_[faceI];
const pointField& points = patch_.points();
const labelList& mp = patch_.meshPoints();
// Retest to classify where on face info is. Note: could be improved. We // Retest to classify where on face info is. Note: could be improved. We
// already have point. // already have point.
@ -242,7 +244,7 @@ Foam::volumeType Foam::treeDataPrimitivePatch<PatchType>::getVolumeType
return indexedOctree<treeDataPrimitivePatch>::getSide return indexedOctree<treeDataPrimitivePatch>::getSide
( (
patch_.pointNormals()[f[fp]], patch_.pointNormals()[localF[fp]],
sample - curPt sample - curPt
); );
} }
@ -280,8 +282,8 @@ Foam::volumeType Foam::treeDataPrimitivePatch<PatchType>::getVolumeType
{ {
label edgeI = fEdges[fEdgeI]; label edgeI = fEdges[fEdgeI];
const edge& e = patch_.edges()[edgeI]; const edge& e = patch_.edges()[edgeI];
const linePointRef ln(points[mp[e.start()]], points[mp[e.end()]]);
pointHit edgeHit = e.line(points).nearestDist(sample); pointHit edgeHit = ln.nearestDist(sample);
if ((magSqr(edgeHit.rawPoint() - curPt)/typDimSqr) < planarTol_) if ((magSqr(edgeHit.rawPoint() - curPt)/typDimSqr) < planarTol_)
{ {
@ -322,11 +324,7 @@ Foam::volumeType Foam::treeDataPrimitivePatch<PatchType>::getVolumeType
forAll(f, fp) forAll(f, fp)
{ {
pointHit edgeHit = linePointRef pointHit edgeHit = linePointRef(points[f[fp]], fc).nearestDist(sample);
(
points[f[fp]],
fc
).nearestDist(sample);
if ((magSqr(edgeHit.rawPoint() - curPt)/typDimSqr) < planarTol_) if ((magSqr(edgeHit.rawPoint() - curPt)/typDimSqr) < planarTol_)
{ {
@ -369,7 +367,8 @@ Foam::volumeType Foam::treeDataPrimitivePatch<PatchType>::getVolumeType
forAll(f, fp) forAll(f, fp)
{ {
Pout<< " vertex:" << f[fp] << " coord:" << points[f[fp]] Pout<< " vertex:" << f[fp]
<< " coord:" << points[f[fp]]
<< endl; << endl;
} }
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -29,7 +29,6 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Check if n is in same direction as normals of all faceLabels
bool Foam::meshTools::visNormal bool Foam::meshTools::visNormal
( (
const vector& n, const vector& n,
@ -309,7 +308,6 @@ bool Foam::meshTools::edgeOnFace
} }
// Return true if faceI part of cellI
bool Foam::meshTools::faceOnCell bool Foam::meshTools::faceOnCell
( (
const primitiveMesh& mesh, const primitiveMesh& mesh,
@ -465,7 +463,6 @@ Foam::label Foam::meshTools::getSharedFace
} }
// Get the two faces on cellI using edgeI.
void Foam::meshTools::getEdgeFaces void Foam::meshTools::getEdgeFaces
( (
const primitiveMesh& mesh, const primitiveMesh& mesh,
@ -511,7 +508,6 @@ void Foam::meshTools::getEdgeFaces
} }
// Return label of other edge connected to vertex
Foam::label Foam::meshTools::otherEdge Foam::label Foam::meshTools::otherEdge
( (
const primitiveMesh& mesh, const primitiveMesh& mesh,
@ -549,7 +545,6 @@ Foam::label Foam::meshTools::otherEdge
} }
// Return face on other side of edgeI
Foam::label Foam::meshTools::otherFace Foam::label Foam::meshTools::otherFace
( (
const primitiveMesh& mesh, const primitiveMesh& mesh,
@ -574,7 +569,6 @@ Foam::label Foam::meshTools::otherFace
} }
// Return face on other side of edgeI
Foam::label Foam::meshTools::otherCell Foam::label Foam::meshTools::otherCell
( (
const primitiveMesh& mesh, const primitiveMesh& mesh,
@ -602,8 +596,6 @@ Foam::label Foam::meshTools::otherCell
} }
// Returns label of edge nEdges away from startEdge (in the direction of
// startVertI)
Foam::label Foam::meshTools::walkFace Foam::label Foam::meshTools::walkFace
( (
const primitiveMesh& mesh, const primitiveMesh& mesh,
@ -688,7 +680,6 @@ void Foam::meshTools::constrainToMeshCentre
} }
//- Set the constrained components of directions/velocity to zero
void Foam::meshTools::constrainDirection void Foam::meshTools::constrainDirection
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -814,7 +805,6 @@ Foam::vector Foam::meshTools::edgeToCutDir
} }
// Find edges most aligned with cutDir
Foam::label Foam::meshTools::cutDirToEdge Foam::label Foam::meshTools::cutDirToEdge
( (
const primitiveMesh& mesh, const primitiveMesh& mesh,

View File

@ -2,8 +2,8 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -200,7 +200,7 @@ namespace meshTools
const label v1 const label v1
); );
//- Return edge between two vertices. Returns -1 if no edge. //- Return edge between two mesh vertices. Returns -1 if no edge.
label findEdge label findEdge
( (
const primitiveMesh&, const primitiveMesh&,

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -242,6 +242,7 @@ void Foam::localPointRegion::countPointRegions
void Foam::localPointRegion::calcPointRegions void Foam::localPointRegion::calcPointRegions
( (
const polyMesh& mesh, const polyMesh& mesh,
const labelPairList& baffles,
boolList& candidatePoint boolList& candidatePoint
) )
{ {
@ -423,6 +424,13 @@ void Foam::localPointRegion::calcPointRegions
minEqOpFace(), minEqOpFace(),
Foam::dummyTransform() // dummy transformation Foam::dummyTransform() // dummy transformation
); );
forAll(baffles, i)
{
label f0 = baffles[i].first();
label f1 = baffles[i].second();
minEqOpFace()(minRegion[f0], minRegion[f1]);
minRegion[f1] = minRegion[f0];
}
} }
@ -469,7 +477,7 @@ Foam::localPointRegion::localPointRegion(const polyMesh& mesh)
} }
} }
calcPointRegions(mesh, candidatePoint); calcPointRegions(mesh, labelPairList(0), candidatePoint);
} }
@ -492,7 +500,31 @@ Foam::localPointRegion::localPointRegion
candidatePoint[candidatePoints[i]] = true; candidatePoint[candidatePoints[i]] = true;
} }
calcPointRegions(mesh, candidatePoint); calcPointRegions(mesh, labelPairList(0), candidatePoint);
}
Foam::localPointRegion::localPointRegion
(
const polyMesh& mesh,
const labelPairList& baffles,
const labelList& candidatePoints
)
:
//nRegions_(0),
meshPointMap_(0),
pointRegions_(0),
meshFaceMap_(0),
faceRegions_(0)
{
boolList candidatePoint(mesh.nPoints(), false);
forAll(candidatePoints, i)
{
candidatePoint[candidatePoints[i]] = true;
}
calcPointRegions(mesh, baffles, candidatePoint);
} }
@ -630,16 +662,20 @@ Foam::List<Foam::labelPair> Foam::localPointRegion::findDuplicateFacePairs
<< " processorPolyPatch." << " processorPolyPatch."
<< "This is not allowed." << nl << "This is not allowed." << nl
<< "Face:" << meshFace0 << "Face:" << meshFace0
<< " fc:" << mesh.faceCentres()[meshFace0]
<< " is on patch:" << patches[patch0].name() << " is on patch:" << patches[patch0].name()
<< nl << nl
<< "Face:" << meshFace1 << "Face:" << meshFace1
<< " fc:" << mesh.faceCentres()[meshFace1]
<< " is on patch:" << patches[patch1].name() << " is on patch:" << patches[patch1].name()
<< abort(FatalError); << abort(FatalError);
} }
else
{
baffles.append(labelPair(meshFace0, meshFace1)); baffles.append(labelPair(meshFace0, meshFace1));
} }
} }
}
return baffles.shrink(); return baffles.shrink();
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -101,10 +101,10 @@ class localPointRegion
void calcPointRegions void calcPointRegions
( (
const polyMesh& mesh, const polyMesh& mesh,
const labelPairList& baffles,
boolList& candidatePoint boolList& candidatePoint
); );
//- Check if two faces are equal. If forward = false checks f1 in //- Check if two faces are equal. If forward = false checks f1 in
// reverse order. // reverse order.
static bool isDuplicate static bool isDuplicate
@ -133,6 +133,14 @@ public:
const labelList& candidatePoints const labelList& candidatePoints
); );
//- Construct from mesh and candidate points for duplication
localPointRegion
(
const polyMesh& mesh,
const labelPairList& baffles,
const labelList& candidatePoints
);
// Member Functions // Member Functions