74inline Foam::label Foam::fileFormats::NASsurfaceFormat<Face>::writeShell
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;
188 if (NASCore::debug > 1)
Info<<
"Process: " <<
line <<
nl;
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));
220 else if (
args.size() >= 3 && (
args[0] ==
"$ANSA_NAME"))
238 groupName = word::validate(line.substr(1));
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)
272 word groupName = word::validate(line.substr(dquote));
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);
322 std::string::size_type linei = 0;
325 const bool freeFormat = line.
contains(
',');
328 const word cmd(word::validate(nextNasField(line, linei, 8)));
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 (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
471 <<
"File:" << is.name() <<
" line:" << is.lineNumber()
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))
494 word groupName = word::validate(lastComment.substr(1));
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
510 <<
"File:" << is.name() <<
" line:" << is.lineNumber()
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);
604 const bool useFaceMap = (surf.
useFaceMap() && zones.size() > 1);
608 bool useOrigFaceIds =
618 for (
const auto&
f : faceLst)
622 useOrigFaceIds =
false;
629 OFstream
os(filename, streamOpt);
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;
Istream and Ostream manipulators taking arguments.
Various functions to operate on Lists.
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.
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
void clearStorage()
Clear the list and delete storage.
void push_back(const T &val)
Copy append an element to the end of this list.
DynamicList< T, SizeMin > & shrink()
Calls shrink_to_fit() and returns a reference to the DynamicList.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
bool contains(const Key &key) const
True if hashed key is contained (found) in table.
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.
bool emplace(const Key &key, Args &&... args)
Emplace insert a new entry, not overwriting existing entries.
void clear()
Remove all entries from table.
Input from file stream as an ISstream, normally using std::ifstream for the actual input.
virtual const fileName & name() const override
Read/write access to the name of the stream.
A simple container for options an IOstream can normally have.
streamFormat format() const noexcept
Get the current stream format.
@ ASCII
"ascii" (normal default)
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 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 noexcept
Const access to the surface zones.
const UList< Face > & surfFaces() const noexcept
Return const access to the faces.
const labelUList & faceIds() const noexcept
Const access to the faceIds, zero-sized when unused.
const labelUList & faceMap() const noexcept
Const access to the faceMap, zero-sized when unused.
const pointField & points() const noexcept
Return const access to the points.
bool useFaceMap() const noexcept
Can/should use faceMap?
pointField & storedPoints()
Non-const access to global points.
virtual void addZones(const UList< surfZone > &, const bool cullEmpty=false)
Add surface zones.
void sortFacesAndStore(DynamicList< Face > &unsortedFaces, DynamicList< label > &zoneIds, DynamicList< label > &elemIds, bool sorted)
Sort faces by zones and store sorted faces.
bool addZonesToFaces()
Propagate zone information on face regions.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
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,...
static bool isTri()
Face-type only handles triangles. Not true in general.
A class for handling file names.
bool contains(char c) const noexcept
True if string contains given character (cf. C++23).
bool starts_with(char c) const
True if string starts with given character (cf. C++20).
bool removeEnd(const std::string &text)
Remove the given text from the end of the string.
static word defaultName(const label n=-1)
Default zone name: "zone" or "zoneN".
A surface zone on a MeshedSurface.
A class for handling words, derived from Foam::string.
static word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
Base class for mesh zones.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define DebugInfo
Report an information message using Foam::Info.
bool found(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as found_if.
const dimensionedScalar c
Speed of light in a vacuum.
Foam::SubStrings split(const std::string &str, const char delim, std::string::size_type pos=0, const bool keepEmpty=false)
Split string into sub-strings at the delimiter character.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
Map< label > invertToMap(const labelUList &values)
Create inverse mapping, which is a lookup table into the given list.
List< surfZone > surfZoneList
List of surfZone.
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)
vector point
Point is a vector.
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...
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)
#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.