ENH: snappyHexMesh. Added leak-path detection.

Detects connections (during refinement) between
locationsInsideMesh and locationsOutsideMesh and
writes a sampledSet for postprocessing.
This commit is contained in:
mattijs
2018-08-02 16:39:06 +01:00
parent 8f858af6c8
commit f4ae4f7b2c
47 changed files with 926746 additions and 128 deletions

View File

@ -52,5 +52,6 @@ $(setWriters)/raw/rawSetWriterRunTime.C
$(setWriters)/vtk/vtkSetWriterRunTime.C
$(setWriters)/xmgrace/xmgraceSetWriterRunTime.C
$(setWriters)/csv/csvSetWriterRunTime.C
$(setWriters)/nastran/nastranSetWriterRunTime.C
LIB = $(FOAM_LIBBIN)/libfileFormats

View File

@ -0,0 +1,228 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ 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 "nastranSetWriter.H"
#include "coordSet.H"
#include "IOmanip.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::nastranSetWriter<Type>::nastranSetWriter()
:
writer<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::nastranSetWriter<Type>::~nastranSetWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::fileName Foam::nastranSetWriter<Type>::getFileName
(
const coordSet& points,
const wordList& valueSetNames
) const
{
return this->getBaseName(points, valueSetNames) + ".nas";
}
template<class Type>
void Foam::nastranSetWriter<Type>::write
(
const coordSet& points,
const wordList& valueSetNames,
const List<const Field<Type>*>& valueSets,
Ostream& os
) const
{
os << "TITLE=OpenFOAM "
<< this->getBaseName(points, valueSetNames).c_str()
<< nl
<< "$" << nl
<< "BEGIN BULK" << nl;
forAll(points, pointi)
{
fileFormats::NASCore::writeKeyword(os, "GRID", fieldFormat::FREE);
const point& pt = points[pointi];
//os.setf(std::ios_base::right);
//os << setw(8) << pointi+1
// << setw(8) << ' '
// << setw(8) << float(pt.x())
// << setw(8) << float(pt.y())
// << setw(8) << float(pt.z())
// << nl;
//os.unsetf(std::ios_base::right);
os << ',' << pointi+1
<< ','
<< ',' << float(pt.x())
<< ',' << float(pt.y())
<< ',' << float(pt.z())
<< nl;
}
if (false)
{
// Single track with multiple segments
const label nEdges = points.size()-1;
for (label edgei = 0; edgei < nEdges; ++edgei)
{
fileFormats::NASCore::writeKeyword
(
os,
"PLOTEL",
fieldFormat::FREE
);
//os.setf(std::ios_base::right);
//os << setw(8) << edgei+1
// << setw(8) << edgei+1
// << setw(8) << edgei+2
// << nl;
//os.unsetf(std::ios_base::right);
os << ',' << edgei+1
<< ',' << edgei+1
<< ',' << edgei+2
<< nl;
}
}
os << "ENDDATA" << nl;
}
template<class Type>
void Foam::nastranSetWriter<Type>::write
(
const bool writeTracks,
const PtrList<coordSet>& tracks,
const wordList& valueSetNames,
const List<List<Field<Type>>>& valueSets,
Ostream& os
) const
{
if (valueSets.size() != valueSetNames.size())
{
FatalErrorInFunction
<< "Number of variables:" << valueSetNames.size() << endl
<< "Number of valueSets:" << valueSets.size()
<< exit(FatalError);
}
if (tracks.empty())
{
return;
}
os << "TITLE=OpenFOAM "
<< this->getBaseName(tracks[0], valueSetNames).c_str()
<< nl
<< "$" << nl
<< "BEGIN BULK" << nl;
// label nTracks = tracks.size();
// label nPoints = 0;
// forAll(tracks, i)
// {
// nPoints += tracks[i].size();
// }
label globalPti = 0;
forAll(tracks, tracki)
{
const coordSet& points = tracks[tracki];
forAll(points, pointi)
{
fileFormats::NASCore::writeKeyword(os, "GRID", fieldFormat::FREE);
const point& pt = points[pointi];
//os.setf(std::ios_base::right);
//os << setw(8) << globalPti++
// << setw(8) << ' '
// << setw(8) << float(pt.x())
// << setw(8) << float(pt.y())
// << setw(8) << float(pt.z())
// << nl;
//os.unsetf(std::ios_base::right);
os << ',' << globalPti++
<< ','
<< ',' << float(pt.x())
<< ',' << float(pt.y())
<< ',' << float(pt.z())
<< nl;
}
}
if (writeTracks)
{
// Write ids of track points to file
label globalEdgei = 0;
label globalPointi = 0;
forAll(tracks, tracki)
{
const coordSet& points = tracks[tracki];
const label nEdges = points.size()-1;
for (label edgei = 0; edgei < nEdges; ++edgei)
{
fileFormats::NASCore::writeKeyword
(
os,
"PLOTEL",
fieldFormat::FREE
);
//os.setf(std::ios_base::right);
//os << setw(8) << globalEdgei+1
// << setw(8) << globalPointi+1
// << setw(8) << globalPointi+2
// << nl;
//os.unsetf(std::ios_base::right);
os << ',' << globalEdgei+1
<< ',' << globalPointi+1
<< ',' << globalPointi+2
<< nl;
globalEdgei++;
globalPointi++;
}
}
}
os << "ENDDATA" << nl;
}
// ************************************************************************* //

View File

@ -0,0 +1,131 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::nastranSetWriter
Description
Line format in Nastran (currently hardcoded to 'free' format)
Does not do field data.
SourceFiles
nastranSetWriter.C
\*---------------------------------------------------------------------------*/
#ifndef nastranSetWriter_H
#define nastranSetWriter_H
#include "writer.H"
#include "NASCore.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class nastranSetWriter Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class nastranSetWriter
:
public writer<Type>
{
public:
//- File field formats
using fieldFormat = Foam::fileFormats::NASCore::fieldFormat;
private:
// Private Member Functions
//- Write the formatted keyword to the output stream
Ostream& writeKeyword
(
Ostream& os,
const word& keyword
) const;
public:
//- Runtime type information
TypeName("nastran");
// Constructors
//- Construct null
nastranSetWriter();
//- Destructor
virtual ~nastranSetWriter();
// Member Functions
virtual fileName getFileName
(
const coordSet&,
const wordList&
) const;
virtual void write
(
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream&
) const;
virtual void write
(
const bool writeTracks,
const PtrList<coordSet>&,
const wordList& valueSetNames,
const List<List<Field<Type>>>&,
Ostream&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "nastranSetWriter.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,37 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ 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 "nastranSetWriter.H"
#include "writers.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makeSetWriters(nastranSetWriter);
}
// ************************************************************************* //

View File

@ -2,6 +2,7 @@ EXE_INC = \
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \

View File

@ -57,6 +57,10 @@ License
#include "motionSmoother.H"
#include "faceSet.H"
// Leak path
#include "shortestPathSet.H"
#include "meshSearch.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
@ -2220,8 +2224,10 @@ Foam::label Foam::meshRefinement::findRegions
const vector& perturbVec,
const pointField& locationsInMesh,
const pointField& locationsOutsideMesh,
const writer<scalar>& leakPathFormatter,
const label nRegions,
labelList& cellRegion
labelList& cellRegion,
const boolList& blockedFace
)
{
bitSet insideCell(mesh.nCells());
@ -2273,11 +2279,170 @@ Foam::label Foam::meshRefinement::findRegions
label index = insideRegions.find(regioni);
if (index != -1)
{
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
fileName outputDir;
if (Pstream::master())
{
outputDir =
mesh.time().path()
/ (Pstream::parRun() ? ".." : "")
/ functionObject::outputPrefix
/ mesh.pointsInstance();
outputDir.clean();
mkDir(outputDir);
}
// Write the leak path
meshSearch searchEngine(mesh);
shortestPathSet leakPath
(
"leakPath",
mesh,
searchEngine,
coordSet::coordFormatNames[coordSet::coordFormat::DISTANCE],
false, //true,
50, // tbd. Number of iterations
pbm.groupPatchIDs()["wall"],
locationsInMesh,
locationsOutsideMesh,
blockedFace
);
// Split leak path according to segment. Note: segment index
// is global (= index in locationsInsideMesh)
List<pointList> segmentPoints;
List<scalarList> segmentDist;
{
label nSegments = 0;
if (leakPath.segments().size())
{
nSegments = max(leakPath.segments())+1;
}
reduce(nSegments, maxOp<label>());
labelList nElemsPerSegment(nSegments, 0);
for (label segmenti : leakPath.segments())
{
nElemsPerSegment[segmenti]++;
}
segmentPoints.setSize(nElemsPerSegment.size());
segmentDist.setSize(nElemsPerSegment.size());
forAll(nElemsPerSegment, i)
{
segmentPoints[i].setSize(nElemsPerSegment[i]);
segmentDist[i].setSize(nElemsPerSegment[i]);
}
nElemsPerSegment = 0;
forAll(leakPath, elemi)
{
label segmenti = leakPath.segments()[elemi];
pointList& points = segmentPoints[segmenti];
scalarList& dist = segmentDist[segmenti];
label& n = nElemsPerSegment[segmenti];
points[n] = leakPath[elemi];
dist[n] = leakPath.curveDist()[elemi];
n++;
}
}
PtrList<coordSet> allLeakPaths(segmentPoints.size());
forAll(allLeakPaths, segmenti)
{
// Collect data from all processors
List<pointList> gatheredPts(Pstream::nProcs());
gatheredPts[Pstream::myProcNo()] =
std::move(segmentPoints[segmenti]);
Pstream::gatherList(gatheredPts);
List<scalarList> gatheredDist(Pstream::nProcs());
gatheredDist[Pstream::myProcNo()] =
std::move(segmentDist[segmenti]);
Pstream::gatherList(gatheredDist);
// Combine processor lists into one big list.
pointList allPts
(
ListListOps::combine<pointList>
(
gatheredPts, accessOp<pointList>()
)
);
scalarList allDist
(
ListListOps::combine<scalarList>
(
gatheredDist, accessOp<scalarList>()
)
);
// Sort according to curveDist
labelList indexSet;
Foam::sortedOrder(allDist, indexSet);
allLeakPaths.set
(
segmenti,
new coordSet
(
leakPath.name(),
leakPath.axis(),
pointList(allPts, indexSet),
//scalarList(allDist, indexSet)
scalarList(allPts.size(), scalar(segmenti))
)
);
}
fileName fName;
if (Pstream::master())
{
List<List<scalarField>> allLeakData(1);
List<scalarField>& varData = allLeakData[0];
varData.setSize(allLeakPaths.size());
forAll(allLeakPaths, segmenti)
{
varData[segmenti] = allLeakPaths[segmenti].curveDist();
}
const wordList valueSetNames(1, "leakPath");
fName =
outputDir
/leakPathFormatter.getFileName
(
allLeakPaths[0],
valueSetNames
);
// Note scope to force writing to finish before
// FatalError exit
OFstream ofs(fName);
if (ofs.opened())
{
leakPathFormatter.write
(
true, // write tracks
allLeakPaths,
valueSetNames,
allLeakData,
ofs
);
}
}
Pstream::scatter(fName);
FatalErrorInFunction
<< "Location in mesh " << locationsInMesh[index]
<< " is inside same mesh region " << regioni
<< " as location outside mesh "
<< locationsOutsideMesh[i]
<< " as one of the locations outside mesh "
<< locationsOutsideMesh
<< nl << " Dumped leak path to " << fName
<< exit(FatalError);
}
}
@ -2309,7 +2474,8 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMeshRegions
const labelList& globalToMasterPatch,
const labelList& globalToSlavePatch,
const pointField& locationsInMesh,
const pointField& locationsOutsideMesh
const pointField& locationsOutsideMesh,
const writer<scalar>& leakPathFormatter
)
{
// Force calculation of face decomposition (used in findCell)
@ -2329,8 +2495,10 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMeshRegions
mergeDistance_ * vector::one, // perturbVec
locationsInMesh,
locationsOutsideMesh,
leakPathFormatter,
cellRegion.nRegions(),
cellRegion
cellRegion,
blockedFace
);
// Subset

View File

@ -56,6 +56,7 @@ SourceFiles
#include "surfaceZonesInfo.H"
#include "volumeType.H"
#include "DynamicField.H"
#include "writer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -1090,7 +1091,8 @@ public:
const labelList& globalToSlavePatch,
const pointField& locationsInMesh,
const wordList& regionsInMesh,
const pointField& locationsOutsideMesh
const pointField& locationsOutsideMesh,
const writer<scalar>& leakPathFormatter
);
//- Merge free-standing baffles
@ -1106,7 +1108,8 @@ public:
const labelList& globalToMasterPatch,
const labelList& globalToSlavePatch,
const pointField& locationsInMesh,
const pointField& locationsOutsideMesh
const pointField& locationsOutsideMesh,
const writer<scalar>& leakPathFormatter
);
//- Split off (with optional buffer layers) unreachable areas
@ -1120,7 +1123,8 @@ public:
const pointField& locationsInMesh,
const wordList& regionsInMesh,
const pointField& locationsOutsideMesh
const pointField& locationsOutsideMesh,
const writer<scalar>& leakPathFormatter
);
//- Remove cells from limitRegions if level -1
@ -1278,8 +1282,10 @@ public:
const vector& perturbVec,
const pointField& locationsInMesh,
const pointField& locationsOutsideMesh,
const writer<scalar>& leakPathFormatter,
const label nRegions,
labelList& cellRegion
labelList& cellRegion,
const boolList& blockedFace
);
//- Split mesh. Keep part containing point. Return empty map if
@ -1289,7 +1295,8 @@ public:
const labelList& globalToMasterPatch,
const labelList& globalToSlavePatch,
const pointField& locationsInMesh,
const pointField& locationsOutsideMesh
const pointField& locationsOutsideMesh,
const writer<scalar>& leakPathFormatter
);
//- Split faces into two

View File

@ -3561,7 +3561,8 @@ void Foam::meshRefinement::baffleAndSplitMesh
const pointField& locationsInMesh,
const wordList& zonesInMesh,
const pointField& locationsOutsideMesh
const pointField& locationsOutsideMesh,
const writer<scalar>& leakPathFormatter
)
{
// Introduce baffles
@ -3695,7 +3696,8 @@ void Foam::meshRefinement::baffleAndSplitMesh
globalToMasterPatch,
globalToSlavePatch,
locationsInMesh,
locationsOutsideMesh
locationsOutsideMesh,
leakPathFormatter
);
if (debug)
@ -3737,7 +3739,8 @@ void Foam::meshRefinement::mergeFreeStandingBaffles
const labelList& globalToMasterPatch,
const labelList& globalToSlavePatch,
const pointField& locationsInMesh,
const pointField& locationsOutsideMesh
const pointField& locationsOutsideMesh,
const writer<scalar>& leakPathFormatter
)
{
// Merge baffles
@ -3803,7 +3806,8 @@ void Foam::meshRefinement::mergeFreeStandingBaffles
globalToMasterPatch,
globalToSlavePatch,
locationsInMesh,
locationsOutsideMesh
locationsOutsideMesh,
leakPathFormatter
);
@ -3827,7 +3831,8 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
const pointField& locationsInMesh,
const wordList& zonesInMesh,
const pointField& locationsOutsideMesh
const pointField& locationsOutsideMesh,
const writer<scalar>& leakPathFormatter
)
{
// Determine patches to put intersections into
@ -3869,7 +3874,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
regionSplit cellRegion(mesh_, blockedFace);
blockedFace.clear();
// Set unreachable cells to -1
findRegions
@ -3878,8 +3882,10 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
mergeDistance_ * vector::one, // perturbVec
locationsInMesh,
locationsOutsideMesh,
leakPathFormatter,
cellRegion.nRegions(),
cellRegion
cellRegion,
blockedFace
);
return splitMesh

View File

@ -60,14 +60,16 @@ Foam::snappyRefineDriver::snappyRefineDriver
decompositionMethod& decomposer,
fvMeshDistribute& distributor,
const labelUList& globalToMasterPatch,
const labelUList& globalToSlavePatch
const labelUList& globalToSlavePatch,
const writer<scalar>& setFormatter
)
:
meshRefiner_(meshRefiner),
decomposer_(decomposer),
distributor_(distributor),
globalToMasterPatch_(globalToMasterPatch),
globalToSlavePatch_(globalToSlavePatch)
globalToSlavePatch_(globalToSlavePatch),
setFormatter_(setFormatter)
{}
@ -1386,7 +1388,8 @@ void Foam::snappyRefineDriver::removeInsideCells
globalToSlavePatch_,
refineParams.locationsInMesh(),
refineParams.zonesInMesh(),
refineParams.locationsOutsideMesh()
refineParams.locationsOutsideMesh(),
setFormatter_
);
if (debug&meshRefinement::MESH)
@ -2353,7 +2356,8 @@ void Foam::snappyRefineDriver::baffleAndSplitMesh
globalToSlavePatch_,
refineParams.locationsInMesh(),
refineParams.zonesInMesh(),
refineParams.locationsOutsideMesh()
refineParams.locationsOutsideMesh(),
setFormatter_
);
@ -2371,7 +2375,8 @@ void Foam::snappyRefineDriver::baffleAndSplitMesh
globalToMasterPatch_,
globalToSlavePatch_,
refineParams.locationsInMesh(),
refineParams.locationsOutsideMesh()
refineParams.locationsOutsideMesh(),
setFormatter_
);
}
}
@ -2481,7 +2486,8 @@ void Foam::snappyRefineDriver::splitAndMergeBaffles
globalToSlavePatch_,
refineParams.locationsInMesh(),
refineParams.zonesInMesh(),
refineParams.locationsOutsideMesh()
refineParams.locationsOutsideMesh(),
setFormatter_
);
// Merge free-standing baffles always
@ -2497,7 +2503,8 @@ void Foam::snappyRefineDriver::splitAndMergeBaffles
globalToMasterPatch_,
globalToSlavePatch_,
refineParams.locationsInMesh(),
refineParams.locationsOutsideMesh()
refineParams.locationsOutsideMesh(),
setFormatter_
);
if (debug)
@ -2536,7 +2543,8 @@ void Foam::snappyRefineDriver::splitAndMergeBaffles
globalToMasterPatch_,
globalToSlavePatch_,
refineParams.locationsInMesh(),
refineParams.locationsOutsideMesh()
refineParams.locationsOutsideMesh(),
setFormatter_
);
if (debug)

View File

@ -38,6 +38,7 @@ SourceFiles
#include "labelList.H"
#include "scalarField.H"
#include "Tuple2.H"
#include "writer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -76,6 +77,9 @@ class snappyRefineDriver
//- From surface region to patch
const labelList globalToSlavePatch_;
//- How to write lines. Used e.g. when writing leak-paths
const writer<scalar>& setFormatter_;
// Private Member Functions
@ -220,7 +224,8 @@ public:
decompositionMethod& decomposer,
fvMeshDistribute& distributor,
const labelUList& globalToMasterPatch,
const labelUList& globalToSlavePatch
const labelUList& globalToSlavePatch,
const writer<scalar>& setFormatter
);

View File

@ -419,7 +419,8 @@ void Foam::sampledSet::setSamples
Foam::autoPtr<Foam::coordSet> Foam::sampledSet::gather
(
labelList& indexSet
labelList& indexSet,
labelList& allSegments
) const
{
// Combine sampleSet from processors. Sort by curveDist. Return
@ -448,13 +449,11 @@ Foam::autoPtr<Foam::coordSet> Foam::sampledSet::gather
gatheredPts, accessOp<List<point>>()
)
);
labelList allSegments
(
allSegments =
ListListOps::combine<labelList>
(
gatheredSegments, accessOp<labelList>()
)
);
);
scalarList allCurveDist
(
ListListOps::combine<scalarList>
@ -475,6 +474,8 @@ Foam::autoPtr<Foam::coordSet> Foam::sampledSet::gather
Foam::sortedOrder(allCurveDist, indexSet); // uses stable sort
scalarList sortedDist(allCurveDist, indexSet); // with indices for mapping
allSegments = UIndirectList<label>(allSegments, indexSet)();
return autoPtr<coordSet>::New
(
name(),

View File

@ -296,7 +296,11 @@ public:
//- Helper: gather onto master and sort.
// \return (on master) gathered set and overall sort order
autoPtr<coordSet> gather(labelList& indexSet) const;
autoPtr<coordSet> gather
(
labelList& indexSet,
labelList& allSegments
) const;
};

View File

@ -69,10 +69,11 @@ void Foam::sampledSets::combineSampledSets
forAll(sampledSets, setI)
{
labelList segments;
masterSampledSets.set
(
setI,
sampledSets[setI].gather(indexSets[setI])
sampledSets[setI].gather(indexSets[setI], segments)
);
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,6 +30,13 @@ License
#include "addToRunTimeSelectionTable.H"
#include "FaceCellWave.H"
#include "syncTools.H"
#include "fvMesh.H"
#include "volFields.H"
#include "OBJstream.H"
#include "surfaceWriter.H"
#include "meshedSurfRef.H"
#include "PatchTools.H"
#include "vtkSurfaceWriter.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -47,6 +54,8 @@ Foam::label Foam::shortestPathSet::findMinFace
const polyMesh& mesh,
const label cellI,
const List<topoDistanceData>& allFaceInfo,
const PackedBoolList& isLeakPoint,
const bool distanceMode,
const point& origin
)
{
@ -56,6 +65,7 @@ Foam::label Foam::shortestPathSet::findMinFace
label minDist = labelMax;
label minFaceI = -1;
label nMin = 0;
forAll(cFaces2, i)
{
label faceI = cFaces2[i];
@ -64,21 +74,63 @@ Foam::label Foam::shortestPathSet::findMinFace
{
minDist = info.distance();
minFaceI = faceI;
nMin = 1;
}
else if (info.distance() == minDist)
{
nMin++;
}
}
// 2. Check all faces with minDist for minimum distance to origin
scalar minDist2 = ROOTVGREAT;
forAll(cFaces2, i)
if (nMin > 1)
{
label faceI = cFaces2[i];
if (allFaceInfo[faceI].distance() == minDist)
// 2. Check all faces with minDist for minimum (or maximum)
// distance to origin
if (distanceMode)
{
scalar d2 = magSqr(mesh.faceCentres()[faceI]-origin);
if (d2 < minDist2)
scalar minDist2 = ROOTVGREAT;
forAll(cFaces2, i)
{
minDist2 = d2;
minFaceI = faceI;
label faceI = cFaces2[i];
if (allFaceInfo[faceI].distance() == minDist)
{
scalar d2 = magSqr(mesh.faceCentres()[faceI]-origin);
if (d2 < minDist2)
{
minDist2 = d2;
minFaceI = faceI;
}
}
}
}
else
{
// Avoid leak points
label minLeakPoints = labelMax;
forAll(cFaces2, i)
{
label faceI = cFaces2[i];
if (allFaceInfo[faceI].distance() == minDist)
{
// Count number of leak points
label nLeak = 0;
{
const face& f = mesh.faces()[faceI];
forAll(f, fp)
{
if (isLeakPoint[f[fp]])
{
nLeak++;
}
}
}
if (nLeak < minLeakPoints)
{
minLeakPoints = nLeak;
minFaceI = faceI;
}
}
}
}
}
@ -87,85 +139,287 @@ Foam::label Foam::shortestPathSet::findMinFace
}
void Foam::shortestPathSet::genSamples(const polyMesh& mesh)
void Foam::shortestPathSet::calculateDistance
(
const label iter,
const polyMesh& mesh,
const label cellI,
List<topoDistanceData>& allFaceInfo,
List<topoDistanceData>& allCellInfo
) const
{
// Storage for sample points
DynamicList<point> samplingPts;
DynamicList<label> samplingCells;
DynamicList<label> samplingFaces;
DynamicList<label> samplingSegments;
DynamicList<scalar> samplingCurveDist;
int dummyTrackData = 0;
forAll(insidePoints_, pointI)
// Seed faces on cell1
DynamicList<topoDistanceData> faceDist;
DynamicList<label> cFaces1;
if (cellI != -1)
{
label cell1I = mesh.findCell(insidePoints_[pointI]);
const labelList& cFaces = mesh.cells()[cellI];
faceDist.reserve(cFaces.size());
cFaces1.reserve(cFaces.size());
//
// Pass1: Set initial changed faces from cell1 (seed)
//
List<topoDistanceData> faceDist;
labelList cFaces1;
if (cell1I != -1)
for (label facei : cFaces)
{
cFaces1 = mesh.cells()[cell1I];
faceDist.setSize
(
cFaces1.size(),
topoDistanceData(123, 0)
);
if (!allFaceInfo[facei].valid(dummyTrackData))
{
cFaces1.append(facei);
faceDist.append(topoDistanceData(123, 0));
}
}
}
// Walk through face-cell wave till all cells are reached
FaceCellWave
<
topoDistanceData
> wallDistCalc
(
mesh,
cFaces1,
faceDist,
allFaceInfo,
allCellInfo,
mesh.globalData().nTotalCells()+1 // max iterations
);
if (debug)
{
const fvMesh& fm = refCast<const fvMesh>(mesh);
const_cast<fvMesh&>(fm).setInstance(fm.time().timeName());
fm.write();
volScalarField fld
(
IOobject
(
"allCellInfo" + Foam::name(iter),
fm.time().timeName(),
fm,
IOobject::NO_READ,
IOobject::NO_WRITE
),
fm,
dimensionedScalar(dimless, Zero)
);
forAll(allCellInfo, celli)
{
fld[celli] = allCellInfo[celli].distance();
}
forAll(fld.boundaryField(), patchi)
{
const polyPatch& pp = mesh.boundaryMesh()[patchi];
SubList<topoDistanceData> p(pp.patchSlice(allFaceInfo));
scalarField pfld(fld.boundaryField()[patchi].size());
forAll(pfld, i)
{
pfld[i] = 1.0*allFaceInfo[pp.start()+i].distance();
}
fld.boundaryFieldRef()[patchi] == pfld;
}
//Note: do not swap cell values so do not do
//fld.correctBoundaryConditions();
fld.write();
}
}
void Foam::shortestPathSet::sync
(
const polyMesh& mesh,
PackedBoolList& isLeakFace,
PackedBoolList& isLeakPoint,
const label celli,
point& origin,
bool& findMinDistance
) const
{
syncTools::syncPointList
(
mesh,
isLeakPoint,
orEqOp<unsigned int>(),
0u
);
syncTools::syncFaceList
(
mesh,
isLeakFace,
orEqOp<unsigned int>()
);
// Sync origin, findMinDistance
{
typedef Tuple2<label, Tuple2<point, bool>> ProcData;
ProcData searchData
(
celli,
Tuple2<point, bool>(origin, findMinDistance)
);
Foam::combineReduce
(
searchData,
[](ProcData& x, const ProcData& y)
{
if (y.first() != -1)
{
x = y;
}
}
);
origin = searchData.second().first();
findMinDistance = searchData.second().second();
}
}
bool Foam::shortestPathSet::touchesWall
(
const polyMesh& mesh,
const label facei,
PackedBoolList& isLeakFace,
const PackedBoolList& isLeakPoint
) const
{
// Check if facei touches leakPoint
const face& f = mesh.faces()[facei];
forAll(f, fp)
{
if (isLeakPoint[f[fp]])
{
if (isLeakFace.set(facei))
{
return true;
}
}
}
return false;
}
void Foam::shortestPathSet::genSamples
(
const bool markLeakPath,
const label maxIter,
const polyMesh& mesh,
const boolList& isBlockedFace,
const point& insidePoint,
const label insideCelli,
const point& outsidePoint,
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<label>& samplingSegments,
DynamicList<scalar>& samplingCurveDist,
PackedBoolList& isLeakCell,
PackedBoolList& isLeakFace,
PackedBoolList& isLeakPoint
) const
{
const topoDistanceData maxData(labelMax, labelMax);
// Get the target point
label outsideCelli = mesh.findCell(outsidePoint);
// Maintain overall track length. Used to make curveDist continuous.
label trackLength = 0;
for (label iter = 0; iter < maxIter; iter++)
{
List<topoDistanceData> allFaceInfo(mesh.nFaces());
List<topoDistanceData> allCellInfo(mesh.nCells());
// Walk through face-cell wave till all cells are reached
FaceCellWave
<
topoDistanceData
> wallDistCalc
(
mesh,
cFaces1,
faceDist,
allFaceInfo,
allCellInfo,
mesh.globalData().nTotalCells()+1 // max iterations
);
// Mark blocked faces with high distance
forAll(isBlockedFace, facei)
{
if (isBlockedFace[facei])
{
allFaceInfo[facei] = maxData;
}
}
// Pass2: walk from outside points backwards. Note: could be done using
// FaceCellWave as well but is overly complex since does
// not allow logic comparing all faces of a cell.
if (markLeakPath)
{
// Mark any previously found leak path. This marks all
// faces of all cells on the path. This will make sure that
// ultimately the path will go through another gap.
forAll(isLeakCell, celli)
{
if (celli != insideCelli && celli != outsideCelli)
{
if (isLeakCell[celli])
{
allCellInfo[celli] = maxData;
const cell& cFaces = mesh.cells()[celli];
for (auto facei : cFaces)
{
allFaceInfo[facei] = maxData;
}
}
}
}
}
// Mark any previously found leak faces. These are faces that
// are (point-)connected to an existing boundary.
forAll(isLeakFace, facei)
{
if (isLeakFace[facei])
{
allFaceInfo[facei] = maxData;
}
}
// Pass1: Get distance to insideCelli
calculateDistance(iter, mesh, insideCelli, allFaceInfo, allCellInfo);
// Pass2: walk from outside points backwards. Note: could be done
// using FaceCellWave as well but is overly complex since
// does not allow logic comparing all faces of a cell.
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
// Get the target point
label cell2I = mesh.findCell(outsidePoints_[pointI]);
// The number of cells between cell1 and cell2 is the max number of
// iterations to search backward
label nPathPoints = 0;
if (cell2I != -1)
bool targetFound = false;
if (outsideCelli != -1)
{
if (!allCellInfo[cell2I].valid(wallDistCalc.data()))
int dummyTrackData;
targetFound = allCellInfo[outsideCelli].valid(dummyTrackData);
if (!targetFound)
{
WarningInFunction
<< "Point " << outsidePoints_[pointI]
<< " not reachable by walk. Probably mesh has "
<< " island/regions. Skipped route detection." << endl;
return;
<< "Point " << outsidePoint
<< " not reachable by walk from " << insidePoint
<< ". Probably mesh has island/regions."
<< " Skipped route detection." << endl;
}
nPathPoints = allCellInfo[cell2I].distance();
}
reduce(nPathPoints, maxOp<label>());
reduce(targetFound, orOp<bool>());
if (!targetFound)
{
break;
}
// Start with given target cell and walk back
label frontCellI = cell2I;
// If point happens to be on multiple processors, random pick
label frontCellI = outsideCelli;
point origin(outsidePoint);
bool findMinDistance = true;
while (nPathPoints--)
while (true)
{
label frontFaceI = -1;
@ -180,21 +434,32 @@ void Foam::shortestPathSet::genSamples(const polyMesh& mesh)
// x | x 2 1 2 2 3 3 4 4
// --- + --- + --- + -3- + -4- + -5-
// x | x 3 2 3 3 4 4 5 5
// e.g. if we start from cell with value = 4, we have neighbour
// faces 4, 4, 5, 5. Choose 4 (least distance to seed)
// and continue...
// e.g. if we start from cell with value = 4, we have
// neighbour faces 4, 4, 5, 5. Choose 4 (least distance
// to seed) and continue...
frontFaceI = findMinFace
(
mesh,
frontCellI,
allFaceInfo,
outsidePoints_[pointI]
isLeakPoint,
findMinDistance, // mode : find min or find max
origin
);
// Loop until we hit a boundary face
PackedBoolList isNewLeakPoint(isLeakPoint);
while (mesh.isInternalFace(frontFaceI))
{
if (isBlockedFace.size() && isBlockedFace[frontFaceI])
{
// Pout<< " Found blocked face" << endl;
frontCellI = -1;
break;
}
// Step to neighbouring cell
label nbrCellI = mesh.faceOwner()[frontFaceI];
if (nbrCellI == frontCellI)
@ -202,7 +467,7 @@ void Foam::shortestPathSet::genSamples(const polyMesh& mesh)
nbrCellI = mesh.faceNeighbour()[frontFaceI];
}
if (nbrCellI == cell1I)
if (nbrCellI == insideCelli)
{
// Pout<< " Found connection seed cell!" << endl;
frontCellI = -1;
@ -217,27 +482,57 @@ void Foam::shortestPathSet::genSamples(const polyMesh& mesh)
mesh,
frontCellI,
allFaceInfo,
outsidePoints_[pointI]
isLeakPoint,
findMinDistance,
origin
);
// Set the sampling point
samplingPts.append(mesh.cellCentres()[frontCellI]);
samplingCells.append(frontCellI);
samplingFaces.append(-1);
samplingSegments.append(pointI);
//Check if mag of distance is useful
samplingCurveDist.append(nPathPoints);
const topoDistanceData& cInfo = allCellInfo[frontCellI];
const topoDistanceData& fInfo = allFaceInfo[frontFaceI];
if (fInfo.distance() <= cInfo.distance())
{
samplingPts.append(mesh.cellCentres()[frontCellI]);
samplingCells.append(frontCellI);
samplingFaces.append(-1);
samplingSegments.append(iter);
samplingCurveDist.append
(
trackLength+cInfo.distance()
);
isLeakCell.set(frontCellI);
if
(
touchesWall
(
mesh,
frontFaceI,
isLeakFace,
isLeakPoint
)
)
{
isNewLeakPoint.set(mesh.faces()[frontFaceI]);
origin = mesh.faceCentres()[frontFaceI];
findMinDistance = false;
}
}
}
isLeakPoint.transfer(isNewLeakPoint);
}
// Situation 1: we found the destination cell (do nothing)
if (!returnReduce(frontCellI != -1, orOp<bool>()))
// Situation 1: we found the destination cell (do nothing),
// frontCellI is -1 on all processors
if (returnReduce(frontCellI == -1, andOp<bool>()))
{
break;
}
// Situation 2: we're on a coupled patch and might need to
// switch processor/cell
// switch processor/cell. We need to transfer:
// -frontface -frontdistance -leak points/faces
boolList isFront(mesh.nBoundaryFaces(), false);
if (frontFaceI != -1)
@ -246,32 +541,259 @@ void Foam::shortestPathSet::genSamples(const polyMesh& mesh)
}
syncTools::swapBoundaryFaceList(mesh, isFront);
label minCellDistance = labelMax;
if (frontCellI != -1)
{
minCellDistance = allCellInfo[frontCellI].distance();
}
reduce(minCellDistance, minOp<label>());
// Sync all leak data
sync
(
mesh,
isLeakFace,
isLeakPoint,
frontCellI,
origin,
findMinDistance
);
const label oldFrontFaceI = frontFaceI;
frontCellI = -1;
frontFaceI = -1;
forAll(pbm, patchI)
{
const polyPatch& pp = pbm[patchI];
forAll(pp, i)
{
label faceI = pp.start()+i;
if (isFront[faceI-mesh.nInternalFaces()])
if
(
oldFrontFaceI == -1
&& isFront[faceI-mesh.nInternalFaces()]
&& (isBlockedFace.empty() || !isBlockedFace[faceI])
)
{
frontFaceI = faceI;
frontCellI = pp.faceCells()[i];
break;
}
}
if (frontCellI != -1)
if
(
frontCellI != -1
&& allCellInfo[frontCellI].distance() < minCellDistance
)
{
const topoDistanceData& cInfo = allCellInfo[frontCellI];
samplingPts.append(mesh.cellCentres()[frontCellI]);
samplingCells.append(frontCellI);
samplingFaces.append(-1);
samplingSegments.append(pointI);
samplingCurveDist.append(nPathPoints);
samplingSegments.append(iter);
samplingCurveDist.append
(
trackLength+cInfo.distance()
);
isLeakCell.set(frontCellI);
// Check if frontFacei touches leakPoint
if
(
touchesWall
(
mesh,
frontFaceI,
isLeakFace,
isLeakPoint
)
)
{
isLeakPoint.set(mesh.faces()[frontFaceI]);
origin = mesh.faceCentres()[frontFaceI];
findMinDistance = false;
}
break;
}
// When seed cell is isolated by processor boundaries
if (insideCelli != -1 && frontCellI == insideCelli)
{
// Pout<< " Found connection seed cell!" << endl;
frontCellI = -1;
break;
}
}
// Sync all leak data
sync
(
mesh,
isLeakFace,
isLeakPoint,
frontCellI,
origin,
findMinDistance
);
}
// Recalculate the overall trackLength
trackLength = returnReduce
(
(
samplingCurveDist.size()
? samplingCurveDist.last()
: 0
),
maxOp<scalar>()
);
if (debug)
{
const fvMesh& fm = refCast<const fvMesh>(mesh);
const_cast<fvMesh&>(fm).setInstance(fm.time().timeName());
volScalarField fld
(
IOobject
(
"isLeakCell",
fm.time().timeName(),
fm,
IOobject::NO_READ,
IOobject::NO_WRITE
),
fm,
dimensionedScalar(dimless, Zero)
);
forAll(isLeakCell, celli)
{
fld[celli] = isLeakCell[celli];
}
fld.correctBoundaryConditions();
fld.write();
}
}
}
void Foam::shortestPathSet::genSamples
(
const bool markLeakPath,
const label maxIter,
const polyMesh& mesh,
const labelUList& wallPatches,
const boolList& isBlockedFace
)
{
// Storage for sample points
DynamicList<point> samplingPts;
DynamicList<label> samplingCells;
DynamicList<label> samplingFaces;
DynamicList<label> samplingSegments;
DynamicList<scalar> samplingCurveDist;
// Seed faces and points on 'real' boundary
PackedBoolList isLeakFace(mesh.nFaces());
PackedBoolList isLeakPoint(mesh.nPoints());
{
// Real boundaries
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
for (label patchi : wallPatches)
{
const polyPatch& pp = pbm[patchi];
forAll(pp, i)
{
isLeakPoint.set(pp[i]);
}
}
// Meshed boundaries
forAll(isBlockedFace, facei)
{
if (isBlockedFace[facei])
{
isLeakPoint.set(mesh.faces()[facei]);
}
}
syncTools::syncPointList
(
mesh,
isLeakPoint,
orEqOp<unsigned int>(),
0u
);
}
// All cells along leak paths
PackedBoolList isLeakCell(mesh.nCells());
label prevSegmenti = 0;
scalar prevDistance = 0.0;
for (auto insidePoint : insidePoints_)
{
const label insideCelli = mesh.findCell(insidePoint);
for (auto outsidePoint : outsidePoints_)
{
const label nOldSamples = samplingSegments.size();
// Append any leak path to sampling*
genSamples
(
markLeakPath,
maxIter,
mesh,
isBlockedFace,
insidePoint,
insideCelli,
outsidePoint,
samplingPts,
samplingCells,
samplingFaces,
samplingSegments,
samplingCurveDist,
isLeakCell,
isLeakFace,
isLeakPoint
);
// Make segment, distance consecutive
label maxSegment = 0;
scalar maxDistance = 0.0;
for (label i = nOldSamples; i < samplingSegments.size(); ++i)
{
samplingSegments[i] += prevSegmenti;
maxSegment = max(maxSegment, samplingSegments[i]);
samplingCurveDist[i] += prevDistance;
maxDistance = max(maxDistance, samplingCurveDist[i]);
}
prevSegmenti = returnReduce(maxSegment, maxOp<label>());
prevDistance = returnReduce(maxDistance, maxOp<scalar>());
}
}
if (debug)
{
const faceList leakFaces(mesh.faces(), isLeakFace.sortedToc());
OBJstream str(mesh.time().path()/"isLeakFace.obj");
str.write(leakFaces, mesh.points(), false);
Pout<< "Writing " << leakFaces.size() << " faces to " << str.name()
<< endl;
}
samplingPts.shrink();
samplingCells.shrink();
@ -304,15 +826,100 @@ Foam::shortestPathSet::shortestPathSet
const polyMesh& mesh,
const meshSearch& searchEngine,
const word& axis,
const bool markLeakPath,
const label maxIter,
const labelUList& wallPatches,
const pointField& insidePoints,
const pointField& outsidePoints
const pointField& outsidePoints,
const boolList& isBlockedFace
)
:
sampledSet(name, mesh, searchEngine, axis),
insidePoints_(insidePoints),
outsidePoints_(outsidePoints)
{
genSamples(mesh);
if (debug)
{
fileName outputDir;
if (Pstream::master())
{
outputDir =
mesh.time().path()
/ (Pstream::parRun() ? ".." : "")
/ functionObject::outputPrefix
/ mesh.pointsInstance();
outputDir.clean();
mkDir(outputDir);
Info<< "shortestPathSet : Writing blocked faces to "
<< outputDir << endl;
}
const vtkSurfaceWriter surfWriter;
const indirectPrimitivePatch setPatch
(
IndirectList<face>
(
mesh.faces(),
findIndices(isBlockedFace, true)
),
mesh.points()
);
if (Pstream::parRun())
{
labelList pointToGlobal;
labelList uniqueMeshPointLabels;
autoPtr<globalIndex> globalPoints;
autoPtr<globalIndex> globalFaces;
faceList mergedFaces;
pointField mergedPoints;
Foam::PatchTools::gatherAndMerge
(
mesh,
setPatch.localFaces(),
setPatch.meshPoints(),
setPatch.meshPointMap(),
pointToGlobal,
uniqueMeshPointLabels,
globalPoints,
globalFaces,
mergedFaces,
mergedPoints
);
// Write
if (Pstream::master())
{
surfWriter.write
(
outputDir,
"blockedFace",
meshedSurfRef
(
mergedPoints,
mergedFaces
)
);
}
}
else
{
surfWriter.write
(
outputDir,
"blockedFace",
meshedSurfRef
(
setPatch.localPoints(),
setPatch.localFaces()
)
);
}
}
genSamples(markLeakPath, maxIter, mesh, wallPatches, isBlockedFace);
}
@ -328,7 +935,22 @@ Foam::shortestPathSet::shortestPathSet
insidePoints_(dict.get<pointField>("insidePoints")),
outsidePoints_(dict.get<pointField>("outsidePoints"))
{
genSamples(mesh);
const label maxIter(dict.lookupOrDefault<label>("maxIter", 50));
const bool markLeakPath(dict.lookupOrDefault<bool>("markLeakPath", true));
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
DynamicList<label> wallPatches(pbm.size());
forAll(pbm, patchi)
{
const polyPatch& pp = pbm[patchi];
if (!pp.coupled() && !isA<emptyPolyPatch>(pp))
{
wallPatches.append(patchi);
}
}
genSamples(markLeakPath, maxIter, mesh, wallPatches, boolList());
}

View File

@ -73,6 +73,7 @@ SourceFiles
#define shortestPathSet_H
#include "sampledSet.H"
#include "PackedBoolList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -106,11 +107,81 @@ class shortestPathSet
const polyMesh& mesh,
const label cellI,
const List<topoDistanceData>& allFaceInfo,
const PackedBoolList& isLeakPoint,
const bool minDistance,
const point& origin
);
//- Generate whole path
void genSamples(const polyMesh& mesh);
//- Sync the leak path data
void sync
(
const polyMesh& mesh,
PackedBoolList& isLeakFace,
PackedBoolList& isLeakPoint,
const label celli,
point& origin,
bool& findMinDistance
) const;
//- Calculate (topological) distance to cellI
void calculateDistance
(
const label iter,
const polyMesh& mesh,
const label cellI,
List<topoDistanceData>& allFaceInfo,
List<topoDistanceData>& allCellInfo
) const;
//- Checks if face uses a leak point
bool touchesWall
(
const polyMesh& mesh,
const label facei,
PackedBoolList& isLeakFace,
const PackedBoolList& isLeakPoint
) const;
//- Calculate path between insideCelli (-1 if not on current processor)
// and outsidePoint. Appends cellcentres on path to track.
// isLeakCell : track passes through cell
// isLeakFace : faces of leak cells that are also on boundary
// isLeakPoint : points of leak faces ,,
void genSamples
(
const bool markLeakPath,
const label maxIter,
const polyMesh& mesh,
const boolList& isBlockedFace,
const point& insidePoint,
const label insideCelli,
const point& outsidePoint,
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<label>& samplingSegments,
DynamicList<scalar>& samplingCurveDist,
PackedBoolList& isLeakCell,
PackedBoolList& isLeakFace,
PackedBoolList& isLeakPoint
) const;
//- Generate whole path. With markLeakPath it will block all faces
// along the whole path so will maximise the chances of finding
// multiple gaps. With markLeakPath=false it will only block any
// faces connected to a boundary. This makes for the nicest
// hole-filling.
void genSamples
(
const bool markLeakPath, // mark all cells along path
const label maxIter,
const polyMesh& mesh,
const labelUList& wallPatches,
const boolList& blockedFace
);
public:
@ -121,15 +192,20 @@ public:
// Constructors
//- Construct from components
//- Construct from components. blockedFace is an optional specification
// of face that behave as if a wall
shortestPathSet
(
const word& name,
const polyMesh& mesh,
const meshSearch& searchEngine,
const word& axis,
const bool markLeakPath,
const label maxIter,
const labelUList& wallPatches,
const pointField& insidePoints,
const pointField& outsidePoints
const pointField& outsidePoints,
const boolList& blockedFace
);
//- Construct from dictionary