35 Info<<
"Writing points to " << fName <<
nl <<
endl;
40 Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
41 vit != finite_vertices_end();
45 if (!internalOnly || vit->internalOrBoundaryPoint())
55 Info<<
"Writing triangles to " << fName <<
nl <<
endl;
58 labelList vertexMap(number_of_vertices(), -2);
63 Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
64 vit != finite_vertices_end();
68 if (!internalOnly || !vit->farPoint())
70 vertexMap[vit->index()] = verti++;
77 Triangulation::Finite_faces_iterator fit = finite_faces_begin();
78 fit != finite_faces_end();
86 fit->vertex(0)->internalOrBoundaryPoint()
87 || fit->vertex(1)->internalOrBoundaryPoint()
88 || fit->vertex(2)->internalOrBoundaryPoint()
93 for (label i = 0; i < 3; ++i)
95 str <<
" " << vertexMap[fit->vertex(i)->index()] + 1;
105 Info<<
"Writing dual faces to " << fName <<
nl <<
endl;
112 Triangulation::Finite_faces_iterator fit = finite_faces_begin();
113 fit != finite_faces_end();
121 fit->vertex(0)->internalOrBoundaryPoint()
122 || fit->vertex(1)->internalOrBoundaryPoint()
123 || fit->vertex(2)->internalOrBoundaryPoint()
127 fit->faceIndex() = dualVerti++;
132 fit->faceIndex() = -1;
138 Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
139 vit != finite_vertices_end();
143 if (!internalOnly || vit->internalOrBoundaryPoint())
145 Face_circulator fcStart = incident_faces(vit);
146 Face_circulator fc = fcStart;
152 if (!is_infinite(fc))
154 if (fc->faceIndex() < 0)
157 <<
"Dual face uses vertex defined by a triangle" 158 " defined by an external point" 162 str<<
' ' << fc->faceIndex() + 1;
164 }
while (++fc != fcStart);
176 EdgeMap<label>& mapEdgesRegion,
177 EdgeMap<label>& indirectPatchEdge
180 label
nPatches = qSurf_.patchNames().size() + 1;
181 label defaultPatchIndex = qSurf_.patchNames().size();
185 mapEdgesRegion.clear();
187 const wordList& existingPatches = qSurf_.patchNames();
189 forAll(existingPatches, sP)
194 patchNames[defaultPatchIndex] =
"CV2D_default_patch";
198 Triangulation::Finite_edges_iterator eit = finite_edges_begin();
199 eit != finite_edges_end();
203 Face_handle fOwner = eit->
first;
204 Face_handle fNeighbor = fOwner->neighbor(eit->second);
206 Vertex_handle vA = fOwner->vertex(cw(eit->second));
207 Vertex_handle vB = fOwner->vertex(ccw(eit->second));
211 (vA->internalOrBoundaryPoint() && !vB->internalOrBoundaryPoint())
212 || (vB->internalOrBoundaryPoint() && !vA->internalOrBoundaryPoint())
218 label patchIndex = qSurf_.findPatch(ptA, ptB);
220 if (patchIndex == -1)
222 patchIndex = defaultPatchIndex;
225 <<
"Dual face found that is not on a surface " 226 <<
"patch. Adding to CV2D_default_patch." 230 edge
e(fOwner->faceIndex(), fNeighbor->faceIndex());
231 patchSizes[patchIndex]++;
232 mapEdgesRegion.insert(
e, patchIndex);
236 indirectPatchEdge.insert(
e, 1);
249 EdgeMap<label>& mapEdgesRegion,
250 EdgeMap<label>& indirectPatchEdge
254 dualPoints.setSize(number_of_faces());
259 Triangulation::Finite_faces_iterator fit = finite_faces_begin();
260 fit != finite_faces_end();
266 fit->vertex(0)->internalOrBoundaryPoint()
267 || fit->vertex(1)->internalOrBoundaryPoint()
268 || fit->vertex(2)->internalOrBoundaryPoint()
271 fit->faceIndex() = dualVerti;
273 dualPoints[dualVerti++] = toPoint2D(circumcenter(fit));
277 fit->faceIndex() = -1;
281 dualPoints.setSize(dualVerti);
283 extractPatches(
patchNames, patchSizes, mapEdgesRegion, indirectPatchEdge);
288 <<
" has size " << patchSizes[patchi] <<
endl;
294 dualFaces.setSize(number_of_vertices());
300 Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
301 vit != finite_vertices_end();
305 if (vit->internalOrBoundaryPoint())
307 Face_circulator fcStart = incident_faces(vit);
308 Face_circulator fc = fcStart;
313 if (!is_infinite(fc))
315 if (fc->faceIndex() < 0)
318 <<
"Dual face uses vertex defined by a triangle" 319 " defined by an external point" 324 faceVerts[verti++] = fc->faceIndex();
326 }
while (++fc != fcStart);
328 if (faceVerts.size() > 2)
330 dualFaces[dualFacei++] =
335 Info<<
"From triangle point:" << vit->index()
336 <<
" coord:" << toPoint2D(vit->point())
337 <<
" generated illegal dualFace:" << faceVerts
343 dualFaces.setSize(dualFacei);
353 EdgeMap<label> mapEdgesRegion;
354 EdgeMap<label> indirectPatchEdge;
369 dualPoints[ip] = toPoint3D(dual2DPoints[ip]);
375 Info<<
"Writing patch to be used with extrudeMesh to file " << fName
378 str << dualPoints <<
nl << dualFaces <<
nl;
void writePatch(const fileName &fName) const
Write patch.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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.
constexpr char nl
The newline '\n' character (0x0a)
T & first()
Access first element of the list, position [0].
Ostream & endl(Ostream &os)
Add newline and flush stream.
Foam::point toPoint3D(const point2D &) const
SubList< label > subList
Declare type of subList.
bool pointPair(const indexedVertex< Gt, Vb > &v0, const indexedVertex< Gt, Vb > &v1)
#define forAll(list, i)
Loop across all elements in list.
List< face > faceList
List of faces.
void writeFaces(const fileName &fName, bool internalOnly) const
Write dual faces as .obj file.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
wordList patchNames(nPatches)
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.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
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
List of word.
void writeTriangles(const fileName &fName, bool internalOnly) const
Write triangles as .obj file.
#define WarningInFunction
Report a warning using Foam::Warning.
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< label > labelList
A List of labels.
void writePoints(const fileName &fName, bool internalOnly) const
Write internal points to .obj file.