PeriDyno 1.0.0
Loading...
Searching...
No Matches
ThreadSystem.cpp
Go to the documentation of this file.
1#include "ThreadSystem.h"
2#include "Topology/PointSet.h"
4#include "Topology/TetrahedronSet.h"
5
6
9
10namespace dyno
11{
12 template<typename TDataType>
14 : Node()
15 {
16 auto topo = std::make_shared<EdgeSet<TDataType>>();
17 this->stateEdgeSet()->setDataPtr(topo);
18 }
19
20 template<typename TDataType>
24
25 template<typename TDataType>
27 {
28 auto edgeSet = TypeInfo::cast<EdgeSet<TDataType>>(this->stateEdgeSet()->getDataPtr());
29 if (edgeSet == nullptr) return;
30
31 if (!this->statePosition()->isEmpty())
32 {
33 int num = this->statePosition()->size();
34 auto& pts = edgeSet->getPoints();
35 if (num != pts.size())
36 {
37 pts.resize(num);
38 }
39
40 //Function1Pt::copy(pts, this->statePosition()->getData());
41 pts.assign(this->statePosition()->getData(), this->statePosition()->getData().size());
42 }
43 }
44
45 template<typename TDataType>
46 void ThreadSystem<TDataType>::addThread(Coord start, Coord end, int segSize)
47 {
48 int idx1;
49 idx1 = particles.size();
50 Real length = (end - start).norm() / segSize;
51 Coord dir = (end - start) / (end - start).norm();
52 for (int i = 0; i < segSize; i++)
53 {
54 particles.push_back(Coord(start + i * length * dir));
55 edges.push_back(TopologyModule::Edge(idx1, idx1 + 1));
56 idx1++;
57 }
58 particles.push_back(end);
59 }
60
61
62 template<typename TDataType>
64 {
65 auto edgeSet = TypeInfo::cast<EdgeSet<TDataType>>(this->stateEdgeSet()->getDataPtr());
66 if (edgeSet == nullptr) return;
67
68
69 edgeSet->setPoints(particles);
70
71 auto& dEdge = edgeSet->getEdges();
72 dEdge.resize(edges.size());
73 dEdge.assign(edges);
74
75 auto& pts = edgeSet->getPoints();
76
77 if (pts.size() > 0)
78 {
79 this->statePosition()->resize(pts.size());
80 this->stateVelocity()->resize(pts.size());
81 this->stateForce()->resize(pts.size());
82
83 this->statePosition()->getData().assign(pts);
84 this->stateVelocity()->getDataPtr()->reset();
85 }
86
88 }
89
91}
#define DEFINE_CLASS(name)
Definition Object.h:140
virtual void resetStates()
Definition Node.cpp:214
void updateTopology() override
void addThread(Coord start, Coord end, int segSize)
~ThreadSystem() override
TDataType::Coord Coord
std::vector< TopologyModule::Edge > edges
void resetStates() override
std::vector< Coord > particles
TDataType::Real Real
VectorND< PointType, 2 > Edge
TA * cast(TB *b)
Definition Typedef.inl:286
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25