mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add 'flip()' in-place method to edge, face, triFace
This commit is contained in:
@ -99,7 +99,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "xB[" << xB->size() << "]\n";
|
Info<< "xB[" << xB->size() << "]\n";
|
||||||
|
|
||||||
DynamicList<label> dl(10);
|
DynamicList<label> dl(10);
|
||||||
for (label i = 0; i < 5; i++)
|
for (label i = 0; i < 5; ++i)
|
||||||
{
|
{
|
||||||
dl.append(i);
|
dl.append(i);
|
||||||
}
|
}
|
||||||
@ -111,11 +111,23 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "f1: " << f1 << endl;
|
Info<< "f1: " << f1 << endl;
|
||||||
Info<< "f2: " << f2 << endl;
|
Info<< "f2: " << f2 << endl;
|
||||||
|
|
||||||
|
// add some more labels
|
||||||
|
for (label i = 5; i < 8; ++i)
|
||||||
|
{
|
||||||
|
dl.append(i);
|
||||||
|
}
|
||||||
|
|
||||||
// note: xfer() method returns a plain labelList
|
// note: xfer() method returns a plain labelList
|
||||||
face f3( dl.xfer() );
|
face f3(dl.xfer());
|
||||||
Info<< "dl[" << dl.size() << "/" << dl.capacity() << "] " << dl << endl;
|
Info<< "dl[" << dl.size() << "/" << dl.capacity() << "] " << dl << endl;
|
||||||
Info<< "f3: " << f3 << endl;
|
Info<< "f3: " << f3 << endl;
|
||||||
|
|
||||||
|
Info<<"\nflip faces:" << endl;
|
||||||
|
f1.flip();
|
||||||
|
f3.flip();
|
||||||
|
Info<< "f1: " << f1 << endl;
|
||||||
|
Info<< "f3: " << f3 << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -853,7 +853,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
foamOwner[faceI] = foamNeighbour[faceI];
|
foamOwner[faceI] = foamNeighbour[faceI];
|
||||||
foamNeighbour[faceI] = own;
|
foamNeighbour[faceI] = own;
|
||||||
foamFaces[faceI] = foamFaces[faceI].reverseFace();
|
foamFaces[faceI].flip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -375,7 +375,7 @@ faceList hexBlock::patchFaces(const label direc, const labelList& range) const
|
|||||||
// turn all faces inside out
|
// turn all faces inside out
|
||||||
forAll(result, faceI)
|
forAll(result, faceI)
|
||||||
{
|
{
|
||||||
result[faceI] = result[faceI].reverseFace();
|
result[faceI].flip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -867,7 +867,7 @@ int main(int argc, char *argv[])
|
|||||||
fm[facei] = true;
|
fm[facei] = true;
|
||||||
if (!cubitFile)
|
if (!cubitFile)
|
||||||
{
|
{
|
||||||
faces[facei] = faces[facei].reverseFace();
|
faces[facei].flip();
|
||||||
}
|
}
|
||||||
Swap(owner[facei], neighbour[facei]);
|
Swap(owner[facei], neighbour[facei]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -226,7 +226,7 @@ int main(int argc, char *argv[])
|
|||||||
if (((fc - cc) & fn) < 0)
|
if (((fc - cc) & fn) < 0)
|
||||||
{
|
{
|
||||||
// Boundary face points inwards. Flip.
|
// Boundary face points inwards. Flip.
|
||||||
boundaryFaces[faceI] = boundaryFaces[faceI].reverseFace();
|
boundaryFaces[faceI].flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done this face so erase from hash
|
// Done this face so erase from hash
|
||||||
|
|||||||
@ -472,7 +472,7 @@ faceList hexBlock::patchFaces(const label direc, const labelList& range) const
|
|||||||
// turn all faces inside out
|
// turn all faces inside out
|
||||||
forAll(result, faceI)
|
forAll(result, faceI)
|
||||||
{
|
{
|
||||||
result[faceI] = result[faceI].reverseFace();
|
result[faceI].flip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1035,7 +1035,7 @@ void starMesh::createCoupleMatches()
|
|||||||
# ifdef DEBUG_RIGHT_HAND_WALK
|
# ifdef DEBUG_RIGHT_HAND_WALK
|
||||||
Info<< "Turning edge for right-hand turn rule" << endl;
|
Info<< "Turning edge for right-hand turn rule" << endl;
|
||||||
# endif
|
# endif
|
||||||
startEdge = startEdge.reverseEdge();
|
startEdge.flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare the loop for the right-hand walk
|
// prepare the loop for the right-hand walk
|
||||||
@ -1348,7 +1348,7 @@ void starMesh::createCoupleMatches()
|
|||||||
) < VSMALL
|
) < VSMALL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
intersectedFace = intersectedFace.reverseFace();
|
intersectedFace.flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the new face to both master and slave
|
// Add the new face to both master and slave
|
||||||
|
|||||||
@ -414,7 +414,7 @@ void Foam::createShellMesh::setRefinement
|
|||||||
{
|
{
|
||||||
// Swap
|
// Swap
|
||||||
Swap(minCellI, maxCellI);
|
Swap(minCellI, maxCellI);
|
||||||
newF = newF.reverseFace();
|
newF.flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Pout<< "for internal edge:" << e
|
//Pout<< "for internal edge:" << e
|
||||||
|
|||||||
@ -295,7 +295,7 @@ autoPtr<mapPolyMesh> reorderMesh
|
|||||||
|
|
||||||
if (nei < own)
|
if (nei < own)
|
||||||
{
|
{
|
||||||
newFaces[faceI] = newFaces[faceI].reverseFace();
|
newFaces[faceI].flip();
|
||||||
Swap(newOwner[faceI], newNeighbour[faceI]);
|
Swap(newOwner[faceI], newNeighbour[faceI]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -403,7 +403,7 @@ void Foam::tecplotWriter::writeConnectivity
|
|||||||
edge e = pp.edges()[edgeI];
|
edge e = pp.edges()[edgeI];
|
||||||
if (e[0] > e[1])
|
if (e[0] > e[1])
|
||||||
{
|
{
|
||||||
e = e.reverseEdge();
|
e.flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
FaceNodes[nodeI++] = INTEGER4(e[0]+1);
|
FaceNodes[nodeI++] = INTEGER4(e[0]+1);
|
||||||
@ -448,7 +448,7 @@ void Foam::tecplotWriter::writeConnectivity
|
|||||||
edge e = pp.edges()[edgeI];
|
edge e = pp.edges()[edgeI];
|
||||||
if (e[0] > e[1])
|
if (e[0] > e[1])
|
||||||
{
|
{
|
||||||
e = e.reverseEdge();
|
e.flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
const face& f0 = pp.localFaces()[eFaces[0]];
|
const face& f0 = pp.localFaces()[eFaces[0]];
|
||||||
|
|||||||
@ -103,6 +103,9 @@ public:
|
|||||||
//- Return common vertex
|
//- Return common vertex
|
||||||
inline label commonVertex(const edge& a) const;
|
inline label commonVertex(const edge& a) const;
|
||||||
|
|
||||||
|
//- Flip the edge in-place.
|
||||||
|
inline void flip();
|
||||||
|
|
||||||
//- Return reverse edge
|
//- Return reverse edge
|
||||||
inline edge reverseEdge() const;
|
inline edge reverseEdge() const;
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,7 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
#include "Swap.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -135,6 +136,12 @@ inline Foam::label Foam::edge::commonVertex(const edge& a) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::edge::flip()
|
||||||
|
{
|
||||||
|
Swap(operator[](0), operator[](1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::edge Foam::edge::reverseEdge() const
|
inline Foam::edge Foam::edge::reverseEdge() const
|
||||||
{
|
{
|
||||||
return edge(end(), start());
|
return edge(end(), start());
|
||||||
|
|||||||
@ -27,11 +27,13 @@ License
|
|||||||
#include "triFace.H"
|
#include "triFace.H"
|
||||||
#include "triPointRef.H"
|
#include "triPointRef.H"
|
||||||
#include "mathematicalConstants.H"
|
#include "mathematicalConstants.H"
|
||||||
|
#include "Swap.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* const Foam::face::typeName = "face";
|
const char* const Foam::face::typeName = "face";
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::tmp<Foam::vectorField>
|
Foam::tmp<Foam::vectorField>
|
||||||
@ -475,6 +477,20 @@ Foam::label Foam::face::collapse()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::face::flip()
|
||||||
|
{
|
||||||
|
const label n = size();
|
||||||
|
|
||||||
|
if (n > 2)
|
||||||
|
{
|
||||||
|
for (label i=1; i < (n+1)/2; ++i)
|
||||||
|
{
|
||||||
|
Swap(operator[](i), operator[](n-i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::point Foam::face::centre(const pointField& meshPoints) const
|
Foam::point Foam::face::centre(const pointField& meshPoints) const
|
||||||
{
|
{
|
||||||
// Calculate the centre by breaking the face into triangles and
|
// Calculate the centre by breaking the face into triangles and
|
||||||
|
|||||||
@ -173,6 +173,10 @@ public:
|
|||||||
// return the collapsed size
|
// return the collapsed size
|
||||||
label collapse();
|
label collapse();
|
||||||
|
|
||||||
|
//- Flip the face in-place.
|
||||||
|
// The starting points of the original and flipped face are identical.
|
||||||
|
void flip();
|
||||||
|
|
||||||
//- Return the points corresponding to this face
|
//- Return the points corresponding to this face
|
||||||
inline pointField points(const pointField& meshPoints) const;
|
inline pointField points(const pointField& meshPoints) const;
|
||||||
|
|
||||||
|
|||||||
@ -98,6 +98,10 @@ public:
|
|||||||
// return the collapsed size, set collapsed point labels to -1
|
// return the collapsed size, set collapsed point labels to -1
|
||||||
inline label collapse();
|
inline label collapse();
|
||||||
|
|
||||||
|
//- Flip the face in-place.
|
||||||
|
// The starting points of the original and flipped face are identical.
|
||||||
|
inline void flip();
|
||||||
|
|
||||||
//- Return the points corresponding to this face
|
//- Return the points corresponding to this face
|
||||||
inline pointField points(const pointField& meshPoints) const;
|
inline pointField points(const pointField& meshPoints) const;
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,7 @@ License
|
|||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "face.H"
|
#include "face.H"
|
||||||
#include "triPointRef.H"
|
#include "triPointRef.H"
|
||||||
|
#include "Swap.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -118,6 +119,12 @@ inline Foam::label Foam::triFace::collapse()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::triFace::flip()
|
||||||
|
{
|
||||||
|
Swap(operator[](1), operator[](2));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::pointField Foam::triFace::points(const pointField& points) const
|
inline Foam::pointField Foam::triFace::points(const pointField& points) const
|
||||||
{
|
{
|
||||||
pointField p(3);
|
pointField p(3);
|
||||||
|
|||||||
@ -360,7 +360,7 @@ void Foam::layerAdditionRemoval::removeCellLayer
|
|||||||
|
|
||||||
if (flipFace)
|
if (flipFace)
|
||||||
{
|
{
|
||||||
newFace = newFace.reverseFace();
|
newFace.flip();
|
||||||
zoneFlip = !zoneFlip;
|
zoneFlip = !zoneFlip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -105,7 +105,7 @@ bool Foam::layerAdditionRemoval::setLayerPairing() const
|
|||||||
// Flip face based on flip index to recover original orientation
|
// Flip face based on flip index to recover original orientation
|
||||||
if (mfFlip[faceI])
|
if (mfFlip[faceI])
|
||||||
{
|
{
|
||||||
curLocalFace = curLocalFace.reverseFace();
|
curLocalFace.flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the opposing face from the master cell
|
// Get the opposing face from the master cell
|
||||||
|
|||||||
@ -1125,7 +1125,7 @@ Foam::label Foam::hexRef8::storeMidPointInfo
|
|||||||
{
|
{
|
||||||
own = anchorCell1;
|
own = anchorCell1;
|
||||||
nei = anchorCell0;
|
nei = anchorCell0;
|
||||||
newFace = newFace.reverseFace();
|
newFace.flip();
|
||||||
|
|
||||||
ownPt = mesh_.points()[anchors.otherVertex(anchorPointI)];
|
ownPt = mesh_.points()[anchors.otherVertex(anchorPointI)];
|
||||||
neiPt = mesh_.points()[anchorPointI];
|
neiPt = mesh_.points()[anchorPointI];
|
||||||
|
|||||||
@ -1078,7 +1078,7 @@ void Foam::polyTopoChange::compact
|
|||||||
&& faceNeighbour_[faceI] < faceOwner_[faceI]
|
&& faceNeighbour_[faceI] < faceOwner_[faceI]
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
faces_[faceI] = faces_[faceI].reverseFace();
|
faces_[faceI].flip();
|
||||||
Swap(faceOwner_[faceI], faceNeighbour_[faceI]);
|
Swap(faceOwner_[faceI], faceNeighbour_[faceI]);
|
||||||
flipFaceFlux_[faceI] =
|
flipFaceFlux_[faceI] =
|
||||||
(
|
(
|
||||||
|
|||||||
@ -89,7 +89,7 @@ void Foam::slidingInterface::decoupleInterface
|
|||||||
|
|
||||||
if (masterPatchFlip[faceI])
|
if (masterPatchFlip[faceI])
|
||||||
{
|
{
|
||||||
newFace = newFace.reverseFace();
|
newFace.flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
ref.setAction
|
ref.setAction
|
||||||
@ -141,7 +141,7 @@ void Foam::slidingInterface::decoupleInterface
|
|||||||
|
|
||||||
if (slavePatchFlip[faceI])
|
if (slavePatchFlip[faceI])
|
||||||
{
|
{
|
||||||
newFace = newFace.reverseFace();
|
newFace.flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recover retired points on the slave side
|
// Recover retired points on the slave side
|
||||||
|
|||||||
@ -519,8 +519,7 @@ void Foam::enrichedPatch::calcCutFaces() const
|
|||||||
|
|
||||||
// Reverse the face such that it
|
// Reverse the face such that it
|
||||||
// points out of the master patch
|
// points out of the master patch
|
||||||
cf[cf.size() - 1] =
|
cf[cf.size() - 1].flip();
|
||||||
cf[cf.size() - 1].reverseFace();
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -315,7 +315,7 @@ void Foam::cuttingPlane::walkCellCuts
|
|||||||
// Orient face to point in the same direction as the plane normal
|
// Orient face to point in the same direction as the plane normal
|
||||||
if ((f.normal(cutPoints) & normal()) < 0)
|
if ((f.normal(cutPoints) & normal()) < 0)
|
||||||
{
|
{
|
||||||
f = f.reverseFace();
|
f.flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// the cut faces are usually quite ugly, so optionally triangulate
|
// the cut faces are usually quite ugly, so optionally triangulate
|
||||||
|
|||||||
Reference in New Issue
Block a user