41 const UList<Face>& faceLst
44 if constexpr (faceTraits<Face>::isTri())
52 for (
const auto&
f : faceLst)
63 <<
"Surface has " << nNonTris <<
'/' << faceLst.size()
64 <<
" non-triangulated faces - not writing!" <<
endl;
100 <<
"Cannot read file " << filename <<
nl 105 string line = this->getLineNoComment(is);
118 auto& pointLst = this->storedPoints();
119 auto& faceLst = this->storedFaces();
120 auto& zoneIds = this->storedZoneIds();
123 faceLst.resize(nElems);
124 zoneIds.resize(nElems);
130 line = this->getLineNoComment(is);
132 IStringStream lineStream(line);
137 pointLst[pointi] =
point(
x,
y, z);
145 line = this->getLineNoComment(is);
147 IStringStream lineStream(line);
151 edges[edgei] =
edge(beg - 1,
end - 1);
159 label e0Label, e1Label, e2Label;
162 line = this->getLineNoComment(is);
164 IStringStream lineStream(line);
166 >> e0Label >> e1Label >> e2Label;
173 if (!lineStream.bad())
188 const edge& e0 = edges[e0Label - 1];
189 const edge& e1 = edges[e1Label - 1];
190 const edge& e2 = edges[e2Label - 1];
192 label common01 = e0.commonVertex(e1);
196 <<
"Edges 0 and 1 of triangle " << facei
197 <<
" do not share a point.\n" 198 <<
" edge0:" << e0 <<
nl 203 const label e0Far = e0.otherVertex(common01);
204 const label e1Far = e1.otherVertex(common01);
206 const label common12 = e1.commonVertex(e2);
210 <<
"Edges 1 and 2 of triangle " << facei
211 <<
" do not share a point.\n" 212 <<
" edge1:" << e1 <<
nl 216 const label e2Far = e2.otherVertex(common12);
219 if (common12 != e1Far || e2Far != e0Far)
222 <<
"Edges of triangle " << facei
223 <<
" reference more than three points.\n" 224 <<
" edge0:" << e0 <<
nl 225 <<
" edge1:" << e1 <<
nl 226 <<
" edge2:" << e2 <<
nl 230 faceLst[facei] = Face{e0Far, common01, e1Far};
231 zoneIds[facei] = zoneI;
235 List<surfZoneIdentifier> newZones(maxZone+1);
238 newZones[zonei] = surfZoneIdentifier
240 surfZoneIdentifier::defaultName(zonei),
245 this->storedZoneToc().transfer(newZones);
246 this->addZonesToFaces();
262 streamOpt.
format(IOstreamOption::ASCII);
271 : surfaceFormatsCore::oneZone(faceLst)
274 checkIfTriangulated(faceLst);
280 <<
"Cannot write file " << filename <<
nl 286 os <<
"# GTS file" <<
nl 291 os <<
"# " << zonei <<
" " 292 << zones[zonei].
name() <<
nl;
296 os <<
"# nPoints nEdges nTriangles" <<
nl 297 << pointLst.
size() <<
' ' << surf.
nEdges() <<
' ' 302 for (
const point& pt : pointLst)
304 os << pt.x() <<
' ' << pt.y() <<
' ' << pt.z() <<
nl;
313 for (
const edge&
e : es)
315 os << meshPts[
e.start()] + 1 <<
' ' 316 << meshPts[
e.end()] + 1 <<
nl;
325 for (
const surfZone& zone : zones)
327 for (label nLocal = zone.size(); nLocal--; ++faceIndex)
329 const label facei = faceIndex;
333 os << fEdges[0] + 1 <<
' ' 334 << fEdges[1] + 1 <<
' ' 335 << fEdges[2] + 1 <<
' ' 354 streamOpt.
format(IOstreamOption::ASCII);
361 checkIfTriangulated(faceLst);
367 <<
"Cannot write file " << filename <<
nl 373 os <<
"# GTS file" <<
nl 378 os <<
"# " << zonei <<
" " 379 << zoneToc[zonei].name() <<
nl;
383 os <<
"# nPoints nEdges nTriangles" <<
nl 384 << pointLst.
size() <<
' ' << surf.
nEdges() <<
' ' 389 for (
const point& pt : pointLst)
391 os << pt.x() <<
' ' << pt.y() <<
' ' << pt.z() <<
nl;
400 for (
const edge&
e : es)
402 os << meshPts[
e.start()] + 1 <<
' ' 403 << meshPts[
e.end()] + 1 <<
nl;
413 os << fEdges[0] + 1 <<
' ' 414 << fEdges[1] + 1 <<
' ' 415 << fEdges[2] + 1 <<
' ' 416 << zoneIds[facei] <<
nl;
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
void size(const label n)
Older name for setAddressableSize.
A class for handling file names.
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...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Input/output from string buffers.
List< edge > edgeList
List of edge.
virtual const fileName & name() const override
Read/write access to the name of the stream.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Output to file stream as an OSstream, normally using std::ofstream for the actual output...
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A simple container for options an IOstream can normally have.
List< labelList > labelListList
List of labelList.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
label size() const
The surface size is the number of faces.
#define forAll(list, i)
Loop across all elements in list.
const dimensionedScalar e
Elementary charge.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const Field< point_type > & points() const noexcept
Return reference to global points.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
label nEdges() const
Number of edges in patch.
const List< Face > & surfFaces() const
Return const access to the faces.
virtual const labelList & zoneIds() const
Return const access to the zone ids.
const wordList edge
Standard (finite-area) edge field types (scalar, vector, tensor, etc)
Input from file stream as an ISstream, normally using std::ifstream for the actual input...
const List< surfZoneIdentifier > & zoneToc() const
Return const access to the zone table-of-contents.
label size() const
The surface size is the number of faces.
vector point
Point is a vector.
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
bool good() const noexcept
True if next operation might succeed.
const labelListList & faceEdges() const
Return face-edge addressing.
List< label > labelList
A List of labels.
const surfZoneList & surfZones() const
Const access to the surface zones.
streamFormat format() const noexcept
Get the current stream format.