Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
Lattices/LatticeVector.cpp
Go to the documentation of this file.
1/* This file is part of PIL, the Particle Interaction 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_LatticeVector_cpp_
9#define model_LatticeVector_cpp_
10
11#include<LatticeModule.h>
12
13namespace model
14{
15
16 template <int dim>
18 {
19 return _base;
20 }
21
22 template <int dim>
24 {
25 return _base;
26 }
27
28 template <int dim>
30 /* init */_base(VectorDimI::Zero())
31 /* init */,lattice(lat)
32 {
35 }
36
37 template <int dim>
39 const LatticeType &lat) :
40 /* init */ _base(d2contra(d, lat))
41 /* init */,lattice(lat)
42 {
43 * Constructs *this by mapping d to the lattice
44 */
45 }
46
47 template <int dim>
49 const LatticeType& lat) :
50 /* init */ _base(n)
51 /* init */,lattice(lat)
52 {
53 * Constructs *this by mapping d to the lattice
54 */
55 }
57 template <int dim>
59 {
60 assert(&lattice == &other.lattice && "LatticeVectors belong to different Lattices.");
61 return LatticeVectorType((base() + other.base()).eval(), lattice);
62 }
63
64 template <int dim>
66 {
67 assert(&lattice == &other.lattice && "LatticeVectors belong to different Lattices.");
68 base() += other.base();
69 return *this;
70 }
71
72 template <int dim>
74 {
75 assert(&lattice == &other.lattice && "LatticeVectors belong to different Lattices.");
76 return LatticeVectorType((base() - other.base()).eval(), lattice);
77 }
78
79 template <int dim>
81 {
82 assert(&lattice == &other.lattice && "LatticeVectors belong to different Lattices.");
83 base() -= other.base();
84 return *this;
85 }
86
87 template <int dim>
89 {
90 return LatticeVector<dim>((base() * scalar).eval(), lattice);
91 }
92
93 template <int dim>
95 {
96 assert(&lattice == &other.lattice && "LatticeVectors belong to different Lattices.");
97 return base().dot(other.base());
98 }
99
100 template <int dim>
102 {
103 assert(&lattice == &other.lattice && "LatticeVectors belong to different Lattices.");
105 }
106
107 template <int dim>
109 {
110 return lattice.latticeBasis * base().template cast<double>();
111 }
112
113 template <int dim>
115 const LatticeType &lat)
116 {
117 const VectorDimD nd(lat.reciprocalBasis.transpose() * d);
118 const VectorDimD rd(nd.array().round());
119 if ((nd - rd).norm() > roundTol)
120 {
121 std::cout << "d2contra, nd=" << nd.transpose() << std::endl;
122 std::cout << "d2contra, rd=" << rd.transpose() << std::endl;
123 throw std::runtime_error("Input vector is not a lattice vector");
124 }
125 return rd.template cast<long int>();
126 }
127
128 template<int dim>
129 LatticeVector<dim> operator*(const long int& scalar, const LatticeVector<dim>& L)
130 {
131 return L*scalar;
132 }
133
134 template class LatticeVector<3>;
135 template LatticeVector<3>operator*(const long int& scalar, const LatticeVector<3>& L);
136
137} // end namespace
138#endif
const MatrixDimD reciprocalBasis
Eigen::Matrix< long int, dim, 1 > BaseType
static constexpr double roundTol
ReciprocalLatticeVector< dim > ReciprocalLatticeVectorType
LatticeVector< dim > LatticeVectorType
static VectorDimI d2contra(const VectorDimD &d, const LatticeType &lat)
LatticeVectorType & operator-=(const LatticeVectorType &other)
LatticeVectorType operator+(const LatticeVectorType &other) const
LatticeVector(const LatticeType &lat)
long int dot(const ReciprocalLatticeVectorType &other) const
ReciprocalLatticeDirection< dim > ReciprocalLatticeDirectionType
LatticeVectorType operator-(const LatticeVectorType &other) const
LatticeVectorType & operator+=(const LatticeVectorType &other)
ReciprocalLatticeDirectionType cross(const LatticeVectorType &other) const
Eigen::Matrix< double, dim, 1 > VectorDimD
LatticeVectorType operator*(const long int &scalar) const
auto operator*(const std::shared_ptr< BilinearForm< T1, T2 > > &f, const IntegrationDomain< FE, D, Q, Rule > &dom)
auto eval(const std::shared_ptr< T > &t)