34 void 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];
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]];
68 void 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++;
151 void 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;
175 void 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);
257 void Foam::patchToPoly2DMesh::createPolyMeshComponents()
264 labelList oldToNew = internalFaceOrder();
271 addPatchFacesToFaces();
273 addPatchFacesToOwner();
279 Foam::patchToPoly2DMesh::patchToPoly2DMesh
281 const MeshedSurface<face>&
patch,
284 const EdgeMap<label>& mapEdgesRegion
289 patchSizes_(patchSizes),
291 mapEdgesRegion_(mapEdgesRegion),
293 faces_(
patch.nEdges()),
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];
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
void size(const label n)
Older name for setAddressableSize.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< edge > edgeList
List of edge.
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< labelList > labelListList
List of labelList.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
#define forAll(list, i)
Loop across all elements in list.
List< face > faceList
List of faces.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
void clear()
Clear the list, i.e. set size to zero.
wordList patchNames(nPatches)
~patchToPoly2DMesh()
Destructor.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
errorManip< error > abort(error &err)
label find(const T &val) const
Find index of the first occurrence of the value.
List< word > wordList
List of word.
void createMesh()
Create the mesh.
const std::string patch
OpenFOAM patch number as a std::string.
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< label > labelList
A List of labels.
forAllConstIters(mixture.phases(), phase)