PeriDyno 1.0.0
Loading...
Searching...
No Matches
ParticleApproximation.h
Go to the documentation of this file.
1
16#pragma once
18
19#include "Kernel.h"
20
21namespace dyno
22{
23
24#define cuIntegralAdh(size, type, scale, Func,...){ \
25 uint pDims = cudaGridSize((uint)size, BLOCK_SIZE); \
26 if (type == KT_Smooth) \
27 { \
28 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
29 return SmoothKernel<Real>::integral(r, h, s); \
30 }; \
31 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, ParticleApproximation<TDataType>::mScalingFactor); \
32 } \
33 else if (type == KT_Spiky) \
34 { \
35 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
36 return SpikyKernel<Real>::integral(r, h, s); \
37 }; \
38 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, ParticleApproximation<TDataType>::mScalingFactor); \
39 } \
40 cuSynchronize(); \
41 }
42
43#define cuIntegral(size, type, scale, Func,...){ \
44 uint pDims = cudaGridSize((uint)size, BLOCK_SIZE); \
45 if (type == ParticleApproximation<TDataType>::KT_Smooth) \
46 { \
47 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
48 return SmoothKernel<Real>::integral(r, h, s); \
49 }; \
50 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, ParticleApproximation<TDataType>::mScalingFactor); \
51 } \
52 else if (type == ParticleApproximation<TDataType>::KT_Spiky) \
53 { \
54 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
55 return SpikyKernel<Real>::integral(r, h, s); \
56 }; \
57 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, ParticleApproximation<TDataType>::mScalingFactor); \
58 } \
59 cuSynchronize(); \
60 }
61
62#define cuZerothOrder(size, type, scale, Func,...){ \
63 uint pDims = cudaGridSize((uint)size, BLOCK_SIZE); \
64 if (type == 0) \
65 { \
66 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
67 return SmoothKernel<Real>::weight(r, h, s); \
68 }; \
69 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
70 } \
71 else if (type == 1) \
72 { \
73 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
74 return SpikyKernel<Real>::weight(r, h, s); \
75 }; \
76 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
77 } \
78 cuSynchronize(); \
79 }
80
81#define cuFirstOrder(size, type, scale, Func,...){ \
82 uint pDims = cudaGridSize((uint)size, BLOCK_SIZE); \
83 if (type == 0) \
84 { \
85 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
86 return SmoothKernel<Real>::gradient(r, h, s); \
87 }; \
88 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
89 } \
90 else if (type == 1) \
91 { \
92 auto lambdaFunc = [=] __device__(Real r, Real h, Real s) -> Real { \
93 return SpikyKernel<Real>::gradient(r, h, s); \
94 }; \
95 Func << <pDims, BLOCK_SIZE >> > (__VA_ARGS__, lambdaFunc, scale); \
96 } \
97 cuSynchronize(); \
98 }
99
100 template<typename TDataType>
102 {
104 public:
105 typedef typename TDataType::Real Real;
106
108 virtual ~ParticleApproximation();
109
110 DECLARE_ENUM(EKernelType,
111 KT_Smooth = 0,
112 KT_Spiky = 1);
113
114 void compute() override {};
115
116 public:
117 DEF_VAR_IN(Real, SmoothingLength, "Smoothing Length");
118 DEF_VAR_IN(Real, SamplingDistance, "Particle sampling distance");
119
120 DEF_ENUM(EKernelType, KernelType, EKernelType::KT_Spiky, "Rendering mode");
121
122 protected:
124
125 private:
127 };
128}
#define DECLARE_TCLASS(name, T1)
Definition Object.h:87
DECLARE_ENUM(EKernelType, KT_Smooth=0, KT_Spiky=1)
DEF_VAR_IN(Real, SmoothingLength, "Smoothing Length")
DEF_ENUM(EKernelType, KernelType, EKernelType::KT_Spiky, "Rendering mode")
DEF_VAR_IN(Real, SamplingDistance, "Particle sampling distance")
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25