17 auto smoothingLength = std::make_shared<FloatingNumber<TDataType>>();
18 smoothingLength->setName(
"Smoothing Length");
19 smoothingLength->varValue()->setValue(
Real(0.012));
23 auto nbrQueryTri = std::make_shared<NeighborTriangleQuery<TDataType>>();
24 smoothingLength->outFloating()->connect(nbrQueryTri->inRadius());
25 this->statePosition()->connect(nbrQueryTri->inPosition());
26 this->inTriangleSet()->connect(nbrQueryTri->inTriangleSet());
30 auto meshCollision = std::make_shared<TriangularMeshConstraint<TDataType>>();
31 this->stateTimeStep()->connect(meshCollision->inTimeStep());
32 this->statePosition()->connect(meshCollision->inPosition());
33 this->stateVelocity()->connect(meshCollision->inVelocity());
34 this->inTriangleSet()->connect(meshCollision->inTriangleSet());
35 nbrQueryTri->outNeighborIds()->connect(meshCollision->inTriangleNeighborIds());
38 this->varNormalFriction()->attach(
39 std::make_shared<FCallBackFunc>(
41 meshCollision->varNormalFriction()->setValue(this->varNormalFriction()->getValue());
45 this->varTangentialFriction()->attach(
46 std::make_shared<FCallBackFunc>(
48 meshCollision->varTangentialFriction()->setValue(this->varTangentialFriction()->getValue());
52 this->varThickness()->attach(
53 std::make_shared<FCallBackFunc>(
55 Real thickness = this->varThickness()->getValue();
56 smoothingLength->varValue()->setValue(thickness);
57 meshCollision->varThickness()->setValue(thickness);
70 auto& particleSystems = this->getParticleSystems();
72 if (particleSystems.size() == 0)
76 for (
int i = 0; i < particleSystems.size(); i++) {
77 new_num += particleSystems[i]->statePosition()->size();
83 int cur_num = this->statePosition()->size();
85 if (new_num != cur_num)
87 this->statePosition()->resize(new_num);
88 this->stateVelocity()->resize(new_num);
91 auto& new_pos = this->statePosition()->getData();
92 auto& new_vel = this->stateVelocity()->getData();
95 for (
int i = 0; i < particleSystems.size(); i++)
97 DArray<Coord>& points = particleSystems[i]->statePosition()->getData();
98 DArray<Coord>& vels = particleSystems[i]->stateVelocity()->getData();
99 int num = points.size();
101 new_pos.assign(points, num, offset);
102 new_vel.assign(vels, num, offset);
117 auto& particleSystems = this->getParticleSystems();
119 if (particleSystems.size() <= 0 || this->statePosition()->size() <= 0)
122 auto& new_pos = this->statePosition()->getData();
123 auto& new_vel = this->stateVelocity()->getData();
126 for (
int i = 0; i < particleSystems.size(); i++)
128 DArray<Coord>& points = particleSystems[i]->statePosition()->getData();
129 DArray<Coord>& vels = particleSystems[i]->stateVelocity()->getData();
131 int num = points.size();
133 points.assign(new_pos, num, 0, offset);
134 vels.assign(new_vel, num, 0, offset);