Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • am-dept/amfe
  • Paul.Dechamps/amfe
2 results
Show changes
Commits on Source (1)
......@@ -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);
......