File: TestReducedPolycone.cpp

package info (click to toggle)
vecgeom 1.2.8%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 24,016 kB
  • sloc: cpp: 88,803; ansic: 6,888; python: 1,035; sh: 582; sql: 538; makefile: 23
file content (210 lines) | stat: -rw-r--r-- 8,896 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*
 * TestReducedPolycone.cpp
 *
 *  Created on: Sep 20, 2018
 *      Author: rasehgal
 */

#include <iostream>
#include "VecGeom/volumes/ReducedPolycone.h"
#include "VecGeom/volumes/UnplacedPolycone.h"
#include "VecGeom/base/Vector2D.h"
#include <iostream>
#include "VecGeom/management/GeoManager.h"
#include "VecGeom/base/FpeEnable.h"

#undef NDEBUG

using namespace vecgeom;
bool TestReducedPolycone()
{

  Vector<Vector2D<Precision>> rzVect;
  bool contour = false;

  std::cout << "================================  (Trivial) ======================================" << std::endl;
  rzVect.push_back(Vector2D<Precision>(0., 0.));
  rzVect.push_back(Vector2D<Precision>(0., 1.));
  rzVect.push_back(Vector2D<Precision>(1., 1.));
  rzVect.push_back(Vector2D<Precision>(1., 2.));
  rzVect.push_back(Vector2D<Precision>(3., 2.));
  rzVect.push_back(Vector2D<Precision>(3., 1.));
  rzVect.push_back(Vector2D<Precision>(4., 1.));
  rzVect.push_back(Vector2D<Precision>(4., 0.));
  vecgeom::ReducedPolycone p(rzVect);
  contour = p.Check();
  assert(contour && "Trivial Fails....");

  std::cout << "========================= (Trivial with Mirror Image) ============================" << std::endl;
  rzVect.clear();

  rzVect.push_back(Vector2D<Precision>(0., 0.));
  rzVect.push_back(Vector2D<Precision>(0., 1.));
  rzVect.push_back(Vector2D<Precision>(1., 1.));
  rzVect.push_back(Vector2D<Precision>(1., 2.));
  rzVect.push_back(Vector2D<Precision>(3., 2.));
  rzVect.push_back(Vector2D<Precision>(3., 1.));
  rzVect.push_back(Vector2D<Precision>(4., 1.));
  rzVect.push_back(Vector2D<Precision>(4., 0.));
  rzVect.push_back(Vector2D<Precision>(4., -1.));
  rzVect.push_back(Vector2D<Precision>(3., -1.));
  rzVect.push_back(Vector2D<Precision>(3., -2.));
  rzVect.push_back(Vector2D<Precision>(1., -2.));
  rzVect.push_back(Vector2D<Precision>(1., -1.));
  rzVect.push_back(Vector2D<Precision>(0., -1.));
  p.SetRZ(rzVect);
  contour = p.Check();
  assert(contour && "Trivial with Mirror Image Fails....");

  std::cout << "==========  (Contour with only one point in Top and Bottom Z) ====================" << std::endl;
  rzVect.clear();

  rzVect.push_back(Vector2D<Precision>(0., 0.));
  rzVect.push_back(Vector2D<Precision>(1., 1.));
  rzVect.push_back(Vector2D<Precision>(1., 2.));
  rzVect.push_back(Vector2D<Precision>(2., 3.));
  rzVect.push_back(Vector2D<Precision>(3., 2.5));
  rzVect.push_back(Vector2D<Precision>(3., -1.));
  rzVect.push_back(Vector2D<Precision>(1., -2.));
  p.SetRZ(rzVect);
  contour = p.Check();
  assert(contour && "A2 Fails ....");

  std::cout << "============================== AnitclockWise Contour =============================" << std::endl;
  rzVect.clear();
  rzVect.push_back(Vector2D<Precision>(0., 0.));
  rzVect.push_back(Vector2D<Precision>(1., -1.));
  rzVect.push_back(Vector2D<Precision>(2., -1.));
  rzVect.push_back(Vector2D<Precision>(2., -2.));
  rzVect.push_back(Vector2D<Precision>(3., -2));
  rzVect.push_back(Vector2D<Precision>(3., -1.));
  rzVect.push_back(Vector2D<Precision>(4., -1.));
  rzVect.push_back(Vector2D<Precision>(4., 2.));
  rzVect.push_back(Vector2D<Precision>(3., 3.));
  p.SetRZ(rzVect);
  contour = p.Check();
  assert(contour && "AnitclockWise Contour Fails ....");

  std::cout << "============================== Triangular Spikes =================================" << std::endl;
  rzVect.clear();
  rzVect.push_back(Vector2D<Precision>(0., 0.));
  rzVect.push_back(Vector2D<Precision>(0., 2.));
  rzVect.push_back(Vector2D<Precision>(1., 4.));
  rzVect.push_back(Vector2D<Precision>(2., 2.));
  rzVect.push_back(Vector2D<Precision>(3., 5.));
  rzVect.push_back(Vector2D<Precision>(4., 2.));
  rzVect.push_back(Vector2D<Precision>(4., -1.));
  rzVect.push_back(Vector2D<Precision>(2., -2.));
  p.SetRZ(rzVect);
  contour = p.Check();
  assert(!contour && "Triangular Spikes Fails ....");

  std::cout << "============================== Square Spikes at End ==============================" << std::endl;
  rzVect.clear();
  rzVect.push_back(Vector2D<Precision>(0., 0.));
  rzVect.push_back(Vector2D<Precision>(0., 1.));
  rzVect.push_back(Vector2D<Precision>(1., 1.));
  rzVect.push_back(Vector2D<Precision>(1., 2.));
  rzVect.push_back(Vector2D<Precision>(2., 2.));
  rzVect.push_back(Vector2D<Precision>(2., 3.));
  rzVect.push_back(Vector2D<Precision>(4., 3.));
  rzVect.push_back(Vector2D<Precision>(4., 2.));
  rzVect.push_back(Vector2D<Precision>(6., 2.));
  rzVect.push_back(Vector2D<Precision>(6., 1.));
  rzVect.push_back(Vector2D<Precision>(4., 1.));
  rzVect.push_back(Vector2D<Precision>(4., -1.));
  rzVect.push_back(Vector2D<Precision>(3., -1.));
  rzVect.push_back(Vector2D<Precision>(3., -2.));
  rzVect.push_back(Vector2D<Precision>(2., -2.));
  rzVect.push_back(Vector2D<Precision>(2., -1.));
  rzVect.push_back(Vector2D<Precision>(1.5, -1.));
  rzVect.push_back(Vector2D<Precision>(1.5, -2.));
  rzVect.push_back(Vector2D<Precision>(0.5, -2.));
  rzVect.push_back(Vector2D<Precision>(0.5, -1.));
  rzVect.push_back(Vector2D<Precision>(0., -1.));
  p.SetRZ(rzVect);
  contour = p.Check();
  assert(!contour && "Square Spikes at End Fails ....");

  std::cout << "============================== Square Spikes in beginning ========================" << std::endl;
  rzVect.clear();
  rzVect.push_back(Vector2D<Precision>(0., 0.));
  rzVect.push_back(Vector2D<Precision>(0., 1.));
  rzVect.push_back(Vector2D<Precision>(1., 1.));
  rzVect.push_back(Vector2D<Precision>(1., 2.));
  rzVect.push_back(Vector2D<Precision>(2., 2.));
  rzVect.push_back(Vector2D<Precision>(2., 1.));
  rzVect.push_back(Vector2D<Precision>(3., 1.));
  rzVect.push_back(Vector2D<Precision>(3., 2.));
  rzVect.push_back(Vector2D<Precision>(4., 2.));
  rzVect.push_back(Vector2D<Precision>(4., 1.));
  rzVect.push_back(Vector2D<Precision>(5., 1.));
  rzVect.push_back(Vector2D<Precision>(5., 0.));
  p.SetRZ(rzVect);
  contour = p.Check();
  assert(!contour && "Square Spikes in beginning Fails ....");

  std::cout << "================================= PLUS symbole ===================================" << std::endl;
  rzVect.clear();
  rzVect.push_back(Vector2D<Precision>(0., 0.));
  rzVect.push_back(Vector2D<Precision>(0., 1.));
  rzVect.push_back(Vector2D<Precision>(1., 1.));
  rzVect.push_back(Vector2D<Precision>(1., 2.));
  rzVect.push_back(Vector2D<Precision>(3., 2.));
  rzVect.push_back(Vector2D<Precision>(3., 1.));
  rzVect.push_back(Vector2D<Precision>(4., 1.));
  rzVect.push_back(Vector2D<Precision>(4., -1.));
  rzVect.push_back(Vector2D<Precision>(3., -1.));
  rzVect.push_back(Vector2D<Precision>(3., -2.));
  rzVect.push_back(Vector2D<Precision>(1., -2.));
  rzVect.push_back(Vector2D<Precision>(1., -1.));
  rzVect.push_back(Vector2D<Precision>(0., -1.));
  p.SetRZ(rzVect);
  contour = p.Check();
  assert(contour && "PLUS symbole Fails ....");

  std::cout << "========================== Contour with only three points ========================" << std::endl;
  rzVect.clear();
  rzVect.push_back(Vector2D<Precision>(1., 1.));
  rzVect.push_back(Vector2D<Precision>(1., -1.));
  rzVect.push_back(Vector2D<Precision>(2., -1.));
  p.SetRZ(rzVect);
  contour = p.Check();
  assert(contour && "X symbole (X) Fails ....");

  std::cout << "================================= X symbole ======================================" << std::endl;
  rzVect.clear();
  rzVect.push_back(Vector2D<Precision>(1., 3.));
  rzVect.push_back(Vector2D<Precision>(1., 1.));
  rzVect.push_back(Vector2D<Precision>(1., -1.));
  rzVect.push_back(Vector2D<Precision>(2., -1.));
  rzVect.push_back(Vector2D<Precision>(1., 1.));
  rzVect.push_back(Vector2D<Precision>(2., 3.));
  p.SetRZ(rzVect);
  contour = p.Check();
  assert(!contour && "X2 symbole (X2) Fails ....");

  std::cout << "======================  (Trivial Using UnplacedPolycone) =========================" << std::endl;
  const int numRZ    = 10;
  Precision r[numRZ] = {0., 0., 0., 1., 1., 3., 3., 4., 4., 0.};
  Precision z[numRZ] = {0., 1., 1., 1., 2., 2., 1., 1., 0., 0.};
  auto poly          = GeoManager::MakeInstance<UnplacedPolycone>(0., kTwoPi, numRZ, r, z);
  std::cout << "SurfaceArea : " << poly->SurfaceArea() << std::endl;

  const int numRZ1       = 7;
  Precision polycone_r[] = {0., 1., 1., 2., 3., 3., 1.};
  Precision polycone_z[] = {0., 1., 2., 3., 2.5, -1., -2.};
  auto poly1             = GeoManager::MakeInstance<UnplacedPolycone>(0., kTwoPi, numRZ1, polycone_r, polycone_z);
  std::cout << "SurfaceArea : " << poly1->SurfaceArea() << std::endl;
  std::cout << "Contour : " << contour << std::endl;
  return true;
}

int main()
{

  TestReducedPolycone();
  std::cout << "**********************************************************************************" << std::endl;
  std::cout << "Reduced Polycone Passed..." << std::endl;
  std::cout << "**********************************************************************************" << std::endl;
}