PeriDyno 1.0.0
Loading...
Searching...
No Matches
Thread.cu
Go to the documentation of this file.
1#include "Thread.h"
2#include "Topology/TriangleSet.h"
3#include "Topology/PointSet.h"
4#include "Mapping/PointSetToPointSet.h"
5
6#include "ParticleSystem/Module/ParticleIntegrator.h"
7
8#include "Collision/NeighborPointQuery.h"
9
10#include "Module/LinearElasticitySolver.h"
11#include "Module/ProjectivePeridynamics.h"
12#include "Module/FixedPoints.h"
13
14#include "SharedFunc.h"
15#include "TriangularSystem.h"
16
17namespace dyno
18{
19 IMPLEMENT_TCLASS(Thread, TDataType)
20
21 template<typename TDataType>
22 Thread<TDataType>::Thread()
23 : ThreadSystem<TDataType>()
24 {
25 auto integrator = std::make_shared<ParticleIntegrator<TDataType>>();
26 this->stateTimeStep()->connect(integrator->inTimeStep());
27 this->statePosition()->connect(integrator->inPosition());
28 this->stateVelocity()->connect(integrator->inVelocity());
29
30 this->animationPipeline()->pushModule(integrator);
31
32 auto elasticity = std::make_shared<LinearElasticitySolver<TDataType>>();
33 this->varHorizon()->connect(elasticity->inHorizon());
34 this->stateTimeStep()->connect(elasticity->inTimeStep());
35 this->statePosition()->connect(elasticity->inY());
36 this->stateVelocity()->connect(elasticity->inVelocity());
37 this->stateRestShape()->connect(elasticity->inBonds());
38 this->animationPipeline()->pushModule(elasticity);
39
40
41 }
42
43 template<typename TDataType>
44 Thread<TDataType>::~Thread()
45 {
46
47 }
48
49 template<typename TDataType>
50 bool Thread<TDataType>::translate(Coord t)
51 {
52 this->stateEdgeSet()->getDataPtr()->translate(t);
53
54 return true;
55 }
56
57 template<typename TDataType>
58 bool Thread<TDataType>::scale(Real s)
59 {
60 this->stateEdgeSet()->getDataPtr()->scale(s);
61 return true;
62 }
63
64
65
66
67 template<typename TDataType>
68 void Thread<TDataType>::resetStates()
69 {
70 ThreadSystem<TDataType>::resetStates();
71
72 auto nbrQuery = std::make_shared<NeighborPointQuery<TDataType>>();
73 this->varHorizon()->connect(nbrQuery->inRadius());
74 this->statePosition()->connect(nbrQuery->inPosition());
75 nbrQuery->update();
76
77 if (!this->statePosition()->isEmpty())
78 {
79 this->stateRestShape()->allocate();
80 auto nbrPtr = this->stateRestShape()->getDataPtr();
81 nbrPtr->resize(nbrQuery->outNeighborIds()->getData());
82
83 constructRestShape(*nbrPtr, nbrQuery->outNeighborIds()->getData(), this->statePosition()->getData());
84 //constructRestShapeForThreads();
85 }
86 }
87
88
89
90
91 DEFINE_CLASS(Thread);
92}