snappyHexMeshConfig: new -closedDomain, -minDimCells, -region options

-closedDomain        domain does not contain inlets or outlets
    -minDimCells <int>   number of cells in the shortest direction, e.g. 10
    -region <name>       specify alternative mesh region
This commit is contained in:
Chris Greenshields
2024-12-12 17:30:50 +00:00
parent aebfc940a1
commit deaea4fe77
6 changed files with 146 additions and 64 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -74,6 +74,11 @@ void Foam::blockMeshCartesianConfiguration::calcBlockMeshDict
Info<< "Bounding box is now " << bb_ << endl;
if (minDimCells_ > 0)
{
nCells_ = setMinDimCells(nCells_, minDimCells_);
}
// Scale nCells_ by refine factor
nCells_ *= refineFactor_;
@ -266,6 +271,7 @@ Foam::blockMeshCartesianConfiguration::blockMeshCartesianConfiguration
const meshingSurfaceList& surfaces,
const bool& boundsOpt,
const Vector<label>& nCells,
const label minDimCells,
const label refineFactor,
const HashTable<Pair<word>>& patchOpts,
const bool clearBoundary
@ -273,6 +279,7 @@ Foam::blockMeshCartesianConfiguration::blockMeshCartesianConfiguration
:
blockMeshConfigurationBase(name, dir, time, surfaces, patchOpts),
nCells_(nCells),
minDimCells_(minDimCells),
refineFactor_(refineFactor),
clearBoundary_(clearBoundary)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -57,6 +57,9 @@ class blockMeshCartesianConfiguration
//- Number of cells in background mesh block
Vector<label> nCells_;
//- Number of cells in background mesh shortest direction
const label minDimCells_;
//- Refinement factor used to scale nCells
const label refineFactor_;
@ -118,6 +121,7 @@ public:
const meshingSurfaceList& surfaces,
const bool& boundsOpt,
const Vector<label>& nCells,
const label minDimCells,
const label refineFactor,
const HashTable<Pair<word>>& patchOpts,
const bool clearBoundary

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -99,6 +99,18 @@ inline vector roundUp(const vector& v, const scalar s)
);
}
inline Vector<label> setMinDimCells(const vector& v, const scalar s)
{
const scalar m(cmptMin(v)/s);
return Vector<label>
(
round(v.x()/m),
round(v.y()/m),
round(v.z()/m)
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -326,12 +326,14 @@ Foam::meshingSurfaceList::meshingSurfaceList
const wordList& baffles,
const boundBox& bb,
const wordList& specifiedInletRegions,
const wordList& specifiedOutletRegions
const wordList& specifiedOutletRegions,
const bool& closedDomain
)
:
PtrList<meshingSurface>(),
bb_(),
rzbb_()
rzbb_(),
closedDomain_(closedDomain)
{
// Load all the surfaces and construct the bounding box
forAll(surfaces, i)
@ -353,6 +355,7 @@ Foam::meshingSurfaceList::meshingSurfaceList
(
operator[](i).closed()
&& operator[](i).nParts() == 1
&& (closedDomain || operator[](i).regions().size() != 1)
&& bbInflate.contains(bb_)
)
{
@ -376,8 +379,13 @@ Foam::meshingSurfaceList::meshingSurfaceList
}
// If inletRegions and outletRegions are both empty, set "template"
// names
if (inletRegions.empty() && outletRegions.empty())
// names, unless "closedDomain" is specified
if
(
inletRegions.empty()
&& outletRegions.empty()
&& !closedDomain
)
{
inletRegions.append("<inletRegion>");
outletRegions.append("<outletRegion>");

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -65,6 +65,9 @@ class meshingSurfaceList
//- Bounding box for the rotatingZone surfaces
boundBox rzbb_;
//- Does the list of surfaces have inlets/outlets?
const bool closedDomain_;
// Private Member Functions
@ -122,7 +125,8 @@ public:
const wordList& baffles,
const boundBox& bb,
const wordList& inletRegions,
const wordList& outletRegions
const wordList& outletRegions,
const bool& closedDomain
);
//- Disallow default bitwise copy construction

View File

@ -95,33 +95,63 @@ Usage
Options:
- \par -surface \<file\>
Single surface geometry file for meshing
- \par -nCells \<cells\>
Number of cells in each direction, e.g. '(10 20 30)'
- \par -baffles \<list\>
Surfaces that form baffles, e.g. '(helical)'
- \par -bounds \<box\>
Bounding box of the mesh, e.g. '((-10 -5 0) (10 5 10))'
- \par -cellZones \<list\>
Surfaces that form cellZones, e.g. '(porousZone heatSource)'
- \par -clearBoundary,
Do not set default patch entries, i.e. xMin, xMax, yMin, etc...
- \par -closedDomain
Domain does not contain inlets or outlets
- \par -cylindricalBackground
Generate a cylindrical background mesh aligned with the z-axis
- \par -defaultPatch \<entry\>
Name and type of default patch, '(\<name\> \<type\>)'
- \par -explicitFeatures,
Use explicit feature capturing, default is implicit
- \par -firstLayerThickness \<value\>
Specify the thickness of the near wall cells for layer addition
- \par -inletRegions \<list\>
Inlet regions on an external surface, e.g. '(inletA inletB)'
- \par -insidePoint \<point\>
Point location inside the region of geometry to be meshed
- \par -layerExpansionRatio \<value\>
Specify the expansion ratio between layers, default 1.2
- \par -layers \<entry\>
Number of layers on specified surfaces, e.g. '((car 3) (ground 4))'
- \par -minDimCells \<cells\>
Number of cells in the shortest direction, e.g. 10
- \par -nCells \<cells\>
Number of cells in each direction, e.g. '(10 20 30)'
- \par -nCellsBetweenLevels \<int\>
Number of cells at successive refinement levels, default 3
- \par -noBackground
Do not write a blockMeshDict file
- \par -outletRegions \<list\>
Outlet regions on an external surface, e.g. '(outletA outletB)'
- \par -refineBackground \<int\>
Integer multiplier for the number of cells (>= 1)
- \par -refinementLevel \<int\>
Refinement level used by snappyHexMesh, default 2
- \par -surfaceLevels \<entry\>
Refinement level at specified surfaces, e.g. '((pipe 2) (baffles 1))'
- \par -refinementRegions \<entry\>
Refinement regions specified by '( (\<surface\> \<level\>) (...) )'
- \par -refinementBoxes \<entry\>
Refinement boxes specified by '( (\<min\> \<max\> \<level\>) (...) )'
@ -129,48 +159,27 @@ Usage
Refinement distance specified by
'( (\<surface\> \<dist\> \<level\>) (...) )'
- \par -defaultPatch \<entry\>
Name and type of default patch, '(\<name\> \<type\>)'
- \par -refinementLevel \<int\>
Refinement level used by snappyHexMesh, default 2
- \par -xMinPatch (-xMaxPatch, -yMinPatch, etc...) \<entry\>
Name and type of the xMin (xMax, yMin, etc...) patch,
'(\<name\> \<type\>)'
- \par -refinementRegions \<entry\>
Refinement regions specified by '( (\<surface\> \<level\>) (...) )'
- \par -clearBoundary,
Do not set default patch entries, i.e. xMin, xMax, yMin, etc...
- \par -explicitFeatures,
Use explicit feature capturing, default is implicit
- \par -layers \<entry\>
Number of layers on specified surfaces, e.g. '((car 3) (ground 4))'
- \par -firstLayerThickness \<value\>
Specify the thickness of the near wall cells for layer addition
- \par -layerExpansionRatio \<value\>
Specify the expansion ratio between layers, default 1.2
- \par -cellZones \<list\>
Surfaces that form cellZones, e.g. '(porousZone heatSource)'
- \par -region \<name\>
Specify alternative mesh region
- \par -rotatingZones \<list\>
Surfaces that form rotatingZones, e.g. '(rotatingZone)'
- \par -baffles \<list\>
Surfaces that form baffles, e.g. '(helical)'
- \par -surface \<file\>
Single surface geometry file for meshing
- \par -insidePoint \<point\>
Point location inside the region of geometry to be meshed
- \par -surfaceLevels \<entry\>
Refinement level at specified surfaces, e.g. '((pipe 2) (baffles 1))'
- \par -nCellsBetweenLevels \<int\>
Number of cells at successive refinement levels, default 3
- \par -inletRegions \<list\>
Inlet regions on an external surface, e.g. '(inletA inletB)'
- \par -outletRegions \<list\>
Outlet regions on an external surface, e.g. '(outletA outletB)'
- \par -xMinPatch (-xMaxPatch, -yMinPatch, etc...) \<entry\>
Name and type of the xMin (xMax, yMin, etc...) patch,
'(\<name\> \<type\>)'
\*---------------------------------------------------------------------------*/
@ -220,6 +229,7 @@ int main(int argc, char *argv[])
);
#include "removeCaseOptions.H"
#include "addRegionOption.H"
argList::addOption
(
@ -235,6 +245,13 @@ int main(int argc, char *argv[])
"number of cells in each direction, e.g. '(10 20 30)'"
);
argList::addOption
(
"minDimCells",
"int",
"number of cells in the shortest direction, e.g. 10"
);
argList::addOption
(
"bounds",
@ -400,9 +417,29 @@ int main(int argc, char *argv[])
"outlet regions on an external surface, e.g. '(outletA outletB)'"
);
argList::addBoolOption
(
"closedDomain",
"domain does not contain inlets or outlets"
);
#include "setRootCase.H"
#include "createTime.H"
word regionName;
word regionPath(runTime.system());
if (args.optionReadIfPresent("region", regionName))
{
regionPath = runTime.system()/regionName;
Info<< "Writing files to " << regionPath << nl <<endl;
if (!isDir(regionPath))
{
mkDir(regionPath);
}
}
fileNameList surfaceNames;
if (args.optionFound("surface"))
@ -492,6 +529,8 @@ int main(int argc, char *argv[])
outletRegions.append(args.optionReadList<word>("outletRegions"));
}
const bool closedDomain(args.optionFound("closedDomain"));
meshingSurfaceList surfaces
(
runTime,
@ -501,13 +540,20 @@ int main(int argc, char *argv[])
baffleNames,
bb,
inletRegions,
outletRegions
outletRegions,
closedDomain
);
const Vector<label> nCells
(
args.optionLookupOrDefault("nCells", Vector<label>::zero)
);
const label minDimCells
(
args.optionLookupOrDefault("minDimCells", 0)
);
const label refineFactor
(
args.optionLookupOrDefault("refineBackground", 1)
@ -529,7 +575,7 @@ int main(int argc, char *argv[])
blockMeshCylindricalConfiguration blockMeshConfig
(
"blockMeshDict",
runTime.system(),
regionPath,
runTime,
surfaces,
args.optionFound("bounds"),
@ -546,11 +592,12 @@ int main(int argc, char *argv[])
blockMeshCartesianConfiguration blockMeshConfig
(
"blockMeshDict",
runTime.system(),
regionPath,
runTime,
surfaces,
args.optionFound("bounds"),
nCells,
minDimCells,
refineFactor,
patchOpts,
clearBoundary
@ -641,7 +688,7 @@ int main(int argc, char *argv[])
surfaceFeaturesConfiguration surfaceFeaturesConfig
(
"surfaceFeaturesDict",
runTime.system(),
regionPath,
runTime,
surfaces
);
@ -652,7 +699,7 @@ int main(int argc, char *argv[])
snappyHexMeshConfiguration snappyConfig
(
"snappyHexMeshDict",
runTime.system(),
regionPath,
runTime,
surfaces,
refinementLevel,
@ -673,7 +720,7 @@ int main(int argc, char *argv[])
meshQualityConfiguration meshQualityConfig
(
"meshQualityDict",
runTime.system(),
regionPath,
runTime
);