ESyS-Particle
2.2
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
Particle.h
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
#ifndef __PARTICLE_H
14
#define __PARTICLE_H
15
16
// -- project includes --
17
#include "
Foundation/Quaternion.h
"
18
#include "
Foundation/vec3.h
"
19
#include "
Foundation/Matrix3.h
"
20
#include "
Model/BasicParticle.h
"
21
#include "
Parallel/CheckPointable.h
"
22
23
//--- STL includes ---
24
#include <map>
25
#include <vector>
26
#include <utility>
27
#include <string>
28
#include <iostream>
29
30
using
std::map;
31
using
std::vector;
32
using
std::pair;
33
using
std::string;
34
35
template
<
class
T>
class
ParallelParticleArray
;
36
class
AMPISGBufferRoot
;
37
class
AMPIBuffer
;
38
39
namespace
esys
40
{
41
namespace
lsm
42
{
43
class
SimpleParticleData;
44
}
45
}
46
50
class
CParticle
:
public
CBasicParticle
,
public
esys::lsm::CheckPointable
51
{
52
public
:
// types
53
class
exchangeType
54
{
55
public
:
56
exchangeType
()
57
:
m_pos
(),
58
m_initPos
(),
59
m_oldPos
(),
60
m_vel
()
61
{
62
m_is_dynamic
=
true
;
63
}
64
65
exchangeType
(
const
Vec3
&pos,
const
Vec3
&initPos,
const
Vec3
&oldPos,
const
Vec3
&vel,
bool
is_dyn)
66
:
m_pos
(pos),
67
m_initPos
(initPos),
68
m_oldPos
(oldPos),
69
m_vel
(vel)
70
{
71
m_is_dynamic
=is_dyn;
72
}
73
74
Vec3
m_pos
;
75
Vec3
m_initPos
;
76
Vec3
m_oldPos
;
77
Vec3
m_vel
;
78
bool
m_is_dynamic
;
79
};
80
81
typedef
double (
CParticle
::*
ScalarFieldFunction
)()
const
;
82
typedef
Vec3
(
CParticle
::*
VectorFieldFunction
)()
const
;
83
84
protected
:
86
Matrix3
m_sigma
;
87
Vec3
m_vel
,
m_force
;
88
Vec3
m_oldpos
;
89
Vec3
m_initpos
;
90
Vec3
m_circular_shift
;
91
double
m_mass
,
m_div_mass
;
92
93
bool
flag
;
94
bool
m_is_dynamic
;
95
96
void
setForce
(
const
Vec3
&force) {
m_force
= force;}
97
98
public
:
99
CParticle
();
100
CParticle
(
double
,
double
,
const
Vec3
&,
const
Vec3
&,
const
Vec3
&,
int
,
bool
);
101
CParticle
(
double
,
double
,
const
Vec3
&,
const
Vec3
&,
const
Vec3
&,
const
Vec3
&,
const
Vec3
&,
int
,
bool
);
// including oldpos
102
CParticle
(
const
esys::lsm::SimpleParticleData
&particleData);
103
virtual
~CParticle
(){};
104
105
106
static
ScalarFieldFunction
getScalarFieldFunction
(
const
string
&);
107
static
VectorFieldFunction
getVectorFieldFunction
(
const
string
&);
108
109
inline
const
Vec3
&
getInitPos
()
const
{
return
m_initpos
;}
110
inline
void
setInitPos
(
const
Vec3
&initPos) {
m_initpos
= initPos;}
111
inline
Vec3
getDisplacement
()
const
{
return
(
m_pos
-
m_oldpos
);} ;
112
inline
Vec3
getTotalDisplacement
()
const
{
return
(
m_pos
-
m_initpos
);} ;
113
inline
const
Vec3
&
getOldPos
()
const
{
return
m_oldpos
;};
114
inline
Vec3
getVel
()
const
{
return
m_vel
;};
115
inline
double
getAbsVel
()
const
{
return
m_vel
.
norm
();};
116
inline
void
setVel
(
const
Vec3
&V){
m_vel
=V;};
117
inline
void
setMass
(
double
mass) {
m_mass
= mass;
m_div_mass
= 1.0/
m_mass
;}
118
inline
double
getMass
()
const
{
return
m_mass
;};
119
inline
double
getInvMass
()
const
{
return
m_div_mass
;};
120
inline
Vec3
getForce
()
const
{
return
m_force
;};
121
virtual
void
setDensity
(
double
);
// needs to be virtual , different for rot. particle (mom. inert)
122
123
void
resetDisplacement
(){
m_oldpos
=
m_pos
;};
124
double
getIDField
()
const
{
return
double(
m_global_id
);};
125
double
getTagField
()
const
{
return
double(
getTag
());};
126
void
applyForce
(
const
Vec3
&,
const
Vec3
&);
127
virtual
void
integrate
(
double
);
128
virtual
void
integrateTherm
(
double
){}
129
virtual
void
zeroForce
();
130
virtual
void
zeroHeat
() {}
131
virtual
void
thermExpansion
() {}
132
inline
void
moveToRel
(
const
Vec3
&v){
m_pos
=
m_initpos
+v;};
133
inline
double
getKineticEnergy
()
const
{
return
0.5*
m_mass
*
m_vel
*
m_vel
;};
134
135
// switching on/off dynamic behaviour
136
virtual
void
setNonDynamic
() {
m_is_dynamic
=
false
;};
137
virtual
void
setNonDynamicLinear
() {
m_is_dynamic
=
false
;};
138
virtual
void
setNonDynamicRot
(){};
// do nothing
139
140
void
setFlag
(
bool
b=
true
){
flag
=b;};
141
bool
isFlagged
()
const
{
return
flag
;};
142
void
writeAsDXLine
(ostream&,
int
slid=0);
143
144
friend
ostream&
operator<<
(ostream&,
const
CParticle
&);
145
void
print
(){
cout
<< *
this
<< endl << flush;};
146
147
void
rescale
() {};
148
exchangeType
getExchangeValues
();
149
void
setExchangeValues
(
const
exchangeType&);
150
151
// circular
152
void
setCircular
(
const
Vec3
&);
153
154
// stress
155
double
sigma_xx_2D
()
const
{
return
m_sigma
(0,0)/(M_PI*
m_rad
*
m_rad
);};
156
double
sigma_xy_2D
()
const
{
return
m_sigma
(0,1)/(M_PI*
m_rad
*
m_rad
);};
157
double
sigma_yy_2D
()
const
{
return
m_sigma
(1,1)/(M_PI*
m_rad
*
m_rad
);};
158
double
sigma_d
()
const
;
159
160
friend
class
TML_PackedMessageInterface
;
161
162
virtual
void
saveCheckPointData
(std::ostream& oStream);
163
virtual
void
saveSnapShotData
(std::ostream& oStream);
164
165
//virtual Quaternion getQuat(){return Quaternion(1.0,Vec3(0.0,0.0,0.0));};
166
virtual
void
applyMoment
(
const
Vec3
&){};
167
168
static
void
get_type
() {
cout
<<
" CParticle"
;};
169
170
virtual
void
loadCheckPointData
(std::istream &iStream);
171
172
template
<
typename
TmplVisitor>
173
void
visit
(TmplVisitor &visitor)
174
{
175
visitor.visitParticle(*
this
);
176
}
177
178
public
:
179
// Ensure that particles only move in the x-y plane 2D computations
180
inline
static
void
setDo2dCalculations
(
bool
do2dCalculations) {
s_do2Calculations
= do2dCalculations;}
181
inline
static
bool
getDo2dCalculations
() {
return
s_do2Calculations
;}
182
183
private
:
184
static
bool
s_do2Calculations
;
185
186
187
};
188
189
/* CParticle extractCParticleFrom(AMPIBuffer*); */
190
/* CParticle extractCParticleFrom(AMPISGBufferRoot*,int); */
191
192
#endif //__PARTICLE_H
193
Model
Particle.h
Generated on Mon May 6 2013 23:26:30 for ESyS-Particle by
1.8.3.1