mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
order of creation consistent with cyclics
This commit is contained in:
@ -48,157 +48,6 @@ using namespace Foam;
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void createBaffles
|
|
||||||
(
|
|
||||||
const polyMesh& mesh,
|
|
||||||
const label faceI,
|
|
||||||
const label oldPatchI,
|
|
||||||
const labelList& newPatches,
|
|
||||||
PackedBoolList& doneFace,
|
|
||||||
polyTopoChange& meshMod
|
|
||||||
)
|
|
||||||
{
|
|
||||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
|
||||||
const faceZoneMesh& faceZones = mesh.faceZones();
|
|
||||||
|
|
||||||
const face& f = mesh.faces()[faceI];
|
|
||||||
label zoneID = faceZones.whichZone(faceI);
|
|
||||||
bool zoneFlip = false;
|
|
||||||
if (zoneID >= 0)
|
|
||||||
{
|
|
||||||
const faceZone& fZone = faceZones[zoneID];
|
|
||||||
zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
|
|
||||||
}
|
|
||||||
label nei = -1;
|
|
||||||
if (oldPatchI == -1)
|
|
||||||
{
|
|
||||||
nei = mesh.faceNeighbour()[faceI];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
face revFace(f.reverseFace());
|
|
||||||
|
|
||||||
forAll(newPatches, i)
|
|
||||||
{
|
|
||||||
if (oldPatchI == -1)
|
|
||||||
{
|
|
||||||
// Internal face
|
|
||||||
if (doneFace.set(faceI))
|
|
||||||
{
|
|
||||||
// First usage of face. Modify.
|
|
||||||
meshMod.setAction
|
|
||||||
(
|
|
||||||
polyModifyFace
|
|
||||||
(
|
|
||||||
f, // modified face
|
|
||||||
faceI, // label of face
|
|
||||||
mesh.faceOwner()[faceI], // owner
|
|
||||||
-1, // neighbour
|
|
||||||
false, // face flip
|
|
||||||
newPatches[i], // patch for face
|
|
||||||
false, // remove from zone
|
|
||||||
zoneID, // zone for face
|
|
||||||
zoneFlip // face flip in zone
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Second or more usage of face. Add.
|
|
||||||
meshMod.setAction
|
|
||||||
(
|
|
||||||
polyAddFace
|
|
||||||
(
|
|
||||||
f, // modified face
|
|
||||||
mesh.faceOwner()[faceI], // owner
|
|
||||||
-1, // neighbour
|
|
||||||
-1, // master point
|
|
||||||
-1, // master edge
|
|
||||||
faceI, // master face
|
|
||||||
false, // face flip
|
|
||||||
newPatches[i], // patch for face
|
|
||||||
zoneID, // zone for face
|
|
||||||
zoneFlip // face flip in zone
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
meshMod.setAction
|
|
||||||
(
|
|
||||||
polyAddFace
|
|
||||||
(
|
|
||||||
revFace, // modified face
|
|
||||||
nei, // owner
|
|
||||||
-1, // neighbour
|
|
||||||
-1, // masterPointID
|
|
||||||
-1, // masterEdgeID
|
|
||||||
faceI, // masterFaceID,
|
|
||||||
true, // face flip
|
|
||||||
newPatches[i], // patch for face
|
|
||||||
zoneID, // zone for face
|
|
||||||
zoneFlip // face flip in zone
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
patches[oldPatchI].coupled()
|
|
||||||
&& patches[newPatches[i]].coupled()
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// Do not allow coupled patches to be moved to different coupled
|
|
||||||
// patches.
|
|
||||||
//WarningIn("createBaffles()")
|
|
||||||
// << "Not moving face from coupled patch "
|
|
||||||
// << patches[oldPatchI].name()
|
|
||||||
// << " to another coupled patch " << patches[newPatches[i]]
|
|
||||||
// << endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (doneFace.set(faceI))
|
|
||||||
{
|
|
||||||
meshMod.setAction
|
|
||||||
(
|
|
||||||
polyModifyFace
|
|
||||||
(
|
|
||||||
f, // modified face
|
|
||||||
faceI, // label of face
|
|
||||||
mesh.faceOwner()[faceI], // owner
|
|
||||||
-1, // neighbour
|
|
||||||
false, // face flip
|
|
||||||
newPatches[i], // patch for face
|
|
||||||
false, // remove from zone
|
|
||||||
zoneID, // zone for face
|
|
||||||
zoneFlip // face flip in zone
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
meshMod.setAction
|
|
||||||
(
|
|
||||||
polyAddFace
|
|
||||||
(
|
|
||||||
f, // modified face
|
|
||||||
mesh.faceOwner()[faceI], // owner
|
|
||||||
-1, // neighbour
|
|
||||||
-1, // master point
|
|
||||||
-1, // master edge
|
|
||||||
faceI, // master face
|
|
||||||
false, // face flip
|
|
||||||
newPatches[i], // patch for face
|
|
||||||
zoneID, // zone for face
|
|
||||||
zoneFlip // face flip in zone
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@ -215,15 +64,16 @@ int main(int argc, char *argv[])
|
|||||||
const word oldInstance = mesh.pointsInstance();
|
const word oldInstance = mesh.pointsInstance();
|
||||||
|
|
||||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||||
|
const faceZoneMesh& faceZones = mesh.faceZones();
|
||||||
|
|
||||||
// Faces to baffle
|
// Faces to baffle
|
||||||
word setName(args.additionalArgs()[0]);
|
word setName(args.additionalArgs()[0]);
|
||||||
Pout<< "Reading faceSet from " << setName << nl << endl;
|
Info<< "Reading faceSet from " << setName << nl << endl;
|
||||||
faceSet facesToSplit(mesh, setName);
|
faceSet facesToSplit(mesh, setName);
|
||||||
// Make sure set is synchronised across couples
|
// Make sure set is synchronised across couples
|
||||||
facesToSplit.sync(mesh);
|
facesToSplit.sync(mesh);
|
||||||
Pout<< "Read " << facesToSplit.size() << " faces from " << setName
|
Info<< "Read " << returnReduce(facesToSplit.size(), sumOp<label>())
|
||||||
<< nl << endl;
|
<< " faces from " << setName << nl << endl;
|
||||||
|
|
||||||
|
|
||||||
// Patches to put baffles into
|
// Patches to put baffles into
|
||||||
@ -231,7 +81,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
word patchName(args.additionalArgs()[1]);
|
word patchName(args.additionalArgs()[1]);
|
||||||
newPatches[0] = patches.findPatchID(patchName);
|
newPatches[0] = patches.findPatchID(patchName);
|
||||||
Pout<< "Using patch " << patchName
|
Info<< "Using patch " << patchName
|
||||||
<< " at index " << newPatches[0] << endl;
|
<< " at index " << newPatches[0] << endl;
|
||||||
|
|
||||||
if (newPatches[0] == -1)
|
if (newPatches[0] == -1)
|
||||||
@ -316,48 +166,181 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
|
|
||||||
// Do the actual changes
|
// Do the actual changes
|
||||||
|
// Note order in which faces are modified/added is so they end up correctly
|
||||||
|
// for cyclic patches (original faces first and then reversed faces)
|
||||||
|
// since otherwise it will have trouble matching baffles.
|
||||||
|
|
||||||
label nBaffled = 0;
|
label nBaffled = 0;
|
||||||
PackedBoolList doneFace(mesh.nFaces());
|
|
||||||
|
|
||||||
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
|
forAll(newPatches, i)
|
||||||
{
|
{
|
||||||
if (facesToSplit.found(faceI))
|
label newPatchI = newPatches[i];
|
||||||
{
|
|
||||||
createBaffles
|
|
||||||
(
|
|
||||||
mesh,
|
|
||||||
faceI,
|
|
||||||
-1, // oldPatchI,
|
|
||||||
newPatches,
|
|
||||||
doneFace,
|
|
||||||
meshMod
|
|
||||||
);
|
|
||||||
nBaffled++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
forAll(patches, patchI)
|
|
||||||
{
|
|
||||||
const polyPatch& pp = patches[patchI];
|
|
||||||
|
|
||||||
forAll(pp, i)
|
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
|
||||||
{
|
{
|
||||||
label faceI = pp.start()+i;
|
|
||||||
|
|
||||||
if (facesToSplit.found(faceI))
|
if (facesToSplit.found(faceI))
|
||||||
{
|
{
|
||||||
createBaffles
|
const face& f = mesh.faces()[faceI];
|
||||||
(
|
label zoneID = faceZones.whichZone(faceI);
|
||||||
mesh,
|
bool zoneFlip = false;
|
||||||
faceI,
|
if (zoneID >= 0)
|
||||||
patchI, // oldPatchI,
|
{
|
||||||
newPatches,
|
const faceZone& fZone = faceZones[zoneID];
|
||||||
doneFace,
|
zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
|
||||||
meshMod
|
}
|
||||||
);
|
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
// First usage of face. Modify.
|
||||||
|
meshMod.setAction
|
||||||
|
(
|
||||||
|
polyModifyFace
|
||||||
|
(
|
||||||
|
f, // modified face
|
||||||
|
faceI, // label of face
|
||||||
|
mesh.faceOwner()[faceI], // owner
|
||||||
|
-1, // neighbour
|
||||||
|
false, // face flip
|
||||||
|
newPatchI, // patch for face
|
||||||
|
false, // remove from zone
|
||||||
|
zoneID, // zone for face
|
||||||
|
zoneFlip // face flip in zone
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Second or more usage of face. Add.
|
||||||
|
meshMod.setAction
|
||||||
|
(
|
||||||
|
polyAddFace
|
||||||
|
(
|
||||||
|
f, // modified face
|
||||||
|
mesh.faceOwner()[faceI], // owner
|
||||||
|
-1, // neighbour
|
||||||
|
-1, // master point
|
||||||
|
-1, // master edge
|
||||||
|
faceI, // master face
|
||||||
|
false, // face flip
|
||||||
|
newPatchI, // patch for face
|
||||||
|
zoneID, // zone for face
|
||||||
|
zoneFlip // face flip in zone
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
nBaffled++;
|
nBaffled++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the reversed face.
|
||||||
|
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
|
||||||
|
{
|
||||||
|
if (facesToSplit.found(faceI))
|
||||||
|
{
|
||||||
|
const face& f = mesh.faces()[faceI];
|
||||||
|
label zoneID = faceZones.whichZone(faceI);
|
||||||
|
bool zoneFlip = false;
|
||||||
|
if (zoneID >= 0)
|
||||||
|
{
|
||||||
|
const faceZone& fZone = faceZones[zoneID];
|
||||||
|
zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
|
||||||
|
}
|
||||||
|
label nei = mesh.faceNeighbour()[faceI];
|
||||||
|
|
||||||
|
meshMod.setAction
|
||||||
|
(
|
||||||
|
polyAddFace
|
||||||
|
(
|
||||||
|
f.reverseFace(), // modified face
|
||||||
|
nei, // owner
|
||||||
|
-1, // neighbour
|
||||||
|
-1, // masterPointID
|
||||||
|
-1, // masterEdgeID
|
||||||
|
faceI, // masterFaceID,
|
||||||
|
true, // face flip
|
||||||
|
newPatchI, // patch for face
|
||||||
|
zoneID, // zone for face
|
||||||
|
zoneFlip // face flip in zone
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
nBaffled++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modify any boundary faces
|
||||||
|
forAll(patches, patchI)
|
||||||
|
{
|
||||||
|
const polyPatch& pp = patches[patchI];
|
||||||
|
|
||||||
|
if (patches[newPatchI].coupled() && pp.coupled())
|
||||||
|
{
|
||||||
|
// Do not allow coupled faces to be moved to different coupled
|
||||||
|
// patches.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
forAll(pp, i)
|
||||||
|
{
|
||||||
|
label faceI = pp.start()+i;
|
||||||
|
|
||||||
|
if (facesToSplit.found(faceI))
|
||||||
|
{
|
||||||
|
const face& f = mesh.faces()[faceI];
|
||||||
|
label zoneID = faceZones.whichZone(faceI);
|
||||||
|
bool zoneFlip = false;
|
||||||
|
if (zoneID >= 0)
|
||||||
|
{
|
||||||
|
const faceZone& fZone = faceZones[zoneID];
|
||||||
|
zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
// First usage of face. Modify.
|
||||||
|
meshMod.setAction
|
||||||
|
(
|
||||||
|
polyModifyFace
|
||||||
|
(
|
||||||
|
f, // modified face
|
||||||
|
faceI, // label of face
|
||||||
|
mesh.faceOwner()[faceI],// owner
|
||||||
|
-1, // neighbour
|
||||||
|
false, // face flip
|
||||||
|
newPatchI, // patch for face
|
||||||
|
false, // remove from zone
|
||||||
|
zoneID, // zone for face
|
||||||
|
zoneFlip // face flip in zone
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Second or more usage of face. Add.
|
||||||
|
meshMod.setAction
|
||||||
|
(
|
||||||
|
polyAddFace
|
||||||
|
(
|
||||||
|
f, // modified face
|
||||||
|
mesh.faceOwner()[faceI],// owner
|
||||||
|
-1, // neighbour
|
||||||
|
-1, // master point
|
||||||
|
-1, // master edge
|
||||||
|
faceI, // master face
|
||||||
|
false, // face flip
|
||||||
|
newPatchI, // patch for face
|
||||||
|
zoneID, // zone for face
|
||||||
|
zoneFlip // face flip in zone
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
nBaffled++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user