29 #ifndef NEMOSYS_EXOMESH_H_ 30 #define NEMOSYS_EXOMESH_H_ 36 #include <vtkCellTypes.h> 38 #include "nemosys_export.h" 49 void NEMOSYS_EXPORT
wrnErrMsg(
int errCode,
const std::string &errMsg =
"None");
179 explicit exoMesh(std::string ifname);
223 const std::string &
getElmBlkName(
int idx)
const {
return _elmBlks[idx].name; }
229 const std::string getElmBlkNameById(
int id)
const;
236 const std::string &
getNdeSetName(
int idx)
const {
return _ndeSets[idx].name; }
243 std::string getNdeSetNameById(
int id)
const;
249 const std::string &
getSdeSetName(
int idx)
const {
return _sdeSets[idx].name; }
255 int getElmBlkIndex(
int id)
const;
261 int getElmBlkIndex(
const std::string name)
const;
273 int getElmBlkId(std::string ebName)
const;
285 int getNdeSetId(
const std::string &nsName)
const;
291 int getNdeSetIndex(
const std::string &nsName)
const;
303 int getSdeSetId(
const std::string &ssName)
const;
309 int getSdeSetIndex(
const std::string &ssName)
const;
327 elementType getElmBlkType(
const std::string &ebName)
const;
339 int getNumElmsInBlk(
const std::string &ebName)
const;
345 int getNumElmsInBlkById(
int id)
const;
357 int getNumNdesInNdeSet(
const std::string &nsName)
const;
363 int getNumNdesInNdeSetById(
int id)
const;
375 int getNumSdesInSdeSet(
const std::string &ssName)
const;
381 int getNumSdesInSdeSetById(
int id)
const;
422 _elmBlks[idx].name = name;
430 void setBlockName(
const std::string &name,
const std::string &newName) {
431 int idx = getElmBlkIndex(name);
432 _elmBlks[idx].name = newName;
441 _sdeSets[idx].name = name;
450 int idx = getSdeSetIndex(name);
451 _sdeSets[idx].name = newName;
460 _ndeSets[idx].name = name;
469 int idx = getNdeSetIndex(name);
470 _ndeSets[idx].name = newName;
487 void addNde(
double x,
double y,
double z) {
488 _xCrds.emplace_back(x);
489 _yCrds.emplace_back(y);
490 _zCrds.emplace_back(z);
497 void addNde(
const std::vector<double> &xyz) {
498 addNde(xyz[0], xyz[1], xyz[2]);
505 _elmBlks.emplace_back(eb);
506 _isPopulated =
false;
513 _ndeSets.emplace_back(ns);
514 _isPopulated =
false;
521 _sdeSets.emplace_back(ss);
522 _isPopulated =
false;
532 void removeElmBlkByName(
const std::string &blkName);
539 void removeElmBlkById(
int id);
548 int findElmBlkIdxByElmId(
int elmId)
const;
555 int findElmBlkIdxByElmIdLst(
const std::vector<int> &elmIds)
const;
566 std::vector<int> lstElmInBlk(
int blkIdx,
const std::vector<int> &elmIds,
576 void combineElmBlks(
const std::vector<int> &blkIdLst,
577 const std::string &newName);
584 void updateSidesets(
const std::map<int, int> &old2NewElmIds);
592 void removeByElmIdLst(
int blkIdx,
const std::vector<int> &idLst);
599 void addElmBlkByElmIdLst(
const std::string &name, std::vector<int> &idLst);
606 void addNdeSetByNdeIdLst(
const std::string &name,
607 const std::vector<int> &idLst);
612 void snapNdeCrdsZero(
double tol = 1e-5);
618 void mergeNodes(
double tol = 1e-15);
624 void scaleNodes(
double sc = 1.0);
635 void stitch(
const exoMesh &otherMesh);
651 void read(
const std::string &ifname = std::string());
668 void togVrb() { _isVerbose = !_isVerbose; };
672 void exoPopulate(
bool updElmLst =
false);
679 template <
typename T>
681 std::map<T, int> countMap;
683 for (
auto &elem : vecOfElements) {
684 auto result = countMap.insert(std::pair<T, int>(elem, 1));
685 if (result.second ==
false) result.first->second++;
689 for (
auto it = countMap.begin(); it != countMap.end();) {
691 it = countMap.erase(it);
736 bool _reindexBlks{
true};
744 #endif // NEMOSYS_EXOMESH_H_ int getElmBlkId(int idx) const
Returns the id for the element block for given index.
int getNumSdesInSdeSet(int idx) const
Returns the number of sides for the sideset.
std::vector< int > _elmBlkIds
elementType v2eEMap(VTKCellType vt)
Convert VTK cell type to EXODUS element type.
const std::vector< std::string > & getElmBlkNames() const
Returns the names of registered element blocks.
int getDimension() const
Returns problem dimension.
elementType getElmBlkType(int idx) const
Returns the element type for the block.
std::vector< std::string > _ndeSetNames
std::vector< double > _xCrds
A complete I/O class for EXODUS II file format.
void setBlockName(int idx, const std::string &name)
Sets/changes block name.
std::vector< int > sdeIds
bool isCompatible() const
int getNumberOfNodeSets() const
Returns total number of node sets.
int getNdeSetId(int idx) const
Returns the id for the nodeset for given index.
std::string elmTypeStr(elementType et)
Convert EXODUS element type to string tab.
void addNde(double x, double y, double z)
Add nodes to the database.
void setSdeSetName(const std::string &name, const std::string &newName)
Sets/changes sideset name.
int elmNumSrf(elementType tag)
Get number of surfaces given EXODUS element type.
std::vector< int > elmIds
elementType elmTypeNum(std::string tag)
Convert string to EXODUS element type.
std::map< T, int > findDuplicates(const std::vector< T > &vecOfElements)
int getNumberOfSideSets() const
Returns total number of side sets.
int getNumElmsInBlk(int idx) const
Returns the number of elements for the block.
void setNdeSetName(const std::string &name, const std::string &newName)
Sets/changes nodeset name.
int getNumberOfNodes() const
Returns total number of nodes.
const std::string & getElmBlkName(int idx) const
Returns the name the element block for given index.
const std::vector< int > & getElmBlkIds() const
Returns the IDs of registered element blocks.
std::vector< sdeSetType > sdeSets
Stores side set information.
void addNde(const std::vector< double > &xyz)
Add nodes to the database.
std::vector< std::string > _elmBlkNames
const std::vector< std::string > & getNdeSetNames() const
Returns the names of registered node sets.
surfaceBCTag bcTagNum(std::string &tag)
std::string bcTagStr(surfaceBCTag tag)
const std::string & getSdeSetName(int idx) const
Returns the name the sideset for given index.
const std::string & getNdeSetName(int idx) const
Returns the name the nodeset for given index.
std::vector< elmBlkType > elmBlks
int getNumNdesInNdeSet(int idx) const
Returns the number of nodes for the nodeset.
void setBlockName(const std::string &name, const std::string &newName)
Sets/changes block name.
void setSdeSetName(int idx, const std::string &name)
Sets/changes sideset name.
Stores element block information.
void togVrb()
Toggle verbosity.
const std::vector< std::string > & getSdeSetNames() const
Returns the names of registered side sets.
void addSdeSet(const sdeSetType &ss)
Add side set to the database.
std::vector< std::vector< int > > glbConn
std::vector< double > _zCrds
std::vector< std::string > _sdeSetNames
void addElmBlk(const elmBlkType &eb)
Add element block to the database.
void addNdeSet(const ndeSetType &ns)
Add node set to the database.
void setDimension(int dim)
Sets/changes the problem dimensionality.
Stores node set information.
void setNdeSetName(int idx, const std::string &name)
Sets/changes nodeset name.
std::vector< int > ndeIds
std::vector< ndeSetType > ndeSets
int getNumberOfElements() const
Returns total number of elements.
VTKCellType e2vEMap(elementType et)
Convert EXODUS element type to VTK cell type.
int elmNumNde(elementType tag, int order)
Get number of nodes given EXODUS element type and order.
int getNumberOfElementBlocks() const
Returns total number of element blocks.
void wrnErrMsg(int errCode, const std::string &msg)
Logging method.
std::vector< double > _yCrds
std::map< int, std::vector< double > > ndeCoords
void setFileName(const std::string &fName)
Change the file name.
int getSdeSetId(int idx) const
Returns the id for the sideset for given index.
std::vector< int > elmIds