Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
BoundarySimplex.h
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_BoundarySimplex_H_
9#define model_BoundarySimplex_H_
10
11namespace model
12{
13
14 /**************************************************************************/
15 /**************************************************************************/
16 template<short int dim,short int dmo>
18 {
19 /**********************************************************************/
20 static bool isBoundarySimplex(const SimplexChild<dim,dim-dmo>& simplexChild)
21 {
22 bool temp(false);
23 for (auto& pParent : simplexChild.parents())
24 {
25 temp=pParent.second->isBoundarySimplex();
26 if (temp)
27 {
28 break;
29 }
30 }
31 return temp;
32 }
33
34 /**********************************************************************/
35 static bool isRegionBoundarySimplex(const SimplexChild<dim,dim-dmo>& simplexChild)
36 {
37 bool temp(false);
38 for (auto& pParent : simplexChild.parents())
39 {
40 temp=pParent.second->isRegionBoundarySimplex();
41 if (temp)
42 {
43 break;
44 }
45 }
46 return temp;
47 }
48
49 /**********************************************************************/
50 static Eigen::Matrix<double,dim,1> outNormal(const Simplex<dim,dim-dmo>& simplexChild)
51 {
52 Eigen::Matrix<double,dim,1> temp(Eigen::Matrix<double,dim,1>::Zero());
53 for(const auto& parent : simplexChild.parents())
54 {
55 if(parent.second->isBoundarySimplex())
56 {
57 temp+=parent.second->outNormal();
58 }
59 }
60 const double tempNorm(temp.norm());
61 return (tempNorm>FLT_EPSILON)? (temp/tempNorm).eval() : Eigen::Matrix<double,dim,1>::Zero();
62 }
63
64 /**********************************************************************/
65 static Eigen::Matrix<double,dim,1> outNormal(const Simplex<dim,dim-dmo>& simplexChild,
66 const size_t& rID)
67 {
68 Eigen::Matrix<double,dim,1> temp(Eigen::Matrix<double,dim,1>::Zero());
69 for(const auto& parent : simplexChild.parents())
70 {
71 temp+=parent.second->outNormal(rID);
72 }
73 const double tempNorm(temp.norm());
74 return (tempNorm>FLT_EPSILON)? (temp/tempNorm).eval() : Eigen::Matrix<double,dim,1>::Zero();
75 }
76
77 };
78
79 /**************************************************************************/
80 /**************************************************************************/
81 template<short int dim>
82 struct BoundarySimplex<dim,1> // this is a Simplex<dim,dim-1>
83 {
84 /**********************************************************************/
85 static bool isBoundarySimplex(const SimplexChild<dim,dim-1>& simplexChild)
86 {
87 return simplexChild.parents().size()==1;
88 }
89
90 /**********************************************************************/
91 static bool isRegionBoundarySimplex(const SimplexChild<dim,dim-1>& simplexChild)
92 {
93 bool temp(false);
94 if(simplexChild.parents().size()==2)
95 {
96// if((*simplexChild.parents().begin())->region->regionID != (*simplexChild.parents().rbegin())->region->regionID)
97 if(simplexChild.parents().begin()->second->region->regionID != simplexChild.parents().rbegin()->second->region->regionID)
98 {
99 temp=true;
100 }
101
102 }
103 return temp;
104 }
105
106 /**********************************************************************/
107 static Eigen::Matrix<double,dim,1> outNormal(const Simplex<dim,dim-1>& simplexChild)
108 {
109 Eigen::Matrix<double,dim,1> temp(Eigen::Matrix<double,dim,1>::Zero());
110 if(simplexChild.isBoundarySimplex())
111 {
112 const size_t faceID=simplexChild.parents().begin()->second->childOrder(simplexChild.xID);
113 temp=simplexChild.parents().begin()->second->nda.col(faceID).normalized();
114 }
115 return temp;
116 }
117
118 /**********************************************************************/
119 static Eigen::Matrix<double,dim,1> outNormal(const Simplex<dim,dim-1>& simplexChild,
120 const size_t& rID)
121 {
122 Eigen::Matrix<double,dim,1> temp(Eigen::Matrix<double,dim,1>::Zero());
123 for(const auto& parent : simplexChild.parents())
124 {
125 if( (parent.second->isBoundarySimplex() || parent.second->isRegionBoundarySimplex())
126 && parent.second->region->regionID==rID)
127 {
128 const size_t faceID=parent.second->childOrder(simplexChild.xID);
129 temp+=parent.second->nda.col(faceID).normalized();
130 }
131 }
132 const double tempNorm(temp.norm());
133 return (tempNorm>FLT_EPSILON)? (temp/tempNorm).eval() : Eigen::Matrix<double,dim,1>::Zero();
134 }
135
136 };
137
138 /**************************************************************************/
139 /**************************************************************************/
140 template<short int dim>
141 struct BoundarySimplex<dim,0> // this is a Simplex<dim,dim>
142 {
143
144 /**********************************************************************/
145 static bool isBoundarySimplex(const Simplex<dim,dim>& simplex)
146 {
147 bool temp(false);
148
149 for (int n=0;n<simplex.nFaces;++n)
150 {
151 temp=simplex.child(n).isBoundarySimplex();
152 if (temp)
153 {
154 break;
155 }
156 }
157 return temp;
158 }
159
160 /**********************************************************************/
161 static bool isRegionBoundarySimplex(const Simplex<dim,dim>& simplex)
162 {
163 bool temp(false);
164
165 for (int n=0;n<simplex.nFaces;++n)
166 {
167 temp=simplex.child(n).isRegionBoundarySimplex();
168 if (temp)
169 {
170 break;
171 }
172 }
173 return temp;
174 }
175
176 };
177
178} // close namespace
179#endif
ParentContainerType parents() const
bool isBoundarySimplex() const
auto eval(const std::shared_ptr< T > &t)
static bool isBoundarySimplex(const Simplex< dim, dim > &simplex)
static bool isRegionBoundarySimplex(const Simplex< dim, dim > &simplex)
static Eigen::Matrix< double, dim, 1 > outNormal(const Simplex< dim, dim-1 > &simplexChild)
static Eigen::Matrix< double, dim, 1 > outNormal(const Simplex< dim, dim-1 > &simplexChild, const size_t &rID)
static bool isBoundarySimplex(const SimplexChild< dim, dim-1 > &simplexChild)
static bool isRegionBoundarySimplex(const SimplexChild< dim, dim-1 > &simplexChild)
static Eigen::Matrix< double, dim, 1 > outNormal(const Simplex< dim, dim-dmo > &simplexChild)
static bool isBoundarySimplex(const SimplexChild< dim, dim-dmo > &simplexChild)
static Eigen::Matrix< double, dim, 1 > outNormal(const Simplex< dim, dim-dmo > &simplexChild, const size_t &rID)
static bool isRegionBoundarySimplex(const SimplexChild< dim, dim-dmo > &simplexChild)
const SimplexIDType xID
Definition SimplexBase.h:31
int parent
vertex temp