Commit da83793c authored by Franjo's avatar Franjo

Description

parent d56f72c9
......@@ -22,8 +22,8 @@ License
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
Performs point relocations in the mesh (smoothing) in order to
improve quality measures. It does not make the mesh invalied.
Generates boundary layers in the existing mesh, based on the settings
given in meshDict. It also performs necessary quality optimisation.
\*---------------------------------------------------------------------------*/
......@@ -31,120 +31,112 @@ Description
#include "Time.H"
#include "polyMeshGenModifier.H"
#include "meshOptimizer.H"
#include "boundaryLayers.H"
#include "refineBoundaryLayers.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
void generateLayer
(
polyMeshGen& mesh,
const dictionary& meshDict,
const bool layers2D
)
{
argList::validArgs.clear();
argList::validOptions.insert("nLoops", "int");
argList::validOptions.insert("nIterations", "int");
argList::validOptions.insert("nSurfaceIterations", "int");
argList::validOptions.insert("qualityThreshold", "scalar");
argList::validOptions.insert("constrainedCellsSet", "word");
# include "setRootCase.H"
# include "createTime.H"
boundaryLayers bl(mesh);
//- read the settings
label nIterations(50);
label nLoops(10);
label nSurfaceIterations(2);
scalar qualityThreshold(0.1);
if( layers2D )
bl.activate2DMode();
if( args.options().found("nLoops") )
if( meshDict.found("boundaryLayers") )
{
nLoops = readLabel(IStringStream(args.options()["nLoops"])());
const dictionary& bndLayers = meshDict.subDict("boundaryLayers");
if( bndLayers.found("nLayers") )
{
const label nLayers = readLabel(bndLayers.lookup("nLayers"));
if( nLayers > 0 )
bl.addLayerForAllPatches();
}
else if( bndLayers.found("patchBoundaryLayers") )
{
const dictionary& patchLayers =
bndLayers.subDict("patchBoundaryLayers");
const wordList createLayers = patchLayers.toc();
forAll(createLayers, patchI)
bl.addLayerForPatch(createLayers[patchI]);
}
}
else
{
Info << "Default number of loops is 10" << endl;
bl.addLayerForAllPatches();
}
}
if( args.options().found("nIterations") )
{
nIterations =
readLabel(IStringStream(args.options()["nIterations"])());
}
else
{
Info << "Default number of iterations is 50" << endl;
}
void meshOptimisation(polyMeshGen& mesh)
{
meshOptimizer mOpt(mesh);
if( args.options().found("nSurfaceIterations") )
{
nSurfaceIterations =
readLabel(IStringStream(args.options()["nSurfaceIterations"])());
}
else
{
Info << "Default number of surface iterations is 2" << endl;
}
mOpt.optimizeMeshFV();
mOpt.optimizeLowQualityFaces();
mOpt.untangleMeshFV();
mOpt.optimizeBoundaryLayer();
mOpt.untangleMeshFV();
}
if( args.options().found("qualityThreshold") )
{
qualityThreshold =
readScalar(IStringStream(args.options()["qualityThreshold"])());
}
else
void layerRefinement(polyMeshGen& mesh, const dictionary& meshDict)
{
if( meshDict.isDict("boundaryLayers") )
{
Info << "Using default quality threshold 0.1" << endl;
}
refineBoundaryLayers refLayers(mesh);
word constrainedCellSet;
refineBoundaryLayers::readSettings(meshDict, refLayers);
if( args.options().found("constrainedCellsSet") )
{
constrainedCellSet = args.options()["constrainedCellsSet"];
}
else
{
Info << "No constraints applied on the smoothing procedure" << endl;
}
//- load the mesh from disk
polyMeshGen pmg(runTime);
pmg.read();
refLayers.refineLayers();
//- construct the smoother
meshOptimizer mOpt(pmg);
meshOptimizer(mesh).untangleBoundaryLayer();
}
}
if( !constrainedCellSet.empty() )
{
//- lock cells in constrainedCellSet
mOpt.lockCellsInSubset(constrainedCellSet);
int main(int argc, char *argv[])
{
argList::validOptions.insert("2DLayers", "bool");
//- find boundary faces which shall be locked
labelLongList lockedBndFaces, selectedCells;
# include "setRootCase.H"
# include "createTime.H"
const label sId = pmg.cellSubsetIndex(constrainedCellSet);
pmg.cellsInSubset(sId, selectedCells);
IOdictionary meshDict
(
IOobject
(
"meshDict",
runTime.system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
boolList activeCell(pmg.cells().size(), false);
forAll(selectedCells, i)
activeCell[selectedCells[i]] = true;
}
//- load the mesh from disk
polyMeshGen pmg(runTime);
pmg.read();
//- clear geometry information before volume smoothing
pmg.clearAddressingData();
bool is2DLayer(false);
if( args.options().found("2DLayers") )
is2DLayer = true;
//- perform optimisation using the laplace smoother and
mOpt.optimizeMeshFV
(
nLoops,
nLoops,
nIterations,
nSurfaceIterations
);
//- generate the initial boundary layer
generateLayer(pmg, meshDict, is2DLayer);
//- perform optimisation of worst quality faces
mOpt.optimizeMeshFVBestQuality(nLoops, qualityThreshold);
//- optimisation of mesh quality
meshOptimisation(pmg);
//- check the mesh again and untangl bad regions if any of them exist
mOpt.untangleMeshFV(nLoops, nIterations, nSurfaceIterations);
//- perform layer refinement
layerRefinement(pmg, meshDict);
Info << "Writing mesh" << endl;
pmg.write();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment