snappyHexMesh: Simplified and rationalised the region refinement level specification

The inside or outside region refinement level is now specified using the simple
"level <level>" entry in refinementRegions e.g.

    refinementRegions
    {
        refinementBox
        {
            mode    inside;
            level   5;
        }
    }

rather than

    refinementRegions
    {
        refinementBox
        {
            mode    inside;
            levels  ((1E15 5));
        }
    }

where the spurious "1E15" number is not used and the '((...))' is unnecessary clutter.
This commit is contained in:
Henry Weller
2021-06-15 13:20:44 +01:00
parent 7b7fa5a9af
commit be9fb841a1
20 changed files with 167 additions and 107 deletions

View File

@ -78,7 +78,7 @@ castellatedMeshControls
CAD
{
mode inside;
levels ((1E15 2));
level 2;
}
}

View File

@ -50,7 +50,7 @@ castellatedMeshControls
CAD
{
mode inside;
levels ((1E15 2));
level 2;
}
}

View File

@ -76,7 +76,7 @@ castellatedMeshControls
rotatingZone
{
mode inside;
levels ((1E15 2));
level 2;
}
*/
}

View File

@ -78,7 +78,7 @@ castellatedMeshControls
CAD
{
mode inside;
levels ((1E15 2));
level 2;
}
}

View File

@ -78,7 +78,7 @@ castellatedMeshControls
CAD
{
mode inside;
levels ((1E15 2));
level 2;
}
}

View File

@ -105,7 +105,7 @@ castellatedMeshControls
rotatingZone
{
mode inside;
levels ((1E15 2));
level 2;
}
*/
}

View File

@ -97,7 +97,7 @@ castellatedMeshControls
CAD
{
mode inside;
levels ((1E15 1));
level 1;
}
}

View File

@ -57,10 +57,35 @@ const Foam::NamedEnum<Foam::shellSurfaces::refineMode, 5>
void Foam::shellSurfaces::setAndCheckLevels
(
const label shelli,
const List<Tuple2<scalar, label>>& distLevels
const dictionary& dict
)
{
if (modes_[shelli] != refineMode::distance && distLevels.size() != 1)
const searchableSurface& shell = allGeometry_[shells_[shelli]];
if
(
modes_[shelli] == refineMode::inside
|| modes_[shelli] == refineMode::outside
)
{
if (!allGeometry_[shells_[shelli]].hasVolumeType())
{
WarningInFunction
<< "Shell " << shell.name()
<< " is not closed so testing for '"
<< refineModeNames_[modes_[shelli]]
<< "' may fail." << endl;
}
distances_[shelli].setSize(0);
levels_[shelli].setSize(1);
if (dict.found("levels") && !(dict.found("level")))
{
// Support 'levels' for backward compatibility
const List<Tuple2<scalar, label>> distLevels(dict.lookup("levels"));
if (distLevels.size() != 1)
{
FatalErrorInFunction
<< "For refinement mode "
@ -70,6 +95,69 @@ void Foam::shellSurfaces::setAndCheckLevels
<< exit(FatalError);
}
levels_[shelli][0] = distLevels[0].second();
}
else
{
if (dict.found("levels"))
{
IOWarningInFunction(dict)
<< "Found both 'level' and 'levels' entries, using 'level'."
<< endl;
}
levels_[shelli][0] = readLabel(dict.lookup("level"));
}
if (modes_[shelli] == refineMode::inside)
{
Info<< "Refinement level " << levels_[shelli][0]
<< " for all cells inside " << shell.name() << endl;
}
else
{
Info<< "Refinement level " << levels_[shelli][0]
<< " for all cells outside " << shell.name() << endl;
}
}
else if
(
modes_[shelli] == refineMode::insideSpan
|| modes_[shelli] == refineMode::outsideSpan
)
{
if (!allGeometry_[shells_[shelli]].hasVolumeType())
{
WarningInFunction
<< "Shell " << shell.name()
<< " is not closed so testing for '"
<< refineModeNames_[modes_[shelli]]
<< "' may fail." << endl;
}
distances_[shelli].setSize(1);
levels_[shelli].setSize(1);
const Tuple2<scalar, label> distLevel(dict.lookup("level"));
distances_[shelli][0] = distLevel.first();
levels_[shelli][0] = distLevel.second();
if (modes_[shelli] == refineMode::insideSpan)
{
Info<< "Refinement level " << levels_[shelli][0]
<< " for all cells inside " << shell.name()
<< " within distance " << distances_[shelli][0] << endl;
}
else
{
Info<< "Refinement level " << levels_[shelli][0]
<< " for all cells outside " << shell.name()
<< " within distance " << distances_[shelli][0] << endl;
}
}
else
{
const List<Tuple2<scalar, label>> distLevels(dict.lookup("levels"));
// Extract information into separate distance and level
distances_[shelli].setSize(distLevels.size());
levels_[shelli].setSize(distLevels.size());
@ -101,8 +189,6 @@ void Foam::shellSurfaces::setAndCheckLevels
}
}
const searchableSurface& shell = allGeometry_[shells_[shelli]];
if (modes_[shelli] == refineMode::distance)
{
Info<< "Refinement level according to distance to "
@ -115,28 +201,6 @@ void Foam::shellSurfaces::setAndCheckLevels
<< " metre." << endl;
}
}
else
{
if (!allGeometry_[shells_[shelli]].hasVolumeType())
{
FatalErrorInFunction
<< "Shell " << shell.name()
<< " does not support testing for "
<< refineModeNames_[modes_[shelli]] << endl
<< "Probably it is not closed."
<< exit(FatalError);
}
if (modes_[shelli] == refineMode::inside)
{
Info<< "Refinement level " << levels_[shelli][0]
<< " for all cells inside " << shell.name() << endl;
}
else
{
Info<< "Refinement level " << levels_[shelli][0]
<< " for all cells outside " << shell.name() << endl;
}
}
}
@ -499,7 +563,7 @@ Foam::shellSurfaces::shellSurfaces
modes_[shelli] = refineModeNames_.read(dict.lookup("mode"));
// Read pairs of distance+level
setAndCheckLevels(shelli, dict.lookup("levels"));
setAndCheckLevels(shelli, dict);
if
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -103,11 +103,7 @@ private:
// Private Member Functions
//- Helper function for initialisation.
void setAndCheckLevels
(
const label shelli,
const List<Tuple2<scalar, label>>&
);
void setAndCheckLevels(const label shelli, const dictionary& dict);
//- Specifically orient triSurfaces using a calculated point outside.
// Done since quite often triSurfaces not of consistent orientation

View File

@ -230,12 +230,12 @@ castellatedMeshControls
innerCylinder
{
mode inside;
levels ((1E15 4));
level 4;
}
middleCylinder
{
mode inside;
levels ((1E15 3));
level 3;
}
}

View File

@ -139,7 +139,7 @@ castellatedMeshControls
refinementBox
{
mode inside;
levels ((1E15 5));
level 5;
}
}

View File

@ -99,13 +99,13 @@ castellatedMeshControls
"(wake|underbody)"
{
mode inside;
levels ((1E15 4));
level 4;
}
".*stream"
{
mode inside;
levels ((1E15 3));
level 3;
}
}

View File

@ -146,7 +146,7 @@ castellatedMeshControls
refinementBox
{
mode inside;
levels ((1E15 4));
level 4;
}
}

View File

@ -57,7 +57,7 @@ castellatedMeshControls
refinementBox
{
mode inside;
levels ((1E15 2));
level 2;
}
}

View File

@ -146,7 +146,7 @@ castellatedMeshControls
// refinementBox
// {
// mode inside;
// levels ((1E15 4));
// level 4;
// }
}

View File

@ -127,7 +127,7 @@ castellatedMeshControls
refineHole
{
mode inside;
levels ((1E15 3));
level 3;
}
}

View File

@ -132,7 +132,7 @@ castellatedMeshControls
refineHole
{
mode inside;
levels ((1E15 3));
level 3;
}
}

View File

@ -62,7 +62,7 @@ castellatedMeshControls
pipeWall
{
mode insideSpan;
levels ((1000 2));
level (1000 2);
cellsAcrossSpan 40;
}
}

View File

@ -230,12 +230,12 @@ castellatedMeshControls
innerCylinder
{
mode inside;
levels ((1E15 4));
level 4;
}
middleCylinder
{
mode inside;
levels ((1E15 3));
level 3;
}
}

View File

@ -49,7 +49,7 @@ castellatedMeshControls
sloshingCylinder
{
mode inside;
levels ((1E15 1));
level 1;
}
}