34void Foam::patchToPoly2DMesh::flipFaceOrder()
36 const edgeList& edges = patch_.edges();
37 const faceList& localFaces = patch_.localFaces();
38 const labelList& meshPoints = patch_.meshPoints();
40 Info<<
"Flipping face order if necessary." <<
endl;
43 const edge&
e = edges[edgeI];
45 faces_[edgeI].setSize(2);
47 label edgeOwner = owner_[edgeI];
49 const face&
f = localFaces[edgeOwner];
51 label fp =
f.find(
e[0]);
53 if (
f.nextLabel(fp) !=
e[1])
55 Info<<
"Flipping face " << faces_[edgeI] <<
endl;
56 faces_[edgeI][0] = meshPoints[
e[1]];
57 faces_[edgeI][1] = meshPoints[
e[0]];
61 faces_[edgeI][0] = meshPoints[
e[0]];
62 faces_[edgeI][1] = meshPoints[
e[1]];
68void Foam::patchToPoly2DMesh::createNeighbours()
70 const edgeList& edges = patch_.edges();
73 Info<<
"Calculating neighbours." <<
endl;
76 const labelList& eFaces = edgeFaces[edgeI];
77 if (eFaces.size() == 2)
79 if (owner_[edgeI] == eFaces[0])
81 neighbour_[edgeI] = eFaces[1];
85 neighbour_[edgeI] = eFaces[0];
88 else if (eFaces.size() == 1)
111 const labelList& fEdges = faceEdges[facei];
117 if (fEdges[feI] < neighbour_.size())
121 label nbrFacei = neighbour_[fEdges[feI]];
123 if (nbrFacei == facei)
125 nbrFacei = owner_[fEdges[feI]];
128 if (facei < nbrFacei)
142 oldToNew[fEdges[nbr.indices()[i]]] = newFacei++;
151void Foam::patchToPoly2DMesh::addPatchFacesToFaces()
153 const labelList& meshPoints = patch_.meshPoints();
155 label offset = patch_.nInternalEdges();
158 forAll(patchNames_, patchi)
162 if (eIter() == patchi)
164 f[0] = meshPoints[eIter.key().start()];
165 f[1] = meshPoints[eIter.key().end()];
166 faces_[offset++] =
f;
175void Foam::patchToPoly2DMesh::addPatchFacesToOwner()
177 const label nInternalEdges = patch_.nInternalEdges();
178 const faceList& faces = patch_.surfFaces();
179 const label nExternalEdges = patch_.edges().size() - nInternalEdges;
180 const labelList& meshPoints = patch_.meshPoints();
189 label bFacei = nInternalEdges;
190 bFacei < faces_.size();
194 const face&
e = faces_[bFacei];
196 bool matched =
false;
200 label bEdgeI = nInternalEdges;
201 bEdgeI < faces_.size();
207 e[0] == meshPoints[patch_.edges()[bEdgeI][0]]
208 &&
e[1] == meshPoints[patch_.edges()[bEdgeI][1]]
211 const face&
f = faces[owner_[bEdgeI]];
215 newOwner[bFacei] = owner_[bEdgeI];
217 if (
f.nextLabel(fp) !=
e[1])
221 faces_[bFacei][0] =
e[1];
222 faces_[bFacei][1] =
e[0];
231 e[0] == meshPoints[patch_.edges()[bEdgeI][1]]
232 &&
e[1] == meshPoints[patch_.edges()[bEdgeI][0]]
235 Info<<
"Warning: Wrong orientation." <<
endl;
242 Info<<
"No match for edge." <<
endl;
246 if (nMatched != nExternalEdges)
248 Info<<
"Number of matched edges, " << nMatched
249 <<
", does not match number of external edges, "
250 << nExternalEdges <<
endl;
253 owner_.transfer(newOwner);
257void Foam::patchToPoly2DMesh::createPolyMeshComponents()
264 labelList oldToNew = internalFaceOrder();
271 addPatchFacesToFaces();
273 addPatchFacesToOwner();
279Foam::patchToPoly2DMesh::patchToPoly2DMesh
289 patchSizes_(patchSizes),
291 mapEdgesRegion_(mapEdgesRegion),
293 faces_(
patch.nEdges()),
295 neighbour_(
patch.nInternalEdges())
309 for (label edgeI = 0; edgeI < patch_.nInternalEdges(); edgeI++)
311 if (patch_.edgeFaces()[edgeI].size() != 2)
314 <<
"internal edge:" << edgeI
315 <<
" patch.edgeFaces()[edgeI]:" << patch_.edgeFaces()[edgeI]
322 label edgeI = patch_.nInternalEdges();
323 edgeI < patch_.nEdges();
327 if (patch_.edgeFaces()[edgeI].size() != 1)
330 <<
"boundary edge:" << edgeI
331 <<
" patch.edgeFaces()[edgeI]:" << patch_.edgeFaces()[edgeI]
336 createPolyMeshComponents();
338 label startFace = patch_.nInternalEdges();
339 forAll(patchNames_, patchi)
341 patchStarts_[patchi] = startFace;
342 startFace += patchSizes_[patchi];
Map from edge (expressed as its endpoints) to value. Hashing (and ==) on an edge is symmetric.
void clear()
Clear the list, i.e. set size to zero.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
A list that is sorted upon construction or when explicitly requested with the sort() method.
label find(const T &val) const
Find index of the first occurrence of the value.
A face is a list of labels corresponding to mesh vertices.
void createMesh()
Create the mesh.
~patchToPoly2DMesh()
Destructor.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const std::string patch
OpenFOAM patch number as a std::string.
List< edge > edgeList
List of edge.
List< word > wordList
List of word.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< face > faceList
List of faces.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
wordList patchNames(nPatches)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.