ESyS-Particle
2.2
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
RotLocalDamping.hpp
Go to the documentation of this file.
1
2
// //
3
// Copyright (c) 2003-2013 by The University of Queensland //
4
// Earth Systems Science Computational Centre (ESSCC) //
5
// http://www.uq.edu.au/esscc //
6
// //
7
// Primary Business: Brisbane, Queensland, Australia //
8
// Licensed under the Open Software License version 3.0 //
9
// http://www.opensource.org/licenses/osl-3.0.php //
10
// //
12
13
14
#ifndef MODEL_ROTLOCALDAMPING_HPP
15
#define MODEL_ROTLOCALDAMPING_HPP
16
17
#include "
Model/RotLocalDamping.h
"
18
26
template
<
class
T>
27
CRotLocalDamping<T>::CRotLocalDamping
(T* P,
double
visc,
double
dt)
28
{
29
m_p=P;
30
m_visc=visc;
31
m_dt=dt;
32
m_force=
Vec3
(0.0,0.0,0.0);
33
}
34
41
template
<
class
T>
42
CRotLocalDamping<T>::CRotLocalDamping
(T* P,
const
CLocalDampingIGP
& param)
43
{
44
m_p=P;
45
m_visc=param.
getVisc
();
46
m_dt=param.
getTimeStep
();
47
m_force=
Vec3
(0.0,0.0,0.0);
48
}
49
56
template
<
class
T>
57
CRotLocalDamping<T>::CRotLocalDamping
(T* P,
CLocalDampingIGP
* param)
58
{
59
m_p=P;
60
m_visc=param->
getVisc
();
61
m_dt=param->
getTimeStep
();
62
m_force=
Vec3
(0.0,0.0,0.0);
63
}
64
68
template
<
class
T>
69
CRotLocalDamping<T>::~CRotLocalDamping
()
70
{}
71
72
template
<
class
T>
73
void
CRotLocalDamping<T>::setTimeStepSize
(
double
dt)
74
{
75
m_dt = dt;
76
}
77
81
template
<
class
T>
82
void
CRotLocalDamping<T>::calcForces
()
83
{
84
m_E_diss=0.0;
// zero dissipated energy
85
Vec3
v=m_p->getAngVel();
86
Vec3
frc=m_p->getMoment();
87
88
double
dampFx, dampFy, dampFz;
89
90
dampFx = fabs(frc.
X
());
91
if
(v.
X
() < 0) {
92
dampFx *= -1.;
93
}
94
if
(v.
X
() == 0) {
95
dampFx = 0.0;
96
}
97
dampFy = fabs(frc.
Y
());
98
if
(v.
Y
() < 0) {
99
dampFy *= -1.;
100
}
101
if
(v.
Y
() == 0) {
102
dampFy = 0.0;
103
}
104
dampFz = fabs(frc.
Z
());
105
if
(v.
Z
() < 0) {
106
dampFz *= -1.;
107
}
108
if
(v.
Z
() == 0) {
109
dampFz = 0.0;
110
}
111
112
m_force=-1.0*m_visc*
Vec3
(dampFx, dampFy, dampFz);
113
114
m_p->applyMoment(m_force);
115
116
m_E_diss=m_visc*m_force.norm()*v.
norm
()*m_dt;
117
}
118
124
template
<
class
T>
125
typename
CRotLocalDamping<T>::ScalarFieldFunction
CRotLocalDamping<T>::getScalarFieldFunction
(
const
string
& name)
126
{
127
typename
CRotLocalDamping<T>::ScalarFieldFunction
sf;
128
129
if
(name==
"dissipated_energy"
){
130
sf=&
CRotLocalDamping<T>::getDissipatedEnergy
;
131
}
else
{
132
sf=
NULL
;
133
cerr <<
"ERROR - invalid name for interaction scalar access function"
<< endl;
134
}
135
136
return
sf;
137
}
138
144
template
<
class
T>
145
typename
CRotLocalDamping<T>::CheckedScalarFieldFunction
CRotLocalDamping<T>::getCheckedScalarFieldFunction
(
const
string
& name)
146
{
147
typename
CRotLocalDamping<T>::CheckedScalarFieldFunction
sf;
148
149
sf=
NULL
;
150
cerr <<
"ERROR - invalid name for interaction scalar access function"
<< endl;
151
152
return
sf;
153
}
154
155
161
template
<
class
T>
162
typename
CRotLocalDamping<T>::VectorFieldFunction
CRotLocalDamping<T>::getVectorFieldFunction
(
const
string
& name)
163
{
164
typename
CRotLocalDamping<T>::VectorFieldFunction
vf;
165
166
if
(name==
"force"
){
167
vf=&
CRotLocalDamping<T>::getForce
;
168
}
else
{
169
vf=
NULL
;
170
cerr <<
"ERROR - invalid name for interaction vector access function"
<< endl;
171
}
172
173
return
vf;
174
}
175
179
template
<
class
T>
180
double
CRotLocalDamping<T>::getDissipatedEnergy
()
const
181
{
182
return
m_E_diss;
183
}
184
185
template
<
class
T>
186
Vec3
CRotLocalDamping<T>::getForce
()
const
187
{
188
return
m_force;
189
}
190
197
template
<
class
T>
198
bool
CRotLocalDamping<T>::hasTag
(
int
tag,
int
mask)
const
199
{
200
int
tag1=m_p->getTag();
201
202
return
((tag1 & mask)==(tag & mask));
203
}
204
208
template
<
class
T>
209
vector<int>
CRotLocalDamping<T>::getAllID
()
const
210
{
211
vector<int> res;
212
213
res.push_back(m_p->getID());
214
215
return
res;
216
}
217
218
#endif
Model
RotLocalDamping.hpp
Generated on Mon May 6 2013 23:26:30 for ESyS-Particle by
1.8.3.1