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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License 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 } // End namespace Foam

View File

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

View File

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

View File

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