PeriDyno 1.0.0
Loading...
Searching...
No Matches
GranularModule.cu
Go to the documentation of this file.
1#include "GranularModule.h"
2
3#include "ParticleSystem/Module/SummationDensity.h"
4
5namespace dyno
6{
7 IMPLEMENT_TCLASS(GranularModule, TDataType)
8
9 template<typename TDataType>
10 GranularModule<TDataType>::GranularModule()
11 : ElastoplasticityModule<TDataType>()
12 {
13 }
14
15 __device__ Real Hardening(Real rho, Real restRho)
16 {
17 if (rho >= restRho)
18 {
19 float ratio = rho / restRho;
20 //ratio = ratio > 1.1f ? 1.1f : ratio;
21 return pow(Real(M_E), Real(ratio - 1.0f));
22 }
23 else
24 {
25 return Real(0);
26 };
27 }
28
29 template <typename Real>
30 __global__ void PM_ComputeStiffness(
31 DArray<Real> stiffiness,
32 DArray<Real> density)
33 {
34 int i = threadIdx.x + (blockIdx.x * blockDim.x);
35 if (i >= stiffiness.size()) return;
36
37 stiffiness[i] = Hardening(density[i], Real(1000));
38 }
39
40 template<typename TDataType>
41 void GranularModule<TDataType>::computeMaterialStiffness()
42 {
43 int num = this->inY()->size();
44 uint pDims = cudaGridSize(num, BLOCK_SIZE);
45
46 m_densitySum->compute();
47
48 PM_ComputeStiffness << <pDims, BLOCK_SIZE >> > (
49 this->mBulkStiffness,
50 m_densitySum->outDensity()->getData());
51 cuSynchronize();
52 }
53
54 DEFINE_CLASS(GranularModule);
55}