Files
OpenFOAM-12/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.C
Henry Weller b39d6b224f snappyHexMesh: Added locationsInMesh specification
In order to select to keep the cells in multiple disconnected regions it is
necessary to specify a location in each of those regions as a list of points,
e.g.

castellatedMeshControls
{
.
.
.
    locationsInMesh
    (
        (-0.18 0.003 0.05 )
        (-0.09 0.003 0.05)
        (0.09  0.003 0.05)
        (0.18  0.003 0.05)
    );
.
.
.
}

The locationInMesh control is still available for backward compatibility and to
specify a point when meshing a single region.
2021-09-27 11:43:01 +01:00

139 lines
4.2 KiB
C++

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "refinementParameters.H"
#include "unitConversion.H"
#include "polyMesh.H"
#include "globalIndex.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::refinementParameters::refinementParameters(const dictionary& dict)
:
maxGlobalCells_(dict.lookup<label>("maxGlobalCells")),
maxLocalCells_(dict.lookup<label>("maxLocalCells")),
minRefineCells_(dict.lookup<label>("minRefinementCells")),
planarAngle_
(
dict.lookupOrDefault
(
"planarAngle",
dict.lookup<scalar>("resolveFeatureAngle")
)
),
nBufferLayers_(dict.lookup<label>("nCellsBetweenLevels")),
locationsInMesh_
(
dict.found("locationsInMesh")
? List<point>(dict.lookup("locationsInMesh"))
: List<point>(1, dict.lookup("locationInMesh"))
),
allowFreeStandingZoneFaces_(dict.lookup("allowFreeStandingZoneFaces")),
useTopologicalSnapDetection_
(
dict.lookupOrDefault<bool>("useTopologicalSnapDetection", true)
),
maxLoadUnbalance_(dict.lookupOrDefault<scalar>("maxLoadUnbalance", 0)),
handleSnapProblems_
(
dict.lookupOrDefault<Switch>("handleSnapProblems", true)
)
{
InfoInFunction << locationsInMesh_ << endl;
scalar featAngle(dict.lookup<scalar>("resolveFeatureAngle"));
if (featAngle < 0 || featAngle > 180)
{
curvature_ = -great;
}
else
{
curvature_ = Foam::cos(degToRad(featAngle));
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::labelList Foam::refinementParameters::findCells(const polyMesh& mesh)
const
{
// Force calculation of tet-diag decomposition (for use in findCell)
(void)mesh.tetBasePtIs();
// Global calculation engine
globalIndex globalCells(mesh.nCells());
// Cell label per point
labelList cellLabels(locationsInMesh_.size());
forAll(locationsInMesh_, i)
{
const point& locationInMesh = locationsInMesh_[i];
label localCelli = mesh.findCell(locationInMesh);
label globalCelli = -1;
if (localCelli != -1)
{
globalCelli = globalCells.toGlobal(localCelli);
}
reduce(globalCelli, maxOp<label>());
if (globalCelli == -1)
{
FatalErrorInFunction
<< "Point " << locationInMesh
<< " is not inside the mesh or on a face or edge." << nl
<< "Bounding box of the mesh:" << mesh.bounds()
<< exit(FatalError);
}
label proci = globalCells.whichProcID(globalCelli);
label procCelli = globalCells.toLocal(proci, globalCelli);
Info<< "Found point " << locationInMesh << " in cell " << procCelli
<< " on processor " << proci << endl;
if (globalCells.isLocal(globalCelli))
{
cellLabels[i] = localCelli;
}
else
{
cellLabels[i] = -1;
}
}
return cellLabels;
}
// ************************************************************************* //