Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
Lattices/LatticePlane.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_LatticePlane_cpp_
9#define model_LatticePlane_cpp_
10
11#include <LatticeModule.h>
12namespace model
13{
14
15 template <int dim>
17 {
19 for (int k = 0; k < dim; ++k)
20 {
21 temp[k] = r(k);
22 }
23 temp[dim] = h;
24 temp[dim + 1] = latticeID;
25 return temp;
26 }
27
28 template <int dim>
30 {
31 return (LongIntType(0) < val) - (val < LongIntType(0));
32 }
33
34 template <int dim>
36 {
37 if(r.squaredNorm()==0)
38 {
39 throw std::runtime_error("LatticePlaneKey::correct_h_sign: A zero normal cannot be used as valid GlidePlane normal.");
40 }
41 for (int d = 0; d < dim; ++d)
42 {
43 const int sgnrd(sgn(r(d)));
44 if (sgnrd != 0)
45 {
46 r *= sgnrd;
47 h *= sgnrd;
48 break;
49 }
50 }
51 return hr2array(r, h, latticeID);
52 }
53
54 template <int dim>
61
62 template <int dim>
65 /* delegate */ LatticePlaneKey(r.base(),r.planeIndexOfPoint(P),r.lattice.sID)
66 {
67
68 }
69
70 template <int dim>
73 /* delegate */ LatticePlaneKey(r.base(),r.planeIndexOfPoint(L),r.lattice.sID)
74 {
75
76 }
77
78 template <int dim>
81 /* init */ LatticePlaneKey(r.base(),hin,r.lattice.sID)
82 {
83
84 }
85
86 template <int dim>
88 {
89 return VectorDimI(Eigen::Map<const VectorDimI>(&array.data()[0]));
90 }
91
92 template <int dim>
94 {
95 return array[dim];
96 }
97
98 template <int dim>
100 {
101 return array[dim + 1];
102 }
103
104 template <int dim>
106 { // allow use in sorted STL containers
107 return array < other.array;
108 }
109
110 template struct LatticePlaneKey<3>;
111
113 const VectorDimD &P)
114 {
116 if(r.base().squaredNorm()==0)
117 {
118 throw std::runtime_error("LatticePlane::computeHeight: A zero normal cannot be used as valid GlidePlane normal");
119 }
120 const double hd(P.dot(r.cartesian()));
121 const long int h(std::lround(hd));
122 return std::make_pair(fabs(hd - h) < FLT_EPSILON, h);
123 }
124
126 const LatticeVector<dim> &L)
127 {
129 if(r.base().squaredNorm()==0)
130 {
131 throw std::runtime_error("LatticePlane::computeHeight: A zero normal cannot be used as valid GlidePlane normal");
132 }
133 return std::make_pair(true, L.dot(r));
134 }
135
138 /* init */ key(P,r)
139 /* init */,n(ReciprocalLatticeVector<dim>(key.reciprocalDirectionComponents(),r.lattice))
140 /* init */,planeIndex(key.planeIndex())
141 {
142 }
143
146 /* init */ key(L,r)
147 /* init */,n(ReciprocalLatticeVector<dim>(key.reciprocalDirectionComponents(),r.lattice))
148 /* init */,planeIndex(key.planeIndex())
149 {
150
151 }
152
153 LatticePlane::LatticePlane(const long int& hin,
155 /* init */ key(hin,r)
156 /* init */,n(ReciprocalLatticeVector<dim>(key.reciprocalDirectionComponents(),r.lattice))
157 /* init */,planeIndex(key.planeIndex())
158 {
159
160 }
161
163 {
164 return planeIndex * n.planeSpacing() * n.cartesian().normalized();
165 }
166}
167#endif
168
long int dot(const ReciprocalLatticeVectorType &other) const
static std::pair< bool, long int > computeHeight(const ReciprocalLatticeDirection< dim > &r, const VectorDimD &P)
static constexpr int dim
const LatticePlaneKey< dim >::LongIntType planeIndex
Eigen::Matrix< double, dim, 1 > VectorDimD
const LatticePlaneKey< dim > key
const ReciprocalLatticeDirection< dim > n
LatticePlane(const VectorDimD &P, const ReciprocalLatticeDirection< dim > &r)
VectorDimD planeOrigin() const
Eigen::Matrix< double, dim, 1 > VectorDimD
static int sgn(const LongIntType &val)
static ArrayType hr2array(const VectorDimI &r, const LongIntType &h, const LongIntType &latticeID)
bool operator<(const LatticePlaneKey< dim > &other) const
Eigen::Matrix< LongIntType, dim, 1 > VectorDimI
LatticePlaneKey(const VectorDimI &r, const LongIntType &h, const LongIntType &latticeID)
const LongIntType & latticeID() const
std::array< LongIntType, dim+2 > ArrayType
const LongIntType & planeIndex() const
static ArrayType correct_h_sign(VectorDimI r, LongIntType h, const LongIntType &latticeID)
VectorDimI reciprocalDirectionComponents() const
int k
REAL * h
vertex temp