PeriDyno 1.0.0
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 default:
48 break;
49 }
50
51 Real total_weight(0);
52 int half_res = (int)(H / d + 1);
53 for (int i = -half_res; i <= half_res; i++)
54 for (int j = -half_res; j <= half_res; j++)
55 for (int k = -half_res; k <= half_res; k++)
56 {
57 Real x = i * d;
58 Real y = j * d;
59 Real z = k * d;
60 Real r = sqrt(x * x + y * y + z * z);
61 total_weight += V * kern->Weight(r, H);
62 }
63
64 mScalingFactor = Real(1) / total_weight;
65
66 delete kern;
67 }
68
70}
#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