Multipole Class Reference

#include <Multipole.h>

+ Inheritance diagram for Multipole:

Public Member Functions

 Multipole (int p, NumericalVector<> *squaredFactorials, Vec3D location)
 
virtual ~Multipole ()
 
virtual void computeMultipoleExpansion ()
 
NumericalVector< std::complex< Mdouble > > TranslateMultipoleExpansionTo (Vec3D location)
 
NumericalVector< std::complex< Mdouble > > convertMultipoleToLocal (Vec3D location)
 
void addMultipoleCoefficients (NumericalVector< std::complex< Mdouble >> multipoleExpansionCoefficients)
 
NumericalVector< std::complex< Mdouble > > getExpansionCoefficients ()
 
void setExpansionCoefficients (NumericalVector< std::complex< Mdouble >> multipoleExpansionCoefficients)
 
NumericalVectorgetSquaredFactorials ()
 
int getP ()
 

Protected Attributes

int p_
 
NumericalVectorsquaredFactorials_
 
Vec3D location_
 
NumericalVector< std::complex< Mdouble > > multipoleExpansionCoefficients_
 

Constructor & Destructor Documentation

◆ Multipole()

Multipole::Multipole ( int  p,
NumericalVector<> *  squaredFactorials,
Vec3D  location 
)
33  :
34  p_(p),
35  squaredFactorials_(squaredFactorials),
36  location_(location)
37 {
38 }
Vec3D location_
Definition: Multipole.h:73
NumericalVector * squaredFactorials_
Definition: Multipole.h:72
int p_
Definition: Multipole.h:71

◆ ~Multipole()

Multipole::~Multipole ( )
virtualdefault

Member Function Documentation

◆ addMultipoleCoefficients()

MERCURYDPM_DEPRECATED void Multipole::addMultipoleCoefficients ( NumericalVector< std::complex< Mdouble >>  multipoleExpansionCoefficients)

Adds multipole coefficients to an existing multipole

Deprecated:
Remove this function; it should not be required anymore:
154 {
155  if (multipoleExpansionCoefficients.size() > multipoleExpansionCoefficients_.size())
156  {
157  logger(ERROR, "Multipole expansion coefficient sizes are not correct.");
158  }
159 
160  multipoleExpansionCoefficients_ += multipoleExpansionCoefficients;
161 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ ERROR
NumericalVector< std::complex< Mdouble > > multipoleExpansionCoefficients_
Definition: Multipole.h:74
std::size_t size() const
Definition: NumericalVector.h:216

References ERROR, logger, and multipoleExpansionCoefficients_.

Referenced by Panel::computeMultipoleExpansion(), and Panel::translateMultipoleExpansion().

◆ computeMultipoleExpansion()

void Multipole::computeMultipoleExpansion ( )
virtual

Reimplemented in Dipole.

44 {
45  int nTerms = 0.5 * (p_ + 1) * (2 * p_ + 2);
47 }

References multipoleExpansionCoefficients_, and p_.

Referenced by Panel::Panel().

◆ convertMultipoleToLocal()

NumericalVector< std::complex< Mdouble > > Multipole::convertMultipoleToLocal ( Vec3D  location)
108 {
109  int nTerms = 0.5 * (p_ + 1) * (2 * p_ + 2);
110  NumericalVector<std::complex<Mdouble>> localExpansionCoefficients(nTerms);
111 
112  //Compute alpha and beta;
113  //Todo: use quarternions to do this shite
114  Mdouble rho = 1.0;
115  Mdouble alpha = 1.0;
116  Mdouble beta = 1.0;
117 
119  beta);
120 
121  for (int j = 0; j <= p_; j++)
122  {
123  for (int k = -j; k <= j; k++)
124  {
125  std::complex<Mdouble> result = 0.0;
126  int location = j * j + (k + j);
127  for (int n = 0; n <= p_; n++)
128  {
129  for (int m = -n; m <= n; m++)
130  {
131  int location_A1 = n * n + (m + n);
132  int location_A2 = j * j + (j + k);
133  int location_A3 = (j + n) * (j + n) + ((m - k) + (j + n));
134  int location_Y = location_A3;
135  int location_O = location_A1;
136  std::complex<Mdouble> J = std::pow(constants::i, std::abs(k - m) - std::abs(k) - std::abs(m));
137  //\todo TW note: a warning says += cannot be done here
138  result += multipoleExpansionCoefficients_[location_O] * J * (*squaredFactorials_)(location_A1) *
139  (*squaredFactorials_)(location_A2) * sphericalHarmonics[location_Y] /
140  ((*squaredFactorials_)(location_A3) * std::pow(rho, (j + n + 1)));
141 
142  }
143  }
144  localExpansionCoefficients[location] = result;
145  }
146  }
147  return localExpansionCoefficients;
148 }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
double Mdouble
Definition: GeneralDefine.h:34
Definition: NumericalVector.h:64
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
Mdouble beta(Mdouble z, Mdouble w)
This is the beta function, returns the approximation based on cmath's implementation of ln(gamma)
Definition: ExtendedMath.cc:164
Definition: ExtendedMath.h:200
NumericalVector< std::complex< Mdouble > > sphericalHarmonics(int p, Mdouble theta, Mdouble phi)
Definition: ExtendedMath.cc:445

References mathsFunc::beta(), constants::i, multipoleExpansionCoefficients_, n, p_, sphericalHarmonics::sphericalHarmonics(), and squaredFactorials_.

◆ getExpansionCoefficients()

NumericalVector<std::complex<Mdouble> > Multipole::getExpansionCoefficients ( )
inline
51  {
53  }

References multipoleExpansionCoefficients_.

◆ getP()

int Multipole::getP ( )
inline
66  {
67  return p_;
68  }

References p_.

◆ getSquaredFactorials()

NumericalVector* Multipole::getSquaredFactorials ( )
inline
61  {
62  return squaredFactorials_;
63  }

References squaredFactorials_.

◆ setExpansionCoefficients()

void Multipole::setExpansionCoefficients ( NumericalVector< std::complex< Mdouble >>  multipoleExpansionCoefficients)
inline
56  {
57  multipoleExpansionCoefficients_ = multipoleExpansionCoefficients;
58  }

References multipoleExpansionCoefficients_.

◆ TranslateMultipoleExpansionTo()

NumericalVector< std::complex< Mdouble > > Multipole::TranslateMultipoleExpansionTo ( Vec3D  location)
50 {
51  //todo: Find a better name for A/squaredFactorials
52  int nTerms = 0.5 * (p_ + 1) * (2 * p_ + 2);
53  NumericalVector<std::complex<Mdouble>> translatedMultipoleCoefficients(nTerms);
54 
55  //Check if a multipole expansion has taken place
56  if (multipoleExpansionCoefficients_.size() == 0)
57  {
58  logger(ERROR, "Multipole is not yet expanded.");
59  }
60 
61  //Determine rho, alpha and beta
62  //Vec3D distance = location_ - location;
63 
64  //Todo: Add a quarternion step in here with distance as input, to avoid NaN values in the angles.
65  Mdouble rho = 1.0;
66  Mdouble alpha = 1.0;
67  Mdouble beta = 1.0;
68 
69 /* std::cout << "rho=" << rho << std::endl;
70  std::cout << "alpha=" << alpha << std::endl;
71  std::cout << "beta=" << beta <<std::endl;*/
72 
73  //Calculate spherical harmonics for alpha and beta
75 
76  //Compute the transfered multipole coefficients
77  for (int j = 0; j <= p_; j++)
78  {
79  for (int k = -j; k <= j; k++)
80  {
81  std::complex<Mdouble> result = 0.0;
82  int location = j * j + (k + j);
83  for (int n = 0; n <= j; n++)
84  {
85  int a = std::max(k + n - j, -n);
86  int b = std::min(k + j - n, n);
87  for (int m = a; m <= b; m++)
88  {
89  int location_O = (j - n) * (j - n) + ((k - m) + (j - n));
90  int location_A1 = n * n + (m + n);
91  int location_Y = n * n + (-m + n);
92  int location_A2 = location_O;
93  int location_A3 = location;
94  result += multipoleExpansionCoefficients_[location_O] *
95  std::pow(constants::i, (std::abs(k) - std::abs(m) - std::abs(k - m)))
96  * (*squaredFactorials_)(location_A1) * (*squaredFactorials_)(location_A2) *
97  std::pow(rho, n) * sphericalHarmonics[location_Y] / (*squaredFactorials_)(location_A3);
98  }
99  }
100  translatedMultipoleCoefficients[location] = result;
101  }
102  }
103 
104  return translatedMultipoleCoefficients;
105 }

References mathsFunc::beta(), ERROR, constants::i, logger, multipoleExpansionCoefficients_, n, p_, sphericalHarmonics::sphericalHarmonics(), and squaredFactorials_.

Member Data Documentation

◆ location_

Vec3D Multipole::location_
protected

Referenced by Dipole::getLocation().

◆ multipoleExpansionCoefficients_

◆ p_

◆ squaredFactorials_

NumericalVector* Multipole::squaredFactorials_
protected

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