snappyHexMeshConfig: removed resizing of bounds specified with '-bounds' option

This commit is contained in:
Chris Greenshields
2023-07-13 16:20:24 +01:00
parent 6e64865cfd
commit 50017eeb80
4 changed files with 30 additions and 6 deletions

View File

@ -37,20 +37,26 @@ const Foam::List<Foam::word> Foam::blockMeshCartesianConfiguration::patches =
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::blockMeshCartesianConfiguration::calcBlockMeshDict()
void Foam::blockMeshCartesianConfiguration::calcBlockMeshDict
(
const bool& boundsOpt
)
{
Info<< "Surface bounding box is " << bb_ << endl;
// Round the bounding box
// Round the bounding box if it is not specified with '-bounds' option
const scalar roundFactor = roundingScale(bb_.minDim());
roundBoundingBox(bb_, roundFactor);
if (!boundsOpt)
{
roundBoundingBox(bb_, roundFactor);
}
// Set nCells with the lowest number of cells within the range 10-20
if (nCells_ == Vector<label>::zero)
{
nCells_ = Vector<label>(bb_.span()/roundFactor);
if (!isEven(nCells_) && cmptMin(nCells_) > 20)
if (!isEven(nCells_) && cmptMin(nCells_) > 20 && !boundsOpt)
{
roundBoundingBox(bb_, 2*roundFactor);
nCells_ = Vector<label>(bb_.span()/roundFactor);
@ -258,6 +264,7 @@ Foam::blockMeshCartesianConfiguration::blockMeshCartesianConfiguration
const fileName& dir,
const Time& time,
const meshingSurfaceList& surfaces,
const bool& boundsOpt,
const Vector<label>& nCells,
const label refineFactor,
const HashTable<Pair<word>>& patchOpts,
@ -269,7 +276,7 @@ Foam::blockMeshCartesianConfiguration::blockMeshCartesianConfiguration
refineFactor_(refineFactor),
clearBoundary_(clearBoundary)
{
calcBlockMeshDict();
calcBlockMeshDict(boundsOpt);
}

View File

@ -67,7 +67,7 @@ class blockMeshCartesianConfiguration
// Private Member Functions
//- Calculate the parameters for the blockMeshDict file
void calcBlockMeshDict();
void calcBlockMeshDict(const bool& boundsOpt);
//- Write backgroundMesh sub-dictionary
void writeBackgroundMesh();
@ -116,6 +116,7 @@ public:
const fileName& dir,
const Time& time,
const meshingSurfaceList& surfaces,
const bool& boundsOpt,
const Vector<label>& nCells,
const label refineFactor,
const HashTable<Pair<word>>& patchOpts,

View File

@ -48,6 +48,11 @@ void Foam::blockMeshCylindricalConfiguration::bbInflate
bb.max() = cmptMultiply(s, bb.max());
}
bool Foam::blockMeshCylindricalConfiguration::isBoundBoxOnZaxis()
{
const vector bbMidNorm = bb_.midpoint()/bb_.mag();
return mag(bbMidNorm.x()) < rootSmall && mag(bbMidNorm.y()) < rootSmall;
}
void Foam::blockMeshCylindricalConfiguration::calcBlockMeshDict()
{
@ -406,6 +411,14 @@ Foam::blockMeshCylindricalConfiguration::blockMeshCylindricalConfiguration
refineFactor_(refineFactor),
clearBoundary_(clearBoundary)
{
if (!isBoundBoxOnZaxis())
{
FatalErrorInFunction
<< "Attempting to create a cylindrical background mesh"
<< nl << "but the geometry bounds are not aligned with the z-axis."
<< exit(FatalError);
}
if (rzbb_.volume() == 0)
{
FatalErrorInFunction

View File

@ -77,6 +77,9 @@ class blockMeshCylindricalConfiguration
//- Inflate a bounding box by a scaling vector
void bbInflate(boundBox& bb, const vector& s);
//- Are the geometry bounds aligned with the z-axis
bool isBoundBoxOnZaxis();
//- Calculate the parameters for the blockMeshDict file
void calcBlockMeshDict();