Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
Lattices_NEW/RationalLatticeDirection.cpp
Go to the documentation of this file.
1/* This file is part of model.
2 *
3 * MoDELib is distributed without any warranty under the MIT License.
4 */
5
6
7#ifndef model_RationalLatticeDirection_cpp_
8#define model_RationalLatticeDirection_cpp_
9
10#include <LatticeModule.h>
11#include <RationalLatticeDirection.h>
12
13namespace model
14{
15 /**********************************************************************/
16 template <int dim>
18/* init */ rat(_rat)
19/* init */,dir(_dir)
20 {
21 }
22
23 /**********************************************************************/
24 template <int dim>
29
30 /**********************************************************************/
31 template <int dim>
33 /* init */ rat(Rational<IntScalarType>(IntegerMath<IntScalarType>::gcd(v), 1)),
34 /* init */ dir(v)
35 {
36 }
37
38 /**********************************************************************/
39
40 template <int dim>
42 {
43 return dir.cartesian() * rat.asDouble();
44 }
45
46 /**********************************************************************/
47 template <int dim>
49 {
50 return rat * dir.dot(other);
51 }
52
53 /**********************************************************************/
54 template <int dim>
59
60 /**********************************************************************/
61 template <int dim>
66
67 /**********************************************************************/
68 template <int dim>
70 {
71 assert(&dir.lattice == &other.dir.lattice && "ReciprocalLatticeVectorType belong to different Lattices.");
72 const VectorDimI temp(rat.n * other.rat.d * dir + other.rat.n * rat.d * other.dir);
74 const LatticeVector<dim> v(temp / gcd, dir.lattice);
76 }
77
78 /**********************************************************************/
79 template <int dim>
80 RationalLatticeDirection<dim> RationalLatticeDirection<dim>::operator-(const RationalLatticeDirection<dim> &other) const
81 {
82 assert(&dir.lattice == &other.dir.lattice && "ReciprocalLatticeVectorType belong to different Lattices.");
83 const VectorDimI temp(rat.n * other.rat.d * dir - other.rat.n * rat.d * other.dir);
84 const IntScalarType gcd(IntegerMath<IntScalarType>::gcd(temp));
85 const LatticeVector<dim> v(temp / gcd, dir.lattice);
86 return RationalLatticeDirection<dim>(Rational(gcd, rat.d * other.rat.d), LatticeDirection<dim>(v));
87 }
88
89 /**********************************************************************/
90 template <int dim>
92 {
93 assert(&dir.lattice == &other.lattice && "ReciprocalLatticeVectorType belong to different Lattices.");
96 }
97
98 /**********************************************************************/
99 template <int dim>
101 {
102 assert(&dir.lattice == &other.lattice && "ReciprocalLatticeVectorType belong to different Lattices.");
105 }
106
107 /**********************************************************************/
108 template <int dim>
110 {
111 return dir.squaredNorm() * std::pow(rat.asDouble(), 2);
112 }
113
114 template<int dim>
119
120 template struct RationalLatticeDirection<1>;
122 template struct RationalLatticeDirection<2>;
124 template struct RationalLatticeDirection<3>;
126
127} // end namespace
128#endif
long int d
Definition Rational.h:28
long int n
Definition Rational.h:27
auto operator+(const std::shared_ptr< T1 > &x, const std::shared_ptr< T2 > &y)
auto operator*(const std::shared_ptr< BilinearForm< T1, T2 > > &f, const IntegrationDomain< FE, D, Q, Rule > &dom)
auto operator-(const std::shared_ptr< T1 > &x, const std::shared_ptr< T2 > &y)
static IntScalarType gcd(const IntScalarType &a, const IntScalarType &b)
Definition IntegerMath.h:22
RationalLatticeDirection< dim > operator-(const RationalLatticeDirection< dim > &other) const
Rational dot(const ReciprocalLatticeVector< dim > &other) const
RationalLatticeDirection< dim > operator+(const RationalLatticeDirection< dim > &other) const
RationalLatticeDirection< dim > operator*(const long int &scalar) const
RationalLatticeDirection< dim > operator/(const long int &scalar) const
RationalLatticeDirection(const Rational &_rat, const LatticeDirection< dim > &_dir)
vertex temp
REAL v[4]