Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
GlidePlaneBase.cpp
Go to the documentation of this file.
1/* This file is part of MoDELib, the Mechanics Of Defects Evolution Library.
2 *
3 *
4 * MODEL is distributed without any warranty under the
5 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6 */
7
8#ifndef model_GlidePlaneBase_cpp_
9#define model_GlidePlaneBase_cpp_
10
11#include <map>
12#include <LatticeModule.h>
13#include <GlidePlaneBase.h>
14
15namespace model
16{
17
19 const LatticeVectorType& v2_in,
20 const std::shared_ptr<GammaSurface>& gammaSurface_in) :
21/* init */ ReciprocalLatticeDirectionType(v1_in,v2_in),
22/* init */ primitiveVectors(std::make_pair(v1_in,v2_in))
23/* init */,G2L(getG2L(v1_in.cartesian(),this->cartesian()))
24/* init */,gammaSurface(gammaSurface_in)
25{
26}
27
29{
30 const Eigen::Matrix<double, 3, 2> B((Eigen::Matrix<double, 2, 3>() << primitiveVectors.first.cartesian().transpose(), primitiveVectors.second.cartesian().transpose()).finished().transpose());
31 const Eigen::Matrix<double, 2, 1> nd = (B.transpose() * B).inverse() * B.transpose() * P;
32 // const Eigen::Matrix<double,3,1> p=B*RoundEigen<double,2>::round(nd);
33 const Eigen::Matrix<double, 3, 1> p = B * nd.array().round().matrix();
34 // return LatticeVectorType(p,primitiveVectors.first.covBasis,primitiveVectors.second.contraBasis);
35 return LatticeVectorType(p, primitiveVectors.first.lattice);
36}
37
39{
40 // return LatticeVectorType(p,primitiveVectors.first.covBasis,primitiveVectors.second.contraBasis);
41 VectorDimD cn(this->cartesian());
42 const double cnNorm(cn.norm());
43 assert(cnNorm > FLT_EPSILON);
44 cn /= cnNorm;
45 return P - P.dot(cn) * cn;
46}
47
49{
50 // const double xNorm(x.norm());
51 // const double zNorm(z.norm());
52 // if(xNorm<FLT_EPSILON || zNorm<FLT_EPSILON)
53 // {
54 // throw std::runtime_error("GlidePlaneBase: cannot cumpute G2L from zero vectors.");
55 // }
56 // assert(xNorm>FLT_EPSILON);
57 // assert(zNorm>FLT_EPSILON);
58 // assert(fabs(x.dot(z)<FLT_EPSILON*xNorm*zNorm));
59 // Eigen::Matrix3d temp(Eigen::Matrix3d::Identity());
60 // temp.col(2)=z/zNorm;
61 // temp.col(0)=x/xNorm;
62 // temp.col(1)=temp.col(2).cross(temp.col(0));
63
64 Eigen::Matrix3d temp(Eigen::Matrix3d::Identity());
65 temp.row(2)=z.normalized();
66 temp.row(0)=x.normalized();
67 temp.row(1)=temp.row(2).cross(temp.row(0));
68 if((temp*temp.transpose()-Eigen::Matrix3d::Identity()).norm()>FLT_EPSILON)
69 {
70 std::cout<<"x1="<<temp.row(0)<<std::endl;
71 std::cout<<"x2="<<temp.row(1)<<std::endl;
72 std::cout<<"x3="<<temp.row(2)<<std::endl;
73 std::cout<<"temp="<<temp<<std::endl;
74 std::cout<<"temp*temp^T="<<temp*temp.transpose()<<std::endl;
75 throw std::runtime_error("GlidePlaneBase: G2L is not orthogonal.");
76 }
77 if(std::fabs(temp.determinant()-1.0)>FLT_EPSILON)
78 {
79 throw std::runtime_error("GlidePlaneBase: G2L is not proper.");
80 }
81 return temp;
82
83 // return temp.transpose();
84}
85
87{
88 const VectorDimD bL(G2L*b);
89 if(std::fabs(bL(2))>FLT_EPSILON)
90 {
91 throw std::runtime_error("SLIP VECTOR NOT ON GlidePlaneBase");
92 }
93 return bL.segment<2>(0);
94}
95
96
98{
99 if(gammaSurface)
100 {
101 // const VectorDimD bL(G2L*b);
102 // if(std::fabs(bL(2))>FLT_EPSILON)
103 // {
104 // throw std::runtime_error("SLIP VECTOR NOT ON GlidePlaneBase");
105 // }
106 return gammaSurface->operator()(localSlipVector(b));
107 }
108 else
109 {
110 return 0.0;
111 }
112}
113
115{
117 temp.col(0)=localSlipVector(primitiveVectors.first.cartesian());
118 temp.col(1)=localSlipVector(primitiveVectors.second.cartesian());
119 return temp;
120}
121
122
123} // end namespace
124#endif
initial point of the source segment B
id z()
b
Definition int_R.m:16
x
Definition int_R.m:12
Eigen::Matrix< double, 3, 1 > VectorDimD
const std::pair< LatticeDirectionType, LatticeDirectionType > primitiveVectors
Eigen::Matrix< double, 2, 1 > VectorLowerDimD
LatticeVector< 3 > LatticeVectorType
static MatrixDim getG2L(const VectorDimD &x, const VectorDimD &z)
GlidePlaneBase(const LatticeVectorType &v1_in, const LatticeVectorType &v2_in, const std::shared_ptr< GammaSurface > &gammaSurface_in)
VectorLowerDimD localSlipVector(const VectorDimD &b) const
MatrixLowerDim localBasis() const
Eigen::Matrix< double, 2, 2 > MatrixLowerDim
const std::shared_ptr< GammaSurface > gammaSurface
LatticeVectorType snapToLattice(const VectorDimD &P) const
double misfitEnergy(const VectorDimD &b) const
VectorDimD snapToPlane(const VectorDimD &P) const
const Eigen::Matrix3d G2L
ReciprocalLatticeDirection< 3 > ReciprocalLatticeDirectionType
Eigen::Matrix< double, 3, 3 > MatrixDim
vertex p[3]
vertex temp