Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
CrackMeshGenerator.cpp
Go to the documentation of this file.
1/* This file is part of MoDELib, the Mechanics Of Defects Evolution Library.
2 *
3 *
4 * MoDELib is distributed without any warranty under the
5 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6 */
7
8#ifndef model_CrackMeshGenerator_cpp_
9#define model_CrackMeshGenerator_cpp_
10
11#include <iostream>
12#include <CrackMeshGenerator.h>
13
14namespace model
15{
16
18{
19 std::cout<<magentaBoldColor<<"Generating individual CrackMesh"<<defaultColor<<std::endl;
20
21 if(spec.nodes.rows()!=spec.burgers.rows())
22 {
23 throw std::runtime_error("nodes.rows()="+std::to_string(spec.nodes.rows())+" NOT EQUAL TO burgers.rows()="+std::to_string(spec.burgers.rows()));
24 }
25
26 const bool success=generateSingle(mg,spec.nodes,spec.burgers,spec.triangles);
27}
28
29
30bool CrackMeshGenerator::generateSingle(MicrostructureGenerator& mg,const Eigen::Matrix<double,Eigen::Dynamic,3>& nodes,const Eigen::Matrix<double,Eigen::Dynamic,3>& burgers,const Eigen::Matrix<int,Eigen::Dynamic,3>& triangles)
31{
32 bool success =false;
33 if(nodes.rows()>2 && triangles.rows()>0)
34 {
35 // Convert to std::vectors
36 std::vector<VectorDimD> nodesV;
37 std::vector<VectorDimD> burgersV;
38 std::vector<VectorDimI> trianglesV;
39
40 for(int k=0;k<nodes.rows();++k)
41 {
42 nodesV.emplace_back(nodes.row(k));
43 burgersV.emplace_back(burgers.row(k));
44 }
45
46 for(int k=0;k<triangles.rows();++k)
47 {
48 trianglesV.emplace_back(triangles.row(k));
49 }
50
51 success=mg.insertCrackMesh(nodesV,burgersV,trianglesV);
52
53
54
55 }
56
57 return success;
58}
59
60}
61#endif
CrackMeshGenerator(const CrackMeshIndividualSpecification &, MicrostructureGenerator &mg)
bool insertCrackMesh(const std::vector< VectorDimD > &nodes, const std::vector< VectorDimD > &burgers, const std::vector< VectorDimI > &triangles)
static std::string defaultColor
static std::string magentaBoldColor
int k
enum insertvertexresult success