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"))
196 const auto args = stringOps::split<std::string>(
line,
';',
true);
198 if (
args.
size() > 4 &&
line.starts_with(
"$ANSA_NAME_COMMENT"))
209 if (!groupName.empty())
212 <<
"PSHELL:" << groupId
213 <<
" = " << groupName <<
nl;
215 nameLookup.
emplace(groupId, std::move(groupName));
235 line.removeEnd(
'\r');
238 if (line.starts_with(
'$'))
243 if (!groupName.empty())
246 <<
"PSHELL:" << groupId
247 <<
" = " << groupName <<
nl;
249 nameLookup.
emplace(groupId, std::move(groupName));
256 else if (line.starts_with(
"$HMNAME COMP"))
263 auto dquote = line.find(
'"', 12);
269 dquote != std::string::npos
270 &&
readLabel(line.substr(12, (dquote - 12)), groupId)
276 if (!groupName.empty())
279 <<
"HMNAME group " << groupId
280 <<
" => " << groupName <<
nl;
282 nameLookup.
emplace(groupId, std::move(groupName));
293 else if (line[0] ==
'$')
301 if (line.size() > 72 && line[72] ==
'+')
310 if (buf.size() > 72 && buf[72] ==
'+')
312 line += buf.substr(8, 64);
316 line += buf.substr(8);
327 label elemId =
readLabel(nextNasField(line, linei, 8));
328 label groupId =
readLabel(nextNasField(line, linei, 8));
329 const auto a =
readLabel(nextNasField(line, linei, 8));
330 const auto b =
readLabel(nextNasField(line, linei, 8));
331 const auto c =
readLabel(nextNasField(line, linei, 8));
334 const auto iterZone = zoneLookup.
cfind(groupId);
337 if (zoneId != iterZone.val())
342 zoneId = iterZone.
val();
346 zoneId = dynSizes.
size();
347 zoneLookup.
insert(groupId, zoneId);
358 else if (cmd ==
"CQUAD4")
360 label elemId =
readLabel(nextNasField(line, linei, 8));
361 label groupId =
readLabel(nextNasField(line, linei, 8));
362 const auto a =
readLabel(nextNasField(line, linei, 8));
363 const auto b =
readLabel(nextNasField(line, linei, 8));
364 const auto c =
readLabel(nextNasField(line, linei, 8));
365 const auto d =
readLabel(nextNasField(line, linei, 8));
368 const auto iterZone = zoneLookup.
cfind(groupId);
371 if (zoneId != iterZone.val())
376 zoneId = iterZone.
val();
380 zoneId = dynSizes.
size();
381 zoneLookup.
insert(groupId, zoneId);
386 if (faceTraits<Face>::isTri())
395 dynSizes[zoneId] += 2;
407 else if (cmd ==
"GRID")
409 label index =
readLabel(nextNasField(line, linei, 8));
410 (void) nextNasField(line, linei, 8);
411 scalar
x = readNasScalar(nextNasField(line, linei, 8));
412 scalar
y = readNasScalar(nextNasField(line, linei, 8));
413 scalar z = readNasScalar(nextNasField(line, linei, 8));
418 else if (cmd ==
"GRID*")
426 label index =
readLabel(nextNasField(line, linei, 16));
427 (void) nextNasField(line, linei, 16);
428 scalar
x = readNasScalar(nextNasField(line, linei, 16));
429 scalar
y = readNasScalar(nextNasField(line, linei, 16));
436 <<
"Expected continuation symbol '*' when reading GRID*" 437 <<
" (double precision coordinate) format" <<
nl 438 <<
"Read:" << line <<
nl 442 (void) nextNasField(line, linei, 8);
443 scalar z = readNasScalar(nextNasField(line, linei, 16));
448 else if (cmd ==
"PSHELL")
455 label groupId =
readLabel(nextNasField(line, linei, 8));
457 if (lastComment.size() > 1 && !nameLookup.
contains(groupId))
461 if (!groupName.empty())
464 <<
"PSHELL:" << groupId
465 <<
" = " << groupName <<
nl;
467 nameLookup.
emplace(groupId, std::move(groupName));
471 else if (unhandledCmd.
insert(cmd))
474 <<
"Unhandled Nastran command " << line <<
nl 494 this->storedPoints().transfer(dynPoints);
500 Map<label> mapPointId;
501 mapPointId.reserve(pointId.
size());
502 for (
const label pointi : pointId)
504 mapPointId.insert(pointi, mapPointId.size());
509 for (Face&
f : dynFaces)
511 for (label& vert :
f)
513 vert = mapPointId[vert];
516 pointId.clearStorage();
520 <<
"PSHELL names:" << nameLookup <<
nl;
526 const label groupId = iter.key();
527 const label zoneId = iter.val();
529 const auto iterName = nameLookup.
cfind(groupId);
532 names[zoneId] = iterName.val();
536 names[zoneId] = surfZone::defaultName(zoneId);
540 this->sortFacesAndStore(dynFaces, dynZones, dynElemId, sorted);
543 this->addZones(dynSizes,
names);
544 this->addZonesToFaces();
560 streamOpt.
format(IOstreamOption::ASCII);
571 ? surfaceFormatsCore::oneZone(faceLst,
"")
579 bool useOrigFaceIds =
589 for (
const auto&
f : faceLst)
593 useOrigFaceIds =
false;
604 <<
"Cannot write file " << filename <<
nl 609 fileFormats::NASCore::setPrecision(
os, fieldFormat::FREE);
612 <<
"TITLE = " <<
os.name().stem() <<
nl;
618 os <<
"$HMNAME COMP" <<
setw(20) << (zonei+1)
619 <<
'"' << zones[zonei].
name() <<
'"' <<
nl;
623 os <<
"$ GRID POINTS" <<
nl 624 <<
"BEGIN BULK" <<
nl;
627 for (
const point& pt : pointLst)
632 << pt.x() <<
',' << pt.y() <<
',' << pt.z() <<
nl;
635 os <<
"$ ELEMENTS" <<
nl;
641 for (
const surfZone& zone : zones)
643 for (label nLocal = zone.size(); nLocal--; ++faceIndex)
646 (useFaceMap ?
faceMap[faceIndex] : faceIndex);
648 const Face&
f = faceLst[facei];
652 elemId = elemIds[facei];
655 elemId = writeShell(
os,
f, elemId, zoneIndex);
661 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, using an OSstream.
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, using an ISstream.
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.
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)
streamFormat format() const noexcept
Get the current stream format.
forAllConstIters(mixture.phases(), phase)