Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
LagrangeNode.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_LagrangeNode_H_
9#define model_LagrangeNode_H_
10
11#include <set>
12#include <Eigen/Dense>
13
14namespace model
15{
16
17
18 /**************************************************************************/
19 /**************************************************************************/
20 template<typename ElementType>
21 struct LagrangeNode : public std::set<const ElementType*>
22 {
23 static constexpr int dim=ElementType::dim;
24
25 typedef Eigen::Matrix<double,dim,1> PositionType;
26
28 const size_t gID; // global ID
29
30 /**********************************************************************/
32 const size_t& gid) :
33 /* init list */ P0(p),
34 /* init list */ gID(gid)
35 {
36
37 }
38
39 /**********************************************************************/
40 Eigen::Matrix<double,dim,1> outNormal() const
41 {
42 Eigen::Matrix<double,dim,1> temp(Eigen::Matrix<double,dim,1>::Zero());
43 for(auto ele : *this)
44 {
45 const Eigen::Matrix<double,dim+1,1> bary(ele->simplex.pos2bary(P0));
46 for(int k=0;k<dim+1;++k)
47 {
48 if (std::fabs(bary(k))<FLT_EPSILON && ele->simplex.child(k).isBoundarySimplex())
49 {
50 temp += ele->simplex.nda.col(k).normalized();
51 }
52 }
53 }
54 const double tempNorm(temp.norm());
55 return tempNorm>FLT_EPSILON? (temp/tempNorm).eval() : Eigen::Matrix<double,dim,1>::Zero();
56 }
57
58 Eigen::Matrix<double,dim,dim> normalTensor() const
59 {
60 Eigen::Matrix<double,dim,dim> temp(Eigen::Matrix<double,dim,dim>::Zero());
61 for(auto ele : *this)
62 {
63 const Eigen::Matrix<double,dim+1,1> bary(ele->simplex.pos2bary(P0));
64 for(int k=0;k<dim+1;++k)
65 {
66 if (std::fabs(bary(k))<FLT_EPSILON && (ele->simplex.child(k).isBoundarySimplex() || ele->simplex.child(k).isRegionBoundarySimplex()))
67 {
68 const Eigen::Matrix<double,dim,1> unitNormal(ele->simplex.nda.col(k).normalized());
69 temp += unitNormal*unitNormal.transpose();
70 }
71 }
72 }
73 return temp;
74 }
75
76 };
77
78
79} // close namespace
80#endif
auto eval(const std::shared_ptr< T > &t)
LagrangeNode(const PositionType &p, const size_t &gid)
const PositionType P0
Eigen::Matrix< double, dim, 1 > PositionType
Eigen::Matrix< double, dim, dim > normalTensor() const
static constexpr int dim
Eigen::Matrix< double, dim, 1 > outNormal() const
vertex p[3]
int k
vertex temp