symmetry.hh

Go to the documentation of this file.
1 
7 #ifndef symmetry_hh
8 #define symmetry_hh
9 
10 #include "basics/typedefs.hh"
11 #include "topology.hh"
12 
13 namespace concepts
14 {
18  template<class T>
19  class Symmetry {
20  public:
23 
26  };
27 
35  template<>
36  class Symmetry<Edge> {
37  public:
39  Symmetry(const Z2 value) : value_(value) {};
41  Symmetry(const Symmetry<Edge>& other) {value_ = other.value_; };
43  void operator= (const Symmetry<Edge>& other) {this->value_ = other.value_; };
46  {
47  return Symmetry<Edge>(i.value_ ^ j.value_);
48  }
50  Real evaluate(const Real x)
51  {
52  if (this->value_ == 1)
53  return 1.0-x;
54  return x;
55  };
58  {
59  return evaluate(x);
60  }
61 
62  protected:
64  };
65 
75  template<>
76  class Symmetry<Quad> {
77  public:
79  Symmetry(const std::array<Z2, 3> value) : value_(value) {} ;
81  Symmetry(const Z2 ix, const Z2 iy, const Z2 ip)
82  {
83  value_[0] = ix;
84  value_[1] = iy;
85  value_[2] = ip;
86  };
88  Symmetry(const Symmetry<Quad>& other) {value_ = other.value_; };
90  void operator= (const Symmetry<Quad>& other) {this->value_ = other.value_; };
93  {
94  // Sy o Sp = Sp o Sx
95  // Sx o Sp = Sp o Sy
96  // Sy o Sx = Sx o Sy -> symmetries Sx and Sy can commute
97  Z2 ix = i.value_[0];
98  Z2 iy = i.value_[1];
99  Z2 ip = i.value_[2];
100  Z2 jx = j.value_[0];
101  Z2 jy = j.value_[1];
102  Z2 jp = j.value_[2];
103  if (jp == 1)
104  std::swap(ix,iy);
105  // in this case, it would return Symmetry(iy^jx, ix^jy, ip^jp);
106  return Symmetry(ix^jx, iy^jy, ip^jp);
107  }
110  {
111  Real x = p[0], y = p[1];
112  // Presence of the symmetry S_x
113  if (value_[0])
114  x = 1.0 - x;
115  // Presence of the symmetry S_y
116  if (value_[1])
117  y = 1.0 - y;
118  // Presence of the symmetry S_p
119  if (value_[2])
120  std::swap(x,y);
121  return Real2d(x,y);
122  };
125  {
126  Real x = p[0], y = p[1];
127  // Presence of the symmetry S_p
128  if (value_[2])
129  std::swap(x,y);
130  // Presence of the symmetry S_y
131  if (value_[1])
132  y = 1.0 - y;
133  // Presence of the symmetry S_x
134  if (value_[0])
135  x = 1.0 - x;
136  return Real2d(x,y);
137  };
138  protected:
139  std::array<Z2, 3> value_;
140  };
141 
142 
156  Real3d evaluatepermutation(const Real3d p, const int index);
157 
158 }
159 
160 #endif // symmetry_hh
Real2d evaluateInverse(const Real2d p)
Evaluation of the inverse.
Definition: symmetry.hh:124
friend Symmetry< Quad > operator*(const Symmetry< Quad > &i, const Symmetry< Quad > &j)
Composition operator.
Definition: symmetry.hh:92
Symmetry(const Symmetry< Edge > &other)
Copy constructor.
Definition: symmetry.hh:41
General class for symmetries on a geometrical object.
Definition: symmetry.hh:19
std::array< Z2, 3 > value_
Definition: symmetry.hh:137
A quadrilateral in the topology.
Definition: topology.hh:272
Point< Real, 2 > Real2d
~Symmetry()
Default destructor.
Point< typename Combtype< F, Real >::type, dim > operator*(const Real x, const Point< F, dim > &y)
Real evaluate(const Real x)
Evaluation.
Definition: symmetry.hh:50
Specialized template for quadrilaterons.
Definition: symmetry.hh:76
Real3d evaluatepermutation(const Real3d p, const int index)
Evaluation of a 3d permutation.
Specialized template for edges.
Definition: symmetry.hh:36
Real evaluateInverse(const Real x)
Evaluation of the inverse.
Definition: symmetry.hh:57
Symmetry(const Z2 value)
Constructor with given value.
Definition: symmetry.hh:39
Symmetry()
Default constructor with no argument given.
Real2d evaluate(const Real2d p)
Evaluation.
Definition: symmetry.hh:109
Symmetry(const Z2 ix, const Z2 iy, const Z2 ip)
Constructor with given indexes.
Definition: symmetry.hh:81
Symmetry(const std::array< Z2, 3 > value)
Constructor with given value.
Definition: symmetry.hh:79
Symmetry(const Symmetry< Quad > &other)
Copy constructor.
Definition: symmetry.hh:88
Binary group (algebraic): only the values 0 and 1 are represented.
Definition: Zm.hh:16
An edge in the topology.
Definition: topology.hh:73
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich