PeriDyno 1.0.0
Loading...
Searching...
No Matches
MakeGhostParticles.cu
Go to the documentation of this file.
1#include "MakeGhostParticles.h"
2
3namespace dyno
4{
5
6 template<typename TDataType>
7 MakeGhostParticles<TDataType>::MakeGhostParticles()
8 : GhostParticles<TDataType>()
9 {
10 this->stateNormal()->promoteInput();
11 }
12
13 template<typename TDataType>
14 MakeGhostParticles<TDataType>::~MakeGhostParticles()
15 {
16 }
17
18 template<typename Coord>
19 __global__ void MakeGhost_ReverseNomals(
20 DArray<Coord> Normals,
21 bool flag
22 )
23 {
24 int pId = threadIdx.x + (blockIdx.x * blockDim.x);
25 if (pId >= Normals.size()) return;
26
27 if (flag == true)
28 {
29 Normals[pId] = (-1.0) * Normals[pId];
30 }
31
32 }
33
34
35 template<typename TDataType>
36 void MakeGhostParticles<TDataType>::resetStates()
37 {
38
39
40 this->GhostParticles<TDataType>::resetStates();
41
42 auto& inTopo = this->inPoints()->getData();
43
44 auto pts = std::make_shared<PointSet<TDataType>>();
45 pts->copyFrom(inTopo);
46
47 int num = pts->getPoints().size();
48
49 if (this->stateNormal()->size() != num)
50 {
51 std::cout << "Ghost particle normals error: " << num << ", " << this->stateNormal()->size() << std::endl;
52 }
53
54 this->statePointSet()->setDataPtr(pts);
55 this->statePosition()->assign(pts->getPoints());
56
57 this->stateVelocity()->allocate();
58 this->stateVelocity()->resize(num);
59 this->stateVelocity()->reset();
60
61 std::vector<Attribute> host_attribute;
62 Attribute attri;
63 attri.setRigid();
64 attri.setFixed();
65 for (int i = 0; i < num; i++)
66 {
67 host_attribute.push_back(attri);
68 }
69 this->stateAttribute()->resize(num);
70 this->stateAttribute()->assign(host_attribute);
71
72 cuExecute(num,
73 MakeGhost_ReverseNomals,
74 this->stateNormal()->getData(),
75 this->varReverseNormal()->getValue()
76 );
77 }
78
79 DEFINE_CLASS(MakeGhostParticles);
80}