60 bool isComment =
true;
63 isComment = (
'*' == is.peek());
70 isComment = (
'*' == is.peek());
98static string getIdentifier(
const word& keyword,
string& inputLine)
115 auto beg = line.find(
"," + key +
"=");
117 if (beg != std::string::npos)
120 beg += key.size() + 2;
123 auto len = line.find(
',', beg);
124 if (len != std::string::npos)
130 return inputLine.substr(beg, len);
146 const std::string&
line,
151 const label nNodes = elemNodes.
size();
155 while (nodei < nNodes &&
pos != std::string::npos)
158 auto len =
line.find(
',',
pos);
160 if (len == std::string::npos)
181 return (nodei >= nNodes);
209 #define checkElemType(Name) elemTypeName.contains(Name)
218 return shapeType::abaqusTria;
228 return shapeType::abaqusQuad;
235 return shapeType::abaqusTet;
242 return shapeType::abaqusPyr;
249 return shapeType::abaqusPrism;
256 return shapeType::abaqusHex;
270 const std::string& setName
273 if (elsetMap_.empty())
286 label setId = elsetMap_.lookup(setName, -1);
301 if (needle == haystack)
308 setId = elsetMap_.size();
321 const label initialCount = points_.size();
329 while (is.
peek() !=
'*' && is.
peek() != EOF)
342 ss >>
id >> sep >>
p.x() >> sep >>
p.y() >> sep >>
p.z();
348 return (points_.size() - initialCount);
369 const label initialCount = elemTypes_.size();
380 while (is.
peek() !=
'*' && is.
peek() != EOF)
387 while (nodei < nNodes)
397 connectivity_.append(elemNodes);
398 elemTypes_.append(shape);
400 elsetIds_.append(setId);
403 return (elemTypes_.size() - initialCount);
422 const auto& abqToFoamFaceMap = abaqusToFoamFaceAddr();
424 const label initialCount = elemTypes_.size();
434 while (is.
peek() !=
'*' && is.
peek() != EOF)
444 || sideName[0] !=
'S'
445 || !std::isdigit(sideName[1])
448 Info<<
"Abaqus reader: unsupported surface element side "
449 <<
id <<
", " << sideName <<
nl;
453 const label index = elemIds_.find(
id);
454 if (
id <= 0 || index < 0)
456 Info<<
"Abaqus reader: unsupported surface element "
461 const auto faceIdIter = abqToFoamFaceMap.cfind(elemTypes_[index]);
462 if (!faceIdIter.good())
464 Info<<
"Abaqus reader: reject non-solid shape: " <<
nl;
468 const label sideNum = (sideName[1] -
'0');
470 const label foamFaceNum = (*faceIdIter)[sideNum - 1];
472 const labelList& connect = connectivity_[index];
477 switch (elemTypes_[index])
479 case shapeType::abaqusTet:
484 case shapeType::abaqusPrism:
489 case shapeType::abaqusHex:
491 elemNodes =
labelList(connect,
hex.modelFaces()[foamFaceNum]);
498 enum shapeType shape = shapeType::abaqusUnknownShape;
500 if (elemNodes.size() == 3)
502 shape = shapeType::abaqusTria;
504 else if (elemNodes.size() == 4)
506 shape = shapeType::abaqusQuad;
512 <<
"Could not map face side for "
513 <<
id <<
", " << sideName <<
nl
521 connectivity_.append(std::move(elemNodes));
522 elemTypes_.append(shape);
523 elemIds_.append(newElemId);
527 return (elemTypes_.size() - initialCount);
547 if (
line[0] !=
'*' || !std::isalpha(
line[1]))
560 if (upperLine.starts_with(
"*NODE"))
566 nread = readPoints(is);
571 <<
"Read " << nread <<
" *NODE entries" <<
nl;
579 if (upperLine.starts_with(
"*ELEMENT,"))
587 const shapeType shape(getElementType(elemTypeName));
595 <<
"Ignore abaqus element type: "
596 << elemTypeName <<
nl;
601 const label elsetId = addNewElset(elsetName);
605 nread = readElements(is, shape, elsetId);
610 <<
"Read " << nread <<
" *ELEMENT entries ("
611 << elemTypeName <<
") elset="
620 if (upperLine.starts_with(
"*SURFACE,"))
631 !surfTypeName.empty()
635 Info<<
"Reading abaqus surface type "
636 << surfTypeName <<
" is not implemented" <<
nl;
641 const label elsetId = addNewElset(elsetName);
645 nread = readSurfaceElements(is, elsetId);
650 <<
"Read " << nread <<
" *SURFACE entries for "
662 bitSet select(elemTypes_.size(),
false);
666 if (!isValidType(elemTypes_[i]) || isSolidType(elemTypes_[i]))
687 if (!nodeIds_.empty())
710 for (
const labelList& elem : connectivity_)
712 for (
const label origId : elem)
714 nodeIdRemapping(origId) = 0;
721 labelList oldToNewLocal(nodeIds_.size(), -1);
725 const label origId = nodeIds_[i];
727 if (nodeIdRemapping.found(origId))
730 nodeIdRemapping(origId) =
nPoints;
742 for (label&
id : elem)
744 id = nodeIdRemapping[id];
756 bitSet usedNodeIds(points_.size());
758 for (
const labelList& elem : connectivity_)
760 usedNodeIds.set(elem);
781 for (label& elemId : elemIds_)
792 const scalar scaleFactor
804 os.setf(std::ios::showpoint);
814 << (scaleFactor *
p.x()) <<
','
815 << (scaleFactor *
p.y()) <<
','
816 << (scaleFactor *
p.z()) <<
nl;
836 auto offsetIter = decompOffsets.
begin();
839 for (
const face&
f : faces)
841 const label
n =
f.size();
843 if (
n != 3 &&
n != 4)
846 f.triangles(
points, decompFaces);
850 *(++offsetIter) = decompFaces.
size();
853 return decompFaces.
size();
static Foam::Map< Foam::labelList > abaqusToFoamFaceAddr_
#define checkElemType(Name)
Various functions to operate on Lists.
Input/output streams with (internal or external) character storage.
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.
bool found(const Key &key) const
Same as contains().
bool good() const noexcept
True if next operation might succeed.
Similar to IStringStream but using an externally managed buffer for its input. This allows the input ...
Generic input stream using a standard (STL) stream.
int peek()
Raw, low-level peek function.
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
void syncState()
Set stream state to match that of the std::istream.
virtual const std::istream & stdStream() const
Const access to underlying std::istream.
bool set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
void resize(const label len)
Adjust allocated size of list.
A HashTable to objects of type <T> with a label key.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool any() const
True if any entries are 'true'.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
void size(const label n)
Older name for setAddressableSize.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void set(const bitSet &bitset)
Set specified bits from another bitset.
Maps a geometry to a set of cell primitives.
const faceList & modelFaces() const noexcept
Return a raw list of model faces.
static const cellModel & ref(const modelType model)
Look up reference to cellModel by enumeration. Fatal on failure.
A face is a list of labels corresponding to mesh vertices.
A class for handling character strings derived from std::string.
static const string null
An empty string.
bool starts_with(char c) const
True if string starts with given character (cf. C++20).
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).
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
List< bool > select(const label n, const labelUList &locations)
Construct a selection list of bools (all false) with the given pre-size, subsequently add specified l...
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
void inplaceRemoveSpace(std::string &s)
Eliminate whitespace inplace.
dimensionedScalar pos(const dimensionedScalar &ds)
void inplaceSubset(const BoolListType &select, ListType &input, const bool invert=false)
Inplace extract elements of the input list when select is true.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values within a list.
static void skipComments(ISstream &iss)
List< label > labelList
A List of labels.
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).
IOstream & hex(IOstream &io)
static string getIdentifier(const word &keyword, string &inputLine)
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
static bool appendCsvLabels(const std::string &line, labelUList &elemNodes, label &nodei)
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
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...
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
constexpr char nl
The newline '\n' character (0x0a).
#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.