60 bool isComment =
true;
63 isComment = (
'*' == is.
peek());
70 isComment = (
'*' == is.
peek());
98 static 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;
261 return shapeType::abaqusUnknownShape;
270 const std::string& setName
273 if (elsetMap_.empty())
286 label setId = elsetMap_.lookup(setName, -1);
301 if (needle == haystack)
308 setId = elsetMap_.size();
309 elsetMap_.set(setName, setId);
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);
524 elsetIds_.append(setId);
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_)
783 renumber0_elemId(elemId);
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 word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
void size(const label n)
Older name for setAddressableSize.
Input/output streams with (internal or external) character storage.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
messageStream InfoErr
Information stream (stderr output on master, null elsewhere)
void resize(const label len)
Adjust allocated size of list.
virtual const std::istream & stdStream() const
Const access to underlying std::istream.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
IOstream & hex(IOstream &io)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
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...
constexpr char nl
The newline '\n' character (0x0a)
void inplaceRemoveSpace(std::string &s)
Eliminate whitespace inplace.
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
void syncState()
Set stream state to match that of the std::istream.
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
void inplaceSubset(const BoolListType &select, ListType &input, const bool invert=false)
Inplace extract elements of the input list when select is true.
#define checkElemType(Name)
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
static const cellModel & ref(const modelType model)
Look up reference to cellModel by enumeration. Fatal on failure.
static string getIdentifier(const word &keyword, string &inputLine)
dimensionedScalar pos(const dimensionedScalar &ds)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
A class for handling words, derived from Foam::string.
int peek()
Raw, low-level peek function.
static void skipComments(ISstream &iss)
const faceList & modelFaces() const noexcept
Return a raw list of model faces.
static bool appendCsvLabels(const std::string &line, labelUList &elemNodes, label &nodei)
iterator begin() noexcept
Return an iterator to begin traversing the UList.
static const string null
An empty string.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values within a list.
Generic input stream using a standard (STL) stream.
vector point
Point is a vector.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
bool good() const noexcept
True if next operation might succeed.
Maps a geometry to a set of cell primitives.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static Foam::Map< Foam::labelList > abaqusToFoamFaceAddr_
List< label > labelList
A List of labels.
ISstream & get(char &c)
Raw, low-level get character function.
Similar to IStringStream but using an externally managed buffer for its input. This allows the input ...
forAllConstIters(mixture.phases(), phase)
A HashTable to objects of type <T> with a label key.
static constexpr const zero Zero
Global zero (0)