52int main(
int argc,
char *argv[])
56 "Corrects the orientation of faceZone"
59 argList::addArgument(
"faceZone");
60 argList::addArgument(
"point",
"A point outside of the mesh");
69 Info<<
"Orienting faceZone " << zoneName
70 <<
" such that " << outsidePoint <<
" is outside"
79 <<
"Face zone " << fZone.
name()
80 <<
" is not parallel synchronised."
81 <<
" Any coupled face also needs its coupled version to be included"
82 <<
" and with opposite flipMap."
96 const bitSet isMasterFace(syncTools::getMasterFaces(
mesh));
109 label nProtected = 0;
113 const label meshFacei = faceLabels[facei];
114 const label patchi = bm.
whichPatch(meshFacei);
120 && !isMasterFace[meshFacei]
124 allFaceInfo[facei] = orientedSurface::NOFLIP;
129 Info<<
"Protected from visiting "
131 <<
" slaves of coupled faces" <<
nl <<
endl;
139 const label meshFacei = faceLabels[facei];
141 if (isMasterFace[meshFacei])
146 nMasterFaces[fEdges[fEdgeI]]++;
151 syncTools::syncEdgeList
161 label nProtected = 0;
163 forAll(nMasterFaces, edgeI)
165 if (nMasterFaces[edgeI] > 2)
167 allEdgeInfo[edgeI] = orientedSurface::NOFLIP;
172 Info<<
"Protected from visiting "
174 <<
" non-manifold edges" <<
nl <<
endl;
196 forAll(allFaceInfo, facei)
198 if (allFaceInfo[facei] == orientedSurface::UNVISITED)
200 unsetFacei = globalFaces.toGlobal(facei);
207 if (unsetFacei == labelMax)
212 label proci = globalFaces.whichProcID(unsetFacei);
213 label seedFacei = globalFaces.toLocal(proci, unsetFacei);
214 Info<<
"Seeding from processor " << proci
215 <<
" face " << seedFacei <<
endl;
217 if (proci == Pstream::myProcNo())
221 vector d = outsidePoint-
patch.faceCentres()[seedFacei];
226 faceInfo = orientedSurface::NOFLIP;
232 Pout<<
"Face " << seedFacei <<
" at "
233 <<
patch.faceCentres()[seedFacei]
234 <<
" with normal " << fn
235 <<
" needs to be flipped." <<
endl;
239 Pout<<
"Face " << seedFacei <<
" at "
240 <<
patch.faceCentres()[seedFacei]
241 <<
" with normal " << fn
242 <<
" points in positive direction (cos = " << (fn&d)/
mag(d)
250 label edgeI = fEdges[fEdgeI];
268 changedEdges.
append(edgeI);
269 changedInfo.
append(edgeInfo);
304 labelList neiStatus(
mesh.nBoundaryFaces(), orientedSurface::UNVISITED);
308 const label meshFacei = faceLabels[i];
309 if (!
mesh.isInternalFace(meshFacei))
311 neiStatus[meshFacei-
mesh.nInternalFaces()] =
312 allFaceInfo[i].flipStatus();
315 syncTools::swapBoundaryFaceList(
mesh, neiStatus);
319 const label meshFacei = faceLabels[i];
320 const label patchi = bm.
whichPatch(meshFacei);
326 && !isMasterFace[meshFacei]
330 label bFacei = meshFacei-
mesh.nInternalFaces();
332 if (neiStatus[bFacei] == orientedSurface::NOFLIP)
334 allFaceInfo[i] = orientedSurface::FLIP;
336 else if (neiStatus[bFacei] == orientedSurface::FLIP)
338 allFaceInfo[i] = orientedSurface::NOFLIP;
343 <<
"Incorrect status for face " << meshFacei
344 <<
abort(FatalError);
353 boolList newFlipMap(allFaceInfo.size(),
false);
355 forAll(allFaceInfo, facei)
357 if (allFaceInfo[facei] == orientedSurface::NOFLIP)
359 newFlipMap[facei] =
false;
361 else if (allFaceInfo[facei] == orientedSurface::FLIP)
363 newFlipMap[facei] =
true;
368 <<
"Problem : unvisited face " << facei
369 <<
" centre:" <<
mesh.faceCentres()[faceLabels[facei]]
370 <<
abort(FatalError);
373 if (fZone.
flipMap()[facei] != newFlipMap[facei])
382 Info<<
"Flipping " << nChanged <<
" out of "
383 << globalFaces.size() <<
" faces." <<
nl <<
endl;
385 mesh.faceZones()[zoneName].resetAddressing(faceLabels, newFlipMap);
386 if (!
mesh.faceZones().write())
389 <<
"Failed writing faceZones" <<
exit(FatalError);
reduce(hasMovingMesh, orOp< bool >())
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
A List with indirect addressing.
Wave propagation of information along patch. Every iteration information goes through one layer of fa...
A list of faces which address into the list of points.
void size(const label n)
Older name for setAddressableSize.
T get(const label index) const
Get a value from the argument at index.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
A subset of mesh faces organised as a primitive patch.
const boolList & flipMap() const noexcept
Return face flip map.
virtual bool checkParallelSync(const bool report=false) const
Check whether all procs have faces synchronised.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Transport of orientation for use in PatchEdgeFaceWave.
void flip()
Reverse the orientation.
bool updateEdge(const polyMesh &mesh, const indirectPrimitivePatch &patch, const label edgeI, const label facei, const patchFaceOrientation &faceInfo, const scalar tol, TrackingData &td)
Influence of face on edge.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
const word & name() const noexcept
The zone name.
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false))
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const std::string patch
OpenFOAM patch number as a std::string.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.