mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Recognise already converted boundary file and change fields accordingly.
This commit is contained in:
@ -50,6 +50,7 @@ Usage
|
|||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "pointFields.H"
|
#include "pointFields.H"
|
||||||
#include "surfaceFields.H"
|
#include "surfaceFields.H"
|
||||||
|
#include "string.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -90,13 +91,7 @@ void rewriteBoundary
|
|||||||
|
|
||||||
if (word(patchDict["type"]) == cyclicPolyPatch::typeName)
|
if (word(patchDict["type"]) == cyclicPolyPatch::typeName)
|
||||||
{
|
{
|
||||||
if (patchDict.found("neighbourPatch"))
|
if (!patchDict.found("neighbourPatch"))
|
||||||
{
|
|
||||||
Info<< "Patch " << patches[patchI].keyword()
|
|
||||||
<< " already has 'neighbourPatch' entry; assuming it"
|
|
||||||
<< " is already converted." << endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Info<< "Patch " << patches[patchI].keyword()
|
Info<< "Patch " << patches[patchI].keyword()
|
||||||
<< " does not have 'neighbourPatch' entry; assuming it"
|
<< " does not have 'neighbourPatch' entry; assuming it"
|
||||||
@ -130,69 +125,102 @@ void rewriteBoundary
|
|||||||
if
|
if
|
||||||
(
|
(
|
||||||
word(patchDict["type"]) == cyclicPolyPatch::typeName
|
word(patchDict["type"]) == cyclicPolyPatch::typeName
|
||||||
&& !patchDict.found("neighbourPatch")
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const word& name = oldPatches[patchI].keyword();
|
const word& name = oldPatches[patchI].keyword();
|
||||||
label nFaces = readLabel(patchDict["nFaces"]);
|
|
||||||
label startFace = readLabel(patchDict["startFace"]);
|
|
||||||
|
|
||||||
Info<< "Detected old style " << word(patchDict["type"])
|
if (patchDict.found("neighbourPatch"))
|
||||||
<< " patch " << name << " with" << nl
|
{
|
||||||
<< " nFaces : " << nFaces << nl
|
patches.set(patchI, oldPatches.set(patchI, NULL));
|
||||||
<< " startFace : " << startFace << endl;
|
oldToNew[patchI] = newPatchI++;
|
||||||
|
|
||||||
word thisName = name + "_half0";
|
// Check if patches come from automatic conversion
|
||||||
word nbrName = name + "_half1";
|
word oldName;
|
||||||
|
|
||||||
thisNames.insert(name, thisName);
|
string::size_type i = name.rfind("_half0");
|
||||||
nbrNames.insert(name, nbrName);
|
if (i != string::npos)
|
||||||
|
{
|
||||||
|
oldName = name.substr(0, i);
|
||||||
|
thisNames.insert(oldName, name);
|
||||||
|
Info<< "Detected converted cyclic patch " << name
|
||||||
|
<< " ; assuming it originates from " << oldName
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i = name.rfind("_half1");
|
||||||
|
if (i != string::npos)
|
||||||
|
{
|
||||||
|
oldName = name.substr(0, i);
|
||||||
|
nbrNames.insert(oldName, name);
|
||||||
|
Info<< "Detected converted cyclic patch " << name
|
||||||
|
<< " ; assuming it originates from " << oldName
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
label nFaces = readLabel(patchDict["nFaces"]);
|
||||||
|
label startFace = readLabel(patchDict["startFace"]);
|
||||||
|
|
||||||
// Save current dictionary
|
Info<< "Detected old style " << word(patchDict["type"])
|
||||||
const dictionary patchDict(patches[patchI].dict());
|
<< " patch " << name << " with" << nl
|
||||||
|
<< " nFaces : " << nFaces << nl
|
||||||
|
<< " startFace : " << startFace << endl;
|
||||||
|
|
||||||
// Change entry on this side
|
word thisName = name + "_half0";
|
||||||
patches.set(patchI, oldPatches.set(patchI, NULL));
|
word nbrName = name + "_half1";
|
||||||
oldToNew[patchI] = newPatchI++;
|
|
||||||
dictionary& thisPatchDict = patches[patchI].dict();
|
|
||||||
thisPatchDict.add("neighbourPatch", nbrName);
|
|
||||||
thisPatchDict.set("nFaces", nFaces/2);
|
|
||||||
patches[patchI].keyword() = thisName;
|
|
||||||
|
|
||||||
// Add entry on other side
|
thisNames.insert(name, thisName);
|
||||||
patches.set
|
nbrNames.insert(name, nbrName);
|
||||||
(
|
|
||||||
addedPatchI,
|
// Save current dictionary
|
||||||
new dictionaryEntry
|
const dictionary patchDict(patches[patchI].dict());
|
||||||
|
|
||||||
|
// Change entry on this side
|
||||||
|
patches.set(patchI, oldPatches.set(patchI, NULL));
|
||||||
|
oldToNew[patchI] = newPatchI++;
|
||||||
|
dictionary& thisPatchDict = patches[patchI].dict();
|
||||||
|
thisPatchDict.add("neighbourPatch", nbrName);
|
||||||
|
thisPatchDict.set("nFaces", nFaces/2);
|
||||||
|
patches[patchI].keyword() = thisName;
|
||||||
|
|
||||||
|
// Add entry on other side
|
||||||
|
patches.set
|
||||||
(
|
(
|
||||||
nbrName,
|
addedPatchI,
|
||||||
dictionary::null,
|
new dictionaryEntry
|
||||||
patchDict
|
(
|
||||||
)
|
nbrName,
|
||||||
);
|
dictionary::null,
|
||||||
oldToNew[addedPatchI] = newPatchI++;
|
patchDict
|
||||||
dictionary& nbrPatchDict = patches[addedPatchI].dict();
|
)
|
||||||
nbrPatchDict.set("neighbourPatch", thisName);
|
);
|
||||||
nbrPatchDict.set("nFaces", nFaces/2);
|
oldToNew[addedPatchI] = newPatchI++;
|
||||||
nbrPatchDict.set("startFace", startFace+nFaces/2);
|
dictionary& nbrPatchDict = patches[addedPatchI].dict();
|
||||||
patches[addedPatchI].keyword() = nbrName;
|
nbrPatchDict.set("neighbourPatch", thisName);
|
||||||
|
nbrPatchDict.set("nFaces", nFaces/2);
|
||||||
|
nbrPatchDict.set("startFace", startFace+nFaces/2);
|
||||||
|
patches[addedPatchI].keyword() = nbrName;
|
||||||
|
|
||||||
Info<< "Replaced with patches" << nl
|
Info<< "Replaced with patches" << nl
|
||||||
<< patches[patchI].keyword() << " with" << nl
|
<< patches[patchI].keyword() << " with" << nl
|
||||||
<< " nFaces : "
|
<< " nFaces : "
|
||||||
<< readLabel(thisPatchDict.lookup("nFaces"))
|
<< readLabel(thisPatchDict.lookup("nFaces"))
|
||||||
<< nl
|
<< nl
|
||||||
<< " startFace : "
|
<< " startFace : "
|
||||||
<< readLabel(thisPatchDict.lookup("startFace")) << nl
|
<< readLabel(thisPatchDict.lookup("startFace")) << nl
|
||||||
<< patches[addedPatchI].keyword() << " with" << nl
|
<< patches[addedPatchI].keyword() << " with" << nl
|
||||||
<< " nFaces : "
|
<< " nFaces : "
|
||||||
<< readLabel(nbrPatchDict.lookup("nFaces"))
|
<< readLabel(nbrPatchDict.lookup("nFaces"))
|
||||||
<< nl
|
<< nl
|
||||||
<< " startFace : "
|
<< " startFace : "
|
||||||
<< readLabel(nbrPatchDict.lookup("startFace"))
|
<< readLabel(nbrPatchDict.lookup("startFace"))
|
||||||
<< nl << endl;
|
<< nl << endl;
|
||||||
|
|
||||||
addedPatchI++;
|
addedPatchI++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -265,6 +293,7 @@ void rewriteField
|
|||||||
dictionary& boundaryField = fieldDict.subDict("boundaryField");
|
dictionary& boundaryField = fieldDict.subDict("boundaryField");
|
||||||
|
|
||||||
label nChanged = 0;
|
label nChanged = 0;
|
||||||
|
|
||||||
forAllConstIter(HashTable<word>, thisNames, iter)
|
forAllConstIter(HashTable<word>, thisNames, iter)
|
||||||
{
|
{
|
||||||
const word& patchName = iter.key();
|
const word& patchName = iter.key();
|
||||||
|
|||||||
Reference in New Issue
Block a user