PeriDyno 1.2.1
Loading...
Searching...
No Matches
ParticleApproximation.cpp
Go to the documentation of this file.
2
3namespace dyno
4{
6
7 template<typename TDataType>
10 {
11// this->inSmoothingLength()->setValue(Real(0.011));
12// this->inSamplingDistance()->setValue(Real(0.005));
13
14 auto callback = std::make_shared<FCallBackFunc>(
16
17 this->varKernelType()->attach(callback);
18 this->inSmoothingLength()->attach(callback);
19 this->inSamplingDistance()->attach(callback);
20
21 //Should be called after above four parameters are all set, this function will recalculate m_factor
22 //calculateScalingFactor();
23 }
24
25 template<typename TDataType>
29
30 template<typename TDataType>
32 {
33 Real d = this->inSamplingDistance()->getValue();
34 Real H = this->inSmoothingLength()->getValue();
35
36 Real V = d * d*d;
37
38 Kernel<Real>* kern;
39 switch (this->varKernelType()->currentKey())
40 {
41 case KT_Spiky:
42 kern = new SpikyKernel<Real>();
43 break;
44 case KT_Smooth:
45 kern = new SmoothKernel<Real>();
46 break;
47 case KT_Cubic:
48 kern = new CubicKernel<Real>();
49 break;
50 case KT_Constant:
51 kern = new ConstantKernel<Real>();
52 break;
53 case KT_Quartic:
54 kern = new QuarticKernel<Real>();
55 break;
56 case KT_Corrected:
57 kern = new CorrectedKernel<Real>();
58 break;
59 case KT_CorrectedQuatic:
60 kern = new CorrectedQuaticKernel<Real>();
61 break;
62 case KT_WendlandC2:
63 kern = new WendlandC2Kernel<Real>();
64 break;
65 case KT_CorrectedMPSKernel:
66 kern = new CorrectedMPSKernel<Real>();
67 break;
68 default:
69 break;
70 }
71
72 Real total_weight(0);
73 int half_res = (int)(H / d + 1);
74 for (int i = -half_res; i <= half_res; i++)
75 for (int j = -half_res; j <= half_res; j++)
76 for (int k = -half_res; k <= half_res; k++)
77 {
78 Real x = i * d;
79 Real y = j * d;
80 Real z = k * d;
81 Real r = sqrt(x * x + y * y + z * z);
82 total_weight += V * kern->Weight(r, H);
83 }
84
85 mScalingFactor = Real(1) / total_weight;
86
87 delete kern;
88 }
89
91}
#define DEFINE_CLASS(name)
Definition Object.h:140
#define IMPLEMENT_TCLASS(name, T1)
Definition Object.h:103
double Real
Definition Typedef.inl:23
virtual DYN_FUNC Real Weight(const Real r, const Real h)
Definition Kernel.h:14
#define V(a, b, c)
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
DYN_FUNC Complex< Real > sqrt(const Complex< Real > &)
Definition Complex.inl:321