Commit ba045603 authored by franjo_j@hotmail.com's avatar franjo_j@hotmail.com
Browse files

Implemented feature edges in the triangulated surface. Added automatic

creation of patches suring the meshing process.


git-svn-id: https://pl5.projectlocker.com/igui/meshGeneration/svn@13 fdcce57e-7e00-11e2-b579-49867b4cea03
parent 2a5c0638
......@@ -75,6 +75,7 @@ triSurfacePartitioner = utilities/triSurfaceTools/triSurfacePartitioner
triSurfaceDetectMaterials = utilities/triSurfaceTools/triSurfaceDetectMaterials
triSurfaceDetectPlanarRegions = utilities/triSurfaceTools/triSurfaceDetectPlanarRegions
triSurfaceDetectFeatureEdges = utilities/triSurfaceTools/triSurfaceDetectFeatureEdges
triSurfacePatchManipulator = utilities/triSurfaceTools/triSurfacePatchManipulator
polyMeshGen = utilities/meshes/polyMeshGen
writePatch = utilities/meshes/polyMeshGen/writePatch
......@@ -413,6 +414,9 @@ $(triSurfaceDetectPlanarRegions)/triSurfaceDetectPlanarRegions.C
$(triSurfaceDetectFeatureEdges)/triSurfaceDetectFeatureEdges.C
$(triSurfaceDetectFeatureEdges)/triSurfaceDetectFeatureEdgesFunctions.C
$(triSurfacePatchManipulator)/triSurfacePatchManipulator.C
$(triSurfacePatchManipulator)/triSurfacePatchManipulatorFunctions.C
$(cartesianMeshExtractor)/cartesianMeshExtractor.C
$(cartesianMeshExtractor)/cartesianMeshExtractorPointsAndAddressing.C
$(cartesianMeshExtractor)/cartesianMeshExtractorPolyMesh.C
......
......@@ -28,6 +28,7 @@ Description
#include "cartesianMeshGenerator.H"
#include "triSurf.H"
#include "triSurfacePatchManipulator.H"
#include "demandDrivenData.H"
#include "objectRegistry.H"
#include "Time.H"
......@@ -347,13 +348,19 @@ cartesianMeshGenerator::cartesianMeshGenerator(const Time& time)
surfacePtr_ = new triSurf(db_.path()/surfaceFile);
// if( meshDict_.found("subsetFileName") )
// {
// fileName subsetFileName = meshDict_.lookup("subsetFileName");
// if( Pstream::parRun() )
// subsetFileName = ".."/subsetFileName;
// surfacePtr_->readFaceSubsets(db_.path()/subsetFileName);
// }
if( surfacePtr_->featureEdges().size() != 0 )
{
//- create surface patches based on the feature edges
//- and update the meshDict based on the given data
triSurfacePatchManipulator manipulator(*surfacePtr_);
const triSurf* surfaceWithPatches =
manipulator.surfaceWithPatches(&meshDict_);
//- delete the old surface and assign the new one
deleteDemandDrivenData(surfacePtr_);
surfacePtr_ = surfaceWithPatches;
}
octreePtr_ = new meshOctree(*surfacePtr_);
......
......@@ -61,45 +61,45 @@ class cartesianMeshGenerator
const Time& db_;
//- pointer to the surface
triSurf* surfacePtr_;
const triSurf* surfacePtr_;
//- IOdictionary containing information about cell sizes, etc..
IOdictionary meshDict_;
//- pointer to the octree
meshOctree* octreePtr_;
//- mesh
polyMeshGen mesh_;
// Private member functions
//- create cartesian mesh
void createCartesianMesh();
//- prepare mesh surface
void surfacePreparation();
//- map mesh to the surface and untangle surface
void mapMeshToSurface();
//- capture edges and corners
void mapEdgesAndCorners();
//- optimise surface mesh
void optimiseMeshSurface();
//- add boundary layers
void generateBoudaryLayers();
//- mesh optimisation
void optimiseFinalMesh();
//- replace boundaries
void replaceBoundaries();
//- renumber the mesh
void renumberMesh();
//- generate mesh
void generateMesh();
......
......@@ -44,6 +44,7 @@ Description
#include "boundaryLayers.H"
#include "renameBoundaryPatches.H"
#include "checkMeshDict.H"
#include "triSurfacePatchManipulator.H"
//#define DEBUG
//#define DEBUGflma
......@@ -323,11 +324,19 @@ hexMeshGenerator::hexMeshGenerator
surfacePtr_ = new triSurf(runTime_.path()/surfaceFile);
// if( meshDict_.found("subsetFileName") )
// {
// const fileName subsetFileName = meshDict_.lookup("subsetFileName");
// surfacePtr_->readFaceSubsets(runTime_.path()/subsetFileName);
// }
if( surfacePtr_->featureEdges().size() != 0 )
{
//- create surface patches based on the feature edges
//- and update the meshDict based on the given data
triSurfacePatchManipulator manipulator(*surfacePtr_);
const triSurf* surfaceWithPatches =
manipulator.surfaceWithPatches(&meshDict_);
//- delete the old surface and assign the new one
deleteDemandDrivenData(surfacePtr_);
surfacePtr_ = surfaceWithPatches;
}
generateOctree();
......
......@@ -61,45 +61,45 @@ class hexMeshGenerator
const Time& runTime_;
//- pointer to the surface
triSurf* surfacePtr_;
const triSurf* surfacePtr_;
//- IOdictionary containing information about cell sizes, etc..
IOdictionary meshDict_;
//- pointer to the octree
meshOctree* octreePtr_;
//- mesh
polyMeshGen mesh_;
// Private member functions
//- generate octree based on user's refinement settings
void generateOctree();
//- generate dual mesh
void generateDualMesh();
//- prepare mesh surface
void surfacePreparation();
//- map mesh to the surface and untangle surface
void mapMeshToSurface();
//- optimise surface of the mesh
void optimiseMeshSurface();
//- add boundary layers
void generateBoundaryLayers();
//- mesh optimisation
void optimiseFinalMesh();
//- replace boundaries
void replaceBoundaries();
//- renumber the mesh
void renumberMesh();
//- generate mesh
void generateMesh();
......
......@@ -45,6 +45,7 @@ Description
#include "boundaryLayers.H"
#include "renameBoundaryPatches.H"
#include "checkMeshDict.H"
#include "triSurfacePatchManipulator.H"
//#define DEBUG
//#define DEBUGfpma
......@@ -297,11 +298,19 @@ tetMeshGenerator::tetMeshGenerator
surfacePtr_ = new triSurf(runTime_.path()/surfaceFile);
// if( meshDict_.found("subsetFileName") )
// {
// const fileName subsetFileName = meshDict_.lookup("subsetFileName");
// surfacePtr_->readFaceSubsets(runTime_.path()/subsetFileName);
// }
if( surfacePtr_->featureEdges().size() != 0 )
{
//- create surface patches based on the feature edges
//- and update the meshDict based on the given data
triSurfacePatchManipulator manipulator(*surfacePtr_);
const triSurf* surfaceWithPatches =
manipulator.surfaceWithPatches(&meshDict_);
//- delete the old surface and assign the new one
deleteDemandDrivenData(surfacePtr_);
surfacePtr_ = surfaceWithPatches;
}
octreePtr_ = new meshOctree(*surfacePtr_);
......
......@@ -61,7 +61,7 @@ class tetMeshGenerator
const Time& runTime_;
//- pointer to the surface
triSurf* surfacePtr_;
const triSurf* surfacePtr_;
//- IOdictionary containing information about cell sizes, etc..
IOdictionary meshDict_;
......
......@@ -29,6 +29,7 @@ Description
#include "checkMeshDict.H"
#include "patchRefinementList.H"
#include "PtrList.H"
#include "LongList.H"
#include "objectRefinement.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -38,7 +39,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void checkMeshDict::checkPatchCellSize()
void checkMeshDict::checkPatchCellSize() const
{
if( meshDict_.found("patchCellSize") )
{
......@@ -57,7 +58,7 @@ void checkMeshDict::checkPatchCellSize()
}
}
void checkMeshDict::checkSubsetCellSize()
void checkMeshDict::checkSubsetCellSize() const
{
if( meshDict_.found("subsetCellSize") )
{
......@@ -75,7 +76,7 @@ void checkMeshDict::checkSubsetCellSize()
}
}
void checkMeshDict::checkKeepCellsIntersectingPatches()
void checkMeshDict::checkKeepCellsIntersectingPatches() const
{
if( meshDict_.found("keepCellsIntersectingPatches") )
{
......@@ -94,7 +95,7 @@ void checkMeshDict::checkKeepCellsIntersectingPatches()
}
}
void checkMeshDict::checkRemoveCellsIntersectingPatches()
void checkMeshDict::checkRemoveCellsIntersectingPatches() const
{
if( meshDict_.found("removeCellsIntersectingPatches") )
{
......@@ -113,7 +114,7 @@ void checkMeshDict::checkRemoveCellsIntersectingPatches()
}
}
void checkMeshDict::checkObjectRefinements()
void checkMeshDict::checkObjectRefinements() const
{
if( meshDict_.found("objectRefinements") )
{
......@@ -165,7 +166,7 @@ void checkMeshDict::checkObjectRefinements()
}
}
void checkMeshDict::checkBoundaryLayers()
void checkMeshDict::checkBoundaryLayers() const
{
if( meshDict_.found("boundaryLayers") )
{
......@@ -183,7 +184,7 @@ void checkMeshDict::checkBoundaryLayers()
}
}
void checkMeshDict::checkRenameBoundary()
void checkMeshDict::checkRenameBoundary() const
{
if( meshDict_.found("renameBoundary") )
{
......@@ -194,7 +195,29 @@ void checkMeshDict::checkRenameBoundary()
{
const dictionary& patchDicts = dict.subDict("newPatchNames");
patchDicts.toc();
const wordList patchNames = patchDicts.toc();
forAll(patchNames, patchI)
{
const word& pName = patchNames[patchI];
if( !patchDicts.isDict(pName) )
FatalErrorIn
(
"void checkMeshDict::checkRenameBoundary() const"
) << "Entry " << pName
<< " is not a dictionary" << exit(FatalError);
const dictionary dict = patchDicts.subDict(pName);
if( !dict.found("newName") )
FatalErrorIn
(
"void checkMeshDict::checkRenameBoundary() const"
) << "Dictionary " << pName
<< " does not contain a newName keyword"
<< exit(FatalError);
}
}
else
{
......@@ -203,13 +226,26 @@ void checkMeshDict::checkRenameBoundary()
dict.lookup("newPatchNames")
);
patchesToRename.size();
forAll(patchesToRename, patchI)
{
const word& pName = patchesToRename[patchI].keyword();
const dictionary dict = patchesToRename[patchI].dict();
if( !dict.found("newName") )
FatalErrorIn
(
"void checkMeshDict::checkRenameBoundary() const"
) << "Dictionary " << pName
<< " does not contain a newName keyword"
<< exit(FatalError);
}
}
}
}
}
void checkMeshDict::checkEntries()
void checkMeshDict::checkEntries() const
{
checkPatchCellSize();
......@@ -226,11 +262,417 @@ void checkMeshDict::checkEntries()
checkRenameBoundary();
}
void checkMeshDict::updatePatchCellSize
(
const std::map<word, wordList>& patchesFromPatch
)
{
if( meshDict_.found("patchCellSize") )
{
LongList<patchRefinement> updatedPatchRefinement;
if( meshDict_.isDict("patchCellSize") )
{
const dictionary dict = meshDict_.subDict("patchCellSize");
const wordList patchNames = dict.toc();
forAll(patchNames, patchI)
{
const word& pName = patchNames[patchI];
std::map<word, wordList>::const_iterator it =
patchesFromPatch.find(pName);
if( it == patchesFromPatch.end() )
continue;
const wordList& updatedPatchNames = it->second;
const dictionary& pDict = dict.subDict(pName);
const scalar cellSize = readScalar(pDict.lookup("cellSize"));
forAll(updatedPatchNames, nameI)
updatedPatchRefinement.append
(
patchRefinement
(
updatedPatchNames[nameI],
cellSize
)
);
}
}
else
{
patchRefinementList prl(meshDict_.lookup("patchCellSize"));
forAll(prl, prlI)
{
const word& pName = prl[prlI].patchName();
const scalar cellSize = prl[prlI].cellSize();
std::map<word, wordList>::const_iterator it =
patchesFromPatch.find(pName);
if( it == patchesFromPatch.end() )
continue;
const wordList& updatedPatchNames = it->second;
forAll(updatedPatchNames, nameI)
updatedPatchRefinement.append
(
patchRefinement
(
updatedPatchNames[nameI],
cellSize
)
);
}
}
meshDict_.add("patchCellSize", updatedPatchRefinement, true);
}
}
void checkMeshDict::updateSubsetCellSize
(
const std::map<word, wordList>& patchesFromPatch
)
{
}
void checkMeshDict::updateKeepCellsIntersectingPatches
(
const std::map<word, wordList>& patchesFromPatch
)
{
if( meshDict_.found("keepCellsIntersectingPatches") )
{
LongList<word> updatedPatchNames;
if( meshDict_.isDict("keepCellsIntersectingPatches") )
{
const dictionary& dict =
meshDict_.subDict("keepCellsIntersectingPatches");
const wordList patchNames = dict.toc();
forAll(patchNames, patchI)
{
const word& pName = patchNames[patchI];
std::map<word, wordList>::const_iterator it =
patchesFromPatch.find(pName);
if( it == patchesFromPatch.end() )
updatedPatchNames.append(pName);
const wordList& newPatchNames = it->second;
forAll(newPatchNames, nameI)
updatedPatchNames.append(newPatchNames[nameI]);
}
}
else
{
wordList kcip(meshDict_.lookup("keepCellsIntersectingPatches"));
forAll(kcip, i)
{
const word& pName = kcip[i];
std::map<word, wordList>::const_iterator it =
patchesFromPatch.find(pName);
if( it == patchesFromPatch.end() )
updatedPatchNames.append(pName);
const wordList& newPatchNames = it->second;
forAll(newPatchNames, nameI)
updatedPatchNames.append(newPatchNames[nameI]);
}
}
meshDict_.add("keepCellsIntersectingPatches", updatedPatchNames, true);
}
}
void checkMeshDict::updateRemoveCellsIntersectingPatches
(
const std::map<word, wordList>& patchesFromPatch
)
{
if( meshDict_.found("removeCellsIntersectingPatches") )
{
LongList<word> updatedPatchNames;
if( meshDict_.isDict("removeCellsIntersectingPatches") )
{
const dictionary& dict =
meshDict_.subDict("removeCellsIntersectingPatches");
const wordList patchNames = dict.toc();
forAll(patchNames, patchI)
{
const word& pName = patchNames[patchI];
std::map<word, wordList>::const_iterator it =
patchesFromPatch.find(pName);
if( it == patchesFromPatch.end() )
updatedPatchNames.append(pName);
const wordList& newPatchNames = it->second;
forAll(newPatchNames, nameI)
updatedPatchNames.append(newPatchNames[nameI]);
}
}
else
{
wordList kcip(meshDict_.lookup("removeCellsIntersectingPatches"));
forAll(kcip, i)
{
const word& pName = kcip[i];
std::map<word, wordList>::const_iterator it =
patchesFromPatch.find(pName);
if( it == patchesFromPatch.end() )
updatedPatchNames.append(pName);
const wordList& newPatchNames = it->second;
forAll(newPatchNames, nameI)
updatedPatchNames.append(newPatchNames[nameI]);
}
}
meshDict_.add
(
"removeCellsIntersectingPatches",
updatedPatchNames,
true
);
}
}
void checkMeshDict::updateObjectRefinements
(
const std::map<word, wordList>& patchesFromPatch
)
{
}
void checkMeshDict::updateBoundaryLayers
(
const std::map<word, wordList>& patchesFromPatch
)
{
}
void checkMeshDict::updateRenameBoundary
(
const std::map<word, wordList>& patchesFromPatch,
const std::map<word, word>& patchTypes
)
{
dictionary newDict;
newDict.add("newPatchNames", dictionary());
if( meshDict_.found("renameBoundary") )
{
const dictionary& dict = meshDict_.subDict("renameBoundary");
//- transfer or generate the default name entry
if( dict.found("defaultName") )
{
const word name(dict.lookup("defaultName"));