Nsound  0.9.4
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Nsound::MeshJunction Class Reference

#include <Nsound/MeshJunction.h>

Public Member Functions

 MeshJunction (const float64 &leak_gain, const float64 &tau, const float64 &delta, const float64 &gamma)
 Constructor. More...
 
 MeshJunction (const MeshJunction &copy)
 This operator can not assign neighbor pointers. More...
 
 ~MeshJunction ()
 Deconstructor. More...
 
void clear ()
 Clears all velicityes in the junctino. More...
 
float64 getVelocity () const
 
MeshJunctionoperator= (const MeshJunction &rhs)
 This operator can not assign neighbor pointers. More...
 
void setNeighborNorth (MeshJunction *ptr)
 
void setNeighborSouth (MeshJunction *ptr)
 
void setNeighborEast (MeshJunction *ptr)
 
void setNeighborWest (MeshJunction *ptr)
 
void saveState ()
 Saves previous south and east velocities. More...
 
void strike (const float64 &velocity)
 Adds velocity to this junction. More...
 
void updateVelocity ()
 updates junction velocity. More...
 

Private Member Functions

void updateBoundry ()
 

Private Attributes

float64 leak_gain_
 updates junction velocity. More...
 
float64 velocity_
 Leak gain. More...
 
float64 velocity_north_
 This junction's velocity. More...
 
float64 velocity_south_
 Velocity going north. More...
 
float64 velocity_east_
 Velocity going south. More...
 
float64 velocity_west_
 Velocity going east. More...
 
float64 previous_velocity_
 Velocity going west. More...
 
float64 previous_velocity_north_
 
float64 previous_velocity_south_
 
float64 previous_velocity_east_
 
float64 previous_velocity_west_
 
float64 vc_
 
float64 yj_
 
float64 yc_
 
MeshJunctionneighbor_north_
 
MeshJunctionneighbor_south_
 
MeshJunctionneighbor_east_
 
MeshJunctionneighbor_west_
 

Detailed Description

WARNING: This is Experimental, you should not use this class as it may not be working or will change in future releases of Nsound.

Definition at line 47 of file MeshJunction.h.

Constructor & Destructor Documentation

MeshJunction::MeshJunction ( const float64 leak_gain,
const float64 tau,
const float64 delta,
const float64 gamma 
)

Constructor.

Definition at line 41 of file MeshJunction.cc.

References leak_gain_, yc_, and yj_.

46  :
47  leak_gain_(leak_gain),
48  velocity_(0.0),
49  velocity_north_(0.0),
50  velocity_south_(0.0),
51  velocity_east_(0.0),
52  velocity_west_(0.0),
53  previous_velocity_(0.0),
58  vc_(0.0),
59  yj_(0.0),
60  yc_(0.0),
61  neighbor_north_(NULL),
62  neighbor_south_(NULL),
63  neighbor_east_(NULL),
64  neighbor_west_(NULL)
65 {
66  yj_ = 2.0 * ( (delta * delta) / (tau * tau * gamma * gamma) );
67  yc_ = 2.0 * ( (delta * delta) / (tau * tau * gamma * gamma) - 2.0);
68 
69  // Ensure the leak gain is negative.
70  if(leak_gain_ > 0.0)
71  {
72  leak_gain_ *= -1.0;
73  }
74 
75 //~ cout << "T = " << t << endl
76 //~ << "delta = " << delta << endl
77 //~ << "gamma = " << gamma << endl
78 //~ << "yj = " << yj_ << endl
79 //~ << "yc = " << yc_ << endl;
80 }
float64 velocity_south_
Velocity going north.
Definition: MeshJunction.h:107
float64 previous_velocity_south_
Definition: MeshJunction.h:113
float64 previous_velocity_east_
Definition: MeshJunction.h:114
float64 leak_gain_
updates junction velocity.
Definition: MeshJunction.h:102
MeshJunction * neighbor_west_
Definition: MeshJunction.h:124
MeshJunction * neighbor_south_
Definition: MeshJunction.h:122
float64 velocity_east_
Velocity going south.
Definition: MeshJunction.h:108
float64 velocity_
Leak gain.
Definition: MeshJunction.h:104
float64 velocity_west_
Velocity going east.
Definition: MeshJunction.h:109
MeshJunction * neighbor_east_
Definition: MeshJunction.h:123
float64 previous_velocity_west_
Definition: MeshJunction.h:115
float64 previous_velocity_north_
Definition: MeshJunction.h:112
float64 velocity_north_
This junction's velocity.
Definition: MeshJunction.h:106
float64 previous_velocity_
Velocity going west.
Definition: MeshJunction.h:111
MeshJunction * neighbor_north_
Definition: MeshJunction.h:121
MeshJunction::MeshJunction ( const MeshJunction copy)

This operator can not assign neighbor pointers.

Definition at line 84 of file MeshJunction.cc.

85  :
86  leak_gain_(0.0),
87  velocity_(0.0),
88  velocity_north_(0.0),
89  velocity_south_(0.0),
90  velocity_east_(0.0),
91  velocity_west_(0.0),
92  previous_velocity_(0.0),
97  vc_(0.0),
98  yj_(0.0),
99  yc_(0.0),
100  neighbor_north_(NULL),
101  neighbor_south_(NULL),
102  neighbor_east_(NULL),
103  neighbor_west_(NULL)
104 {
105  *this = copy;
106  // This operator can not assign neighbor pointers.
107 }
float64 velocity_south_
Velocity going north.
Definition: MeshJunction.h:107
float64 previous_velocity_south_
Definition: MeshJunction.h:113
float64 previous_velocity_east_
Definition: MeshJunction.h:114
float64 leak_gain_
updates junction velocity.
Definition: MeshJunction.h:102
MeshJunction * neighbor_west_
Definition: MeshJunction.h:124
MeshJunction * neighbor_south_
Definition: MeshJunction.h:122
float64 velocity_east_
Velocity going south.
Definition: MeshJunction.h:108
float64 velocity_
Leak gain.
Definition: MeshJunction.h:104
float64 velocity_west_
Velocity going east.
Definition: MeshJunction.h:109
MeshJunction * neighbor_east_
Definition: MeshJunction.h:123
float64 previous_velocity_west_
Definition: MeshJunction.h:115
float64 previous_velocity_north_
Definition: MeshJunction.h:112
float64 velocity_north_
This junction's velocity.
Definition: MeshJunction.h:106
float64 previous_velocity_
Velocity going west.
Definition: MeshJunction.h:111
MeshJunction * neighbor_north_
Definition: MeshJunction.h:121
MeshJunction::~MeshJunction ( )

Deconstructor.

Definition at line 111 of file MeshJunction.cc.

112 {
113 }

Member Function Documentation

void MeshJunction::clear ( )

Clears all velicityes in the junctino.

Definition at line 117 of file MeshJunction.cc.

References previous_velocity_, previous_velocity_east_, previous_velocity_north_, previous_velocity_south_, previous_velocity_west_, velocity_, velocity_east_, velocity_north_, velocity_south_, and velocity_west_.

Referenced by Nsound::Mesh2D::clear().

118 {
119  velocity_ =
129 }
float64 velocity_south_
Velocity going north.
Definition: MeshJunction.h:107
float64 previous_velocity_south_
Definition: MeshJunction.h:113
float64 previous_velocity_east_
Definition: MeshJunction.h:114
float64 velocity_east_
Velocity going south.
Definition: MeshJunction.h:108
float64 velocity_
Leak gain.
Definition: MeshJunction.h:104
float64 velocity_west_
Velocity going east.
Definition: MeshJunction.h:109
float64 previous_velocity_west_
Definition: MeshJunction.h:115
float64 previous_velocity_north_
Definition: MeshJunction.h:112
float64 velocity_north_
This junction's velocity.
Definition: MeshJunction.h:106
float64 previous_velocity_
Velocity going west.
Definition: MeshJunction.h:111
float64 MeshJunction::getVelocity ( ) const

Definition at line 133 of file MeshJunction.cc.

References velocity_.

Referenced by Nsound::Mesh2D::getEnergy(), Nsound::Mesh2D::strike(), and Nsound::Mesh2D::tick().

134 {
135  return velocity_;
136 }
float64 velocity_
Leak gain.
Definition: MeshJunction.h:104
MeshJunction & MeshJunction::operator= ( const MeshJunction rhs)

This operator can not assign neighbor pointers.

Definition at line 141 of file MeshJunction.cc.

References leak_gain_, previous_velocity_, previous_velocity_east_, previous_velocity_north_, previous_velocity_south_, previous_velocity_west_, vc_, velocity_, velocity_east_, velocity_north_, velocity_south_, velocity_west_, yc_, and yj_.

142 {
143  if(this == & rhs)
144  {
145  return *this;
146  }
147 
148  leak_gain_ = rhs.leak_gain_;
149 
150  velocity_ = rhs.velocity_;
151 
156 
162 
163  vc_ = rhs.vc_;
164  yj_ = rhs.yj_;
165  yc_ = rhs.yc_;
166 
167  // This operator can not assign neighbor pointers.
168 
169  return *this;
170 }
float64 velocity_south_
Velocity going north.
Definition: MeshJunction.h:107
float64 previous_velocity_south_
Definition: MeshJunction.h:113
float64 previous_velocity_east_
Definition: MeshJunction.h:114
float64 leak_gain_
updates junction velocity.
Definition: MeshJunction.h:102
float64 velocity_east_
Velocity going south.
Definition: MeshJunction.h:108
float64 velocity_
Leak gain.
Definition: MeshJunction.h:104
float64 velocity_west_
Velocity going east.
Definition: MeshJunction.h:109
float64 previous_velocity_west_
Definition: MeshJunction.h:115
float64 previous_velocity_north_
Definition: MeshJunction.h:112
float64 velocity_north_
This junction's velocity.
Definition: MeshJunction.h:106
float64 previous_velocity_
Velocity going west.
Definition: MeshJunction.h:111
void MeshJunction::setNeighborNorth ( MeshJunction ptr)

Definition at line 174 of file MeshJunction.cc.

References neighbor_north_.

Referenced by Nsound::Mesh2D::allocMemory().

175 {
176  neighbor_north_ = ptr;
177 }
MeshJunction * neighbor_north_
Definition: MeshJunction.h:121
void MeshJunction::setNeighborSouth ( MeshJunction ptr)

Definition at line 181 of file MeshJunction.cc.

References neighbor_south_.

Referenced by Nsound::Mesh2D::allocMemory().

182 {
183  neighbor_south_ = ptr;
184 }
MeshJunction * neighbor_south_
Definition: MeshJunction.h:122
void MeshJunction::setNeighborEast ( MeshJunction ptr)

Definition at line 188 of file MeshJunction.cc.

References neighbor_east_.

Referenced by Nsound::Mesh2D::allocMemory().

189 {
190  neighbor_east_ = ptr;
191 }
MeshJunction * neighbor_east_
Definition: MeshJunction.h:123
void MeshJunction::setNeighborWest ( MeshJunction ptr)

Definition at line 195 of file MeshJunction.cc.

References neighbor_west_.

Referenced by Nsound::Mesh2D::allocMemory().

196 {
197  neighbor_west_ = ptr;
198 }
MeshJunction * neighbor_west_
Definition: MeshJunction.h:124
void MeshJunction::saveState ( )

Saves previous south and east velocities.

Definition at line 214 of file MeshJunction.cc.

References previous_velocity_, previous_velocity_east_, previous_velocity_north_, previous_velocity_south_, previous_velocity_west_, velocity_, velocity_east_, velocity_north_, velocity_south_, and velocity_west_.

Referenced by Nsound::Mesh2D::tick().

215 {
221 }
float64 velocity_south_
Velocity going north.
Definition: MeshJunction.h:107
float64 previous_velocity_south_
Definition: MeshJunction.h:113
float64 previous_velocity_east_
Definition: MeshJunction.h:114
float64 velocity_east_
Velocity going south.
Definition: MeshJunction.h:108
float64 velocity_
Leak gain.
Definition: MeshJunction.h:104
float64 velocity_west_
Velocity going east.
Definition: MeshJunction.h:109
float64 previous_velocity_west_
Definition: MeshJunction.h:115
float64 previous_velocity_north_
Definition: MeshJunction.h:112
float64 velocity_north_
This junction's velocity.
Definition: MeshJunction.h:106
float64 previous_velocity_
Velocity going west.
Definition: MeshJunction.h:111
void MeshJunction::strike ( const float64 velocity)

Adds velocity to this junction.

Definition at line 202 of file MeshJunction.cc.

References velocity_, velocity_east_, velocity_north_, velocity_south_, velocity_west_, and yj_.

Referenced by Nsound::Mesh2D::tick().

203 {
204  velocity_ += velocity;
205 
206  velocity_north_ += yj_ / 8.0 * velocity;
207  velocity_south_ += yj_ / 8.0 * velocity;
208  velocity_east_ += yj_ / 8.0 * velocity;
209  velocity_west_ += yj_ / 8.0 * velocity;
210 }
float64 velocity_south_
Velocity going north.
Definition: MeshJunction.h:107
float64 velocity_east_
Velocity going south.
Definition: MeshJunction.h:108
float64 velocity_
Leak gain.
Definition: MeshJunction.h:104
float64 velocity_west_
Velocity going east.
Definition: MeshJunction.h:109
float64 velocity_north_
This junction's velocity.
Definition: MeshJunction.h:106
void MeshJunction::updateVelocity ( )

updates junction velocity.

Definition at line 225 of file MeshJunction.cc.

References neighbor_east_, neighbor_north_, neighbor_south_, neighbor_west_, previous_velocity_east_, previous_velocity_north_, previous_velocity_south_, previous_velocity_west_, updateBoundry(), vc_, velocity_, velocity_east_, velocity_north_, velocity_south_, velocity_west_, yc_, and yj_.

Referenced by Nsound::Mesh2D::tick().

226 {
231  + yc_ * vc_);
232 
233  if(neighbor_north_)
234  {
236  }
237 
238  if(neighbor_south_)
239  {
241  }
242 
243  if(neighbor_west_)
244  {
246  }
247 
248  if(neighbor_east_)
249  {
251  }
252 
253  vc_ = velocity_ - vc_;
254 
255  updateBoundry();
256 
257 }
float64 velocity_south_
Velocity going north.
Definition: MeshJunction.h:107
float64 previous_velocity_south_
Definition: MeshJunction.h:113
float64 previous_velocity_east_
Definition: MeshJunction.h:114
MeshJunction * neighbor_west_
Definition: MeshJunction.h:124
MeshJunction * neighbor_south_
Definition: MeshJunction.h:122
float64 velocity_east_
Velocity going south.
Definition: MeshJunction.h:108
float64 velocity_
Leak gain.
Definition: MeshJunction.h:104
float64 velocity_west_
Velocity going east.
Definition: MeshJunction.h:109
MeshJunction * neighbor_east_
Definition: MeshJunction.h:123
float64 previous_velocity_west_
Definition: MeshJunction.h:115
float64 previous_velocity_north_
Definition: MeshJunction.h:112
float64 velocity_north_
This junction's velocity.
Definition: MeshJunction.h:106
MeshJunction * neighbor_north_
Definition: MeshJunction.h:121
void MeshJunction::updateBoundry ( )
private

Definition at line 262 of file MeshJunction.cc.

References leak_gain_, neighbor_east_, neighbor_north_, neighbor_south_, neighbor_west_, velocity_east_, velocity_north_, velocity_south_, and velocity_west_.

Referenced by updateVelocity().

263 {
264  if(neighbor_north_ == NULL)
265  {
266  float64 vtemp = velocity_north_;
267 
269 
270  if(neighbor_south_)
271  {
273  }
274 
275  }
276 
277  if(neighbor_south_ == NULL)
278  {
279  float64 vtemp = velocity_south_;
280 
281  velocity_south_ = leak_gain_ * velocity_north_;
282 
283  if(neighbor_north_)
284  {
286  }
287 
288  }
289 
290  if(neighbor_east_ == NULL)
291  {
292  float64 vtemp = velocity_east_;
293 
295 
296  if(neighbor_west_)
297  {
299  }
300 
301  }
302 
303  if(neighbor_west_ == NULL)
304  {
305  float64 vtemp = velocity_west_;
306 
307  velocity_west_ = leak_gain_ * velocity_east_;
308 
309  if(neighbor_east_)
310  {
312  }
313 
314  }
315 }
float64 velocity_south_
Velocity going north.
Definition: MeshJunction.h:107
float64 leak_gain_
updates junction velocity.
Definition: MeshJunction.h:102
MeshJunction * neighbor_west_
Definition: MeshJunction.h:124
MeshJunction * neighbor_south_
Definition: MeshJunction.h:122
float64 velocity_east_
Velocity going south.
Definition: MeshJunction.h:108
double float64
Definition: Nsound.h:146
float64 velocity_west_
Velocity going east.
Definition: MeshJunction.h:109
MeshJunction * neighbor_east_
Definition: MeshJunction.h:123
float64 velocity_north_
This junction's velocity.
Definition: MeshJunction.h:106
MeshJunction * neighbor_north_
Definition: MeshJunction.h:121

Member Data Documentation

float64 Nsound::MeshJunction::leak_gain_
private

updates junction velocity.

Definition at line 102 of file MeshJunction.h.

Referenced by MeshJunction(), operator=(), and updateBoundry().

float64 Nsound::MeshJunction::velocity_
private

Leak gain.

Definition at line 104 of file MeshJunction.h.

Referenced by clear(), getVelocity(), operator=(), saveState(), strike(), and updateVelocity().

float64 Nsound::MeshJunction::velocity_north_
private

This junction's velocity.

Definition at line 106 of file MeshJunction.h.

Referenced by clear(), operator=(), saveState(), strike(), updateBoundry(), and updateVelocity().

float64 Nsound::MeshJunction::velocity_south_
private

Velocity going north.

Definition at line 107 of file MeshJunction.h.

Referenced by clear(), operator=(), saveState(), strike(), updateBoundry(), and updateVelocity().

float64 Nsound::MeshJunction::velocity_east_
private

Velocity going south.

Definition at line 108 of file MeshJunction.h.

Referenced by clear(), operator=(), saveState(), strike(), updateBoundry(), and updateVelocity().

float64 Nsound::MeshJunction::velocity_west_
private

Velocity going east.

Definition at line 109 of file MeshJunction.h.

Referenced by clear(), operator=(), saveState(), strike(), updateBoundry(), and updateVelocity().

float64 Nsound::MeshJunction::previous_velocity_
private

Velocity going west.

Definition at line 111 of file MeshJunction.h.

Referenced by clear(), operator=(), and saveState().

float64 Nsound::MeshJunction::previous_velocity_north_
private

Definition at line 112 of file MeshJunction.h.

Referenced by clear(), operator=(), saveState(), and updateVelocity().

float64 Nsound::MeshJunction::previous_velocity_south_
private

Definition at line 113 of file MeshJunction.h.

Referenced by clear(), operator=(), saveState(), and updateVelocity().

float64 Nsound::MeshJunction::previous_velocity_east_
private

Definition at line 114 of file MeshJunction.h.

Referenced by clear(), operator=(), saveState(), and updateVelocity().

float64 Nsound::MeshJunction::previous_velocity_west_
private

Definition at line 115 of file MeshJunction.h.

Referenced by clear(), operator=(), saveState(), and updateVelocity().

float64 Nsound::MeshJunction::vc_
private

Definition at line 117 of file MeshJunction.h.

Referenced by operator=(), and updateVelocity().

float64 Nsound::MeshJunction::yj_
private

Definition at line 118 of file MeshJunction.h.

Referenced by MeshJunction(), operator=(), strike(), and updateVelocity().

float64 Nsound::MeshJunction::yc_
private

Definition at line 119 of file MeshJunction.h.

Referenced by MeshJunction(), operator=(), and updateVelocity().

MeshJunction* Nsound::MeshJunction::neighbor_north_
private

Definition at line 121 of file MeshJunction.h.

Referenced by setNeighborNorth(), updateBoundry(), and updateVelocity().

MeshJunction* Nsound::MeshJunction::neighbor_south_
private

Definition at line 122 of file MeshJunction.h.

Referenced by setNeighborSouth(), updateBoundry(), and updateVelocity().

MeshJunction* Nsound::MeshJunction::neighbor_east_
private

Definition at line 123 of file MeshJunction.h.

Referenced by setNeighborEast(), updateBoundry(), and updateVelocity().

MeshJunction* Nsound::MeshJunction::neighbor_west_
private

Definition at line 124 of file MeshJunction.h.

Referenced by setNeighborWest(), updateBoundry(), and updateVelocity().


The documentation for this class was generated from the following files: