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

Modified the API. It now possible to set all meshing properties as

dictionaries


git-svn-id: https://pl5.projectlocker.com/igui/meshGeneration/svn@10 fdcce57e-7e00-11e2-b579-49867b4cea03
parent 2b8405bb
......@@ -215,7 +215,18 @@ void cartesianMeshGenerator::generateBoudaryLayers()
if( meshDict_.found("boundaryLayers") )
{
wordList createLayers(meshDict_.lookup("boundaryLayers"));
wordList createLayers;
if( meshDict_.isDict("boundaryLayers") )
{
const dictionary& dict = meshDict_.subDict("boundaryLayers");
createLayers = dict.toc();
}
else
{
wordList bndLayers(meshDict_.lookup("boundaryLayers"));
createLayers.transfer(bndLayers);
}
forAll(createLayers, patchI)
bl.addLayerForPatch(createLayers[patchI]);
......
......@@ -191,7 +191,18 @@ void dualMeshGenerator::generateBoudaryLayers()
if( meshDict_.found("boundaryLayers") )
{
wordList createLayers(meshDict_.lookup("boundaryLayers"));
wordList createLayers;
if( meshDict_.isDict("boundaryLayers") )
{
const dictionary& dict = meshDict_.subDict("boundaryLayers");
createLayers = dict.toc();
}
else
{
wordList bndLayers(meshDict_.lookup("boundaryLayers"));
createLayers.transfer(bndLayers);
}
forAll(createLayers, patchI)
bl.addLayerForPatch(createLayers[patchI]);
......
......@@ -190,7 +190,18 @@ void hexMeshGenerator::generateBoundaryLayers()
if( meshDict_.found("boundaryLayers") )
{
wordList createLayers(meshDict_.lookup("boundaryLayers"));
wordList createLayers;
if( meshDict_.isDict("boundaryLayers") )
{
const dictionary& dict = meshDict_.subDict("boundaryLayers");
createLayers = dict.toc();
}
else
{
wordList bndLayers(meshDict_.lookup("boundaryLayers"));
createLayers.transfer(bndLayers);
}
forAll(createLayers, patchI)
bl.addLayerForPatch(createLayers[patchI]);
......
......@@ -173,10 +173,21 @@ void tetMeshGenerator::generateBoudaryLayers()
if( meshDict_.found("boundaryLayers") )
{
wordList createLayers(meshDict_.lookup("boundaryLayers"));
wordList createLayers;
if( meshDict_.isDict("boundaryLayers") )
{
const dictionary& dict = meshDict_.subDict("boundaryLayers");
createLayers = dict.toc();
}
else
{
wordList bndLayers(meshDict_.lookup("boundaryLayers"));
createLayers.transfer(bndLayers);
}
forAll(createLayers, patchI)
bl.addLayerForPatch(createLayers[patchI]);
bl.addLayerForPatch(createLayers[patchI]);
}
# ifdef DEBUG
......
......@@ -35,22 +35,62 @@ Description
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void checkMeshDict::checkPatchCellSize()
{
if( meshDict_.found("patchCellSize") )
{
patchRefinementList prl(meshDict_.lookup("patchCellSize"));
if( meshDict_.isDict("patchCellSize") )
{
const dictionary& dict = meshDict_.subDict("patchCellSize");
const wordList patchNames = dict.toc();
patchNames.size();
}
else
{
patchRefinementList prl(meshDict_.lookup("patchCellSize"));
prl.size();
}
}
}
void checkMeshDict::checkSubsetCellSize()
{
if( meshDict_.found("subsetCellSize") )
{
if( meshDict_.isDict("subsetCellSize") )
{
const dictionary& dict = meshDict_.subDict("subsetCellSize");
const wordList subsetNames = dict.toc();
subsetNames.size();
}
else
{
patchRefinementList prl(meshDict_.lookup("patchCellSize"));
}
}
}
void checkMeshDict::checkKeepCellsIntersectingPatches()
{
if( meshDict_.found("keepCellsIntersectingPatches") )
{
wordList kcip(meshDict_.lookup("keepCellsIntersectingPatches"));
if( meshDict_.isDict("keepCellsIntersectingPatches") )
{
const dictionary& dict =
meshDict_.subDict("keepCellsIntersectingPatches");
const wordList patchNames = dict.toc();
patchNames.size();
}
else
{
wordList kcip(meshDict_.lookup("keepCellsIntersectingPatches"));
}
}
}
......@@ -58,31 +98,69 @@ void checkMeshDict::checkRemoveCellsIntersectingPatches()
{
if( meshDict_.found("removeCellsIntersectingPatches") )
{
wordList kcip(meshDict_.lookup("removeCellsIntersectingPatches"));
if( meshDict_.isDict("removeCellsIntersectingPatches") )
{
const dictionary& dict =
meshDict_.subDict("removeCellsIntersectingPatches");
const wordList patchNames = dict.toc();
patchNames.size();
}
else
{
wordList kcip(meshDict_.lookup("removeCellsIntersectingPatches"));
}
}
}
void checkMeshDict::checkObjectRefinements()
{
if( meshDict_.found("objectRefinements") )
{
PtrList<objectRefinement> refObjects;
Istream& is = meshDict_.lookup("objectRefinements");
PtrList<entry> objectEntries(is);
refObjects.setSize(objectEntries.size());
forAll(refObjects, objectI)
if( meshDict_.isDict("objectRefinements") )
{
const dictionary& dict = meshDict_.subDict("objectRefinements");
const wordList objectNames = dict.toc();
refObjects.setSize(objectNames.size());
forAll(refObjects, objectI)
{
const entry& objectEntry =
dict.lookupEntry(objectNames[objectI], false, false);
refObjects.set
(
objectI,
objectRefinement::New
(
objectEntry.keyword(),
objectEntry.dict()
)
);
}
}
else
{
refObjects.set
(
objectI,
objectRefinement::New
Istream& is = meshDict_.lookup("objectRefinements");
PtrList<entry> objectEntries(is);
refObjects.setSize(objectEntries.size());
forAll(refObjects, objectI)
{
refObjects.set
(
objectEntries[objectI].keyword(),
objectEntries[objectI].dict()
)
);
objectI,
objectRefinement::New
(
objectEntries[objectI].keyword(),
objectEntries[objectI].dict()
)
);
}
}
}
}
......@@ -91,7 +169,17 @@ void checkMeshDict::checkBoundaryLayers()
{
if( meshDict_.found("boundaryLayers") )
{
wordList bl(meshDict_.lookup("boundaryLayers"));
if( meshDict_.isDict("boundaryLayers") )
{
const dictionary& dict = meshDict_.subDict("boundaryLayers");
const wordList layerNames = dict.toc();
layerNames.size();
}
else
{
wordList bl(meshDict_.lookup("boundaryLayers"));
}
}
}
......@@ -102,7 +190,21 @@ void checkMeshDict::checkRenameBoundary()
const dictionary& dict = meshDict_.subDict("renameBoundary");
if( dict.found("newPatchNames") )
{
PtrList<entry> patchesToRename(dict.lookup("newPatchNames"));
if( dict.isDict("newPatchNames") )
{
const dictionary& patchDicts = dict.subDict("newPatchNames");
patchDicts.toc();
}
else
{
const PtrList<entry> patchesToRename
(
dict.lookup("newPatchNames")
);
patchesToRename.size();
}
}
}
}
......@@ -110,15 +212,17 @@ void checkMeshDict::checkRenameBoundary()
void checkMeshDict::checkEntries()
{
checkPatchCellSize();
checkSubsetCellSize();
checkKeepCellsIntersectingPatches();
checkRemoveCellsIntersectingPatches();
checkObjectRefinements();
checkBoundaryLayers();
checkRenameBoundary();
}
......
......@@ -51,39 +51,42 @@ class checkMeshDict
{
//- Reference to the mesh
const IOdictionary& meshDict_;
// Private member functions
//- check patchCellSize entry
void checkPatchCellSize();
//- check subsetCellSize entry
void checkSubsetCellSize();
//- check keepCellsIntersectingPatches entry
void checkKeepCellsIntersectingPatches();
//- check removeCellsIntersectingPatches entry
void checkRemoveCellsIntersectingPatches();
//- check objectRefinements entry
void checkObjectRefinements();
//- check entry for boundary layers
void checkBoundaryLayers();
//- check renameBoundary entry
void checkRenameBoundary();
//- perform all checks
void checkEntries();
public:
// Constructors
//- Construct from IOdictionary
checkMeshDict(const IOdictionary& meshDict);
// Destructor
~checkMeshDict();
// Public member functions
};
......
......@@ -36,7 +36,6 @@ SourceFiles
#ifndef findCellsIntersectingSurface_H
#define findCellsIntersectingSurface_H
#include "IOdictionary.H"
#include "boolList.H"
#include "VRWGraph.H"
......
......@@ -28,7 +28,6 @@ Description
#include "meshOctree.H"
#include "triSurf.H"
#include "IOdictionary.H"
#include "boundBox.H"
#include "demandDrivenData.H"
......@@ -43,7 +42,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from surface and IOdictionary
// Construct from surface
meshOctree::meshOctree(const triSurf& ts)
:
surface_(ts),
......
......@@ -49,7 +49,6 @@ namespace Foam
// Forward declarations
class triSurf;
class IOdictionary;
/*---------------------------------------------------------------------------*\
Class meshOctree Declaration
......
......@@ -32,10 +32,11 @@ Description
#include "demandDrivenData.H"
#include "meshOctree.H"
#include "labelListPMG.H"
#include "IOdictionary.H"
#include "triSurf.H"
# ifdef USE_OMP
#include <omp.h>
# endif
//#define DEBUGVrt
......@@ -347,10 +348,24 @@ void meshOctreeAddressing::findUsedBoxes() const
//- do not use boxes intersecting given patches
if( meshDict_.found("removeCellsIntersectingPatches") )
{
wordHashSet patchesToRemove
(
meshDict_.lookup("removeCellsIntersectingPatches")
);
wordHashSet patchesToRemove;
if( meshDict_.isDict("removeCellsIntersectingPatches") )
{
const dictionary& dict =
meshDict_.subDict("removeCellsIntersectingPatches");
const wordList patchNames = dict.toc();
forAll(patchNames, patchI)
patchesToRemove.insert(patchNames[patchI]);
}
else
{
wordHashSet patchesToRemoveCopy
(
meshDict_.lookup("removeCellsIntersectingPatches")
);
patchesToRemove.transfer(patchesToRemoveCopy);
}
const triSurf& ts = octree_.surface();
boolList removeFacets(ts.size(), false);
......@@ -400,10 +415,25 @@ void meshOctreeAddressing::findUsedBoxes() const
}
else if( meshDict_.found("keepCellsIntersectingPatches") )
{
const wordHashSet patchesToKeep
(
meshDict_.lookup("keepCellsIntersectingPatches")
);
wordHashSet patchesToKeep;
if( meshDict_.isDict("keepCellsIntersectingPatches") )
{
const dictionary& dict =
meshDict_.subDict("keepCellsIntersectingPatches");
const wordList patchNames = dict.toc();
forAll(patchNames, patchI)
patchesToKeep.insert(patchNames[patchI]);
}
else
{
wordHashSet patchesToKeepCopy
(
meshDict_.lookup("keepCellsIntersectingPatches")
);
patchesToKeep.transfer(patchesToKeepCopy);
}
const triSurf& ts = octree_.surface();
boolList keepFacets(ts.size(), false);
......
......@@ -38,7 +38,9 @@ Description
#include "Map.H"
# ifdef USE_OMP
#include <omp.h>
# endif
//#define DEBUGAutoRef
......
......@@ -28,7 +28,6 @@ Description
#include "meshOctreeCreator.H"
#include "triSurf.H"
#include "IOdictionary.H"
#include "boundBox.H"
#include "demandDrivenData.H"
......
......@@ -31,12 +31,13 @@ Description
#include "boundBox.H"
#include "demandDrivenData.H"
#include "objectRefinementList.H"
#include "IOdictionary.H"
#include "VRWGraph.H"
#include "meshOctreeModifier.H"
#include "HashSet.H"
# ifdef USE_OMP
#include <omp.h>
# endif
//#define OCTREETiming
//#define DEBUGSearch
......@@ -152,25 +153,51 @@ void meshOctreeCreator::refineBoxesContainedInObjects()
objectRefinementList refObjects;
// Read polyPatchList
Istream& is = meshDictPtr_->lookup("objectRefinements");
if( meshDictPtr_->isDict("objectRefinements") )
{
const dictionary& dict = meshDictPtr_->subDict("objectRefinements");
const wordList objectNames = dict.toc();
PtrList<entry> objectEntries(is);
refObjects.setSize(objectEntries.size());
refObjects.setSize(objectNames.size());
forAll(refObjects, objectI)
{
refObjects.set
(
objectI,
objectRefinement::New
forAll(refObjects, objectI)
{
const entry& objectEntry =
dict.lookupEntry(objectNames[objectI], false, false);
refObjects.set
(
objectEntries[objectI].keyword(),
objectEntries[objectI].dict()
)
);
objectI,
objectRefinement::New
(
objectEntry.keyword(),
objectEntry.dict()
)
);
}
}
else
{
Istream& is = meshDictPtr_->lookup("objectRefinements");
PtrList<entry> objectEntries(is);
refObjects.setSize(objectEntries.size());
objectEntries.clear();
forAll(refObjects, objectI)
{
refObjects.set
(
objectI,
objectRefinement::New
(
objectEntries[objectI].keyword(),
objectEntries[objectI].dict()
)
);
}
objectEntries.clear();
}
scalar s(readScalar(meshDictPtr_->lookup("maxCellSize")));
......
......@@ -162,7 +162,35 @@ void meshOctreeCreator::setRootCubeSizeAndRefParameters()
//- set patch-wise ref levels
if( meshDictPtr_->found("patchCellSize") )
{
patchRefinementList refPatches(meshDictPtr_->lookup("patchCellSize"));
patchRefinementList refPatches;
if( meshDictPtr_->isDict("patchCellSize") )
{
const dictionary& dict = meshDictPtr_->subDict("patchCellSize");
const wordList patchNames = dict.toc();
refPatches.setSize(patchNames.size());
label counter(0);
forAll(patchNames, patchI)
{
if( !dict.isDict(patchNames[patchI]) )
continue;
const dictionary& patchDict = dict.subDict(patchNames[patchI]);
const scalar cs = readScalar(patchDict.lookup("cellSize"));
refPatches[counter] = patchRefinement(patchNames[patchI], cs);
++counter;