1#include "MakeGhostParticles.h"
6 template<typename TDataType>
7 MakeGhostParticles<TDataType>::MakeGhostParticles()
8 : GhostParticles<TDataType>()
10 this->stateNormal()->promoteInput();
13 template<typename TDataType>
14 MakeGhostParticles<TDataType>::~MakeGhostParticles()
18 template<typename Coord>
19 __global__ void MakeGhost_ReverseNomals(
20 DArray<Coord> Normals,
24 int pId = threadIdx.x + (blockIdx.x * blockDim.x);
25 if (pId >= Normals.size()) return;
29 Normals[pId] = (-1.0) * Normals[pId];
35 template<typename TDataType>
36 void MakeGhostParticles<TDataType>::resetStates()
40 this->GhostParticles<TDataType>::resetStates();
42 auto& inTopo = this->inPoints()->getData();
44 auto pts = std::make_shared<PointSet<TDataType>>();
45 pts->copyFrom(inTopo);
47 int num = pts->getPoints().size();
49 if (this->stateNormal()->size() != num)
51 std::cout << "Ghost particle normals error: " << num << ", " << this->stateNormal()->size() << std::endl;
54 this->statePointSet()->setDataPtr(pts);
55 this->statePosition()->assign(pts->getPoints());
57 this->stateVelocity()->allocate();
58 this->stateVelocity()->resize(num);
59 this->stateVelocity()->reset();
61 std::vector<Attribute> host_attribute;
65 for (int i = 0; i < num; i++)
67 host_attribute.push_back(attri);
69 this->stateAttribute()->resize(num);
70 this->stateAttribute()->assign(host_attribute);
73 MakeGhost_ReverseNomals,
74 this->stateNormal()->getData(),
75 this->varReverseNormal()->getValue()
79 DEFINE_CLASS(MakeGhostParticles);