34void Foam::patchToPoly2DMesh::flipFaceOrder()
40 Info<<
"Flipping face order if necessary." <<
endl;
43 const edge&
e = edges[edgeI];
47 label edgeOwner = owner_[edgeI];
49 const face&
f = localFaces[edgeOwner];
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];
113 SortableList<label> nbr(fEdges.size(), -1);
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();
281 const MeshedSurface<face>& patch,
284 const EdgeMap<label>& mapEdgesRegion
289 patchSizes_(patchSizes),
291 mapEdgesRegion_(mapEdgesRegion),
294 owner_(PatchTools::edgeOwner(
patch)),
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];
void setSize(const label n)
Alias for resize()
void clear()
Clear the list, i.e. set size to zero.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
void size(const label n)
Older name for setAddressableSize.
Convert a primitivePatch into a 2D polyMesh.
void createMesh()
Create the mesh.
~patchToPoly2DMesh()
Destructor.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const labelList nEdges(UPstream::listGatherValues< label >(aMesh.nEdges()))
const std::string patch
OpenFOAM patch number as a std::string.
List< word > wordList
A List of words.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere)
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.
List< labelList > labelListList
A List of labelList.
errorManip< error > abort(error &err)
List< edge > edgeList
A List of edges.
List< face > faceList
A List of faces.
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.