-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMCommonParticle.cpp
More file actions
executable file
·73 lines (58 loc) · 1.13 KB
/
MCommonParticle.cpp
File metadata and controls
executable file
·73 lines (58 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "MCommonParticle.h"
MCommonParticle::MCommonParticle()
{
llpointer = LINKEDLISTEND;
active = true;
fromOtherProc = false;
lennardJones = false;
color = 1;
N = 0;
nnbr = 0;
x.resize(3); x.clear();
xzero.resize(3); xzero.clear();
v.resize(3); v.clear();
p = 0.0;
sigma.resize(3,3); sigma.clear();
q.resize(3,3); q.clear();
}
MCommonParticle::~MCommonParticle()
{
}
void MCommonParticle::CalculateVabs(int ndim)
{
vabs = 0.0;
for (int j=0; j<ndim; j++) vabs+= SQR( v(j) );
vabs = sqrt(vabs);
}
real MCommonParticle::Distance(const MCommonParticle &other, int ndim)
{
real dist_sq = 0.0;
int j;
for (j=0; j<ndim; j++)
dist_sq+= SQR(x(j)-other.x(j));
return sqrt(dist_sq);
}
real MCommonParticle::DistanceSquared(const MCommonParticle &other, int ndim)
{
real dist_sq = 0.0;
int j;
for (j=0; j<ndim; j++)
dist_sq+= SQR(x(j)-other.x(j));
return dist_sq;
}
int MCommonParticle::AddNeighbour(int id)
{
m_nbrlist(nnbr++) = id;
return OK;
}
int MCommonParticle::RemoveNeighbours()
{
nnbr = 0;
m_nbrlist.clear();
return OK;
}
int MCommonParticle::ReserveMemForNbrs(int size)
{
m_nbrlist.resize(size);
return OK;
}