Commit 24593943 authored by Philippose Rajan's avatar Philippose Rajan
Browse files

renameBoundaryPatches now supports regular expressions in the meshDict patch name specification


Signed-off-by: default avatarPhilippose Rajan <sarith@rocketmail.com>
parent 9cb1bd68
......@@ -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