orsa_interaction_tree.cc File Reference

#include "orsa_interaction.h"
#include "orsa_secure_math.h"
#include "orsa_universe.h"
#include <iostream>
#include <list>
#include <stack>
#include <map>

Include dependency graph for orsa_interaction_tree.cc:

Go to the source code of this file.

Namespaces

namespace  orsa

Functions

double delta_function (const unsigned int i, const unsigned int j)
Vector ComputeAcceleration (const list< Body >::const_iterator body_it, const list< TreeNode >::const_iterator node_domain_it, const bool compute_quadrupole=true)


Function Documentation

Vector ComputeAcceleration const list< Body >::const_iterator  body_it,
const list< TreeNode >::const_iterator  node_domain_it,
const bool  compute_quadrupole = true
 

Definition at line 96 of file orsa_interaction_tree.cc.

References Vector::IsZero(), Vector::LengthSquared(), orsa::secure_pow(), Vector::x, Vector::y, and Vector::z.

Referenced by GravitationalTree::Acceleration().

00096                                                                                                                                                             {
00097     
00098     Vector a;
00099     
00100     if (node_domain_it->node_mass()==0.0) return a;
00101     
00102     Vector d = node_domain_it->node_center_of_mass() - body_it->position();
00103     
00104     // monopole
00105     
00106     const double l2 = d.LengthSquared();
00107     
00108     if (d.IsZero()) {
00109       cerr << "*** Warning: two objects in the same position! (" << l2 << ")" << endl;
00110       // continue;
00111       return a;
00112     }
00113     
00114     a += d * secure_pow(l2,-1.5) * node_domain_it->node_mass();
00115     
00116     if (!compute_quadrupole) {
00117       return a;
00118     }
00119     
00120     // quadrupole
00121     
00122     double x[3];
00123     
00124     x[0] = d.x;
00125     x[1] = d.y;
00126     x[2] = d.z;
00127     
00128     double coefficient = 0.0;
00129     unsigned int i,j;
00130     double c_node_quadrupole[3][3];
00131     memcpy((void*)c_node_quadrupole, (const void*)node_domain_it->node_quadrupole(), 3*3*sizeof(double)); // works?
00132     for (i=0;i<3;++i) {
00133       for (j=0;j<3;++j) {
00134         coefficient += c_node_quadrupole[i][j]*x[i]*x[j];
00135       }
00136     }
00137     
00138     a += d * secure_pow(l2,-3.0) * coefficient;
00139     
00140     return a;
00141   }

Here is the call graph for this function:

double delta_function const unsigned int  i,
const unsigned int  j
 

Definition at line 91 of file orsa_interaction_tree.cc.

00091                                                                     {
00092     if (i==j) return 1.0;
00093     return 0.0;
00094   }


Generated on Tue Jan 11 15:27:05 2005 for liborsa by  doxygen 1.4.0