MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Box Class Reference

#include <Box.h>

Public Member Functions

 Box (int maxLevel, int nTerms)
 
void addPanel (int level, Panel *panel)
 
void upwardPass ()
 
void downwardPass ()
 
void computeFlow (int k)
 
int getMaxLevel ()
 
int getNrPanelsOnLevel (int level)
 
int getNumberOfTerms ()
 

Private Attributes

int maxLevel_
 
int p_
 
std::vector< std::vector
< Panel * > > 
levels_
 
std::vector< Sphere * > spheres_
 

Detailed Description

Definition at line 31 of file Box.h.

Constructor & Destructor Documentation

Box::Box ( int  maxLevel,
int  nTerms 
)

Definition at line 30 of file Box.cc.

References levels_.

30  : maxLevel_(maxLevel), p_(nTerms)
31 {
32  for (int iL = 0; iL <= maxLevel; iL++)
33  {
34  std::vector<Panel*>* boxLevel = new std::vector<Panel*>;
35  levels_.push_back(*boxLevel);
36  }
37 }
int maxLevel_
Definition: Box.h:61
int p_
Definition: Box.h:62
std::vector< std::vector< Panel * > > levels_
Definition: Box.h:63

Member Function Documentation

void Box::addPanel ( int  level,
Panel panel 
)

Definition at line 39 of file Box.cc.

References levels_.

Referenced by Panel::Panel().

40 {
41  levels_[level].push_back(panel);
42 }
std::vector< std::vector< Panel * > > levels_
Definition: Box.h:63
void Box::computeFlow ( int  k)

Definition at line 109 of file Box.cc.

References downwardPass(), constants::i, levels_, maxLevel_, p_, spheres_, and upwardPass().

110 {
111  //***************************************
112  //* Initialise spheres *
113  //***************************************
114 
115  // The first step is to add dipoles with correct location and strengths in the domain
116  // All dipoles in the domain are now expanded into multipoles
117  std::cout << "Initialising spheres" << std::endl;
118  upwardPass();
119  downwardPass();
120 
121  //For all panels on the finest level
122  for (Panel* panel : levels_[maxLevel_])
123  {
124  //For all dipoles on the finest level
125  for (Dipole* iD : panel->getDipoles())
126  {
127  // Add a multipole in the domain
128  //Multipole* multipole = new Multipole(iD->getP, iD->getSquaredFactorials, iD->getLocation());
129  //panel->multipoles_.push_back(multipole);
130 
131  // Construct a sphere
132  //Sphere* sphere = new Sphere(panel, iD->getLocation(), iD, multipole);
133 
134  // Add the sphere to the list of spheres and to the panel list
135  //spheres_.push_back(sphere);
136  //spheres_.push_back(sphere);
137  }
138  }
139 
140  //***********************************
141  //* Compue Mirror Multipoles *
142  //***********************************
143 
144 
145  // Compute k order mirrors
146  for (int i = 1; k <= i; i++)
147  {
148  //For all panels on the finest level
149  for (Panel* panel : levels_[maxLevel_])
150  {
151  // For all spheres: add a new multipole to the centre of a sphere to compensate
152  for (Sphere* sphere : panel->getSpheres())
153  {
154  std::vector<std::complex<Mdouble>> localExpansionAroundSphere;
155  Vec3D sphereCentre = sphere->getLocation();
156 
157  // Compute panel local expansion around sphere
158  //localExpansionAroundSphere = panel->localExpansionAroundCentre_->translateLocalExpansion(sphereCentre);
159 
160  // Compute other sphere local expansion around sphere
161  for (Sphere* sphereOther: spheres_)
162  {
163  if (sphereOther != sphere)
164  {
165  // todo: implement this shizzle
166  //localExpansionAroundSphere += sphereOther->multipole_->convertMultipoleToLocal(sphereCentre);
167  }
168  }
169  // Compute multipole
170  size_t nTerms = (p_ + 1) * (p_ + 1);
171  NumericalVector<std::complex<Mdouble>> multipoleExpansionCoefficients(nTerms);
172  for (int n = 0; n <= p_; n++)
173  {
174  for (int m = -n; m <= n; m++)
175  {
176  int location = n * n + (m + n);
177  //multipoleExpansionCoefficients[location] = localExpansionAroundSphere[0]*n/(n+1)*std::pow(sphere->getRadius,2n+1);
178  }
179  }
180  //sphere->multipole_->setExpansionCoefficients(multipoleExpansionCoefficients);
181  }
182  }
183 
184  //Perform and upward and downward pass to compute the new coefficients
185  upwardPass();
186  downwardPass();
187  }
188 
189 
190 }
Definition: Panel.h:42
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
Definition: Dipole.h:34
void upwardPass()
Definition: Box.cc:44
int maxLevel_
Definition: Box.h:61
int p_
Definition: Box.h:62
std::vector< std::vector< Panel * > > levels_
Definition: Box.h:63
Definition: Sphere.h:34
std::vector< Sphere * > spheres_
Definition: Box.h:64
Definition: Vector.h:49
void downwardPass()
Definition: Box.cc:68
void Box::downwardPass ( )

Definition at line 68 of file Box.cc.

References levels_, and maxLevel_.

Referenced by Panel::computeCoefficients(), and computeFlow().

69 {
70  std::cout << "============================" << std::endl;
71  std::cout << "Starting the downward pass." << std::endl;
72 
73  //Set the first part of the local expansion to zero: everything is in the interaction list or closer
74  NumericalVector<std::complex<Mdouble>> localExpansionCoefficients;
75  for (Panel* panel : levels_[1])
76  {
77  panel->setLocalExpansionZero();
78  }
79 
80  // Compute all local expansions for intermediate levels
81  for (int iL = 1; iL < maxLevel_; iL++)
82  {
83  std::cout << "Computing nearby Local Expansions on level " << iL << "." << std::endl;
84  for (Panel* panel : levels_[iL])
85  {
86  panel->computePartialLocalExpansion();
87  panel->computeLocalExpansion();
88 
89  }
90 
91  std::cout << "Translating local expansions to children" << std::endl;
92  for (Panel* panel : levels_[iL])
93  {
94  panel->translateLocalExpansion();
95  }
96  }
97 
98  // Compute local expansions for the remaining interaction list on the finest level
99  std::cout << "Computing nearby local expansions on finest level " << std::endl;
100  for (Panel* panel : levels_[maxLevel_])
101  {
102  panel->computePartialLocalExpansion();
103  panel->computeLocalExpansion();
104  }
105 
106  std::cout << "Finished downward pass." << std::endl;
107 }
Definition: Panel.h:42
int maxLevel_
Definition: Box.h:61
std::vector< std::vector< Panel * > > levels_
Definition: Box.h:63
int Box::getMaxLevel ( )
inline

Definition at line 44 of file Box.h.

References maxLevel_.

45  {
46  return maxLevel_;
47  }
int maxLevel_
Definition: Box.h:61
int Box::getNrPanelsOnLevel ( int  level)
inline
Todo:
some ints here should be unsigned long

Definition at line 50 of file Box.h.

References levels_.

51  {
52  return levels_[level].size();
53  }
std::vector< std::vector< Panel * > > levels_
Definition: Box.h:63
int Box::getNumberOfTerms ( )
inline

Definition at line 55 of file Box.h.

References p_.

Referenced by Panel::Panel().

56  {
57  return p_;
58  }
int p_
Definition: Box.h:62
void Box::upwardPass ( )

Definition at line 44 of file Box.cc.

References levels_, and maxLevel_.

Referenced by Panel::computeCoefficients(), and computeFlow().

45 {
46  std::cout << "============================" << std::endl;
47  std::cout << "Starting the upward pass." << std::endl;
48  // Perform a multipole expansion about the centre of all panels located on the finest mesh
49  std::cout << "Computing multipole expansion on finest level." << std::endl;
50  for (Panel* panel : levels_[maxLevel_])
51  {
52  panel->computeMultipoleExpansion();
53  }
54 
55  // Perform an upward pass, each level combine the previous level multipole expansions by shifting them to the centre of the current panel
56  for (int iL = maxLevel_ - 1; iL >= 0; iL--)
57  {
58  std::cout << "Shifting multipole expansions on level " << iL << "." << std::endl;
59  for (Panel* panel : levels_[iL])
60  {
61  panel->translateMultipoleExpansion();
62  }
63  }
64  std::cout << "Finished upward pass." << std::endl;
65 
66 }
Definition: Panel.h:42
int maxLevel_
Definition: Box.h:61
std::vector< std::vector< Panel * > > levels_
Definition: Box.h:63

Member Data Documentation

std::vector<std::vector<Panel*> > Box::levels_
private

Definition at line 63 of file Box.h.

Referenced by addPanel(), Box(), computeFlow(), downwardPass(), getNrPanelsOnLevel(), and upwardPass().

int Box::maxLevel_
private

Definition at line 61 of file Box.h.

Referenced by computeFlow(), downwardPass(), getMaxLevel(), and upwardPass().

int Box::p_
private

Definition at line 62 of file Box.h.

Referenced by computeFlow(), and getNumberOfTerms().

std::vector<Sphere*> Box::spheres_
private

Definition at line 64 of file Box.h.

Referenced by computeFlow().


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