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 
)
24  :
25  panelLevel_(panelLevel),
26  leftBound_(leftBound),
27  rightBound_(rightBound),
28  root_(root),
29  sources_(sources),
30  dipoles_(dipoles),
31  box_(box)
32 {
33  //Initialise the panel characteristics
34  // I am using Vec3D, so the size is always constant
35 /* if (leftBound.size() != rightBound.size())
36  {
37  std::cout << "Bounds are not of correct dimensions" << std::endl;
38  std::exit(-1);
39  }*/
40 
41  // This code only works for 3D problems, since the maths is significantly different from 2D and 1D
42  // The datastructure however allows for 1D and 2D structures,
43  // In future 2D support might be added (by a master student?)
44  dim_ = 3;
45 
46  // The panel is a cube with same size in all directions
47  // Note this is half the length of a cube side
48  size_ = 0.5 * (rightBound.getComponent(0) - leftBound.getComponent(0));
49 
50  // Determine the centre
51  for (int iD = 0; iD < dim_; iD++)
52  {
53  centre_.setComponent(iD, (leftBound.getComponent(iD) + size_));
54  }
55 
56  //Add panel to the complete box
57  box->addPanel(panelLevel, this);
58 
59  //Set multipole and local expansion coefficients
60  multipoleAroundCentre_ = new Multipole(box_->getNumberOfTerms(), squaredFactorials, centre_);
61  multipoleAroundCentre_->computeMultipoleExpansion(); // Set vector with zeros to correct length
63  partialLocalExpansionAroundCentre_->initialiseLocalExpansion(); // Set vector with zeros to correct length
65  localExpansionAroundCentre_->initialiseLocalExpansion(); // Set vector with zeros to correct length
66 
67  //Create childeren based on the given dimensions;
68  if (panelLevel < box->getMaxLevel()) // final level is obtained if this value is 0
69  {
70  //Note: For an adaptive grid, add a check to see if this panel contains enough sources to have childeren.
71 
72  Vec3D leftBoundChild;
73  Vec3D rightBoundChild;
74 
75  createPanels(1, sources, dipoles, leftBoundChild, rightBoundChild, squaredFactorials);
76  }
77 
78 }
void addPanel(int level, Panel *panel)
Definition: Box.cc:19
int getNumberOfTerms()
Definition: Box.h:35
Definition: LocalExpansion.h:15
void initialiseLocalExpansion()
Definition: LocalExpansion.cc:23
Definition: Multipole.h:14
virtual void computeMultipoleExpansion()
Definition: Multipole.cc:23
const int panelLevel_
Definition: Panel.h:135
std::vector< Source * > sources_
Definition: Panel.h:150
Panel * root_
Definition: Panel.h:143
Vec3D leftBound_
Definition: Panel.h:137
void createPanels(int dim, std::vector< Source * > &sources, std::vector< Dipole * > &dipoles, Vec3D &leftBoundChild, Vec3D &rightBoundChild, NumericalVector<> *squaredFactorials)
Definition: Panel.cc:80
double size_
Definition: Panel.h:139
Vec3D centre_
Definition: Panel.h:140
std::vector< Dipole * > dipoles_
Definition: Panel.h:151
LocalExpansion * partialLocalExpansionAroundCentre_
Definition: Panel.h:163
Vec3D rightBound_
Definition: Panel.h:138
Mdouble dim_
Definition: Panel.h:136
LocalExpansion * localExpansionAroundCentre_
Definition: Panel.h:164
Multipole * multipoleAroundCentre_
Definition: Panel.h:162
Box * box_
Definition: Panel.h:158
Definition: Kernel/Math/Vector.h:30
Mdouble getComponent(int index) const
Returns the requested component of this Vec3D.
Definition: Vector.cc:174
void setComponent(int index, double val)
Sets the requested component of this Vec3D to the requested value.
Definition: Vector.cc:197

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 ( )
151 {
152  //Start upward pass creating multipole methods and shifting them on parent panels
153  box_->upwardPass();
154 
155  //Start the downward pass
156  box_->downwardPass();
157 }
void downwardPass()
Definition: Box.cc:48
void upwardPass()
Definition: Box.cc:24

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

◆ computeLocalExpansion()

void Panel::computeLocalExpansion ( )
288 {
291  );
292 }
NumericalVector< std::complex< Mdouble > > getExpansionCoefficients()
Definition: LocalExpansion.h:30
void addLocalExpansionCoefficients(NumericalVector< std::complex< Mdouble >> localExpansionCoefficients)
Definition: LocalExpansion.cc:80

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

231 {
232 
234  // todo: write this part of the code
235  // A source can be expanded around the centre of the panel without translations
236  //add(iS->computeMultipoleExpansion();)
237 
239  for (Dipole* iD : dipoles_)
240  {
241  //Convert to a multipole
242  //todo: This must be done when the actual dipole is made.
243  iD->computeMultipoleExpansion();
244 
245  //Translate multipole to centre of the panel
246  multipoleAroundCentre_->addMultipoleCoefficients(iD->TranslateMultipoleExpansionTo(centre_));
247 
248  }
249 
251  for (Multipole* iM : multipoles_)
252  {
253  multipoleAroundCentre_->addMultipoleCoefficients(iM->TranslateMultipoleExpansionTo(centre_));
254  }
255 
256 }
Definition: Dipole.h:15
void addMultipoleCoefficients(NumericalVector< std::complex< Mdouble >> multipoleExpansionCoefficients)
Definition: Multipole.cc:133
std::vector< Multipole * > multipoles_
Definition: Panel.h:152

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

◆ computePartialLocalExpansion()

void Panel::computePartialLocalExpansion ( )
277 {
278  //For all panels in the interactionlist, add a local expansion of the multipole to the partialLocalExpansion
279  for (Panel* panel : interactionList_)
280  {
282  panel->multipoleAroundCentre_->convertMultipoleToLocal(centre_)
283  );
284  }
285 }
Definition: Panel.h:23
std::vector< Panel * > interactionList_
Definition: Panel.h:147

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 
)
86 {
87  std::vector<Source*> sourcesChild;
88  std::vector<Dipole*> dipolesChild;
89 
90 
91  for (int iSide = 0; iSide < 2; ++iSide)
92  {
93  //Determine the x boundaries
94  leftBoundChild.setComponent(dim - 1, (leftBound_.getComponent(dim - 1) + size_ * iSide));
95  rightBoundChild.setComponent(dim - 1, (leftBoundChild.getComponent(dim - 1) + size_));
96 
97  //Determine the sources in this domain
98  for (Source* iS : sources)
99  {
100  if ((iS->getLocation().getComponent(dim - 1) > leftBoundChild.getComponent(dim - 1)) &&
101  (iS->getLocation().getComponent(dim - 1) <= rightBoundChild.getComponent(dim - 1)))
102  {
103  sourcesChild.push_back(iS);
104  }
105  }
106 
107  //Determine the dipoles in this domain
108  for (Dipole* iD : dipoles)
109  {
110  if ((iD->getLocation().getComponent(dim - 1) > leftBoundChild.getComponent(dim - 1)) &&
111  (iD->getLocation().getComponent(dim - 1) <= rightBoundChild.getComponent(dim - 1)))
112  {
113  dipolesChild.push_back(iD);
114  }
115  }
116 
117  if (dim != dim_)
118  {
119  createPanels(dim + 1, sourcesChild, dipolesChild, leftBoundChild, rightBoundChild, squaredFactorials);
120  }
121  else
122  {
123  //Create childeren
124 /* std::cout << "Creating a child with bounds: " << std::endl;
125  std::cout << "In x-direction: " << std::endl;
126  std::cout << "Left bound: " << leftBoundChild[0] << " and right bound: " << rightBoundChild[0] << std::endl;
127  std::cout << "In y-direction: " << std::endl;
128  std::cout << "Left bound: " << leftBoundChild[1] << " and right bound: " << rightBoundChild[1] << std::endl;
129  std::cout << "In z-direction: " << std::endl;
130  std::cout << "Left bound: " << leftBoundChild[2] << " and right bound: " << rightBoundChild[2] << std::endl;
131  std::cout << "Child contains " << sourcesChild.size() << " sources" << std::endl;
132  std::cout << "==============" << std::endl;*/
133  Panel* child = new Panel(this, panelLevel_ + 1, leftBoundChild, rightBoundChild, sourcesChild, dipolesChild,
134  squaredFactorials, box_);
135  childeren_.push_back(child);
136 
137  //reset leftBoundChild and rightBoundChild
138  }
139  sourcesChild.clear();
140  }
141 }
std::vector< Panel * > childeren_
Definition: Panel.h:144
Panel(Panel *root, int maximumPanelLevel, Vec3D leftBound, Vec3D rightBound, std::vector< Source * > sources, std::vector< Dipole * > dipoles, NumericalVector<> *squaredFactorials, Box *box)
Definition: Panel.cc:17
Definition: Source.h:14

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

Referenced by Panel().

◆ findPanelInteractions()

void Panel::findPanelInteractions ( )
160 {
161  if (getRoot() == nullptr)
162  {
163  //nothing happens
164  }
165  else
166  {
167  //Crate the links between panels
168  this->setPanelInteractions();
169  }
170 
171  //Initialise child panels
172  for (Panel* iP : childeren_)
173  {
174  iP->findPanelInteractions();
175  }
176 }
Panel * getRoot()
Definition: Panel.h:68
void setPanelInteractions()
Definition: Panel.cc:178

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

Referenced by initialise().

◆ getCentre()

Vec3D Panel::getCentre ( )
inline
64  {
65  return centre_;
66  }

References centre_.

◆ getChilderen()

std::vector<Panel*> Panel::getChilderen ( )
inline
74  {
75  return childeren_;
76  }

References childeren_.

Referenced by setPanelInteractions().

◆ getDipoles()

std::vector<Dipole*> Panel::getDipoles ( )
inline
104  {
105  return dipoles_;
106  }

References dipoles_.

◆ getInteractionList()

std::vector<Panel*> Panel::getInteractionList ( )
inline
89  {
90  return interactionList_;
91  }

References interactionList_.

◆ getLocalExpansion()

NumericalVector<std::complex<Mdouble> > Panel::getLocalExpansion ( )
inline
129  {
130  return localExpansion_;
131  }
NumericalVector< std::complex< Mdouble > > localExpansion_
Definition: Panel.h:166

References localExpansion_.

◆ getMultipoles()

std::vector<Multipole*> Panel::getMultipoles ( )
inline
109  {
110  return multipoles_;
111  }

References multipoles_.

◆ getNeighbours()

std::vector<Panel*> Panel::getNeighbours ( )
inline
79  {
80  return neighbours_;
81  }
std::vector< Panel * > neighbours_
Definition: Panel.h:145

References neighbours_.

Referenced by setPanelInteractions().

◆ getPanelLevel()

int Panel::getPanelLevel ( )
inline
119  {
120  return panelLevel_;
121  }

References panelLevel_.

◆ getPartialLocalExpansion()

NumericalVector<std::complex<Mdouble> > Panel::getPartialLocalExpansion ( )
inline
124  {
125  return partialLocalExpansion_;
126  }
NumericalVector< std::complex< Mdouble > > partialLocalExpansion_
Definition: Panel.h:165

References partialLocalExpansion_.

◆ getRoot()

Panel* Panel::getRoot ( )
inline
69  {
70  return root_;
71  }

References root_.

Referenced by findPanelInteractions().

◆ getSecondNeighbours()

std::vector<Panel*> Panel::getSecondNeighbours ( )
inline
84  {
85  return secondNeighbours_;
86  }
std::vector< Panel * > secondNeighbours_
Definition: Panel.h:146

References secondNeighbours_.

Referenced by setPanelInteractions().

◆ getSource()

Source* Panel::getSource ( int  index)
inline
99  {
100  return sources_[index];
101  }

References sources_.

◆ getSources()

std::vector<Source*> Panel::getSources ( )
inline
94  {
95  return sources_;
96  }

References sources_.

◆ getSpheres()

std::vector<Sphere*> Panel::getSpheres ( )
inline
114  {
115  return spheres_;
116  }
std::vector< Sphere * > spheres_
Definition: Panel.h:155

References spheres_.

◆ initialise()

void Panel::initialise ( )
144 {
145  //Create neighbour list and interaction list
147 
148 }
void findPanelInteractions()
Definition: Panel.cc:159

References findPanelInteractions().

◆ setLocalExpansionZero()

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

◆ setPanelInteractions()

void Panel::setPanelInteractions ( )
179 {
180  //Childeren of a parent are always a neighbour of eachother
181  //Note: by definition, a panel is always a neighbour of itself
182  for (Panel* iC : root_->getChilderen())
183  {
184  neighbours_.push_back(iC);
185  }
186 
187  //For all the neighbours of the parent of this panel
188  for (Panel* iN : root_->getNeighbours())
189  {
190  //For all their childeren, check if the childeren are a neighbour or a second neighbour of this panel
191  // Note that all second neighbour panels are also childeren of these paretn neighbours
192  for (Panel* iC : iN->getChilderen())
193  {
194  //Compute distance between the centre of the current panel and possible neighbour panel
195  Mdouble distance = Vec3D::getDistance(iC->getCentre(), this->getCentre());
196 
197  //Check if the possible neighbour panel is close enough
198  if (distance < 3.0 * size_) //warning: slight hack. I assume all sides are equally long
199  {
200  neighbours_.push_back(iC);
201  //std::cout << "A neighbour has been created with a centre around: (" << iC->getCentre()[0] << "," << iC->getCentre()[1] << ")" << std::endl;
202  //std::cout << "Current panel has centre: (" << this->getCentre()[0] << "," << this->getCentre()[1] << ")" << std::endl;
203  //std::cout << "===============" << std::endl;
204  }
205  else if (distance < 6.0 * size_)
206  {
207  secondNeighbours_.push_back(iC);
208  }
209  else
210  {
211  // If it is not a neighbour or nearest neighbour, it belongs to the interactionlist group
212  interactionList_.push_back(iC);
213  //std::cout << "A panel is added to the interactionlist with a centre around: (" << iC->getCentre()[0] << "," << iC->getCentre()[1] << ")" << std::endl;
214  //std::cout << "Current panel has centre: (" << this->getCentre()[0] << "," << this->getCentre()[1] << ")" << std::endl;
215  //std::cout << "===============" << std::endl;
216  }
217  }
218  }
219 
220  // All childeren of the second nearest neighbour of the current panel's parent, are in the interactionlist
221  for (Panel* iN : root_->getSecondNeighbours())
222  {
223  for (Panel* iC : iN->getChilderen())
224  {
225  secondNeighbours_.push_back(iC);
226  }
227  }
228 }
double Mdouble
Definition: GeneralDefine.h:13
std::vector< Panel * > getNeighbours()
Definition: Panel.h:78
std::vector< Panel * > getSecondNeighbours()
Definition: Panel.h:83
std::vector< Panel * > getChilderen()
Definition: Panel.h:73
static Mdouble getDistance(const Vec3D &a, const Vec3D &b)
Calculates the distance between two Vec3D: .
Definition: Vector.cc:155

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

Referenced by findPanelInteractions().

◆ translateLocalExpansion()

void Panel::translateLocalExpansion ( )
295 {
296  for (Panel* iC : childeren_)
297  {
298  Vec3D centreChild = iC->getCentre();
299  iC->localExpansionAroundCentre_->addLocalExpansionCoefficients(
301  );
302  }
303 }
NumericalVector< std::complex< Mdouble > > translateLocalExpansion(Vec3D location)
Definition: LocalExpansion.cc:29

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

◆ translateMultipoleExpansion()

void Panel::translateMultipoleExpansion ( )
259 {
260  // Extract the multipole of all the childeren
261  for (Panel* iC : childeren_)
262  {
263  //Translate the multipole in the center of the child to the centre of the current panel
264  //And then add it to the multipole in the centre of the current panel
266  iC->multipoleAroundCentre_->TranslateMultipoleExpansionTo(centre_)
267  );
268  }
269 }

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: