Skip to content
Snippets Groups Projects
Verified Commit c7a0c45e authored by Paul Dechamps's avatar Paul Dechamps :speech_balloon:
Browse files

(feat) Add ability to save which elements are on old tag

This is usefull to generate sections in BLASTER by identifying upper and lower sides
parent c617c41e
No related branches found
No related tags found
No related merge requests found
Pipeline #51947 passed
......@@ -24,6 +24,8 @@
#include "wLine2.h"
#include "wTri3.h"
#include <fstream>
using namespace tbox;
MshCrack::MshCrack(std::shared_ptr<MshData> _msh, int _nDim) : wSharedObject(), msh(_msh), nDim(_nDim)
......@@ -337,14 +339,21 @@ void MshCrack::mergeTags(std::vector<Groups *> &grps)
// Merge tags
Tag *refTag = gs->groups[0]->tag;
Tag *oldTag = gs->groups[1]->tag;
std::vector<int> elems_oldTag;
// Modify element tags
for (auto e : gs->groups[1]->tag->elems)
{
elems_oldTag.push_back(e->no);
e->ptag = refTag;
}
// Append elements to new tag
refTag->elems.insert(refTag->elems.end(), oldTag->elems.begin(), oldTag->elems.end());
// Delete old tag and remove from mesh maps
msh->ptags.erase(oldTag->no);
msh->ntags.erase(oldTag->name);
this->writeElems(elems_oldTag, oldTag->name + ".dat");
delete oldTag;
}
}
......@@ -410,3 +419,16 @@ void MshCrack::write(std::ostream &out) const
{
out << "MshCrack on " << msh << std::endl;
}
void MshCrack::writeElems(std::vector<int> const &elmsNo, std::string const filename) const
{
std::ofstream outFile(filename);
if (outFile.is_open())
{
for (const auto &elem : elmsNo)
outFile << elem << '\n';
outFile.close();
}
else
std::cerr << "Unable to open file: " << filename << std::endl;
}
......@@ -56,6 +56,7 @@ private:
size_t findClosest(std::vector<Eigen::Vector3d> const &cga, Eigen::Vector3d const &cgb);
void mergeTags(std::vector<Groups *> &grps);
void swapNodes(std::vector<Element *> &elms);
void writeElems(std::vector<int> const &elmsNo, std::string const filename) const;
public:
MshCrack(std::shared_ptr<MshData> _msh, int _nDim);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment