MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LevelSetWall.cc
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #include <limits>
27 
28 #include "LevelSetWall.h"
29 #include "Particles/BaseParticle.h"
30 #include "InteractionHandler.h"
31 #include "WallHandler.h"
32 #include "DPMBase.h"
33 #include "InfiniteWall.h"
34 
35 // Constructor; currently only allows predefined shapes
36 LevelSetWall::LevelSetWall(Shape s, double radius, ParticleSpecies* sp) : radius_(radius)
37 {
38  setSpecies(sp);
39  if (s == Shape::Sphere)
40  {
43  }
44  else if (s == Shape::Cube)
45  {
46  setShapeCube();
47  createVTKCube();
48  }
49  else if (s == Shape::Diamond)
50  {
52  createVTK();
53  }
54  else if (s == Shape::Cylinder)
55  {
57  createVTK();
58  }
59  else if (s == Shape::FourSided)
60  {
62  createVTK();
63  }
64  else
65  {
66  logger(ERROR, "Shape unknown");
67  }
68 }
69 
71 {
72  logger(DEBUG, "LevelSetWall::~LevelSetWall finished");
73 }
74 
79 {
80  return new LevelSetWall(*this);
81 }
82 
84 // * \param[in] otherPosition The position to which the distance must be computed to.
85 // * \return The distance of the wall to the particle.
86 // */
87 //Mdouble LevelSetWall::getDistance(Vec3D otherPosition) const
88 //{
89 // return getOrientation().getDistance(otherPosition,getPosition());
90 //}
91 
104 bool LevelSetWall::getDistanceAndNormal(const BaseParticle& p, Mdouble& distance, Vec3D& normal_return) const
105 {
106  //transform coordinates into position-orientation frame
107  Vec3D position = p.getPosition() - getPosition();
108  getOrientation().rotateBack(position);
110  if (getDistanceAndNormalLabCoordinates(position, p.getWallInteractionRadius(this), distance, normal_return))
111  {
112  getOrientation().rotate(normal_return);
113  return true;
114  }
115  return false;
116  //return getDistanceAndNormal(p.getPosition(), distance, normal_return, p.getRadius(), p.getInteractionRadius());
117 }
118 
122 void LevelSetWall::read(std::istream& is)
123 {
124  BaseWall::read(is);
125  std::string dummy;
126  is >> dummy;
128 }
129 
133 std::string LevelSetWall::getName() const
134 {
135  return "LevelSetWall";
136 }
137 
139 {
141  vtk.points = vtkLabFrame_.points;
142  for (Vec3D& p : vtk.points)
143  {
144  getOrientation().rotate(p);
145  p += getPosition();
146  }
147 }
148 
150 {
151  Mdouble r = radius_ * (N - 1) / N;
152  vtkLabFrame_.points.resize(8);
153  vtkLabFrame_.points[0] = r * Vec3D(-1, -1, -1);
154  vtkLabFrame_.points[1] = r * Vec3D(-1, -1, 1);
155  vtkLabFrame_.points[2] = r * Vec3D(-1, 1, -1);
156  vtkLabFrame_.points[3] = r * Vec3D(-1, 1, 1);
157  vtkLabFrame_.points[4] = r * Vec3D(1, -1, -1);
158  vtkLabFrame_.points[5] = r * Vec3D(1, -1, 1);
159  vtkLabFrame_.points[6] = r * Vec3D(1, 1, -1);
160  vtkLabFrame_.points[7] = r * Vec3D(1, 1, 1);
161  vtkLabFrame_.triangleStrips.resize(6);
162  vtkLabFrame_.triangleStrips[0] = {0, 1, 2, 3};
163  vtkLabFrame_.triangleStrips[1] = {4, 5, 6, 7};
164  vtkLabFrame_.triangleStrips[2] = {0, 1, 4, 5};
165  vtkLabFrame_.triangleStrips[3] = {2, 3, 6, 7};
166  vtkLabFrame_.triangleStrips[4] = {0, 2, 4, 6};
167  vtkLabFrame_.triangleStrips[5] = {1, 3, 5, 7};
168 }
169 
171 {
172  vtkLabFrame_.points.resize(6);
173  vtkLabFrame_.points[0] = radius_ * Vec3D(-1, 0, 0);
174  vtkLabFrame_.points[1] = radius_ * Vec3D(1, 0, 0);
175  vtkLabFrame_.points[2] = radius_ * Vec3D(0, -1, 0);
176  vtkLabFrame_.points[3] = radius_ * Vec3D(0, 1, 0);
177  vtkLabFrame_.points[4] = radius_ * Vec3D(0, 0, -1);
178  vtkLabFrame_.points[5] = radius_ * Vec3D(0, 0, 1);
179  vtkLabFrame_.triangleStrips.resize(8);
180  vtkLabFrame_.triangleStrips[0] = {0, 3, 4};
181  vtkLabFrame_.triangleStrips[1] = {0, 3, 5};
182  vtkLabFrame_.triangleStrips[2] = {0, 2, 4};
183  vtkLabFrame_.triangleStrips[3] = {0, 2, 5};
184  vtkLabFrame_.triangleStrips[4] = {1, 3, 4};
185  vtkLabFrame_.triangleStrips[5] = {1, 3, 5};
186  vtkLabFrame_.triangleStrips[6] = {1, 2, 4};
187  vtkLabFrame_.triangleStrips[7] = {1, 2, 5};
188 }
189 
191 {
192  Mdouble distance;
193  Vec3D normal;
194  InfiniteWall wall;
195 
196  Mdouble interactionRadius = radius_/(2*N);
197  for (int i=-N; i<N; ++i) {
198  for (int j=-N; j<N; ++j) {
199  for (int k=-N; k<N; ++k) {
200  Vec3D min = interactionRadius*Vec3D(2*i,2*j,2*k);
201  Vec3D max = min + interactionRadius*Vec3D(2,2,2);
202  Vec3D position = min + interactionRadius*Vec3D(1,1,1);
203  if (getDistanceAndNormalLabCoordinates(position, 2*interactionRadius, distance, normal)) {
204  wall.set(normal,position+distance*normal);
205  std::vector<Vec3D> points;
206  wall.createVTK(points,min,max);
207  if (!points.empty()) {
208  wall.addToVTK(points, vtkLabFrame_);
209  }
210  }
211  }
212  }
213  }
214 }
215 
217 {
218  vtkLabFrame_.points.clear();
220 
221  const unsigned nr = 40;
222  const unsigned nz = 40;
223 
224  std::array<Mdouble, nr> s, c;
225  for (unsigned i = 0; i < nr; ++i)
226  {
227  s[i] = sin(2.0 * constants::pi * i / nr);
228  c[i] = cos(2.0 * constants::pi * i / nr);
229  }
230  std::array<Mdouble, nz> h, r;
231  for (unsigned j = 0; j < nz; ++j)
232  {
233  r[j] = radius_ * sin(2.0 * constants::pi * j / nz);
234  h[j] = radius_ * cos(2.0 * constants::pi * j / nz);
235  }
236 
237  for (unsigned j = 0; j < nz; ++j)
238  {
239  for (unsigned i = 0; i < nr; ++i)
240  {
241  vtkLabFrame_.points.emplace_back(r[j] * s[i], r[j] * c[i], h[j]);
242  }
243  }
244 
245  vtkLabFrame_.triangleStrips.reserve(nz - 1);
246  for (unsigned j = 0; j < nz - 1; ++j)
247  {
248  std::vector<double> cell;
249  cell.reserve(2 * nr + 2);
250  for (unsigned i = 0; i < nr; ++i)
251  {
252  cell.push_back(i + j * nr);
253  cell.push_back(i + (j + 1) * nr);
254  }
255  cell.push_back(j * nr);
256  cell.push_back((j + 1) * nr);
257  vtkLabFrame_.triangleStrips.push_back(cell);
258  }
259 }
260 
261 void LevelSetWall::writeToFile(int n, double extraRadius) const
262 {
263  std::stringstream s;
264  s << "Values of level set function\n";
265  Vec3D normal;
266  Mdouble distance;
267  double meshSize = (radius_ + extraRadius) / n;
268  for (int k = -n; k <= n; ++k)
269  {
270  for (int j = -n; j <= n; ++j)
271  {
272  for (int i = -n; i <= n; ++i)
273  {
274  Vec3D position = meshSize * Vec3D(i, j, k);
275  getDistanceAndNormalLabCoordinates(position, radius_ + extraRadius, distance, normal);
276  s << position << ' '
277  << distance << ' '
278  << normal << '\n';
279  }
280  }
281  }
282  helpers::writeToFile("LevelSet.txt", s.str());
283  helpers::writeToFile("LevelSet.m", "close all\n"
284  "data=importdata('LevelSet.txt');\n"
285  "N = nthroot(size(data.data,1),3);\n"
286  "x = reshape(data.data(:,1),N,N,N);\n"
287  "y = reshape(data.data(:,2),N,N,N);\n"
288  "z = reshape(data.data(:,3),N,N,N);\n"
289  "d = reshape(data.data(:,4),N,N,N);\n"
290  "nx= reshape(data.data(:,5),N,N,N);\n"
291  "ny= reshape(data.data(:,6),N,N,N);\n"
292  "nz= reshape(data.data(:,7),N,N,N);\n"
293  "mid = (N-1)/2;\n"
294  "surf(x(:,:,mid),y(:,:,mid),d(:,:,mid),'FaceColor','none')\n"
295  "hold on\n"
296  "quiver(x(:,:,mid),y(:,:,mid),nx(:,:,mid),ny(:,:,mid))\n"
297  "legend('distance','normal');\n"
298  "if (min(min(d(:,:,mid)))<0 && max(max(d(:,:,mid)))>0)\n"
299  " contourf(x(:,:,mid),y(:,:,mid),d(:,:,mid),[0 0])\n"
300  " legend('distance','normal','distance>=0'); set(legend,'Location','best');\n"
301  "end\n"
302  "hold off\n"
303  "xlabel('x'); ylabel('y'); title('cross-section at z=0');\n"
304  "view(0,0); axis equal;");
305  logger(INFO, "Run LevelSet.m to view level set");
306 }
307 
308 bool LevelSetWall::getDistanceAndNormalLabCoordinates(Vec3D position, Mdouble interactionRadius, Mdouble& distance,
309  Vec3D& normal) const
310 {
311  //scale values [-radius,radius] to [0,2*N]
312  Vec3D positionScaled = position / radius_ * static_cast<double>(N) + Vec3D(1, 1, 1) * static_cast<double>(N);
313  // index of level set value used for interpolation (the discrete level-set value left of the interpolation point)
314  int i = std::max(std::min((int) positionScaled.X, 2 * N - 1), 0);
315  int j = std::max(std::min((int) positionScaled.Y, 2 * N - 1), 0);
316  int k = std::max(std::min((int) positionScaled.Z, 2 * N - 1), 0);
317  // scaled difference between position and discrete level-set value, in [0,1) for interpolation
318  double x = positionScaled.X - i;
319  double y = positionScaled.Y - j;
320  double z = positionScaled.Z - k;
321  // trilinear interpolation
322  distance = levelSet_[i][j][k] * (1 - x) * (1 - y) * (1 - z)
323  + levelSet_[i + 1][j][k] * x * (1 - y) * (1 - z)
324  + levelSet_[i][j + 1][k] * (1 - x) * y * (1 - z)
325  + levelSet_[i + 1][j + 1][k] * x * y * (1 - z)
326  + levelSet_[i][j][k + 1] * (1 - x) * (1 - y) * z
327  + levelSet_[i + 1][j][k + 1] * x * (1 - y) * z
328  + levelSet_[i][j + 1][k + 1] * (1 - x) * y * z
329  + levelSet_[i + 1][j + 1][k + 1] * x * y * z;
330  if (distance < interactionRadius)
331  {
332  normal.X = -levelSet_[i][j][k] * (1 - y) * (1 - z)
333  + levelSet_[i + 1][j][k] * (1 - y) * (1 - z)
334  - levelSet_[i][j + 1][k] * y * (1 - z)
335  + levelSet_[i + 1][j + 1][k] * y * (1 - z)
336  - levelSet_[i][j][k + 1] * (1 - y) * z
337  + levelSet_[i + 1][j][k + 1] * (1 - y) * z
338  - levelSet_[i][j + 1][k + 1] * y * z
339  + levelSet_[i + 1][j + 1][k + 1] * y * z;
340  normal.Y = -levelSet_[i][j][k] * (1 - x) * (1 - z)
341  - levelSet_[i + 1][j][k] * x * (1 - z)
342  + levelSet_[i][j + 1][k] * (1 - x) * (1 - z)
343  + levelSet_[i + 1][j + 1][k] * x * (1 - z)
344  - levelSet_[i][j][k + 1] * (1 - x) * z
345  - levelSet_[i + 1][j][k + 1] * x * z
346  + levelSet_[i][j + 1][k + 1] * (1 - x) * z
347  + levelSet_[i + 1][j + 1][k + 1] * x * z;
348  normal.Z = -levelSet_[i][j][k] * (1 - x) * (1 - y)
349  - levelSet_[i + 1][j][k] * x * (1 - y)
350  - levelSet_[i][j + 1][k] * (1 - x) * y
351  - levelSet_[i + 1][j + 1][k] * x * y
352  + levelSet_[i][j][k + 1] * (1 - x) * (1 - y)
353  + levelSet_[i + 1][j][k + 1] * x * (1 - y)
354  + levelSet_[i][j + 1][k + 1] * (1 - x) * y
355  + levelSet_[i + 1][j + 1][k + 1] * x * y;
356  Mdouble length = normal.getLength();
357  if (length != 0)
358  normal /= -length;
359  else
360  normal = {1,0,0};
361  return true;
362  }
363  return false;
364 }
365 
367 {
368  logger(INFO, "Creating a sphere");
369  for (int k = -N; k <= N; ++k)
370  {
371  for (int j = -N; j <= N; ++j)
372  {
373  for (int i = -N; i <= N; ++i)
374  {
375  levelSet_[i + N][j + N][k + N] = radius_ * sqrt(i * i + j * j + k * k) / N - radius_;
376  }
377  }
378  }
379 }
380 
382 {
383  logger(INFO, "Creating a cylinder");
384  for (int k = -N; k <= N; ++k)
385  {
386  for (int j = -N; j <= N; ++j)
387  {
388  for (int i = -N; i <= N; ++i)
389  {
390  levelSet_[i + N][j + N][k + N] = radius_*std::fmax(sqrt(i * i + j * j) / N - 1,fabs(k)/N-1);
391  }
392  }
393  }
394 }
395 
397 {
398  logger(INFO, "Creating a cube");
399  radius_ *= N / (N - 1);
400  Mdouble h = radius_ / N;
401  for (int k = -N; k <= N; ++k)
402  {
403  for (int j = -N; j <= N; ++j)
404  {
405  for (int i = -N; i <= N; ++i)
406  {
407  std::array<int, 3> sort;
408  sort[0] = abs(i);
409  sort[1] = abs(j);
410  sort[2] = abs(k);
411  std::sort(sort.begin(), sort.end());
412  if (sort[1] < N)
413  {
414  // face
415  levelSet_[i + N][j + N][k + N] = h * (sort[2] - (N - 1));
416  }
417  else if (sort[0] < N)
418  {
419  // edge
420  levelSet_[i + N][j + N][k + N] = h * 2;
421  }
422  else
423  {
424  //vertex
425  levelSet_[i + N][j + N][k + N] = h * 3;
426  }
427  //edge and vertex distances longer than real, otherwise trilinear extrapolation is problematic.
428  }
429  }
430  }
431 }
432 
434 {
435  logger(INFO, "Creating a diamond square");
436  for (int k = -N; k <= N; ++k)
437  {
438  for (int j = -N; j <= N; ++j)
439  {
440  for (int i = -N; i <= N; ++i)
441  {
442  levelSet_[i + N][j + N][k + N] = radius_ / sqrt(3) / N * ((double) (abs(i) + abs(j) + abs(k)) - N);
443  }
444  }
445  }
446 }
447 
449 {
450  //open filestream
451  std::string fileName = "fourSided.txt";
452  std::ifstream is(fileName.c_str(), std::ios::in);
453  if (is.fail())
454  {
455  helpers::writeToFile("fourSided.m",
456  "%% parameters\n"
457  "n=10; % 2n+1 is the number of cells in the level set per dimension\n"
458  "w=1; % [-w,w] is the width of the shape in z-direction\n"
459  "% define a few points on the xy-cross section of the shape that will be interpolated\n"
460  "% we define a quarter of the cross section only; thus the first point has differ \n"
461  "% from the last point by a quarter rotation around the origin\n"
462  "x0=[1 1.8 1.8 1.4 1];\n"
463  "y0=[-1 0 1 1.4 1];\n"
464  "\n"
465  "%% create curve, and plot\n"
466  "% define a parameter t0, such that the parametrisation is x0(t0), y0(t0)\n"
467  "t0=1:length(x0);\n"
468  "% define a more fine-grained parameter t1, and interpolate, obtaining a \n"
469  "% finer parametrisation x1(t1), y1(t1)\n"
470  "t1= linspace(1,length(x0));\n"
471  "x1=interpn(t0,x0,t1,'spline');\n"
472  "y1=interpn(t0,y0,t1,'spline');\n"
473  "% complete the shape by repeating it four times, each rotated by 90 deg\n"
474  "% the points (x,y) are on the shape \n"
475  "x=[x1 -y1 -x1 y1];\n"
476  "y=[y1 x1 -y1 -x1];\n"
477  "% plot the resulting shape\n"
478  "figure(1)\n"
479  "plot(x,y,'-',x0,y0,'o')\n"
480  "axis equal\n"
481  "\n"
482  "%% create level set, and plot\n"
483  "% compute the size of the domain needed to contain the shape ...\n"
484  "radius = max([max(abs(x)),max(abs(y)),abs(w)]);\n"
485  "% .. then divide by the number of cells to get the cell size\n"
486  "radius = n/floor(n/radius);\n"
487  "% create xLS,yLS,zLS values of the level set function dist(xLS,yLS,zLS)\n"
488  "LS = linspace(-radius,radius,2*n+1);\n"
489  "[xLS,yLS,zLS]=meshgrid(LS);\n"
490  "% define the level set function by computing the distance of (xLS,yLS,zLS)\n"
491  "% to the nearest point on the shape (x,y,+-w)\n"
492  "dist = zeros(size(xLS));\n"
493  "for i=1:length(xLS(:))\n"
494  " dist(i) = sqrt(min((x-xLS(i)).^2+(y-yLS(i)).^2));\n"
495  " % make it a signed distance\n"
496  " if inpolygon(xLS(i),yLS(i),x,y)\n"
497  " dist(i) = -dist(i);\n"
498  " end\n"
499  " % compute the signed distance as the max of signed distances in xy and z\n"
500  " dist(i) = max(dist(i),abs(zLS(i))-w);\n"
501  "end\n"
502  "% rescale the distance\n"
503  "dist = dist/radius;\n"
504  "\n"
505  "% plot the i-th cross-section in xy (i=n+1 is in the center)\n"
506  "figure(2)\n"
507  "i=n+4\n"
508  "mesh(xLS(:,:,i),yLS(:,:,i),dist(:,:,i),'FaceColor','none')\n"
509  "hold on\n"
510  "contourf(xLS(:,:,i),yLS(:,:,i),dist(:,:,i),[0 0])\n"
511  "plot(x0,y0,'ro')\n"
512  "hold off\n"
513  "view(0,90)\n"
514  "axis equal\n"
515  "title(['z=' num2str(unique(zLS(:,:,i)))])\n"
516  "xlabel('x'), ylabel('y'), zlabel('dist')\n"
517  "\n"
518  "% plot the i-th cross-section in yz (i=n+1 is in the center)\n"
519  "figure(3)\n"
520  "mesh(squeeze(yLS(:,i,:)),squeeze(zLS(:,i,:)),squeeze(dist(:,i,:)),'FaceColor','none')\n"
521  "hold on\n"
522  "contourf(squeeze(yLS(:,i,:)),squeeze(zLS(:,i,:)),squeeze(dist(:,i,:)),[0 0])\n"
523  "hold off\n"
524  "view(90,0)\n"
525  "axis equal\n"
526  "title(['x=' num2str(unique(xLS(:,i,:)))])\n"
527  "xlabel('y'), ylabel('z'), zlabel('dist')\n"
528  "\n"
529  "% plot the i-th cross-section in xz (i=n+1 is in the center)\n"
530  "figure(4)\n"
531  "mesh(squeeze(xLS(i,:,:)),squeeze(zLS(i,:,:)),squeeze(dist(i,:,:)),'FaceColor','none')\n"
532  "hold on\n"
533  "contourf(squeeze(xLS(i,:,:)),squeeze(zLS(i,:,:)),squeeze(dist(i,:,:)),[0 0])\n"
534  "hold off\n"
535  "view(90,0)\n"
536  "axis equal\n"
537  "title(['y=' num2str(unique(yLS(i,:,:)))])\n"
538  "xlabel('x'), ylabel('z'), zlabel('dist')\n"
539  "\n"
540  "%% write n and dist values to file (read into Mercury)\n"
541  "fid = fopen('fourSided.txt','w');\n"
542  "fprintf(fid,'%d\\n',n);\n"
543  "fprintf(fid,'%f ',dist);\n"
544  "fclose(fid);");
545  logger(ERROR, "readFromFile: file % could not be opened; make sure you run fourSided.m first.", fileName);
546  }
547 
548  int n;
549  is >> n;
550  if (n != N)
551  {
552  logger(ERROR, "readFromFile: level set size does not match %", n);
553  }
554 
555  Mdouble unitDistance;
556  for (int k = -N; k <= N; ++k)
557  {
558  for (int j = -N; j <= N; ++j)
559  {
560  for (int i = -N; i <= N; ++i)
561  {
562  is >> unitDistance;
563  levelSet_[i + N][j + N][k + N] = radius_ * unitDistance;
564  }
565  }
566  }
567 }
void writeToFile(int n, double radiusContact) const
LevelSetWall * copy() const override
Wall copy method. It calls the copy constructor of this Wall, useful for polymorphism.
Definition: LevelSetWall.cc:78
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Definition: Helpers.cc:446
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Mdouble X
the vector components
Definition: Vector.h:65
void createVTKDiamond()
~LevelSetWall() override
Default destructor.
Definition: LevelSetWall.cc:70
double levelSet_[2 *N+1][2 *N+1][2 *N+1]
Definition: LevelSetWall.h:140
void rotateBack(Vec3D &position) const
Applies the inverse rotation to a position.
Definition: Quaternion.cc:592
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
void createVTK(std::vector< Vec3D > &myPoints) const
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
static void addToVTK(const std::vector< Vec3D > &points, VTKContainer &vtk)
Takes the points provided and adds a triangle strip connecting these points to the vtk container...
Definition: BaseWall.cc:471
void setShapeSphere()
void createVTK()
void rotate(Vec3D &position) const
Applies the rotation to a position.
Definition: Quaternion.cc:563
void setShapeDiamond()
void createVTKCube()
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
Definition: Vector.cc:331
Mdouble cos(Mdouble x)
Definition: ExtendedMath.cc:64
VTKContainer vtkLabFrame_
Definition: LevelSetWall.h:145
Mdouble getWallInteractionRadius(const BaseWall *wall) const
returns the radius plus the interactionDistance
Definition: BaseParticle.h:383
Mdouble sin(Mdouble x)
Definition: ExtendedMath.cc:44
LevelSetWall(Shape s, double radius, ParticleSpecies *sp=nullptr)
Definition: LevelSetWall.cc:36
const Mdouble pi
Definition: ExtendedMath.h:45
bool getDistanceAndNormalLabCoordinates(Vec3D position, Mdouble interactionRadius, Mdouble &distance, Vec3D &normal) const
std::vector< std::vector< double > > triangleStrips
Definition: BaseWall.h:39
void setShapeFourSided()
void createVTKSphere()
void read(std::istream &is) override
Function that reads a BaseWall from an input stream, usually a restart file.
Definition: BaseWall.cc:80
This is a class defining walls.
Definition: LevelSetWall.h:47
bool getDistanceAndNormal(const BaseParticle &p, Mdouble &distance, Vec3D &normal_return) const override
Returns the distance of the wall to the particle.
Mdouble Y
Definition: Vector.h:65
std::vector< Vec3D > points
Definition: BaseWall.h:38
static const int N
Definition: LevelSetWall.h:137
void read(std::istream &is) override
Reads LevelSetWall from a restart file.
void set(Vec3D normal, Vec3D point)
Defines a standard wall, given an outward normal vector s.t. normal*x=normal*point for all x of the w...
std::string getName() const override
Returns the name of the object, in this case the string "LevelSetWall".
void setShapeCube()
double radius_
Definition: LevelSetWall.h:143
This is a class defining walls.
Definition: InfiniteWall.h:47
void setShapeCylinder()
Definition: Vector.h:49
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
Mdouble Z
Definition: Vector.h:65
void writeVTK(VTKContainer &vtk) const override
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:171