46 const label
n =
f.size();
52 << (groupId + 1) <<
','
61 << (groupId + 1) <<
','
71 for (label fp1 = 1; fp1 <
f.size() - 1; ++fp1)
73 const label fp2 =
f.fcIndex(fp1);
77 << (groupId + 1) <<
','
79 << (
f[fp1] + 1) <<
','
80 << (
f[fp2] + 1) <<
nl;
115 <<
"Cannot read file " << filename <<
nl
134 bool ignoreElemId =
false;
144 word ansaType, ansaName;
158 if (
line.starts_with(
"$ANSA_NAME"))
160 const auto sem0 =
line.find(
';', 0);
161 const auto sem1 =
line.find(
';', sem0+1);
162 const auto sem2 =
line.find(
';', sem1+1);
166 sem0 != std::string::npos
167 && sem1 != std::string::npos
168 && sem2 != std::string::npos
172 ansaType =
line.substr(sem1+1, sem2-sem1-1);
188 if (line.
starts_with(
"$HMNAME COMP") && line.find(
'"') != string::npos)
190 label groupId =
readLabel(line.substr(16, 16));
195 nameLookup.insert(groupId, groupName);
199 if (line.empty() || line[0] ==
'$')
205 if (line.size() > 72 && line[72] ==
'+')
214 if (buf.size() > 72 && buf[72] ==
'+')
216 line += buf.substr(8, 64);
220 line += buf.substr(8);
231 label elemId =
readLabel(nextNasField(line, linei, 8));
232 label groupId =
readLabel(nextNasField(line, linei, 8));
233 const auto a =
readLabel(nextNasField(line, linei, 8));
234 const auto b =
readLabel(nextNasField(line, linei, 8));
235 const auto c =
readLabel(nextNasField(line, linei, 8));
238 const auto iterZone = zoneLookup.cfind(groupId);
239 if (iterZone.found())
241 if (zoneId != *iterZone)
250 zoneId = dynSizes.size();
251 zoneLookup.insert(groupId, zoneId);
262 else if (cmd ==
"CQUAD4")
264 label elemId =
readLabel(nextNasField(line, linei, 8));
265 label groupId =
readLabel(nextNasField(line, linei, 8));
266 const auto a =
readLabel(nextNasField(line, linei, 8));
267 const auto b =
readLabel(nextNasField(line, linei, 8));
268 const auto c =
readLabel(nextNasField(line, linei, 8));
269 const auto d =
readLabel(nextNasField(line, linei, 8));
272 const auto iterZone = zoneLookup.cfind(groupId);
273 if (iterZone.found())
275 if (zoneId != *iterZone)
284 zoneId = dynSizes.size();
285 zoneLookup.insert(groupId, zoneId);
290 if (faceTraits<Face>::isTri())
296 dynFaces.
append(Face{
c, d, a});
299 dynSizes[zoneId] += 2;
311 else if (cmd ==
"GRID")
313 label index =
readLabel(nextNasField(line, linei, 8));
314 (void) nextNasField(line, linei, 8);
315 scalar
x = readNasScalar(nextNasField(line, linei, 8));
316 scalar
y = readNasScalar(nextNasField(line, linei, 8));
317 scalar z = readNasScalar(nextNasField(line, linei, 8));
322 else if (cmd ==
"GRID*")
330 label index =
readLabel(nextNasField(line, linei, 16));
331 (void) nextNasField(line, linei, 16);
332 scalar
x = readNasScalar(nextNasField(line, linei, 16));
333 scalar
y = readNasScalar(nextNasField(line, linei, 16));
340 <<
"Expected continuation symbol '*' when reading GRID*"
341 <<
" (double precision coordinate) format" <<
nl
342 <<
"Read:" << line <<
nl
346 (void) nextNasField(line, linei, 8);
347 scalar z = readNasScalar(nextNasField(line, linei, 16));
352 else if (cmd ==
"PSHELL")
355 label groupId =
readLabel(nextNasField(line, linei, 8));
356 if (groupId == ansaId && ansaType ==
"PSHELL")
359 nameLookup.insert(groupId, groupName);
363 else if (unhandledCmd.
insert(cmd))
365 Info<<
"Unhandled Nastran command " << line <<
nl
381 this->storedPoints().transfer(dynPoints);
387 Map<label> mapPointId(2*pointId.size());
390 mapPointId.insert(pointId[i], i);
395 for (Face&
f : dynFaces)
397 for (label& vert :
f)
399 vert = mapPointId[vert];
407 List<word>
names(dynSizes.size());
410 const label groupId = iter.key();
411 const label zoneId = iter.val();
413 const auto iterName = nameLookup.cfind(groupId);
414 if (iterName.found())
416 names[zoneId] = *iterName;
420 names[zoneId] = surfZone::defaultName(zoneId);
424 this->sortFacesAndStore(dynFaces, dynZones, dynElemId, sorted);
427 this->addZones(dynSizes,
names);
428 this->addZonesToFaces();
444 streamOpt.
format(IOstream::ASCII);
455 ? surfaceFormatsCore::oneZone(faceLst,
"")
459 const bool useFaceMap = (surf.
useFaceMap() && zones.size() > 1);
463 bool useOrigFaceIds =
473 for (
const auto&
f : faceLst)
477 useOrigFaceIds =
false;
488 <<
"Cannot write file " << filename <<
nl
493 fileFormats::NASCore::setPrecision(
os, fieldFormat::FREE);
496 <<
"TITLE = " <<
os.name().nameLessExt() <<
nl;
502 os <<
"$HMNAME COMP" <<
setw(20) << (zonei+1)
503 <<
'"' << zones[zonei].
name() <<
'"' <<
nl;
507 os <<
"$ GRID POINTS" <<
nl
508 <<
"BEGIN BULK" <<
nl;
511 for (
const point& pt : pointLst)
516 << pt.x() <<
',' << pt.y() <<
',' << pt.z() <<
nl;
519 os <<
"$ ELEMENTS" <<
nl;
525 for (
const surfZone& zone : zones)
527 for (label nLocal = zone.size(); nLocal--; ++faceIndex)
530 (useFaceMap ?
faceMap[faceIndex] : faceIndex);
532 const Face&
f = faceLst[facei];
536 elemId = elemIds[facei];
539 elemId = writeShell(
os,
f, elemId, zoneIndex);
545 os <<
"ENDDATA" <<
nl;