82 const label
n =
f.size();
88 << (groupId + 1) <<
',' 97 << (groupId + 1) <<
',' 107 for (label fp1 = 1; fp1 <
f.size() - 1; ++fp1)
109 const label fp2 =
f.fcIndex(fp1);
111 os <<
"CTRIA3" <<
',' 113 << (groupId + 1) <<
',' 115 << (
f[fp1] + 1) <<
',' 116 << (
f[fp2] + 1) <<
nl;
151 <<
"Cannot read file " << filename <<
nl 170 bool ignoreElemId =
false;
191 if (
line.starts_with(
"$ANSA_NAME"))
196 if (
args.
size() > 4 &&
line.starts_with(
"$ANSA_NAME_COMMENT"))
207 if (!groupName.empty())
210 <<
"PSHELL:" << groupId
211 <<
" = " << groupName <<
nl;
213 nameLookup.
emplace(groupId, std::move(groupName));
241 if (!groupName.empty())
244 <<
"PSHELL:" << groupId
245 <<
" = " << groupName <<
nl;
247 nameLookup.
emplace(groupId, std::move(groupName));
261 auto dquote = line.find(
'"', 12);
267 dquote != std::string::npos
268 &&
readLabel(line.substr(12, (dquote - 12)), groupId)
274 if (!groupName.empty())
277 <<
"HMNAME group " << groupId
278 <<
" => " << groupName <<
nl;
280 nameLookup.
emplace(groupId, std::move(groupName));
291 else if (line[0] ==
'$')
299 if (line.size() > 72 && line[72] ==
'+')
308 if (buf.size() > 72 && buf[72] ==
'+')
310 line += buf.substr(8, 64);
314 line += buf.substr(8);
325 const bool freeFormat = line.
contains(
',');
339 label elemId =
readLabel(nextNasField(line, linei, 8, freeFormat));
340 label groupId =
readLabel(nextNasField(line, linei, 8, freeFormat));
341 const auto a =
readLabel(nextNasField(line, linei, 8, freeFormat));
342 const auto b =
readLabel(nextNasField(line, linei, 8, freeFormat));
343 const auto c =
readLabel(nextNasField(line, linei, 8, freeFormat));
346 const auto iterZone = zoneLookup.
cfind(groupId);
349 if (zoneId != iterZone.val())
354 zoneId = iterZone.
val();
358 zoneId = dynSizes.
size();
359 zoneLookup.
insert(groupId, zoneId);
370 else if (cmd ==
"CQUAD4")
380 label elemId =
readLabel(nextNasField(line, linei, 8, freeFormat));
381 label groupId =
readLabel(nextNasField(line, linei, 8, freeFormat));
382 const auto a =
readLabel(nextNasField(line, linei, 8, freeFormat));
383 const auto b =
readLabel(nextNasField(line, linei, 8, freeFormat));
384 const auto c =
readLabel(nextNasField(line, linei, 8, freeFormat));
385 const auto d =
readLabel(nextNasField(line, linei, 8, freeFormat));
388 const auto iterZone = zoneLookup.
cfind(groupId);
391 if (zoneId != iterZone.val())
396 zoneId = iterZone.
val();
400 zoneId = dynSizes.
size();
401 zoneLookup.
insert(groupId, zoneId);
406 if constexpr (faceTraits<Face>::isTri())
415 dynSizes[zoneId] += 2;
427 else if (cmd ==
"GRID")
439 label index =
readLabel(nextNasField(line, linei, 8, freeFormat));
440 (void) nextNasField(line, linei, 8, freeFormat);
441 scalar
x = readNasScalar(nextNasField(line, linei, 8, freeFormat));
442 scalar
y = readNasScalar(nextNasField(line, linei, 8, freeFormat));
443 scalar z = readNasScalar(nextNasField(line, linei, 8, freeFormat));
448 else if (cmd ==
"GRID*")
458 label index =
readLabel(nextNasField(line, linei, 16));
459 (void) nextNasField(line, linei, 16);
460 scalar
x = readNasScalar(nextNasField(line, linei, 16));
461 scalar
y = readNasScalar(nextNasField(line, linei, 16));
468 <<
"Expected continuation symbol '*' when reading GRID*" 469 <<
" (double precision coordinate) format" <<
nl 470 <<
"Read:" << line <<
nl 474 (void) nextNasField(line, linei, 8);
475 scalar z = readNasScalar(nextNasField(line, linei, 16));
480 else if (cmd ==
"PSHELL")
490 label groupId =
readLabel(nextNasField(line, linei, 8, freeFormat));
492 if (lastComment.size() > 1 && !nameLookup.
contains(groupId))
496 if (!groupName.empty())
499 <<
"PSHELL:" << groupId
500 <<
" = " << groupName <<
nl;
502 nameLookup.
emplace(groupId, std::move(groupName));
506 else if (unhandledCmd.
insert(cmd))
509 <<
"Unhandled Nastran command " << line <<
nl 529 this->storedPoints().transfer(dynPoints);
539 for (Face&
f : dynFaces)
541 for (label& vert :
f)
543 vert = mapPointId[vert];
549 <<
"PSHELL names:" << nameLookup <<
nl;
555 const label groupId = iter.key();
556 const label zoneId = iter.val();
558 const auto iterName = nameLookup.
cfind(groupId);
561 names[zoneId] = iterName.val();
565 names[zoneId] = surfZone::defaultName(zoneId);
569 this->sortFacesAndStore(dynFaces, dynZones, dynElemId, sorted);
572 this->addZones(dynSizes,
names);
573 this->addZonesToFaces();
589 streamOpt.
format(IOstreamOption::ASCII);
600 ? surfaceFormatsCore::oneZone(faceLst,
"")
604 const bool useFaceMap = (surf.
useFaceMap() && zones.size() > 1);
608 bool useOrigFaceIds =
618 for (
const auto&
f : faceLst)
622 useOrigFaceIds =
false;
633 <<
"Cannot write file " << filename <<
nl 638 fileFormats::NASCore::setPrecision(os, fieldFormat::FREE);
641 <<
"TITLE = " << os.name().stem() <<
nl;
647 os <<
"$HMNAME COMP" <<
setw(20) << (zonei+1)
648 <<
'"' << zones[zonei].
name() <<
'"' <<
nl;
652 os <<
"$ GRID POINTS" <<
nl 653 <<
"BEGIN BULK" <<
nl;
656 for (
const point& pt : pointLst)
661 << pt.x() <<
',' << pt.y() <<
',' << pt.z() <<
nl;
664 os <<
"$ ELEMENTS" <<
nl;
670 for (
const surfZone& zone : zones)
672 for (label nLocal = zone.size(); nLocal--; ++faceIndex)
675 (useFaceMap ?
faceMap[faceIndex] : faceIndex);
677 const Face&
f = faceLst[facei];
681 elemId = elemIds[facei];
684 elemId = writeShell(os,
f, elemId, zoneIndex);
690 os <<
"ENDDATA" <<
nl;
reference val() const
Const access to referenced object (value)
void size(const label n)
Older name for setAddressableSize.
A class for handling file names.
bool emplace(const label &key, Args &&... args)
Emplace insert a new entry, not overwriting existing entries.
bool contains(char c) const noexcept
True if string contains given character (cf. C++23)
errorManipArg< error, int > exit(error &err, const int errNo=1)
messageStream InfoErr
Information stream (stderr output on master, null elsewhere)
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.
Output to file stream as an OSstream, normally using std::ofstream for the actual output...
constexpr char nl
The newline '\n' character (0x0a)
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
A simple container for options an IOstream can normally have.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
const pointField & points() const noexcept
Return const access to the points.
const labelUList & faceMap() const noexcept
Const access to the faceMap, zero-sized when unused.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
StringType validate(const std::string &str, const UnaryPredicate &accept, const bool invert=false)
Return a copy of the input string with validated characters.
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
virtual const fileName & name() const override
Read/write access to the name of the stream.
bool contains(const label &key) const
True if hashed key is contained (found) in table.
bool useFaceMap() const noexcept
Can/should use faceMap?
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
A class for handling words, derived from Foam::string.
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
const UList< surfZone > & surfZones() const noexcept
Const access to the surface zones.
label size() const noexcept
The number of arguments.
graph_traits< Graph >::vertices_size_type size_type
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
#define DebugInfo
Report an information message using Foam::Info.
Istream and Ostream manipulators taking arguments.
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
int debug
Static debugging option.
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats...
Input from file stream as an ISstream, normally using std::ifstream for the actual input...
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void push_back(const T &val)
Copy append an element to the end of this list.
label lineNumber() const noexcept
Const access to the current stream line number.
static bool split(const std::string &line, std::string &key, std::string &val)
bool starts_with(char c) const
True if string starts with given character (cf. C++20)
vector point
Point is a vector.
const labelUList & faceIds() const noexcept
Const access to the faceIds, zero-sized when unused.
bool good() const noexcept
True if next operation might succeed.
const dimensionedScalar c
Speed of light in a vacuum.
DynamicList< T, SizeMin > & shrink()
Calls shrink_to_fit() and returns a reference to the DynamicList.
void clearStorage()
Clear the list and delete storage.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Omanip< int > setw(const int i)
const UList< Face > & surfFaces() const noexcept
Return const access to the faces.
Foam::argList args(argc, argv)
Map< label > invertToMap(const labelUList &values)
Create inverse mapping, which is a lookup table into the given list.
streamFormat format() const noexcept
Get the current stream format.
bool removeEnd(const std::string &text)
Remove the given text from the end of the string.
forAllConstIters(mixture.phases(), phase)