Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
MeshRegionBoundary.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_MeshRegionBoundary_cpp_
9#define model_MeshRegionBoundary_cpp_
10
11
12#include <MeshRegionBoundary.h>
13#include <PolyhedralMesh.h>
14#include <MeshModule.h>
15
16namespace model
17{
18
19 template<int dim>
20 void MeshRegionBoundary<dim>::buildSingleFace(const Simplex<dim,dim-1>* newStart,
21 std::shared_ptr<Polyhedron<dim,dim-1>> newFace,
22 std::set<const Simplex<dim,dim-1>*>& allSimplices)
23 {
24 allSimplices.erase(newStart);
25 const auto regionBoundaryNeighbors(newStart->regionBoundaryNeighbors());
26 for(const auto& neighbor : regionBoundaryNeighbors)
27 {
28 const auto neighborRgnIDs(neighbor->regionIDs());
29 if( neighborRgnIDs.find(regionBndID.first)!=neighborRgnIDs.end() // neighbor in region
30 && neighborRgnIDs.find(regionBndID.second)!=neighborRgnIDs.end()
31 && allSimplices.find(neighbor)!=allSimplices.end()) // neighbor found in allSimplices
32 {
33 if( (newStart->outNormal(regionBndID.first)-neighbor->outNormal(regionBndID.first)).norm()<FLT_EPSILON
34 && (newStart->outNormal(regionBndID.second)-neighbor->outNormal(regionBndID.second)).norm()<FLT_EPSILON
35 )
36 {// same plane
37 allSimplices.erase(neighbor);
38 newFace->insert(neighbor);
39 buildSingleFace(neighbor,newFace,allSimplices);
40 }
41 }
42 }
43 faces().emplace(newFace->sID,newFace);
44 }
45
46
47 template<int dim>
48 void MeshRegionBoundary<dim>::buildFaces()
49 {
52 const auto t0= std::chrono::system_clock::now();
53 std::cout<<"MeshRegionBoundary ("<<regionBndID.first<<","<<regionBndID.second<<") buiding faces "<<std::flush;
54
55 faces().clear();
56 std::set<const Simplex<dim,dim-1>*> allSimplices(simplices()); //copy simplices
57 while(allSimplices.size())
58 {
59 auto newFace = topology.createFace(*allSimplices.begin());
60 buildSingleFace(*allSimplices.begin(),newFace,allSimplices);
61 }
62
63 while(allSimplices.size())
64 {
65 auto newFace = topology.createFace(*allSimplices.begin());
66 buildSingleFace(*allSimplices.begin(),newFace,allSimplices);
67 }
68
69 for(auto& face : faces())
70 {
71 face.second->finalize();
72 }
73 std::cout<<magentaColor<<" ["<<(std::chrono::duration<double>(std::chrono::system_clock::now()-t0)).count()<<" sec]"<<defaultColor<<std::endl;
74
75 }
76
77
78
79 template<int dim>
80 MeshRegionBoundary<dim>::MeshRegionBoundary(const std::pair<size_t,size_t>& rbndID, PolyhedralMesh<dim>& topologyIn) :
81 topology(topologyIn),
82 /* init */ regionBndID(rbndID)
83 {
84 }
85
86 template<int dim>
88 {
89 buildFaces();
90 }
91
92 template<int dim>
93 const std::set<const typename MeshRegionBoundary<dim>::SimplexType*>& MeshRegionBoundary<dim>::simplices() const
94 {
95 return *this;
96 }
97
98 template<int dim>
99 std::set<const typename MeshRegionBoundary<dim>::SimplexType*>& MeshRegionBoundary<dim>::simplices()
100 {
101 return *this;
102 }
103
104 template<int dim>
106 {
107 return *this;
108 }
109
110 template<int dim>
115
116 /**********************************************************************/
117 // std::set<const Simplex<dim,dim-2>*> unsortedBoundary() const __attribute__ ((deprecated))
118 // {
119 // std::set<const Simplex<dim,dim-2>*> temp;
120 // for(const auto& simplex : this->simplices())
121 // {
122 // for(const auto& child : simplex->children())
123 // {
124 // if(child->regionIDs().size()>2 || child->isBoundarySimplex())
125 // {
126 // temp.insert(child.get());
127 // }
128 // }
129 // }
130 // return temp;
131 // }
132
133
134
135// template struct MeshRegionBoundary<2>;
136 template struct MeshRegionBoundary<1>;
137 template struct MeshRegionBoundary<2>;
138 template struct MeshRegionBoundary<3>;
139
140} // close namespace
141#endif
size_t InstanceCount< Derived >::count
static std::string magentaColor
static std::string defaultColor
MeshRegionBoundary(const std::pair< size_t, size_t > &rbndID, PolyhedralMesh< dim > &topologyIn)
std::map< size_t, std::shared_ptr< PlanarMeshFaceType > > MeshFacesContainerType
const MeshFacesContainerType & faces() const
const std::set< const SimplexType * > & simplices() const
const std::pair< int, int > regionBndID
struct otri neighbor
REAL t0