33 Info<<
"Writing points to " << fName <<
nl <<
endl;
38 Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
39 vit != finite_vertices_end();
43 if (!internalOnly || vit->internalOrBoundaryPoint())
53 Info<<
"Writing triangles to " << fName <<
nl <<
endl;
56 labelList vertexMap(number_of_vertices(), -2);
61 Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
62 vit != finite_vertices_end();
66 if (!internalOnly || !vit->farPoint())
68 vertexMap[vit->index()] = verti++;
75 Triangulation::Finite_faces_iterator fit = finite_faces_begin();
76 fit != finite_faces_end();
84 fit->vertex(0)->internalOrBoundaryPoint()
85 || fit->vertex(1)->internalOrBoundaryPoint()
86 || fit->vertex(2)->internalOrBoundaryPoint()
91 for (
label i = 0; i < 3; ++i)
93 str <<
" " << vertexMap[fit->vertex(i)->index()] + 1;
103 Info<<
"Writing dual faces to " << fName <<
nl <<
endl;
110 Triangulation::Finite_faces_iterator fit = finite_faces_begin();
111 fit != finite_faces_end();
119 fit->vertex(0)->internalOrBoundaryPoint()
120 || fit->vertex(1)->internalOrBoundaryPoint()
121 || fit->vertex(2)->internalOrBoundaryPoint()
125 fit->faceIndex() = dualVerti++;
130 fit->faceIndex() = -1;
136 Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
137 vit != finite_vertices_end();
141 if (!internalOnly || vit->internalOrBoundaryPoint())
143 Face_circulator fcStart = incident_faces(vit);
144 Face_circulator fc = fcStart;
150 if (!is_infinite(fc))
152 if (fc->faceIndex() < 0)
155 <<
"Dual face uses vertex defined by a triangle" 156 " defined by an external point" 160 str<<
' ' << fc->faceIndex() + 1;
162 }
while (++fc != fcStart);
174 EdgeMap<label>& mapEdgesRegion,
175 EdgeMap<label>& indirectPatchEdge
181 patchNames.setSize(nPatches);
182 patchSizes.setSize(nPatches, 0);
183 mapEdgesRegion.clear();
187 forAll(existingPatches, sP)
189 patchNames[sP] = existingPatches[sP];
192 patchNames[defaultPatchIndex] =
"CV2D_default_patch";
196 Triangulation::Finite_edges_iterator eit = finite_edges_begin();
197 eit != finite_edges_end();
201 Face_handle fOwner = eit->first;
202 Face_handle fNeighbor = fOwner->neighbor(eit->second);
204 Vertex_handle vA = fOwner->vertex(cw(eit->second));
205 Vertex_handle vB = fOwner->vertex(ccw(eit->second));
209 (vA->internalOrBoundaryPoint() && !vB->internalOrBoundaryPoint())
210 || (vB->internalOrBoundaryPoint() && !vA->internalOrBoundaryPoint())
218 if (patchIndex == -1)
220 patchIndex = defaultPatchIndex;
223 <<
"Dual face found that is not on a surface " 224 <<
"patch. Adding to CV2D_default_patch." 228 edge
e(fOwner->faceIndex(), fNeighbor->faceIndex());
229 patchSizes[patchIndex]++;
230 mapEdgesRegion.insert(
e, patchIndex);
234 indirectPatchEdge.insert(
e, 1);
247 EdgeMap<label>& mapEdgesRegion,
248 EdgeMap<label>& indirectPatchEdge
252 dualPoints.setSize(number_of_faces());
257 Triangulation::Finite_faces_iterator fit = finite_faces_begin();
258 fit != finite_faces_end();
264 fit->vertex(0)->internalOrBoundaryPoint()
265 || fit->vertex(1)->internalOrBoundaryPoint()
266 || fit->vertex(2)->internalOrBoundaryPoint()
269 fit->faceIndex() = dualVerti;
271 dualPoints[dualVerti++] =
toPoint2D(circumcenter(fit));
275 fit->faceIndex() = -1;
279 dualPoints.setSize(dualVerti);
281 extractPatches(patchNames, patchSizes, mapEdgesRegion, indirectPatchEdge);
286 <<
" has size " << patchSizes[
patchi] <<
endl;
292 dualFaces.setSize(number_of_vertices());
294 DynamicList<label> faceVerts(maxNvert);
298 Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
299 vit != finite_vertices_end();
303 if (vit->internalOrBoundaryPoint())
305 Face_circulator fcStart = incident_faces(vit);
306 Face_circulator fc = fcStart;
312 if (!is_infinite(fc))
314 if (fc->faceIndex() < 0)
317 <<
"Dual face uses vertex defined by a triangle" 318 " defined by an external point" 323 faceVerts.append(fc->faceIndex());
325 }
while (++fc != fcStart);
327 if (faceVerts.size() > 2)
329 dualFaces[dualFacei++] = face(faceVerts);
333 Info<<
"From triangle point:" << vit->index()
335 <<
" generated illegal dualFace:" << faceVerts
341 dualFaces.setSize(dualFacei);
351 EdgeMap<label> mapEdgesRegion;
352 EdgeMap<label> indirectPatchEdge;
367 dualPoints[ip] =
toPoint3D(dual2DPoints[ip]);
373 Info<<
"Writing patch to be used with extrudeMesh to file " << fName
376 str << dualPoints <<
nl << dualFaces <<
nl;
#define forAll(list, i)
Loop across all elements in list.
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void writePatch(const fileName &fName) const
Write patch.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
point toPoint3D(const point2D &) const
bool pointPair(const indexedVertex< Gt, Vb > &v0, const indexedVertex< Gt, Vb > &v1)
const point2D & toPoint2D(const point &) const
void writeFaces(const fileName &fName, bool internalOnly) const
Write dual faces as .obj file.
vectorField pointField
pointField is a vectorField.
wordList patchNames(nPatches)
List< label > labelList
A List of labels.
void calcDual(point2DField &dualPoints, faceList &dualFaces, wordList &patchNames, labelList &patchSizes, EdgeMap< label > &mapEdgesRegion, EdgeMap< label > &indirectPatchEdge) const
Calculates dual points (circumcentres of tets) and faces.
vector2DField point2DField
point2DField is a vector2DField.
void extractPatches(wordList &patchNames, labelList &patchSizes, EdgeMap< label > &mapEdgesRegion, EdgeMap< label > &indirectPatchEdge) const
Extract patch names and sizes.
List< word > wordList
A List of words.
void writeTriangles(const fileName &fName, bool internalOnly) const
Write triangles as .obj file.
#define WarningInFunction
Report a warning using Foam::Warning.
const doubleScalar e
Elementary charge.
void writePoints(const fileName &fName, bool internalOnly) const
Write internal points to .obj file.