PeriDyno 1.0.0
Loading...
Searching...
No Matches
ContactsToPointSet.cu
Go to the documentation of this file.
1#include "ContactsToPointSet.h"
2
3namespace dyno
4{
5 IMPLEMENT_TCLASS(ContactsToPointSet, TDataType);
6
7 template<typename TDataType>
8 ContactsToPointSet<TDataType>::ContactsToPointSet()
9 : TopologyMapping()
10 {
11 }
12
13 template<typename Coord>
14 __global__ void SetupContactPoints(
15 DArray<Coord> vertices,
16 DArray<TContactPair<Real>> contacts)
17 {
18 int tId = threadIdx.x + (blockIdx.x * blockDim.x);
19 if (tId >= contacts.size()) return;
20
21 auto contact = contacts[tId];
22 Coord v0 = contact.pos1;
23
24 vertices[tId] = v0;
25 }
26
27 template<typename TDataType>
28 bool ContactsToPointSet<TDataType>::apply()
29 {
30 if (this->outPointSet()->isEmpty())
31 {
32 this->outPointSet()->allocate();
33 }
34
35 auto outSet = this->outPointSet()->getDataPtr();
36
37 if (this->inContacts()->isEmpty())
38 {
39 outSet->clear();
40 return true;
41 }
42
43 auto& inContacts = this->inContacts()->getData();
44
45 auto& vertices = outSet->getPoints();
46
47 uint contactNum = inContacts.size();
48 vertices.resize(contactNum);
49
50 cuExecute(contactNum,
51 SetupContactPoints,
52 vertices,
53 inContacts);
54
55 return true;
56 }
57
58 template<typename TDataType>
59 bool ContactsToPointSet<TDataType>::validateInputs()
60 {
61 return true;
62 }
63
64 DEFINE_CLASS(ContactsToPointSet);
65}