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"))
195 stringOps::split<std::string>(
line,
';', 0,
true);
197 if (
args.
size() > 4 &&
line.starts_with(
"$ANSA_NAME_COMMENT"))
208 if (!groupName.empty())
211 <<
"PSHELL:" << groupId
212 <<
" = " << groupName <<
nl;
214 nameLookup.
emplace(groupId, std::move(groupName));
234 line.removeEnd(
'\r');
237 if (line.starts_with(
'$'))
242 if (!groupName.empty())
245 <<
"PSHELL:" << groupId
246 <<
" = " << groupName <<
nl;
248 nameLookup.
emplace(groupId, std::move(groupName));
255 else if (line.starts_with(
"$HMNAME COMP"))
262 auto dquote = line.find(
'"', 12);
268 dquote != std::string::npos
269 &&
readLabel(line.substr(12, (dquote - 12)), groupId)
275 if (!groupName.empty())
278 <<
"HMNAME group " << groupId
279 <<
" => " << groupName <<
nl;
281 nameLookup.
emplace(groupId, std::move(groupName));
292 else if (line[0] ==
'$')
300 if (line.size() > 72 && line[72] ==
'+')
309 if (buf.size() > 72 && buf[72] ==
'+')
311 line += buf.substr(8, 64);
315 line += buf.substr(8);
326 const bool freeFormat = line.contains(
',');
340 label elemId =
readLabel(nextNasField(line, linei, 8, freeFormat));
341 label groupId =
readLabel(nextNasField(line, linei, 8, freeFormat));
342 const auto a =
readLabel(nextNasField(line, linei, 8, freeFormat));
343 const auto b =
readLabel(nextNasField(line, linei, 8, freeFormat));
344 const auto c =
readLabel(nextNasField(line, linei, 8, freeFormat));
347 const auto iterZone = zoneLookup.
cfind(groupId);
350 if (zoneId != iterZone.val())
355 zoneId = iterZone.
val();
359 zoneId = dynSizes.
size();
360 zoneLookup.
insert(groupId, zoneId);
371 else if (cmd ==
"CQUAD4")
381 label elemId =
readLabel(nextNasField(line, linei, 8, freeFormat));
382 label groupId =
readLabel(nextNasField(line, linei, 8, freeFormat));
383 const auto a =
readLabel(nextNasField(line, linei, 8, freeFormat));
384 const auto b =
readLabel(nextNasField(line, linei, 8, freeFormat));
385 const auto c =
readLabel(nextNasField(line, linei, 8, freeFormat));
386 const auto d =
readLabel(nextNasField(line, linei, 8, freeFormat));
389 const auto iterZone = zoneLookup.
cfind(groupId);
392 if (zoneId != iterZone.val())
397 zoneId = iterZone.
val();
401 zoneId = dynSizes.
size();
402 zoneLookup.
insert(groupId, zoneId);
407 if (faceTraits<Face>::isTri())
416 dynSizes[zoneId] += 2;
428 else if (cmd ==
"GRID")
440 label index =
readLabel(nextNasField(line, linei, 8, freeFormat));
441 (void) nextNasField(line, linei, 8, freeFormat);
442 scalar
x = readNasScalar(nextNasField(line, linei, 8, freeFormat));
443 scalar
y = readNasScalar(nextNasField(line, linei, 8, freeFormat));
444 scalar z = readNasScalar(nextNasField(line, linei, 8, freeFormat));
449 else if (cmd ==
"GRID*")
459 label index =
readLabel(nextNasField(line, linei, 16));
460 (void) nextNasField(line, linei, 16);
461 scalar
x = readNasScalar(nextNasField(line, linei, 16));
462 scalar
y = readNasScalar(nextNasField(line, linei, 16));
469 <<
"Expected continuation symbol '*' when reading GRID*" 470 <<
" (double precision coordinate) format" <<
nl 471 <<
"Read:" << line <<
nl 475 (void) nextNasField(line, linei, 8);
476 scalar z = readNasScalar(nextNasField(line, linei, 16));
481 else if (cmd ==
"PSHELL")
491 label groupId =
readLabel(nextNasField(line, linei, 8, freeFormat));
493 if (lastComment.size() > 1 && !nameLookup.
contains(groupId))
497 if (!groupName.empty())
500 <<
"PSHELL:" << groupId
501 <<
" = " << groupName <<
nl;
503 nameLookup.
emplace(groupId, std::move(groupName));
507 else if (unhandledCmd.
insert(cmd))
510 <<
"Unhandled Nastran command " << line <<
nl 530 this->storedPoints().transfer(dynPoints);
540 for (Face&
f : dynFaces)
542 for (label& vert :
f)
544 vert = mapPointId[vert];
550 <<
"PSHELL names:" << nameLookup <<
nl;
556 const label groupId = iter.key();
557 const label zoneId = iter.val();
559 const auto iterName = nameLookup.
cfind(groupId);
562 names[zoneId] = iterName.val();
566 names[zoneId] = surfZone::defaultName(zoneId);
570 this->sortFacesAndStore(dynFaces, dynZones, dynElemId, sorted);
573 this->addZones(dynSizes,
names);
574 this->addZonesToFaces();
590 streamOpt.
format(IOstreamOption::ASCII);
601 ? surfaceFormatsCore::oneZone(faceLst,
"")
609 bool useOrigFaceIds =
619 for (
const auto&
f : faceLst)
623 useOrigFaceIds =
false;
634 <<
"Cannot write file " << filename <<
nl 639 fileFormats::NASCore::setPrecision(
os, fieldFormat::FREE);
642 <<
"TITLE = " <<
os.name().stem() <<
nl;
648 os <<
"$HMNAME COMP" <<
setw(20) << (zonei+1)
649 <<
'"' << zones[zonei].
name() <<
'"' <<
nl;
653 os <<
"$ GRID POINTS" <<
nl 654 <<
"BEGIN BULK" <<
nl;
657 for (
const point& pt : pointLst)
662 << pt.x() <<
',' << pt.y() <<
',' << pt.z() <<
nl;
665 os <<
"$ ELEMENTS" <<
nl;
671 for (
const surfZone& zone : zones)
673 for (label nLocal = zone.size(); nLocal--; ++faceIndex)
676 (useFaceMap ?
faceMap[faceIndex] : faceIndex);
678 const Face&
f = faceLst[facei];
682 elemId = elemIds[facei];
685 elemId = writeShell(
os,
f, elemId, zoneIndex);
691 os <<
"ENDDATA" <<
nl;
reference val() const
Const access to referenced object (value)
void size(const label n)
Older name for setAddressableSize.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
A class for handling file names.
bool emplace(const label &key, Args &&... args)
Emplace insert a new entry, not overwriting existing entries.
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)
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
StringType validate(const std::string &str, const UnaryPredicate &accept, const bool invert=false)
Return a copy of the input string with validated characters.
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.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
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.
DynamicList< T, SizeMin > & shrink()
Calls shrink_to_fit() and returns a reference to the DynamicList.
OBJstream os(runTime.globalPath()/outputName)
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.
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.
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.
forAllConstIters(mixture.phases(), phase)