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

Implemented a unified localRefinement settings accepting both patches

and face subsets. It can be extended to feature edge subsets, too.


git-svn-id: https://pl5.projectlocker.com/igui/meshGeneration/svn@40 fdcce57e-7e00-11e2-b579-49867b4cea03
parent 240e0fae
......@@ -76,6 +76,47 @@ void checkMeshDict::checkSubsetCellSize() const
}
}
void checkMeshDict::checkLocalRefinementLevel() const
{
if( meshDict_.found("localRefinement") )
{
if( meshDict_.isDict("localRefinement") )
{
const dictionary& refDict = meshDict_.subDict("localRefinement");
const wordList entries = refDict.toc();
forAll(entries, dictI)
{
const dictionary& dict = refDict.subDict(entries[dictI]);
if( !dict.found("additionalRefinementLevels") )
FatalErrorIn
(
"void checkMeshDict::checkLocalRefinementLevel() const"
) << "Cannot read keyword additionalRefinementLevels "
<< "for " << entries[dictI] << exit(FatalError);
const label nLevels =
readLabel(dict.lookup("additionalRefinementLevels"));
if( nLevels < 0 )
WarningIn
(
"void checkMeshDict::checkLocalRefinementLevel() const"
) << "Refinement level for " << entries[dictI]
<< " is negative" << endl;
}
}
else
{
FatalErrorIn
(
"void checkMeshDict::checkLocalRefinementLevel() const"
) << "Cannot read localRefinement" << exit(FatalError);
}
}
}
void checkMeshDict::checkKeepCellsIntersectingPatches() const
{
if( meshDict_.found("keepCellsIntersectingPatches") )
......@@ -386,6 +427,48 @@ void checkMeshDict::updateSubsetCellSize
}
void checkMeshDict::updateLocalRefinementLevel
(
const std::map<word, wordList>& patchesFromPatch
)
{
if( meshDict_.found("localRefinement") )
{
if( meshDict_.isDict("localRefinement") )
{
dictionary& dict = meshDict_.subDict("localRefinement");
const wordList entries = dict.toc();
forAll(entries, dictI)
{
const word& pName = entries[dictI];
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 label nLevels =
readLabel(pDict.lookup("additionalRefinementLevels"));
dictionary copy;
copy.add("additionalRefinementLevels", nLevels);
//- add new patches
forAll(updatedPatchNames, nameI)
dict.add(updatedPatchNames[nameI], copy);
//- remove the current patch
dict.remove(pName);
}
}
}
}
void checkMeshDict::updateKeepCellsIntersectingPatches
(
const std::map<word, wordList>& patchesFromPatch
......@@ -771,6 +854,8 @@ void checkMeshDict::updateDictionaries
updateSubsetCellSize(patchesFromPatch);
updateLocalRefinementLevel(patchesFromPatch);
updateKeepCellsIntersectingPatches(patchesFromPatch);
updateRemoveCellsIntersectingPatches(patchesFromPatch);
......
......@@ -61,6 +61,9 @@ class checkMeshDict
//- check subsetCellSize entry
void checkSubsetCellSize() const;
//- check local refinement level
void checkLocalRefinementLevel() const;
//- check keepCellsIntersectingPatches entry
void checkKeepCellsIntersectingPatches() const;
......@@ -85,6 +88,9 @@ class checkMeshDict
//- update subsetCellSize entry
void updateSubsetCellSize(const std::map<word, wordList>&);
//- update local refinement
void updateLocalRefinementLevel(const std::map<word, wordList>&);
//- check keepCellsIntersectingPatches entry
void updateKeepCellsIntersectingPatches
(
......
......@@ -93,6 +93,9 @@ public:
const ListType& elements
);
//- Copy construct
inline meshSubset(const meshSubset&);
//- Construct from Istream
inline meshSubset(Istream&);
......
......@@ -70,6 +70,16 @@ inline meshSubset::meshSubset
data_.insert(elements[i]);
}
inline meshSubset::meshSubset(const meshSubset& ms)
:
name_(ms.name_),
type_(ms.type_),
data_()
{
forAllConstIter(HashSet<label>, ms.data_, it)
data_.insert(it.key());
}
inline meshSubset::meshSubset(Istream& is)
:
name_(),
......@@ -128,7 +138,8 @@ inline void meshSubset::updateSubset(const ListType& newLabels)
}
data_.clear();
data_ = newData;
forAllConstIter(HashSet<label>, newData, it)
data_.insert(it.key());
}
inline void meshSubset::updateSubset(const VRWGraph& newLabels)
......@@ -142,7 +153,8 @@ inline void meshSubset::updateSubset(const VRWGraph& newLabels)
}
data_.clear();
data_ = newData;
forAllConstIter(HashSet<label>, newData, it)
data_.insert(it.key());
}
inline bool meshSubset::contains(const label elmt) const
......@@ -154,7 +166,10 @@ inline void meshSubset::operator=(const meshSubset& ms)
{
name_ = ms.name_;
type_ = ms.type_;
data_ = ms.data_;
data_.clear();
forAllConstIter(HashSet<label>, ms.data_, it)
data_.insert(it.key());
}
inline bool meshSubset::operator==(const meshSubset& ms) const
......
......@@ -100,6 +100,8 @@ void triSurf::readFromFMS(const fileName& fName)
forAll(subsets, subsetI)
triSurfFacets::facetSubsets_.insert(subsetI, subsets[subsetI]);
subsets.clear();
//- read subsets on feature edges
fStream >> subsets;
forAll(subsets, subsetI)
......
......@@ -309,6 +309,69 @@ void meshOctreeCreator::setRootCubeSizeAndRefParameters()
surfRefLevel_[subsetFaces[tI]] = level;
}
}
if( meshDictPtr_->found("localRefinement") )
{
if( meshDictPtr_->isDict("localRefinement") )
{
const dictionary& dict = meshDictPtr_->subDict("localRefinement");
const wordList entries = dict.toc();
//- map patch name to its index
std::map<word, label> patchToIndex;
forAll(surface.patches(), patchI)
patchToIndex[surface.patches()[patchI].name()] = patchI;
//- map a facet subset name to its index
std::map<word, label> setToIndex;
DynList<label> setIDs;
surface.facetSubsetIndices(setIDs);
forAll(setIDs, i)
setToIndex[surface.facetSubsetName(setIDs[i])] = setIDs[i];
//- set refinement for these entries
forAll(entries, dictI)
{
if( !dict.isDict(entries[dictI]) )
continue;
const word& pName = entries[dictI];
const dictionary& patchDict = dict.subDict(pName);
const direction nLevel =
readLabel(patchDict.lookup("additionalRefinementLevels"));
const direction level = globalRefLevel_ + nLevel;
if( patchToIndex.find(pName) != patchToIndex.end() )
{
//- patch-based refinement
const label patchI = patchToIndex[pName];
forAll(surface, triI)
{
if( surface[triI].region() == patchI )
surfRefLevel_[triI] =
Foam::max(surfRefLevel_[triI], level);
}
}
if( setToIndex.find(pName) != setToIndex.end() )
{
//- this is a facet subset
const label subsetId = setToIndex[pName];
labelListPMG facetsInSubset;
surface.facetsInSubset(subsetId, facetsInSubset);
forAll(facetsInSubset, i)
{
const label triI = facetsInSubset[i];
surfRefLevel_[triI] =
Foam::max(surfRefLevel_[triI], level);
}
}
}
}
}
}
void meshOctreeCreator::refineInsideAndUnknownBoxes()
......
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