Panel Class Reference

#include <Panel.h>

Public Member Functions

 Panel (Panel *root, int maximumPanelLevel, Vec3D leftBound, Vec3D rightBound, std::vector< Source * > sources, std::vector< Dipole * > dipoles, NumericalVector<> *squaredFactorials, Box *box)
 
void initialise ()
 
void computeCoefficients ()
 
void createPanels (int dim, std::vector< Source * > &sources, std::vector< Dipole * > &dipoles, Vec3D &leftBoundChild, Vec3D &rightBoundChild, NumericalVector<> *squaredFactorials)
 
void findPanelInteractions ()
 
void setPanelInteractions ()
 
void computeMultipoleExpansion ()
 
void translateMultipoleExpansion ()
 
void setLocalExpansionZero ()
 
void computePartialLocalExpansion ()
 
void translateLocalExpansion ()
 
void computeLocalExpansion ()
 
Vec3D getCentre ()
 
PanelgetRoot ()
 
std::vector< Panel * > getChilderen ()
 
std::vector< Panel * > getNeighbours ()
 
std::vector< Panel * > getSecondNeighbours ()
 
std::vector< Panel * > getInteractionList ()
 
std::vector< Source * > getSources ()
 
SourcegetSource (int index)
 
std::vector< Dipole * > getDipoles ()
 
std::vector< Multipole * > getMultipoles ()
 
std::vector< Sphere * > getSpheres ()
 
int getPanelLevel ()
 
NumericalVector< std::complex< Mdouble > > getPartialLocalExpansion ()
 
NumericalVector< std::complex< Mdouble > > getLocalExpansion ()
 

Private Attributes

const int panelLevel_
 
Mdouble dim_
 
Vec3D leftBound_
 
Vec3D rightBound_
 
double size_
 
Vec3D centre_
 
Panelroot_ = nullptr
 
std::vector< Panel * > childeren_
 
std::vector< Panel * > neighbours_
 
std::vector< Panel * > secondNeighbours_
 
std::vector< Panel * > interactionList_
 
std::vector< Source * > sources_
 
std::vector< Dipole * > dipoles_
 
std::vector< Multipole * > multipoles_
 
std::vector< Sphere * > spheres_
 
Boxbox_
 
MultipolemultipoleAroundCentre_
 
LocalExpansionpartialLocalExpansionAroundCentre_
 
LocalExpansionlocalExpansionAroundCentre_
 
NumericalVector< std::complex< Mdouble > > partialLocalExpansion_
 
NumericalVector< std::complex< Mdouble > > localExpansion_
 

Constructor & Destructor Documentation

◆ Panel()

Panel::Panel ( Panel root,
int  maximumPanelLevel,
Vec3D  leftBound,
Vec3D  rightBound,
std::vector< Source * >  sources,
std::vector< Dipole * >  dipoles,
NumericalVector<> *  squaredFactorials,
Box box 
)
44  :
45  panelLevel_(panelLevel),
46  leftBound_(leftBound),
47  rightBound_(rightBound),
48  root_(root),
49  sources_(sources),
50  dipoles_(dipoles),
51  box_(box)
52 {
53  //Initialise the panel characteristics
54  // I am using Vec3D, so the size is always constant
55 /* if (leftBound.size() != rightBound.size())
56  {
57  std::cout << "Bounds are not of correct dimensions" << std::endl;
58  std::exit(-1);
59  }*/
60 
61  // This code only works for 3D problems, since the maths is significantly different from 2D and 1D
62  // The datastructure however allows for 1D and 2D structures,
63  // In future 2D support might be added (by a master student?)
64  dim_ = 3;
65 
66  // The panel is a cube with same size in all directions
67  // Note this is half the length of a cube side
68  size_ = 0.5 * (rightBound.getComponent(0) - leftBound.getComponent(0));
69 
70  // Determine the centre
71  for (int iD = 0; iD < dim_; iD++)
72  {
73  centre_.setComponent(iD, (leftBound.getComponent(iD) + size_));
74  }
75 
76  //Add panel to the complete box
77  box->addPanel(panelLevel, this);
78 
79  //Set multipole and local expansion coefficients
80  multipoleAroundCentre_ = new Multipole(box_->getNumberOfTerms(), squaredFactorials, centre_);
81  multipoleAroundCentre_->computeMultipoleExpansion(); // Set vector with zeros to correct length
83  partialLocalExpansionAroundCentre_->initialiseLocalExpansion(); // Set vector with zeros to correct length
85  localExpansionAroundCentre_->initialiseLocalExpansion(); // Set vector with zeros to correct length
86 
87  //Create childeren based on the given dimensions;
88  if (panelLevel < box->getMaxLevel()) // final level is obtained if this value is 0
89  {
90  //Note: For an adaptive grid, add a check to see if this panel contains enough sources to have childeren.
91 
92  Vec3D leftBoundChild;
93  Vec3D rightBoundChild;
94 
95  createPanels(1, sources, dipoles, leftBoundChild, rightBoundChild, squaredFactorials);
96  }
97 
98 }
void addPanel(int level, Panel *panel)
Definition: Box.cc:39
int getNumberOfTerms()
Definition: Box.h:55
Definition: LocalExpansion.h:35
void initialiseLocalExpansion()
Definition: LocalExpansion.cc:43
Definition: Multipole.h:34
virtual void computeMultipoleExpansion()
Definition: Multipole.cc:43
const int panelLevel_
Definition: Panel.h:155
std::vector< Source * > sources_
Definition: Panel.h:170
Panel * root_
Definition: Panel.h:163
Vec3D leftBound_
Definition: Panel.h:157
void createPanels(int dim, std::vector< Source * > &sources, std::vector< Dipole * > &dipoles, Vec3D &leftBoundChild, Vec3D &rightBoundChild, NumericalVector<> *squaredFactorials)
Definition: Panel.cc:100
double size_
Definition: Panel.h:159
Vec3D centre_
Definition: Panel.h:160
std::vector< Dipole * > dipoles_
Definition: Panel.h:171
LocalExpansion * partialLocalExpansionAroundCentre_
Definition: Panel.h:183
Vec3D rightBound_
Definition: Panel.h:158
Mdouble dim_
Definition: Panel.h:156
LocalExpansion * localExpansionAroundCentre_
Definition: Panel.h:184
Multipole * multipoleAroundCentre_
Definition: Panel.h:182
Box * box_
Definition: Panel.h:178
Definition: Vector.h:51
Mdouble getComponent(int index) const
Returns the requested component of this Vec3D.
Definition: Vector.cc:194
void setComponent(int index, double val)
Sets the requested component of this Vec3D to the requested value.
Definition: Vector.cc:217

References Box::addPanel(), box_, centre_, Multipole::computeMultipoleExpansion(), createPanels(), dim_, Vec3D::getComponent(), Box::getNumberOfTerms(), LocalExpansion::initialiseLocalExpansion(), localExpansionAroundCentre_, multipoleAroundCentre_, partialLocalExpansionAroundCentre_, Vec3D::setComponent(), and size_.

Referenced by createPanels().

Member Function Documentation

◆ computeCoefficients()

void Panel::computeCoefficients ( )
171 {
172  //Start upward pass creating multipole methods and shifting them on parent panels
173  box_->upwardPass();
174 
175  //Start the downward pass
176  box_->downwardPass();
177 }
void downwardPass()
Definition: Box.cc:68
void upwardPass()
Definition: Box.cc:44

References box_, Box::downwardPass(), and Box::upwardPass().

◆ computeLocalExpansion()

void Panel::computeLocalExpansion ( )
308 {
311  );
312 }
NumericalVector< std::complex< Mdouble > > getExpansionCoefficients()
Definition: LocalExpansion.h:50
void addLocalExpansionCoefficients(NumericalVector< std::complex< Mdouble >> localExpansionCoefficients)
Definition: LocalExpansion.cc:100

References LocalExpansion::addLocalExpansionCoefficients(), LocalExpansion::getExpansionCoefficients(), localExpansionAroundCentre_, and partialLocalExpansionAroundCentre_.

◆ computeMultipoleExpansion()

void Panel::computeMultipoleExpansion ( )

Source: perform a multipole expansion around the centre of the box

Dipole: perform a multipole expansion around the centre of the box

Multipole: Transfer a multipole in the box to the centre of the box

251 {
252 
254  // todo: write this part of the code
255  // A source can be expanded around the centre of the panel without translations
256  //add(iS->computeMultipoleExpansion();)
257 
259  for (Dipole* iD : dipoles_)
260  {
261  //Convert to a multipole
262  //todo: This must be done when the actual dipole is made.
263  iD->computeMultipoleExpansion();
264 
265  //Translate multipole to centre of the panel
266  multipoleAroundCentre_->addMultipoleCoefficients(iD->TranslateMultipoleExpansionTo(centre_));
267 
268  }
269 
271  for (Multipole* iM : multipoles_)
272  {
273  multipoleAroundCentre_->addMultipoleCoefficients(iM->TranslateMultipoleExpansionTo(centre_));
274  }
275 
276 }
Definition: Dipole.h:35
void addMultipoleCoefficients(NumericalVector< std::complex< Mdouble >> multipoleExpansionCoefficients)
Definition: Multipole.cc:153
std::vector< Multipole * > multipoles_
Definition: Panel.h:172

References Multipole::addMultipoleCoefficients(), centre_, dipoles_, multipoleAroundCentre_, and multipoles_.

◆ computePartialLocalExpansion()

void Panel::computePartialLocalExpansion ( )
297 {
298  //For all panels in the interactionlist, add a local expansion of the multipole to the partialLocalExpansion
299  for (Panel* panel : interactionList_)
300  {
302  panel->multipoleAroundCentre_->convertMultipoleToLocal(centre_)
303  );
304  }
305 }
Definition: Panel.h:43
std::vector< Panel * > interactionList_
Definition: Panel.h:167

References LocalExpansion::addLocalExpansionCoefficients(), centre_, interactionList_, and partialLocalExpansionAroundCentre_.

◆ createPanels()

void Panel::createPanels ( int  dim,
std::vector< Source * > &  sources,
std::vector< Dipole * > &  dipoles,
Vec3D leftBoundChild,
Vec3D rightBoundChild,
NumericalVector<> *  squaredFactorials 
)
106 {
107  std::vector<Source*> sourcesChild;
108  std::vector<Dipole*> dipolesChild;
109 
110 
111  for (int iSide = 0; iSide < 2; ++iSide)
112  {
113  //Determine the x boundaries
114  leftBoundChild.setComponent(dim - 1, (leftBound_.getComponent(dim - 1) + size_ * iSide));
115  rightBoundChild.setComponent(dim - 1, (leftBoundChild.getComponent(dim - 1) + size_));
116 
117  //Determine the sources in this domain
118  for (Source* iS : sources)
119  {
120  if ((iS->getLocation().getComponent(dim - 1) > leftBoundChild.getComponent(dim - 1)) &&
121  (iS->getLocation().getComponent(dim - 1) <= rightBoundChild.getComponent(dim - 1)))
122  {
123  sourcesChild.push_back(iS);
124  }
125  }
126 
127  //Determine the dipoles in this domain
128  for (Dipole* iD : dipoles)
129  {
130  if ((iD->getLocation().getComponent(dim - 1) > leftBoundChild.getComponent(dim - 1)) &&
131  (iD->getLocation().getComponent(dim - 1) <= rightBoundChild.getComponent(dim - 1)))
132  {
133  dipolesChild.push_back(iD);
134  }
135  }
136 
137  if (dim != dim_)
138  {
139  createPanels(dim + 1, sourcesChild, dipolesChild, leftBoundChild, rightBoundChild, squaredFactorials);
140  }
141  else
142  {
143  //Create childeren
144 /* std::cout << "Creating a child with bounds: " << std::endl;
145  std::cout << "In x-direction: " << std::endl;
146  std::cout << "Left bound: " << leftBoundChild[0] << " and right bound: " << rightBoundChild[0] << std::endl;
147  std::cout << "In y-direction: " << std::endl;
148  std::cout << "Left bound: " << leftBoundChild[1] << " and right bound: " << rightBoundChild[1] << std::endl;
149  std::cout << "In z-direction: " << std::endl;
150  std::cout << "Left bound: " << leftBoundChild[2] << " and right bound: " << rightBoundChild[2] << std::endl;
151  std::cout << "Child contains " << sourcesChild.size() << " sources" << std::endl;
152  std::cout << "==============" << std::endl;*/
153  Panel* child = new Panel(this, panelLevel_ + 1, leftBoundChild, rightBoundChild, sourcesChild, dipolesChild,
154  squaredFactorials, box_);
155  childeren_.push_back(child);
156 
157  //reset leftBoundChild and rightBoundChild
158  }
159  sourcesChild.clear();
160  }
161 }
std::vector< Panel * > childeren_
Definition: Panel.h:164
Panel(Panel *root, int maximumPanelLevel, Vec3D leftBound, Vec3D rightBound, std::vector< Source * > sources, std::vector< Dipole * > dipoles, NumericalVector<> *squaredFactorials, Box *box)
Definition: Panel.cc:37
Definition: Source.h:34

References box_, childeren_, dim_, Vec3D::getComponent(), leftBound_, Panel(), panelLevel_, Vec3D::setComponent(), and size_.

Referenced by Panel().

◆ findPanelInteractions()

void Panel::findPanelInteractions ( )
180 {
181  if (getRoot() == nullptr)
182  {
183  //nothing happens
184  }
185  else
186  {
187  //Crate the links between panels
188  this->setPanelInteractions();
189  }
190 
191  //Initialise child panels
192  for (Panel* iP : childeren_)
193  {
194  iP->findPanelInteractions();
195  }
196 }
Panel * getRoot()
Definition: Panel.h:88
void setPanelInteractions()
Definition: Panel.cc:198

References childeren_, getRoot(), and setPanelInteractions().

Referenced by initialise().

◆ getCentre()

Vec3D Panel::getCentre ( )
inline
84  {
85  return centre_;
86  }

References centre_.

◆ getChilderen()

std::vector<Panel*> Panel::getChilderen ( )
inline
94  {
95  return childeren_;
96  }

References childeren_.

Referenced by setPanelInteractions().

◆ getDipoles()

std::vector<Dipole*> Panel::getDipoles ( )
inline
124  {
125  return dipoles_;
126  }

References dipoles_.

◆ getInteractionList()

std::vector<Panel*> Panel::getInteractionList ( )
inline
109  {
110  return interactionList_;
111  }

References interactionList_.

◆ getLocalExpansion()

NumericalVector<std::complex<Mdouble> > Panel::getLocalExpansion ( )
inline
149  {
150  return localExpansion_;
151  }
NumericalVector< std::complex< Mdouble > > localExpansion_
Definition: Panel.h:186

References localExpansion_.

◆ getMultipoles()

std::vector<Multipole*> Panel::getMultipoles ( )
inline
129  {
130  return multipoles_;
131  }

References multipoles_.

◆ getNeighbours()

std::vector<Panel*> Panel::getNeighbours ( )
inline
99  {
100  return neighbours_;
101  }
std::vector< Panel * > neighbours_
Definition: Panel.h:165

References neighbours_.

Referenced by setPanelInteractions().

◆ getPanelLevel()

int Panel::getPanelLevel ( )
inline
139  {
140  return panelLevel_;
141  }

References panelLevel_.

◆ getPartialLocalExpansion()

NumericalVector<std::complex<Mdouble> > Panel::getPartialLocalExpansion ( )
inline
144  {
145  return partialLocalExpansion_;
146  }
NumericalVector< std::complex< Mdouble > > partialLocalExpansion_
Definition: Panel.h:185

References partialLocalExpansion_.

◆ getRoot()

Panel* Panel::getRoot ( )
inline
89  {
90  return root_;
91  }

References root_.

Referenced by findPanelInteractions().

◆ getSecondNeighbours()

std::vector<Panel*> Panel::getSecondNeighbours ( )
inline
104  {
105  return secondNeighbours_;
106  }
std::vector< Panel * > secondNeighbours_
Definition: Panel.h:166

References secondNeighbours_.

Referenced by setPanelInteractions().

◆ getSource()

Source* Panel::getSource ( int  index)
inline
119  {
120  return sources_[index];
121  }

References sources_.

◆ getSources()

std::vector<Source*> Panel::getSources ( )
inline
114  {
115  return sources_;
116  }

References sources_.

◆ getSpheres()

std::vector<Sphere*> Panel::getSpheres ( )
inline
134  {
135  return spheres_;
136  }
std::vector< Sphere * > spheres_
Definition: Panel.h:175

References spheres_.

◆ initialise()

void Panel::initialise ( )
164 {
165  //Create neighbour list and interaction list
167 
168 }
void findPanelInteractions()
Definition: Panel.cc:179

References findPanelInteractions().

◆ setLocalExpansionZero()

void Panel::setLocalExpansionZero ( )
292 {
293  //Note: nothing has to be done here, the current implementation initialises all local expansions with 0.
294 }

◆ setPanelInteractions()

void Panel::setPanelInteractions ( )
199 {
200  //Childeren of a parent are always a neighbour of eachother
201  //Note: by definition, a panel is always a neighbour of itself
202  for (Panel* iC : root_->getChilderen())
203  {
204  neighbours_.push_back(iC);
205  }
206 
207  //For all the neighbours of the parent of this panel
208  for (Panel* iN : root_->getNeighbours())
209  {
210  //For all their childeren, check if the childeren are a neighbour or a second neighbour of this panel
211  // Note that all second neighbour panels are also childeren of these paretn neighbours
212  for (Panel* iC : iN->getChilderen())
213  {
214  //Compute distance between the centre of the current panel and possible neighbour panel
215  Mdouble distance = Vec3D::getDistance(iC->getCentre(), this->getCentre());
216 
217  //Check if the possible neighbour panel is close enough
218  if (distance < 3.0 * size_) //warning: slight hack. I assume all sides are equally long
219  {
220  neighbours_.push_back(iC);
221  //std::cout << "A neighbour has been created with a centre around: (" << iC->getCentre()[0] << "," << iC->getCentre()[1] << ")" << std::endl;
222  //std::cout << "Current panel has centre: (" << this->getCentre()[0] << "," << this->getCentre()[1] << ")" << std::endl;
223  //std::cout << "===============" << std::endl;
224  }
225  else if (distance < 6.0 * size_)
226  {
227  secondNeighbours_.push_back(iC);
228  }
229  else
230  {
231  // If it is not a neighbour or nearest neighbour, it belongs to the interactionlist group
232  interactionList_.push_back(iC);
233  //std::cout << "A panel is added to the interactionlist with a centre around: (" << iC->getCentre()[0] << "," << iC->getCentre()[1] << ")" << std::endl;
234  //std::cout << "Current panel has centre: (" << this->getCentre()[0] << "," << this->getCentre()[1] << ")" << std::endl;
235  //std::cout << "===============" << std::endl;
236  }
237  }
238  }
239 
240  // All childeren of the second nearest neighbour of the current panel's parent, are in the interactionlist
241  for (Panel* iN : root_->getSecondNeighbours())
242  {
243  for (Panel* iC : iN->getChilderen())
244  {
245  secondNeighbours_.push_back(iC);
246  }
247  }
248 }
double Mdouble
Definition: GeneralDefine.h:34
std::vector< Panel * > getNeighbours()
Definition: Panel.h:98
std::vector< Panel * > getSecondNeighbours()
Definition: Panel.h:103
std::vector< Panel * > getChilderen()
Definition: Panel.h:93
static Mdouble getDistance(const Vec3D &a, const Vec3D &b)
Calculates the distance between two Vec3D: .
Definition: Vector.cc:175

References getChilderen(), Vec3D::getDistance(), getNeighbours(), getSecondNeighbours(), interactionList_, neighbours_, root_, secondNeighbours_, and size_.

Referenced by findPanelInteractions().

◆ translateLocalExpansion()

void Panel::translateLocalExpansion ( )
315 {
316  for (Panel* iC : childeren_)
317  {
318  Vec3D centreChild = iC->getCentre();
319  iC->localExpansionAroundCentre_->addLocalExpansionCoefficients(
321  );
322  }
323 }
NumericalVector< std::complex< Mdouble > > translateLocalExpansion(Vec3D location)
Definition: LocalExpansion.cc:49

References childeren_, localExpansionAroundCentre_, and LocalExpansion::translateLocalExpansion().

◆ translateMultipoleExpansion()

void Panel::translateMultipoleExpansion ( )
279 {
280  // Extract the multipole of all the childeren
281  for (Panel* iC : childeren_)
282  {
283  //Translate the multipole in the center of the child to the centre of the current panel
284  //And then add it to the multipole in the centre of the current panel
286  iC->multipoleAroundCentre_->TranslateMultipoleExpansionTo(centre_)
287  );
288  }
289 }

References Multipole::addMultipoleCoefficients(), centre_, childeren_, and multipoleAroundCentre_.

Member Data Documentation

◆ box_

Box* Panel::box_
private

◆ centre_

◆ childeren_

◆ dim_

Mdouble Panel::dim_
private

Referenced by createPanels(), and Panel().

◆ dipoles_

std::vector<Dipole*> Panel::dipoles_
private

◆ interactionList_

std::vector<Panel*> Panel::interactionList_
private

◆ leftBound_

Vec3D Panel::leftBound_
private

Referenced by createPanels().

◆ localExpansion_

NumericalVector<std::complex<Mdouble> > Panel::localExpansion_
private

Referenced by getLocalExpansion().

◆ localExpansionAroundCentre_

LocalExpansion* Panel::localExpansionAroundCentre_
private

◆ multipoleAroundCentre_

Multipole* Panel::multipoleAroundCentre_
private

◆ multipoles_

std::vector<Multipole*> Panel::multipoles_
private

◆ neighbours_

std::vector<Panel*> Panel::neighbours_
private

◆ panelLevel_

const int Panel::panelLevel_
private

Referenced by createPanels(), and getPanelLevel().

◆ partialLocalExpansion_

NumericalVector<std::complex<Mdouble> > Panel::partialLocalExpansion_
private

◆ partialLocalExpansionAroundCentre_

LocalExpansion* Panel::partialLocalExpansionAroundCentre_
private

◆ rightBound_

Vec3D Panel::rightBound_
private

◆ root_

Panel* Panel::root_ = nullptr
private

Referenced by getRoot(), and setPanelInteractions().

◆ secondNeighbours_

std::vector<Panel*> Panel::secondNeighbours_
private

◆ size_

double Panel::size_
private

◆ sources_

std::vector<Source*> Panel::sources_
private

Referenced by getSource(), and getSources().

◆ spheres_

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

Referenced by getSpheres().


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