Commit db3f8105 authored by Franjo's avatar Franjo
Browse files

Merge branch 'feature-regExpPatches' into development

parents 1323bcfe fa45982c
......@@ -156,7 +156,12 @@ void refineBoundaryLayers::setNumberOfLayersForPatch
return;
}
numLayersForPatch_[patchName] = nLayers;
labelList matchedIDs = mesh_.findPatches(patchName);
forAll(matchedIDs, matchI)
{
numLayersForPatch_[mesh_.getPatchName(matchedIDs[matchI])] = nLayers;
}
}
void refineBoundaryLayers::setThicknessRatioForPatch
......@@ -177,7 +182,12 @@ void refineBoundaryLayers::setThicknessRatioForPatch
return;
}
thicknessRatioForPatch_[patchName] = thicknessRatio;
labelList matchedIDs = mesh_.findPatches(patchName);
forAll(matchedIDs, matchI)
{
thicknessRatioForPatch_[mesh_.getPatchName(matchedIDs[matchI])] = thicknessRatio;
}
}
void refineBoundaryLayers::setMaxThicknessOfFirstLayerForPatch
......@@ -198,12 +208,22 @@ void refineBoundaryLayers::setMaxThicknessOfFirstLayerForPatch
return;
}
maxThicknessForPatch_[patchName] = maxThickness;
labelList matchedIDs = mesh_.findPatches(patchName);
forAll(matchedIDs, matchI)
{
maxThicknessForPatch_[mesh_.getPatchName(matchedIDs[matchI])] = maxThickness;
}
}
void refineBoundaryLayers::setInteruptForPatch(const word& patchName)
{
discontinuousLayersForPatch_.insert(patchName);
labelList matchedIDs = mesh_.findPatches(patchName);
forAll(matchedIDs, matchI)
{
discontinuousLayersForPatch_.insert(mesh_.getPatchName(matchedIDs[matchI]));
}
}
void refineBoundaryLayers::refineLayers()
......
......@@ -31,6 +31,7 @@ Description
#include "IOobjectList.H"
#include "faceSet.H"
#include "demandDrivenData.H"
#include "stringListOps.H"
namespace Foam
{
......@@ -201,6 +202,65 @@ label polyMeshGenFaces::faceIsInPatch(const label faceLabel) const
return -1;
}
wordList polyMeshGenFaces::patchNames() const
{
wordList t(boundaries_.size());
forAll(boundaries_, patchI)
{
t[patchI] = boundaries_[patchI].patchName();
}
return t;
}
label polyMeshGenFaces::getPatchID(const word& patchName) const
{
forAll(boundaries_, patchI)
{
if(boundaries_.set(patchI))
{
if(boundaries_[patchI].patchName() == patchName)
{
return patchI;
}
}
}
// If the code gets here, it implies that the patch was not found.
// return a -1 in this case
return -1;
}
word polyMeshGenFaces::getPatchName(const label patchID) const
{
if((patchID < 0) || (patchID >= boundaries_.size()))
{
FatalErrorIn
(
"polyMeshGenFaces::getPatchName(const label patchID) const"
) << "invalid patch ID supplied"
<< abort(FatalError);
}
return boundaries_[patchID].patchName();
}
labelList polyMeshGenFaces::findPatches(const word& patchName) const
{
wordList allPatches = patchNames();
labelList patchIDs = findStrings(patchName, allPatches);
if(patchIDs.empty())
{
WarningIn("polyMeshGenFaces::findPatches(const word&)")
<< "Cannot find any patch names matching " << patchName << endl;
}
return patchIDs;
}
label polyMeshGenFaces::addFaceSubset(const word& setName)
{
label id = faceSubsetIndex(setName);
......
......@@ -142,7 +142,20 @@ public:
//- return patch label for the given face label
label faceIsInPatch(const label faceLabel) const;
//- return list of patches in the boundary
wordList patchNames() const;
//- return the index of a patch given its name
label getPatchID(const word& patchName) const;
//- return the name of a patch given its ID
word getPatchName(const label patchID) const;
//- return a list of patch indices corresponding to the given
// name, expanding regular expressions
labelList findPatches(const word& patchName) const;
// Subsets
label addFaceSubset(const word&);
......
......@@ -29,6 +29,7 @@ Description
#include "pointIOField.H"
#include "IOobjectList.H"
#include "pointSet.H"
#include "stringListOps.H"
namespace Foam
{
......@@ -72,6 +73,33 @@ triSurfFacets::~triSurfFacets()
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
wordList triSurfFacets::patchNames() const
{
wordList t(patches_.size());
forAll(patches_, patchI)
{
t[patchI] = patches_[patchI].name();
}
return t;
}
labelList triSurfFacets::findPatches(const word& patchName) const
{
wordList allPatches = patchNames();
labelList patchIDs = findStrings(patchName, allPatches);
if(patchIDs.empty())
{
WarningIn("triSurfFacets::findPatches(const word&)")
<< "Cannot find any patch names matching " << patchName << endl;
}
return patchIDs;
}
label triSurfFacets::addFacetSubset(const word& subsetName)
{
label id = facetSubsetIndex(subsetName);
......
......@@ -98,6 +98,13 @@ public:
//- access to patches
inline const geometricSurfacePatchList& patches() const;
//- return list of patches in the boundary
wordList patchNames() const;
//- return a list of patch indices corresponding to the given
// name, expanding regular expressions
labelList findPatches(const word& patchName) const;
//- append a triangle to the end of the list
inline void appendTriangle(const labelledTri& tria);
......
......@@ -168,8 +168,9 @@ void meshOctreeCreator::setRootCubeSizeAndRefParameters()
{
const dictionary& dict = meshDictPtr_->subDict("patchCellSize");
const wordList patchNames = dict.toc();
const wordList allPatches = surface.patchNames();
refPatches.setSize(patchNames.size());
refPatches.setSize(allPatches.size());
label counter(0);
forAll(patchNames, patchI)
......@@ -180,8 +181,12 @@ void meshOctreeCreator::setRootCubeSizeAndRefParameters()
const dictionary& patchDict = dict.subDict(patchNames[patchI]);
const scalar cs = readScalar(patchDict.lookup("cellSize"));
refPatches[counter] = patchRefinement(patchNames[patchI], cs);
++counter;
labelList matchedIDs = surface.findPatches(patchNames[patchI]);
forAll(matchedIDs, matchI)
{
refPatches[counter] = patchRefinement(allPatches[matchedIDs[matchI]], cs);
++counter;
}
}
refPatches.setSize(counter);
......@@ -317,11 +322,6 @@ void meshOctreeCreator::setRootCubeSizeAndRefParameters()
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;
......@@ -369,10 +369,12 @@ void meshOctreeCreator::setRootCubeSizeAndRefParameters()
const direction level = globalRefLevel_ + nLevel;
if( patchToIndex.find(pName) != patchToIndex.end() )
labelList matchedPatches = surface.findPatches(pName);
forAll(matchedPatches, matchI)
{
//- patch-based refinement
const label patchI = patchToIndex[pName];
const label patchI = matchedPatches[matchI];
forAll(surface, triI)
{
......
......@@ -46,19 +46,6 @@ void renameBoundaryPatches::calculateNewBoundary()
const dictionary& dict = meshDict_.subDict("renameBoundary");
std::map<word, label> patchToLabel;
forAll(mesh_.boundaries(), patchI)
{
patchToLabel.insert
(
std::pair<word, label>
(
mesh_.boundaries()[patchI].patchName(),
patchI
)
);
}
labelList patchToNew(mesh_.boundaries().size(), -1);
wordList newPatchNames(patchToNew.size());
......@@ -100,9 +87,11 @@ void renameBoundaryPatches::calculateNewBoundary()
{
const word patchName = patchesToRename[patchI].keyword();
if( patchToLabel.find(patchName) == patchToLabel.end() )
labelList matchedPatches = mesh_.findPatches(patchName);
if(matchedPatches.empty())
{
Info << "Patch " << patchName << " does not exist!!" << endl;
Warning << "No matches for " << patchName << " found!!" << endl;
continue;
}
......@@ -116,32 +105,36 @@ void renameBoundaryPatches::calculateNewBoundary()
const dictionary pDict = patchesToRename[patchI].dict();
word newName(patchName);
if( pDict.found("newName") )
newName = word(pDict.lookup("newName"));
if( newNameToPos.find(newName) != newNameToPos.end() )
forAll(matchedPatches, matchI)
{
//- patch with the same name already exists
patchToNew[patchToLabel[patchName]] = newNameToPos[newName];
continue;
word newName(mesh_.getPatchName(matchedPatches[matchI]));
if( pDict.found("newName") )
newName = word(pDict.lookup("newName"));
if( newNameToPos.find(newName) != newNameToPos.end() )
{
//- patch with the same name already exists
patchToNew[matchedPatches[matchI]] = newNameToPos[newName];
continue;
}
//- add a new patch
newNameToPos.insert(std::pair<word, label>(newName, newPatchI));
newPatchNames[newPatchI] = newName;
if( pDict.found("type") )
{
const word newType(pDict.lookup("type"));
newPatchTypes[newPatchI] = newType;
}
else
{
newPatchTypes[newPatchI] = "wall";
}
patchToNew[matchedPatches[matchI]] = newPatchI;
++newPatchI;
}
//- add a new patch
newNameToPos.insert(std::pair<word, label>(newName, newPatchI));
newPatchNames[newPatchI] = newName;
if( pDict.found("type") )
{
const word newType(pDict.lookup("type"));
newPatchTypes[newPatchI] = newType;
}
else
{
newPatchTypes[newPatchI] = "wall";
}
patchToNew[patchToLabel[patchName]] = newPatchI;
++newPatchI;
}
}
......
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