Commit 9492038b authored by franjo's avatar franjo
Browse files

Added scaling factor for cell size + improvements of the polymesher

git-svn-id: https://pl5.projectlocker.com/igui/meshGeneration/svn@3 fdcce57e-7e00-11e2-b579-49867b4cea03
parent 18c1d6cb
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
/* EXE_LIBS = -lcfdTools */
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2005-2007 Franjo Juretic
\\ / A nd | Copyright(C) 2005-2007 Franjo Juretic
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -10,7 +10,7 @@ License
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 2 of the License, or (at your
Free Software Foundation; either version 2 of the License, or(at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
......@@ -64,18 +64,18 @@ namespace Foam
void tetMeshGenerator::createTetMesh()
{
//- create tet Mesh from octree and Delaunay tets
tetMeshExtractorOctree tme ( *octreePtr_, meshDict_, mesh_ );
tetMeshExtractorOctree tme(*octreePtr_, meshDict_, mesh_);
tme.createMesh();
# ifdef DEBUG
mesh_.write();
# ifdef DEBUGfpma
writeMeshFPMA ( mesh_, "tetMesh" );
writeMeshFPMA(mesh_, "tetMesh");
# else
writeMeshEnsight ( mesh_, "tetMesh" );
writeMeshEnsight(mesh_, "tetMesh");
# endif
::exit ( EXIT_FAILURE );
::exit(EXIT_FAILURE);
# endif
}
......@@ -86,18 +86,18 @@ void tetMeshGenerator::surfacePreparation()
//- It also checks topology of cells after morphing is performed
do
{
surfaceMorpherCells* cmPtr = new surfaceMorpherCells ( mesh_ );
surfaceMorpherCells* cmPtr = new surfaceMorpherCells(mesh_);
cmPtr->morphMesh();
deleteDemandDrivenData ( cmPtr );
deleteDemandDrivenData(cmPtr);
}
while ( topologicalCleaner ( mesh_ ).cleanTopology() );
while( topologicalCleaner(mesh_).cleanTopology() );
# ifdef DEBUG
mesh_.write();
# ifdef DEBUGfpma
writeMeshFPMA ( mesh_, "afterTopoCleaning" );
writeMeshFPMA(mesh_, "afterTopoCleaning");
# else
writeMeshEnsight ( mesh_, "afterTopoCleaning" );
writeMeshEnsight(mesh_, "afterTopoCleaning");
# endif
//::exit(EXIT_FAILURE);
# endif
......@@ -106,46 +106,46 @@ void tetMeshGenerator::surfacePreparation()
void tetMeshGenerator::mapMeshToSurface()
{
//- calculate mesh surface
meshSurfaceEngine* msePtr = new meshSurfaceEngine ( mesh_ );
meshSurfaceEngine* msePtr = new meshSurfaceEngine(mesh_);
//- map mesh surface on the geometry surface
meshSurfaceMapper ( *msePtr, *octreePtr_ ).mapVerticesOntoSurface();
meshSurfaceMapper(*msePtr, *octreePtr_).mapVerticesOntoSurface();
# ifdef DEBUG
# ifdef DEBUGfpma
writeMeshFPMA ( mesh_, "afterMapping" );
writeMeshFPMA(mesh_, "afterMapping");
# else
writeMeshEnsight ( mesh_, "afterMapping" );
writeMeshEnsight(mesh_, "afterMapping");
# endif
mesh_.write();
//::exit(EXIT_FAILURE);
# endif
//- untangle surface faces
meshSurfaceOptimizer ( *msePtr, *octreePtr_ ).preOptimizeSurface();
meshSurfaceOptimizer(*msePtr, *octreePtr_).preOptimizeSurface();
# ifdef DEBUG
# ifdef DEBUGfpma
writeMeshFPMA ( mesh_, "afterSurfaceSmoothing" );
writeMeshFPMA(mesh_, "afterSurfaceSmoothing");
# else
writeMeshEnsight ( mesh_, "afterSurfaceSmoothing" );
writeMeshEnsight(mesh_, "afterSurfaceSmoothing");
# endif
mesh_.write();
//::exit(EXIT_FAILURE);
# endif
deleteDemandDrivenData ( msePtr );
deleteDemandDrivenData(msePtr);
}
void tetMeshGenerator::mapEdgesAndCorners()
{
meshSurfaceEdgeExtractorNonTopo ( mesh_, *octreePtr_ );
meshSurfaceEdgeExtractorNonTopo(mesh_, *octreePtr_);
# ifdef DEBUG
mesh_.write();
//meshOptimizer(*octreePtr_, mesh_).preOptimize();
# ifdef DEBUGfpma
writeMeshFPMA ( mesh_, "withEdges" );
writeMeshFPMA(mesh_, "withEdges");
# else
writeMeshEnsight ( mesh_, "withEdges" );
writeMeshEnsight(mesh_, "withEdges");
#endif
//::exit(EXIT_FAILURE);
# endif
......@@ -153,15 +153,15 @@ void tetMeshGenerator::mapEdgesAndCorners()
void tetMeshGenerator::optimiseMeshSurface()
{
meshSurfaceEngine mse ( mesh_ );
meshSurfaceOptimizer ( mse, *octreePtr_ ).optimizeSurface();
meshSurfaceEngine mse(mesh_);
meshSurfaceOptimizer(mse, *octreePtr_).optimizeSurface();
# ifdef DEBUG
mesh_.write();
# ifdef DEBUGfpma
writeMeshFPMA ( mesh_, "optSurfaceWithEdges" );
writeMeshFPMA(mesh_, "optSurfaceWithEdges");
# else
writeMeshEnsight ( mesh_, "optSurfaceWithEdges" );
writeMeshEnsight(mesh_, "optSurfaceWithEdges");
#endif
//::exit(EXIT_FAILURE);
# endif
......@@ -169,18 +169,18 @@ void tetMeshGenerator::optimiseMeshSurface()
void tetMeshGenerator::generateBoudaryLayers()
{
boundaryLayers bl ( mesh_ );
boundaryLayers bl(mesh_);
if ( meshDict_.found ( "boundaryLayers" ) )
if( meshDict_.found("boundaryLayers") )
{
wordList createLayers ( meshDict_.lookup ( "boundaryLayers" ) );
wordList createLayers(meshDict_.lookup("boundaryLayers"));
forAll ( createLayers, patchI )
bl.addLayerForPatch ( createLayers[patchI] );
forAll(createLayers, patchI)
bl.addLayerForPatch(createLayers[patchI]);
}
# ifdef DEBUG
writeMeshEnsight ( mesh_, "meshWithBndLayer" );
writeMeshEnsight(mesh_, "meshWithBndLayer");
mesh_.write();
//::exit(EXIT_FAILURE);
# endif
......@@ -189,45 +189,45 @@ void tetMeshGenerator::generateBoudaryLayers()
void tetMeshGenerator::optimiseFinalMesh()
{
//- final optimisation
meshOptimizer optimizer ( mesh_ );
meshOptimizer optimizer(mesh_);
optimizer.optimizeSurface ( *octreePtr_ );
optimizer.optimizeSurface(*octreePtr_);
deleteDemandDrivenData ( octreePtr_ );
deleteDemandDrivenData(octreePtr_);
optimizer.optimizeMeshFV();
# ifdef DEBUG
# ifdef DEBUGfpma
writeMeshFPMA ( mesh_,"optimisedMesh" );
writeMeshFPMA(mesh_,"optimisedMesh");
# else
writeMeshEnsight ( mesh_, "optimisedMesh" );
writeMeshEnsight(mesh_, "optimisedMesh");
#endif
# endif
}
void tetMeshGenerator::replaceBoundaries()
{
renameBoundaryPatches rbp ( mesh_, meshDict_ );
renameBoundaryPatches rbp(mesh_, meshDict_);
# ifdef DEBUG
# ifdef DEBUGfpma
writeMeshFPMA ( mesh_,"renamedPatchesMesh" );
writeMeshFPMA(mesh_,"renamedPatchesMesh");
# else
writeMeshEnsight ( mesh_, "renamedPatchesMesh" );
writeMeshEnsight(mesh_, "renamedPatchesMesh");
#endif
# endif
}
void tetMeshGenerator::renumberMesh()
{
polyMeshGenModifier ( mesh_ ).renumberMesh();
polyMeshGenModifier(mesh_).renumberMesh();
# ifdef DEBUG
# ifdef DEBUGfpma
writeMeshFPMA ( mesh_,"renumberedMesh" );
writeMeshFPMA(mesh_,"renumberedMesh");
# else
writeMeshEnsight ( mesh_, "renumberedMesh" );
writeMeshEnsight(mesh_, "renumberedMesh");
#endif
# endif
}
......@@ -260,41 +260,44 @@ tetMeshGenerator::tetMeshGenerator
(
const Time& time
)
:
runTime_ ( time ),
surfacePtr_ ( NULL ),
meshDict_
:
runTime_(time),
surfacePtr_(NULL),
meshDict_
(
IOobject
(
IOobject
(
"meshDict",
runTime_.system(),
runTime_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
octreePtr_ ( NULL ),
mesh_ ( time )
"meshDict",
runTime_.system(),
runTime_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
octreePtr_(NULL),
mesh_(time)
{
if ( true )
if( true )
{
checkMeshDict cmd ( meshDict_ );
checkMeshDict cmd(meshDict_);
}
const fileName surfaceFile = meshDict_.lookup ( "surfaceFile" );
const fileName surfaceFile = meshDict_.lookup("surfaceFile");
surfacePtr_ = new triSurf ( runTime_.path() /surfaceFile );
surfacePtr_ = new triSurf(runTime_.path()/surfaceFile);
if ( meshDict_.found ( "subsetFileName" ) )
if( meshDict_.found("subsetFileName") )
{
const fileName subsetFileName = meshDict_.lookup ( "subsetFileName" );
surfacePtr_->readFaceSubsets ( runTime_.path() /subsetFileName );
const fileName subsetFileName = meshDict_.lookup("subsetFileName");
surfacePtr_->readFaceSubsets(runTime_.path()/subsetFileName);
}
octreePtr_ = new meshOctree ( *surfacePtr_ );
octreePtr_ = new meshOctree(*surfacePtr_);
meshOctreeCreator ( *octreePtr_, meshDict_ ).createOctreeBoxes();
meshOctreeCreator* octreeCreatorPtr =
new meshOctreeCreator(*octreePtr_, meshDict_);
octreeCreatorPtr->createOctreeBoxes();
deleteDemandDrivenData(octreeCreatorPtr);
generateMesh();
}
......@@ -309,18 +312,18 @@ tetMeshGenerator::tetMeshGenerator
runTime_(time),
surfacePtr_(NULL),
meshDict_
(
(
IOobject
(
(
"meshDict",
runTime_.constant(),
runTime_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
)
),
octreePtr_(NULL),
mesh_(time)
mesh_(time)
{
fileName surfaceFile = meshDict_.lookup("surfaceFile");
......@@ -336,8 +339,8 @@ tetMeshGenerator::tetMeshGenerator
tetMeshGenerator::~tetMeshGenerator()
{
deleteDemandDrivenData ( surfacePtr_ );
deleteDemandDrivenData ( octreePtr_ );
deleteDemandDrivenData(surfacePtr_);
deleteDemandDrivenData(octreePtr_);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -45,6 +45,7 @@ namespace Foam
meshOctreeCreator::meshOctreeCreator(meshOctree& mo)
:
octree_(mo),
scalingFactor_(1.0),
meshDictPtr_(NULL),
hexRefinement_(false),
globalRefLevel_(0),
......@@ -58,6 +59,7 @@ meshOctreeCreator::meshOctreeCreator
)
:
octree_(mo),
scalingFactor_(1.0),
meshDictPtr_(&dict),
hexRefinement_(false),
globalRefLevel_(0),
......@@ -73,6 +75,7 @@ meshOctreeCreator::meshOctreeCreator
)
:
octree_(mo),
scalingFactor_(1.0),
meshDict_(dict),
hexRefinement_(false),
globalRefLevel_(0),
......@@ -101,6 +104,11 @@ meshOctreeCreator::~meshOctreeCreator()
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void meshOctreeCreator::setScalingFactor(const scalar s)
{
scalingFactor_ = s;
}
void meshOctreeCreator::activateHexRefinement()
{
hexRefinement_ = true;
......
......@@ -65,6 +65,9 @@ protected:
//- Reference to meshOctree
meshOctree& octree_;
//- Scaling factor
scalar scalingFactor_;
//- Dictionary containing information necessary to perform refinement
const IOdictionary* meshDictPtr_;
......@@ -137,6 +140,9 @@ public:
// Member Functions
//- set the scaling factor
void setScalingFactor(const scalar);
//- activate octree refinement which marks all sons of an octree box
//- for refinement in case a single son is marked for refinement
//- this type of refinement is necessary for creating hex meshes
......
......@@ -171,17 +171,18 @@ void meshOctreeCreator::refineBoxesContainedInObjects()
objectEntries.clear();
scalar s(readScalar(meshDictPtr_->lookup("maxCellSize")));
List<direction> refLevels(refObjects.size(), globalRefLevel_);
label nMarked;
do
{
nMarked = 0;
forAll(refObjects, oI)
if( refObjects[oI].cellSize() <= s * (1.+SMALL) )
{
++nMarked;
++refLevels[oI];
}
if( refObjects[oI].cellSize() <= s * (1.+SMALL) )
{
++nMarked;
++refLevels[oI];
}
s /= 2.0;
......
......@@ -57,7 +57,11 @@ void meshOctreeCreator::setRootCubeSizeAndRefParameters()
return;
}
const scalar maxSize(readScalar(meshDictPtr_->lookup("maxCellSize")));
const scalar maxSize
(
scalingFactor_ *
readScalar(meshDictPtr_->lookup("maxCellSize"))
);
octreeModifier.searchRangeAccess() = 0.25 * maxSize;
......@@ -116,7 +120,7 @@ void meshOctreeCreator::setRootCubeSizeAndRefParameters()
{
direction boundaryRefLevel_ = globalRefLevel_;
scalar cs(readScalar(meshDictPtr_->lookup("boundaryCellSize")));
cs *= (1.0 + SMALL);
cs *= (scalingFactor_ + SMALL);
octreeModifier.searchRangeAccess() = cs;
......@@ -166,7 +170,7 @@ void meshOctreeCreator::setRootCubeSizeAndRefParameters()
continue;
scalar cs = refPatches[patchI].cellSize();
cs *= (1.0 + SMALL);
cs *= (scalingFactor_ + SMALL);
label addLevel(0);
do
......@@ -216,7 +220,7 @@ void meshOctreeCreator::setRootCubeSizeAndRefParameters()
}
scalar cs = refPatches[patchI].cellSize();
cs *= (1.0 + SMALL);
cs *= (scalingFactor_+ SMALL);
label addLevel(0);
do
......
......@@ -37,10 +37,10 @@ Description
#include "meshSurfaceMapper.H"
//#include "meshSurfaceEdgeExtractorNonTopo.H"
//#include "decomposeCellsNearConcaveEdges.H"
//#include "surfaceMorpherCells.H"
#include "surfaceMorpherCells.H"
#include "meshOptimizer.H"
#include "meshSurfaceOptimizer.H"
//#include "topologicalCleaner.H"
#include "topologicalCleaner.H"
#include "boundaryLayers.H"
#include "renameBoundaryPatches.H"
#include "checkMeshDict.H"
......@@ -89,7 +89,15 @@ void voronoiMeshGenerator::surfacePreparation()
//- removes unnecessary cells and morph the boundary
//- such that there is only one boundary face per cell
//- It also checks topology of cells after morphing is performed
bool changed;
do
{
surfaceMorpherCells* cmPtr = new surfaceMorpherCells(mesh_);
cmPtr->morphMesh();
deleteDemandDrivenData(cmPtr);
}
while( topologicalCleaner(mesh_).cleanTopology() );
/* bool changed;
do
{
changed = false;
......@@ -106,6 +114,7 @@ void voronoiMeshGenerator::surfacePreparation()
} while( changed );
checkBoundaryFacesSharingTwoEdges(mesh_).improveTopology();
*/
# ifdef DEBUG
mesh_.write();
......@@ -335,7 +344,10 @@ voronoiMeshGenerator::voronoiMeshGenerator
octreePtr_ = new meshOctree(*surfacePtr_);
meshOctreeCreator(*octreePtr_, meshDict_).createOctreeBoxes();
meshOctreeCreator* octreeCreatorPtr =
new meshOctreeCreator(*octreePtr_, meshDict_);
octreeCreatorPtr->createOctreeBoxes();
deleteDemandDrivenData(octreeCreatorPtr);
generateMesh();
}
......
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