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;
193 if (
line.starts_with(
"$ANSA_NAME"))
197 stringOps::split<std::string>(
line,
';', 0,
true);
199 if (
args.
size() > 4 &&
line.starts_with(
"$ANSA_NAME_COMMENT"))
210 if (!groupName.empty())
213 <<
"PSHELL:" << groupId
214 <<
" = " << groupName <<
nl;
216 nameLookup.
emplace(groupId, std::move(groupName));
236 line.removeEnd(
'\r');
239 if (line.starts_with(
'$'))
244 if (!groupName.empty())
247 <<
"PSHELL:" << groupId
248 <<
" = " << groupName <<
nl;
250 nameLookup.
emplace(groupId, std::move(groupName));
257 else if (line.starts_with(
"$HMNAME COMP"))
264 auto dquote = line.find(
'"', 12);
270 dquote != std::string::npos
271 &&
readLabel(line.substr(12, (dquote - 12)), groupId)
277 if (!groupName.empty())
280 <<
"HMNAME group " << groupId
281 <<
" => " << groupName <<
nl;
283 nameLookup.
emplace(groupId, std::move(groupName));
294 else if (line[0] ==
'$')
302 if (line.size() > 72 && line[72] ==
'+')
311 if (buf.size() > 72 && buf[72] ==
'+')
313 line += buf.substr(8, 64);
317 line += buf.substr(8);
328 label elemId =
readLabel(nextNasField(line, linei, 8));
329 label groupId =
readLabel(nextNasField(line, linei, 8));
330 const auto a =
readLabel(nextNasField(line, linei, 8));
331 const auto b =
readLabel(nextNasField(line, linei, 8));
332 const auto c =
readLabel(nextNasField(line, linei, 8));
335 const auto iterZone = zoneLookup.
cfind(groupId);
338 if (zoneId != iterZone.val())
343 zoneId = iterZone.
val();
347 zoneId = dynSizes.
size();
348 zoneLookup.
insert(groupId, zoneId);
359 else if (cmd ==
"CQUAD4")
361 label elemId =
readLabel(nextNasField(line, linei, 8));
362 label groupId =
readLabel(nextNasField(line, linei, 8));
363 const auto a =
readLabel(nextNasField(line, linei, 8));
364 const auto b =
readLabel(nextNasField(line, linei, 8));
365 const auto c =
readLabel(nextNasField(line, linei, 8));
366 const auto d =
readLabel(nextNasField(line, linei, 8));
369 const auto iterZone = zoneLookup.
cfind(groupId);
372 if (zoneId != iterZone.val())
377 zoneId = iterZone.
val();
381 zoneId = dynSizes.
size();
382 zoneLookup.
insert(groupId, zoneId);
387 if (faceTraits<Face>::isTri())
396 dynSizes[zoneId] += 2;
408 else if (cmd ==
"GRID")
410 label index =
readLabel(nextNasField(line, linei, 8));
411 (void) nextNasField(line, linei, 8);
412 scalar
x = readNasScalar(nextNasField(line, linei, 8));
413 scalar
y = readNasScalar(nextNasField(line, linei, 8));
414 scalar z = readNasScalar(nextNasField(line, linei, 8));
419 else if (cmd ==
"GRID*")
427 label index =
readLabel(nextNasField(line, linei, 16));
428 (void) nextNasField(line, linei, 16);
429 scalar
x = readNasScalar(nextNasField(line, linei, 16));
430 scalar
y = readNasScalar(nextNasField(line, linei, 16));
437 <<
"Expected continuation symbol '*' when reading GRID*" 438 <<
" (double precision coordinate) format" <<
nl 439 <<
"Read:" << line <<
nl 443 (void) nextNasField(line, linei, 8);
444 scalar z = readNasScalar(nextNasField(line, linei, 16));
449 else if (cmd ==
"PSHELL")
456 label groupId =
readLabel(nextNasField(line, linei, 8));
458 if (lastComment.size() > 1 && !nameLookup.
contains(groupId))
462 if (!groupName.empty())
465 <<
"PSHELL:" << groupId
466 <<
" = " << groupName <<
nl;
468 nameLookup.
emplace(groupId, std::move(groupName));
472 else if (unhandledCmd.
insert(cmd))
475 <<
"Unhandled Nastran command " << line <<
nl 495 this->storedPoints().transfer(dynPoints);
505 for (Face&
f : dynFaces)
507 for (label& vert :
f)
509 vert = mapPointId[vert];
515 <<
"PSHELL names:" << nameLookup <<
nl;
521 const label groupId = iter.key();
522 const label zoneId = iter.val();
524 const auto iterName = nameLookup.
cfind(groupId);
527 names[zoneId] = iterName.val();
531 names[zoneId] = surfZone::defaultName(zoneId);
535 this->sortFacesAndStore(dynFaces, dynZones, dynElemId, sorted);
538 this->addZones(dynSizes,
names);
539 this->addZonesToFaces();
555 streamOpt.
format(IOstreamOption::ASCII);
566 ? surfaceFormatsCore::oneZone(faceLst,
"")
574 bool useOrigFaceIds =
584 for (
const auto&
f : faceLst)
588 useOrigFaceIds =
false;
599 <<
"Cannot write file " << filename <<
nl 604 fileFormats::NASCore::setPrecision(
os, fieldFormat::FREE);
607 <<
"TITLE = " <<
os.name().stem() <<
nl;
613 os <<
"$HMNAME COMP" <<
setw(20) << (zonei+1)
614 <<
'"' << zones[zonei].
name() <<
'"' <<
nl;
618 os <<
"$ GRID POINTS" <<
nl 619 <<
"BEGIN BULK" <<
nl;
622 for (
const point& pt : pointLst)
627 << pt.x() <<
',' << pt.y() <<
',' << pt.z() <<
nl;
630 os <<
"$ ELEMENTS" <<
nl;
636 for (
const surfZone& zone : zones)
638 for (label nLocal = zone.size(); nLocal--; ++faceIndex)
641 (useFaceMap ?
faceMap[faceIndex] : faceIndex);
643 const Face&
f = faceLst[facei];
647 elemId = elemIds[facei];
650 elemId = writeShell(
os,
f, elemId, zoneIndex);
656 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)