PeriDyno 1.0.0
Loading...
Searching...
No Matches
LinearDamping.cu
Go to the documentation of this file.
1#include "LinearDamping.h"
2
3namespace dyno
4{
5// IMPLEMENT_TCLASS(LinearDamping, TDataType)
6
7 template<typename TDataType>
8 LinearDamping<TDataType>::LinearDamping()
9 : ConstraintModule()
10 {
11 }
12
13 template<typename TDataType>
14 LinearDamping<TDataType>::~LinearDamping()
15 {
16 }
17
18 template <typename Real, typename Coord>
19 __global__ void LP_Damping(
20 DArray<Coord> vel,
21 Real coefficient)
22 {
23 int pId = threadIdx.x + (blockIdx.x * blockDim.x);
24 if (pId >= vel.size()) return;
25
26 vel[pId] *= coefficient;
27 }
28
29 template<typename TDataType>
30 void LinearDamping<TDataType>::constrain()
31 {
32 Real coef = this->varDampingCoefficient()->getData();
33 auto& vels = this->inVelocity()->getData();
34
35 int num = vels.size();
36 cuExecute(num,
37 LP_Damping,
38 vels,
39 coef);
40 }
41
42 DEFINE_CLASS(LinearDamping);
43}