Merge branch 'feature-writeLeakFaces' into 'develop'
ENH: snappyHexMesh: write leak-closure faces See merge request Development/openfoam!615
This commit is contained in:
commit
95b820368c
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,6 +52,7 @@ Description
|
||||
#include "snapParameters.H"
|
||||
#include "layerParameters.H"
|
||||
#include "vtkCoordSetWriter.H"
|
||||
#include "vtkSurfaceWriter.H"
|
||||
#include "faceSet.H"
|
||||
#include "motionSmoother.H"
|
||||
#include "polyTopoChange.H"
|
||||
@ -859,19 +860,36 @@ int main(int argc, char *argv[])
|
||||
// Writer for writing lines
|
||||
autoPtr<coordSetWriter> setFormatter;
|
||||
{
|
||||
const word setFormat
|
||||
const word writerType
|
||||
(
|
||||
meshDict.getOrDefault<word>
|
||||
(
|
||||
"setFormat",
|
||||
coordSetWriters::vtkWriter::typeName // Default: "vtk"
|
||||
coordSetWriters::vtkWriter::typeName // Default: "vtk"
|
||||
)
|
||||
);
|
||||
|
||||
setFormatter = coordSetWriter::New
|
||||
(
|
||||
setFormat,
|
||||
meshDict.subOrEmptyDict("formatOptions").optionalSubDict(setFormat)
|
||||
writerType,
|
||||
meshDict.subOrEmptyDict("formatOptions").optionalSubDict(writerType)
|
||||
);
|
||||
}
|
||||
// Writer for writing surfaces
|
||||
refPtr<surfaceWriter> surfFormatter;
|
||||
{
|
||||
const word type
|
||||
(
|
||||
meshDict.getOrDefault<word>
|
||||
(
|
||||
"surfaceFormat",
|
||||
surfaceWriters::vtkWriter::typeName // Default: "vtk"
|
||||
)
|
||||
);
|
||||
surfFormatter = surfaceWriter::New
|
||||
(
|
||||
type,
|
||||
meshDict.subOrEmptyDict("formatOptions").optionalSubDict(type)
|
||||
);
|
||||
}
|
||||
|
||||
@ -1774,6 +1792,7 @@ int main(int argc, char *argv[])
|
||||
globalToMasterPatch,
|
||||
globalToSlavePatch,
|
||||
setFormatter(),
|
||||
surfFormatter,
|
||||
dryRun
|
||||
);
|
||||
|
||||
|
@ -868,6 +868,9 @@ meshQualityControls
|
||||
//// Format for writing lines. E.g. leak path. Default is vtk format.
|
||||
//setFormat ensight;
|
||||
|
||||
//// Format to use for surfaces. E.g. leak-closure faces. Default is vtk format.
|
||||
//surfaceFormat vtk;
|
||||
|
||||
// Merge tolerance. Is fraction of overall bounding box of initial mesh.
|
||||
// Note: the write tolerance needs to be higher than this.
|
||||
mergeTolerance 1e-6;
|
||||
|
@ -60,6 +60,7 @@ SourceFiles
|
||||
#include "volumeType.H"
|
||||
#include "DynamicField.H"
|
||||
#include "coordSetWriter.H"
|
||||
#include "surfaceWriter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -613,6 +614,7 @@ private:
|
||||
const pointField& locationsOutsideMesh,
|
||||
const bool exitIfLeakPath,
|
||||
const refPtr<coordSetWriter>& leakPathFormatter,
|
||||
refPtr<surfaceWriter>& surfFormatter,
|
||||
|
||||
const labelList& neiLevel,
|
||||
const pointField& neiCc,
|
||||
@ -873,6 +875,7 @@ private:
|
||||
const pointField& locationsOutsideMesh,
|
||||
const bool exitIfLeakPath,
|
||||
const refPtr<coordSetWriter>& leakPathFormatter,
|
||||
refPtr<surfaceWriter>& surfFormatter,
|
||||
|
||||
labelList& cellToZone,
|
||||
labelList& unnamedRegion1,
|
||||
@ -1343,7 +1346,8 @@ public:
|
||||
const wordList& regionsInMesh,
|
||||
const pointField& locationsOutsideMesh,
|
||||
const bool exitIfLeakPath,
|
||||
const refPtr<coordSetWriter>& leakPathFormatter
|
||||
const refPtr<coordSetWriter>& leakPathFormatter,
|
||||
refPtr<surfaceWriter>& surfFormatter
|
||||
);
|
||||
|
||||
//- Merge free-standing baffles
|
||||
@ -1375,7 +1379,8 @@ public:
|
||||
const wordList& regionsInMesh,
|
||||
const pointField& locationsOutsideMesh,
|
||||
const bool exitIfLeakPath,
|
||||
const refPtr<coordSetWriter>& leakPathFormatter
|
||||
const refPtr<coordSetWriter>& leakPathFormatter,
|
||||
refPtr<surfaceWriter>& surfFormatter
|
||||
);
|
||||
|
||||
//- Remove cells from limitRegions if level -1
|
||||
@ -1479,6 +1484,7 @@ public:
|
||||
const pointField& locationsOutsideMesh,
|
||||
const bool exitIfLeakPath,
|
||||
const refPtr<coordSetWriter>& leakPathFormatter,
|
||||
refPtr<surfaceWriter>& surfFormatter,
|
||||
wordPairHashTable& zonesToFaceZone
|
||||
);
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -291,6 +291,7 @@ void Foam::meshRefinement::getBafflePatches
|
||||
const pointField& locationsOutsideMesh,
|
||||
const bool exitIfLeakPath,
|
||||
const refPtr<coordSetWriter>& leakPathFormatter,
|
||||
refPtr<surfaceWriter>& surfFormatter,
|
||||
const labelList& neiLevel,
|
||||
const pointField& neiCc,
|
||||
|
||||
@ -326,6 +327,7 @@ void Foam::meshRefinement::getBafflePatches
|
||||
locationsOutsideMesh,
|
||||
exitIfLeakPath,
|
||||
leakPathFormatter,
|
||||
surfFormatter,
|
||||
|
||||
cellToZone,
|
||||
unnamedRegion1,
|
||||
@ -2848,6 +2850,7 @@ void Foam::meshRefinement::zonify
|
||||
const pointField& locationsOutsideMesh,
|
||||
const bool exitIfLeakPath,
|
||||
const refPtr<coordSetWriter>& leakPathFormatter,
|
||||
refPtr<surfaceWriter>& surfFormatter,
|
||||
|
||||
labelList& cellToZone,
|
||||
labelList& unnamedRegion1,
|
||||
@ -3221,27 +3224,66 @@ void Foam::meshRefinement::zonify
|
||||
str.write(mesh_.points()[pointi]);
|
||||
}
|
||||
}
|
||||
if (debug && returnReduceOr(unnamedClosureFaces.size()))
|
||||
|
||||
if (returnReduceOr(unnamedClosureFaces.size()) && surfFormatter)
|
||||
{
|
||||
mkDir(mesh_.time().timePath());
|
||||
OBJstream str(mesh_.time().timePath()/"unnamedClosureFaces.obj");
|
||||
Pout<< "Writing " << unnamedClosureFaces.size()
|
||||
<< " unnamedClosureFaces to " << str.name() << endl;
|
||||
for (const label facei : unnamedClosureFaces)
|
||||
{
|
||||
str.write(mesh_.faces()[facei], mesh_.points(), false);
|
||||
}
|
||||
fileName outputName
|
||||
(
|
||||
mesh_.time().globalPath()
|
||||
/ functionObject::outputPrefix
|
||||
/ mesh_.pointsInstance()
|
||||
/ "unnamedClosureFaces"
|
||||
);
|
||||
outputName.clean(); // Remove unneeded ".."
|
||||
|
||||
Info<< "Writing "
|
||||
<< returnReduce(unnamedClosureFaces.size(), sumOp<label>())
|
||||
<< " unnamedClosureFaces to " << outputName << endl;
|
||||
|
||||
const indirectPrimitivePatch setPatch
|
||||
(
|
||||
IndirectList<face>(mesh_.faces(), unnamedClosureFaces),
|
||||
mesh_.points()
|
||||
);
|
||||
|
||||
surfFormatter->open
|
||||
(
|
||||
setPatch.localPoints(),
|
||||
setPatch.localFaces(),
|
||||
outputName
|
||||
);
|
||||
surfFormatter->write();
|
||||
surfFormatter->clear();
|
||||
}
|
||||
if (debug && returnReduceOr(namedClosureFaces.size()))
|
||||
if (returnReduceOr(namedClosureFaces.size()) && surfFormatter)
|
||||
{
|
||||
mkDir(mesh_.time().timePath());
|
||||
OBJstream str(mesh_.time().timePath()/"namedClosureFaces.obj");
|
||||
Pout<< "Writing " << namedClosureFaces.size()
|
||||
<< " namedClosureFaces to " << str.name() << endl;
|
||||
for (const label facei : namedClosureFaces)
|
||||
{
|
||||
str.write(mesh_.faces()[facei], mesh_.points(), false);
|
||||
}
|
||||
fileName outputName
|
||||
(
|
||||
mesh_.time().globalPath()
|
||||
/ functionObject::outputPrefix
|
||||
/ mesh_.pointsInstance()
|
||||
/ "namedClosureFaces"
|
||||
);
|
||||
outputName.clean(); // Remove unneeded ".."
|
||||
|
||||
Info<< "Writing "
|
||||
<< returnReduce(namedClosureFaces.size(), sumOp<label>())
|
||||
<< " namedClosureFaces to " << outputName << endl;
|
||||
|
||||
const indirectPrimitivePatch setPatch
|
||||
(
|
||||
IndirectList<face>(mesh_.faces(), namedClosureFaces),
|
||||
mesh_.points()
|
||||
);
|
||||
|
||||
surfFormatter->open
|
||||
(
|
||||
setPatch.localPoints(),
|
||||
setPatch.localFaces(),
|
||||
outputName
|
||||
);
|
||||
surfFormatter->write();
|
||||
surfFormatter->clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4541,7 +4583,8 @@ void Foam::meshRefinement::baffleAndSplitMesh
|
||||
const wordList& zonesInMesh,
|
||||
const pointField& locationsOutsideMesh,
|
||||
const bool exitIfLeakPath,
|
||||
const refPtr<coordSetWriter>& leakPathFormatter
|
||||
const refPtr<coordSetWriter>& leakPathFormatter,
|
||||
refPtr<surfaceWriter>& surfFormatter
|
||||
)
|
||||
{
|
||||
// Introduce baffles
|
||||
@ -4560,6 +4603,8 @@ void Foam::meshRefinement::baffleAndSplitMesh
|
||||
calcNeighbourData(neiLevel, neiCc);
|
||||
|
||||
labelList ownPatch, neiPatch;
|
||||
|
||||
refPtr<surfaceWriter> dummyWriter(nullptr);
|
||||
getBafflePatches
|
||||
(
|
||||
nErodeCellZones,
|
||||
@ -4570,6 +4615,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
|
||||
locationsOutsideMesh,
|
||||
exitIfLeakPath,
|
||||
refPtr<coordSetWriter>(nullptr),
|
||||
dummyWriter,
|
||||
|
||||
neiLevel,
|
||||
neiCc,
|
||||
@ -4635,6 +4681,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
|
||||
calcNeighbourData(neiLevel, neiCc);
|
||||
|
||||
labelList ownPatch, neiPatch;
|
||||
refPtr<surfaceWriter> dummyWriter(nullptr);
|
||||
getBafflePatches
|
||||
(
|
||||
nErodeCellZones,
|
||||
@ -4645,6 +4692,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
|
||||
locationsOutsideMesh,
|
||||
exitIfLeakPath,
|
||||
refPtr<coordSetWriter>(nullptr),
|
||||
dummyWriter,
|
||||
|
||||
neiLevel,
|
||||
neiCc,
|
||||
@ -4819,7 +4867,8 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
|
||||
const wordList& zonesInMesh,
|
||||
const pointField& locationsOutsideMesh,
|
||||
const bool exitIfLeakPath,
|
||||
const refPtr<coordSetWriter>& leakPathFormatter
|
||||
const refPtr<coordSetWriter>& leakPathFormatter,
|
||||
refPtr<surfaceWriter>& surfFormatter
|
||||
)
|
||||
{
|
||||
// Determine patches to put intersections into
|
||||
@ -4843,6 +4892,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
|
||||
locationsOutsideMesh,
|
||||
exitIfLeakPath,
|
||||
leakPathFormatter,
|
||||
surfFormatter,
|
||||
|
||||
neiLevel,
|
||||
neiCc,
|
||||
@ -5384,6 +5434,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::removeLimitShells
|
||||
|
||||
// Find intersections with all unnamed(!) surfaces
|
||||
labelList ownPatch, neiPatch;
|
||||
refPtr<surfaceWriter> dummyWriter(nullptr);
|
||||
getBafflePatches
|
||||
(
|
||||
nErodeCellZones,
|
||||
@ -5394,6 +5445,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::removeLimitShells
|
||||
locationsOutsideMesh,
|
||||
false, // do not exit. Use leak-closure instead.
|
||||
refPtr<coordSetWriter>(nullptr),
|
||||
dummyWriter,
|
||||
|
||||
neiLevel,
|
||||
neiCc,
|
||||
@ -5705,6 +5757,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
|
||||
const pointField& locationsOutsideMesh,
|
||||
const bool exitIfLeakPath,
|
||||
const refPtr<coordSetWriter>& leakPathFormatter,
|
||||
refPtr<surfaceWriter>& surfFormatter,
|
||||
wordPairHashTable& zonesToFaceZone
|
||||
)
|
||||
{
|
||||
@ -5787,6 +5840,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
|
||||
locationsOutsideMesh,
|
||||
exitIfLeakPath,
|
||||
leakPathFormatter,
|
||||
surfFormatter,
|
||||
|
||||
cellToZone,
|
||||
unnamedRegion1,
|
||||
|
@ -68,6 +68,7 @@ Foam::snappyRefineDriver::snappyRefineDriver
|
||||
const labelUList& globalToMasterPatch,
|
||||
const labelUList& globalToSlavePatch,
|
||||
coordSetWriter& setFormatter,
|
||||
refPtr<surfaceWriter>& surfFormatter,
|
||||
const bool dryRun
|
||||
)
|
||||
:
|
||||
@ -77,6 +78,7 @@ Foam::snappyRefineDriver::snappyRefineDriver
|
||||
globalToMasterPatch_(globalToMasterPatch),
|
||||
globalToSlavePatch_(globalToSlavePatch),
|
||||
setFormatter_(setFormatter),
|
||||
surfFormatter_(surfFormatter),
|
||||
dryRun_(dryRun)
|
||||
{}
|
||||
|
||||
@ -1810,7 +1812,8 @@ void Foam::snappyRefineDriver::removeInsideCells
|
||||
refineParams.zonesInMesh(),
|
||||
refineParams.locationsOutsideMesh(),
|
||||
!refineParams.useLeakClosure(),
|
||||
setFormatter_
|
||||
setFormatter_,
|
||||
surfFormatter_
|
||||
);
|
||||
|
||||
if (debug&meshRefinement::MESH)
|
||||
@ -2793,7 +2796,8 @@ void Foam::snappyRefineDriver::baffleAndSplitMesh
|
||||
refineParams.zonesInMesh(),
|
||||
refineParams.locationsOutsideMesh(),
|
||||
!refineParams.useLeakClosure(),
|
||||
setFormatter_
|
||||
setFormatter_,
|
||||
surfFormatter_
|
||||
);
|
||||
|
||||
|
||||
@ -2859,6 +2863,7 @@ void Foam::snappyRefineDriver::zonify
|
||||
refineParams.locationsOutsideMesh(),
|
||||
!refineParams.useLeakClosure(),
|
||||
setFormatter_,
|
||||
surfFormatter_,
|
||||
zonesToFaceZone
|
||||
);
|
||||
|
||||
@ -2931,7 +2936,8 @@ void Foam::snappyRefineDriver::splitAndMergeBaffles
|
||||
refineParams.zonesInMesh(),
|
||||
refineParams.locationsOutsideMesh(),
|
||||
!refineParams.useLeakClosure(),
|
||||
setFormatter_
|
||||
setFormatter_,
|
||||
surfFormatter_
|
||||
);
|
||||
|
||||
// Merge free-standing baffles always
|
||||
|
@ -85,6 +85,9 @@ class snappyRefineDriver
|
||||
//- How to write lines. Used e.g. when writing leak-paths
|
||||
coordSetWriter& setFormatter_;
|
||||
|
||||
//- How to write surfaces. Used e.g. when writing leak closure faces
|
||||
refPtr<surfaceWriter>& surfFormatter_;
|
||||
|
||||
//- Are we operating in test mode?
|
||||
const bool dryRun_;
|
||||
|
||||
@ -276,6 +279,7 @@ public:
|
||||
const labelUList& globalToMasterPatch,
|
||||
const labelUList& globalToSlavePatch,
|
||||
coordSetWriter& setFormatter,
|
||||
refPtr<surfaceWriter>& surfFormatter,
|
||||
const bool dryRun = false
|
||||
);
|
||||
|
||||
|
@ -15,6 +15,7 @@ runApplication blockMesh
|
||||
runParallel -s decompose redistributePar -decompose -constant $fileHandler
|
||||
runParallel snappyHexMesh -overwrite $fileHandler
|
||||
runParallel checkMesh -allTopology -allGeometry $fileHandler
|
||||
runParallel -s reconstruct redistributePar -reconstruct $fileHandler
|
||||
|
||||
# runParallel -s redistrib $decomp16 redistributePar -constant $fileHandler
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user