46 const label
n =
f.size();
52 << (groupId + 1) <<
','
61 << (groupId + 1) <<
','
71 for (label fp1 = 1; fp1 <
f.size() - 1; ++fp1)
73 const label fp2 =
f.fcIndex(fp1);
77 << (groupId + 1) <<
','
79 << (
f[fp1] + 1) <<
','
80 << (
f[fp2] + 1) << nl;
115 <<
"Cannot read file " << filename <<
nl
134 bool ignoreElemId =
false;
144 word ansaType, ansaName;
158 if (
line.starts_with(
"$ANSA_NAME"))
160 const auto sem0 =
line.find(
';', 0);
161 const auto sem1 =
line.find(
';', sem0+1);
162 const auto sem2 =
line.find(
';', sem1+1);
166 sem0 != std::string::npos
167 && sem1 != std::string::npos
168 && sem2 != std::string::npos
172 ansaType =
line.substr(sem1+1, sem2-sem1-1);
177 ansaName = word::validate(rawName.substr(1));
188 if (
line.starts_with(
"$HMNAME COMP") &&
line.find(
'"') != string::npos)
193 const word groupName = word::validate(
line.substr(32));
195 nameLookup.
insert(groupId, groupName);
205 if (
line.size() > 72 &&
line[72] ==
'+')
214 if (buf.size() > 72 && buf[72] ==
'+')
216 line += buf.substr(8, 64);
220 line += buf.substr(8);
227 const word cmd(word::validate(nextNasField(
line, linei, 8)));
238 const auto iterZone = zoneLookup.
cfind(groupId);
239 if (iterZone.found())
241 if (zoneId != *iterZone)
250 zoneId = dynSizes.
size();
251 zoneLookup.
insert(groupId, zoneId);
258 dynFaces.
append(Face{a,
b, c});
262 else if (cmd ==
"CQUAD4")
272 const auto iterZone = zoneLookup.
cfind(groupId);
273 if (iterZone.found())
275 if (zoneId != *iterZone)
284 zoneId = dynSizes.
size();
285 zoneLookup.
insert(groupId, zoneId);
295 dynFaces.
append(Face{a,
b, c});
296 dynFaces.
append(Face{c, d, a});
299 dynSizes[zoneId] += 2;
306 dynFaces.
append(Face{a,
b,c,d});
311 else if (cmd ==
"GRID")
314 (void) nextNasField(
line, linei, 8);
315 scalar
x = readNasScalar(nextNasField(
line, linei, 8));
316 scalar
y = readNasScalar(nextNasField(
line, linei, 8));
317 scalar z = readNasScalar(nextNasField(
line, linei, 8));
322 else if (cmd ==
"GRID*")
331 (void) nextNasField(
line, linei, 16);
332 scalar
x = readNasScalar(nextNasField(
line, linei, 16));
333 scalar
y = readNasScalar(nextNasField(
line, linei, 16));
340 <<
"Expected continuation symbol '*' when reading GRID*"
341 <<
" (double precision coordinate) format" <<
nl
346 (void) nextNasField(
line, linei, 8);
347 scalar z = readNasScalar(nextNasField(
line, linei, 16));
352 else if (cmd ==
"PSHELL")
356 if (groupId == ansaId && ansaType ==
"PSHELL")
358 const word groupName = word::validate(ansaName);
359 nameLookup.
insert(groupId, groupName);
363 else if (unhandledCmd.
insert(cmd))
365 Info<<
"Unhandled Nastran command " <<
line <<
nl
381 this->storedPoints().transfer(dynPoints);
390 mapPointId.
insert(pointId[i], i);
395 for (Face&
f : dynFaces)
397 for (label& vert :
f)
399 vert = mapPointId[vert];
410 const label groupId = iter.key();
411 const label zoneId = iter.val();
413 const auto iterName = nameLookup.
cfind(groupId);
414 if (iterName.found())
416 names[zoneId] = *iterName;
420 names[zoneId] = surfZone::defaultName(zoneId);
424 this->sortFacesAndStore(dynFaces, dynZones, dynElemId, sorted);
427 this->addZones(dynSizes, names);
428 this->addZonesToFaces();
444 streamOpt.
format(IOstream::ASCII);
455 ? surfaceFormatsCore::oneZone(faceLst,
"")
463 bool useOrigFaceIds =
473 for (
const auto&
f : faceLst)
477 useOrigFaceIds =
false;
488 <<
"Cannot write file " << filename <<
nl
493 fileFormats::NASCore::setPrecision(
os, fieldFormat::FREE);
496 <<
"TITLE = " <<
os.name().nameLessExt() <<
nl;
502 os <<
"$HMNAME COMP" <<
setw(20) << (zonei+1)
503 <<
'"' << zones[zonei].
name() <<
'"' <<
nl;
507 os <<
"$ GRID POINTS" <<
nl
508 <<
"BEGIN BULK" <<
nl;
511 for (
const point& pt : pointLst)
516 << pt.x() <<
',' << pt.y() <<
',' << pt.z() <<
nl;
519 os <<
"$ ELEMENTS" <<
nl;
527 for (label nLocal =
zone.
size(); nLocal--; ++faceIndex)
530 (useFaceMap ?
faceMap[faceIndex] : faceIndex);
532 const Face&
f = faceLst[facei];
536 elemId = elemIds[facei];
539 elemId = writeShell(
os,
f, elemId, zoneIndex);
545 os <<
"ENDDATA" <<
nl;
Istream and Ostream manipulators taking arguments.
Various functions to operate on Lists.
label size_type
The type to represent the size of a buffer.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
DynamicList< T, SizeMin > & shrink()
Shrink the allocated space to the number of elements used.
void append(const T &val)
Copy append an element to the end of this list.
void clearStorage()
Clear the list and delete storage.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
void clear()
Clear all entries from table.
Input from file stream, using an ISstream.
virtual const fileName & name() const
Read/write access to the name of the stream.
The IOstreamOption is a simple container for options an IOstream can normally have.
streamFormat format() const noexcept
Get the current stream format.
label lineNumber() const noexcept
Const access to the current stream line number.
bool good() const noexcept
True if next operation might succeed.
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A HashTable to objects of type <T> with a label key.
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
const UList< surfZone > & surfZones() const
Const access to the surface zones.
const UList< Face > & surfFaces() const
Return const access to the faces.
bool useFaceMap() const
Can/should use faceMap?
const labelUList & faceIds() const
Const access to the faceIds, zero-sized when unused.
const pointField & points() const
Return const access to the points.
const labelUList & faceMap() const
Const access to the faceMap, zero-sized when unused.
Output to file stream, using an OSstream.
virtual bool read()
Re-read model coefficients if they have changed.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
void size(const label n)
Older name for setAddressableSize.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A class for handling file names.
virtual bool write()
Write the output fields.
bool removeEnd(const std::string &text)
Remove the given text from the end of the string.
A surface zone on a MeshedSurface.
A class for handling words, derived from Foam::string.
Base class for mesh zones.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Omanip< int > setw(const int i)
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#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.