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 
)
13  :
14  p_(p),
15  squaredFactorials_(squaredFactorials),
16  location_(location)
17 {
18 }
float * p
Definition: Tutorial_Map_using.cpp:9
Vec3D location_
Definition: Multipole.h:53
NumericalVector * squaredFactorials_
Definition: Multipole.h:52
int p_
Definition: Multipole.h:51

◆ ~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:
134 {
135  if (multipoleExpansionCoefficients.size() > multipoleExpansionCoefficients_.size())
136  {
137  logger(ERROR, "Multipole expansion coefficient sizes are not correct.");
138  }
139 
140  multipoleExpansionCoefficients_ += multipoleExpansionCoefficients;
141 }
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:54
std::size_t size() const
Definition: NumericalVector.h:196

References ERROR, logger, and multipoleExpansionCoefficients_.

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

◆ computeMultipoleExpansion()

void Multipole::computeMultipoleExpansion ( )
virtual

Reimplemented in Dipole.

24 {
25  int nTerms = 0.5 * (p_ + 1) * (2 * p_ + 2);
27 }

References multipoleExpansionCoefficients_, and p_.

Referenced by Panel::Panel().

◆ convertMultipoleToLocal()

NumericalVector< std::complex< Mdouble > > Multipole::convertMultipoleToLocal ( Vec3D  location)
88 {
89  int nTerms = 0.5 * (p_ + 1) * (2 * p_ + 2);
90  NumericalVector<std::complex<Mdouble>> localExpansionCoefficients(nTerms);
91 
92  //Compute alpha and beta;
93  //Todo: use quarternions to do this shite
94  Mdouble rho = 1.0;
95  Mdouble alpha = 1.0;
96  Mdouble beta = 1.0;
97 
99  beta);
100 
101  for (int j = 0; j <= p_; j++)
102  {
103  for (int k = -j; k <= j; k++)
104  {
105  std::complex<Mdouble> result = 0.0;
106  int location = j * j + (k + j);
107  for (int n = 0; n <= p_; n++)
108  {
109  for (int m = -n; m <= n; m++)
110  {
111  int location_A1 = n * n + (m + n);
112  int location_A2 = j * j + (j + k);
113  int location_A3 = (j + n) * (j + n) + ((m - k) + (j + n));
114  int location_Y = location_A3;
115  int location_O = location_A1;
116  std::complex<Mdouble> J = std::pow(constants::i, std::abs(k - m) - std::abs(k) - std::abs(m));
117  //\todo TW note: a warning says += cannot be done here
118  result += multipoleExpansionCoefficients_[location_O] * J * (*squaredFactorials_)(location_A1) *
119  (*squaredFactorials_)(location_A2) * sphericalHarmonics[location_Y] /
120  ((*squaredFactorials_)(location_A3) * std::pow(rho, (j + n + 1)));
121 
122  }
123  }
124  localExpansionCoefficients[location] = result;
125  }
126  }
127  return localExpansionCoefficients;
128 }
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
double Mdouble
Definition: GeneralDefine.h:13
JacobiRotation< float > J
Definition: Jacobi_makeJacobi.cpp:3
Definition: NumericalVector.h:44
RealScalar alpha
Definition: level1_cplx_impl.h:151
int * m
Definition: level2_cplx_impl.h:294
Scalar beta
Definition: level2_cplx_impl.h:36
char char char int int * k
Definition: level2_impl.h:374
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 pow(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:625
const std::complex< Mdouble > i
Definition: ExtendedMath.h:31
Definition: ExtendedMath.h:180
NumericalVector< std::complex< Mdouble > > sphericalHarmonics(int p, Mdouble theta, Mdouble phi)
Definition: ExtendedMath.cc:424
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References abs(), alpha, beta, constants::i, J, j, k, m, multipoleExpansionCoefficients_, n, p_, Eigen::bfloat16_impl::pow(), sphericalHarmonics::sphericalHarmonics(), and squaredFactorials_.

◆ getExpansionCoefficients()

NumericalVector<std::complex<Mdouble> > Multipole::getExpansionCoefficients ( )
inline
31  {
33  }

References multipoleExpansionCoefficients_.

◆ getP()

int Multipole::getP ( )
inline
46  {
47  return p_;
48  }

References p_.

◆ getSquaredFactorials()

NumericalVector* Multipole::getSquaredFactorials ( )
inline
41  {
42  return squaredFactorials_;
43  }

References squaredFactorials_.

◆ setExpansionCoefficients()

void Multipole::setExpansionCoefficients ( NumericalVector< std::complex< Mdouble >>  multipoleExpansionCoefficients)
inline
36  {
37  multipoleExpansionCoefficients_ = multipoleExpansionCoefficients;
38  }

References multipoleExpansionCoefficients_.

◆ TranslateMultipoleExpansionTo()

NumericalVector< std::complex< Mdouble > > Multipole::TranslateMultipoleExpansionTo ( Vec3D  location)
30 {
31  //todo: Find a better name for A/squaredFactorials
32  int nTerms = 0.5 * (p_ + 1) * (2 * p_ + 2);
33  NumericalVector<std::complex<Mdouble>> translatedMultipoleCoefficients(nTerms);
34 
35  //Check if a multipole expansion has taken place
36  if (multipoleExpansionCoefficients_.size() == 0)
37  {
38  logger(ERROR, "Multipole is not yet expanded.");
39  }
40 
41  //Determine rho, alpha and beta
42  //Vec3D distance = location_ - location;
43 
44  //Todo: Add a quarternion step in here with distance as input, to avoid NaN values in the angles.
45  Mdouble rho = 1.0;
46  Mdouble alpha = 1.0;
47  Mdouble beta = 1.0;
48 
49 /* std::cout << "rho=" << rho << std::endl;
50  std::cout << "alpha=" << alpha << std::endl;
51  std::cout << "beta=" << beta <<std::endl;*/
52 
53  //Calculate spherical harmonics for alpha and beta
55 
56  //Compute the transfered multipole coefficients
57  for (int j = 0; j <= p_; j++)
58  {
59  for (int k = -j; k <= j; k++)
60  {
61  std::complex<Mdouble> result = 0.0;
62  int location = j * j + (k + j);
63  for (int n = 0; n <= j; n++)
64  {
65  int a = std::max(k + n - j, -n);
66  int b = std::min(k + j - n, n);
67  for (int m = a; m <= b; m++)
68  {
69  int location_O = (j - n) * (j - n) + ((k - m) + (j - n));
70  int location_A1 = n * n + (m + n);
71  int location_Y = n * n + (-m + n);
72  int location_A2 = location_O;
73  int location_A3 = location;
74  result += multipoleExpansionCoefficients_[location_O] *
76  * (*squaredFactorials_)(location_A1) * (*squaredFactorials_)(location_A2) *
77  std::pow(rho, n) * sphericalHarmonics[location_Y] / (*squaredFactorials_)(location_A3);
78  }
79  }
80  translatedMultipoleCoefficients[location] = result;
81  }
82  }
83 
84  return translatedMultipoleCoefficients;
85 }
Scalar * b
Definition: benchVecAdd.cpp:17
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
const Scalar * a
Definition: level2_cplx_impl.h:32

References a, abs(), alpha, b, beta, ERROR, constants::i, j, k, logger, m, max, min, multipoleExpansionCoefficients_, n, p_, Eigen::bfloat16_impl::pow(), 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: