LocalExpansion Class Reference

#include <LocalExpansion.h>

Public Member Functions

 LocalExpansion (int p, NumericalVector<> *squaredFactorials, Vec3D location)
 
virtual ~LocalExpansion ()
 
void initialiseLocalExpansion ()
 
NumericalVector< std::complex< Mdouble > > translateLocalExpansion (Vec3D location)
 
void addLocalExpansionCoefficients (NumericalVector< std::complex< Mdouble >> localExpansionCoefficients)
 
NumericalVector< std::complex< Mdouble > > getExpansionCoefficients ()
 

Private Attributes

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

Constructor & Destructor Documentation

◆ LocalExpansion()

LocalExpansion::LocalExpansion ( 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: LocalExpansion.h:38
NumericalVector * squaredFactorials_
Definition: LocalExpansion.h:37
int p_
Definition: LocalExpansion.h:36

◆ ~LocalExpansion()

LocalExpansion::~LocalExpansion ( )
virtualdefault

Member Function Documentation

◆ addLocalExpansionCoefficients()

void LocalExpansion::addLocalExpansionCoefficients ( NumericalVector< std::complex< Mdouble >>  localExpansionCoefficients)
81 {
82  if (localExpansionCoefficients.size() > localExpansionCoefficients_.size())
83  {
84  logger(ERROR, "Multipole expansion coefficient sizes are not correct.");
85  }
86 
87  localExpansionCoefficients_ += localExpansionCoefficients;
88 
89 }
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 > > localExpansionCoefficients_
Definition: LocalExpansion.h:39
std::size_t size() const
Definition: NumericalVector.h:196

References ERROR, localExpansionCoefficients_, and logger.

Referenced by Panel::computeLocalExpansion(), and Panel::computePartialLocalExpansion().

◆ getExpansionCoefficients()

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

References localExpansionCoefficients_.

Referenced by Panel::computeLocalExpansion().

◆ initialiseLocalExpansion()

void LocalExpansion::initialiseLocalExpansion ( )
24 {
25  size_t nTerms = 0.5 * (p_ + 1) * (2 * p_ + 2);
27 }

References localExpansionCoefficients_, and p_.

Referenced by Panel::Panel().

◆ translateLocalExpansion()

NumericalVector< std::complex< Mdouble > > LocalExpansion::translateLocalExpansion ( Vec3D  location)
30 {
31  int nTerms = 0.5 * (p_ + 1) * (2 * p_ + 2);
32  NumericalVector<std::complex<Mdouble>> translatedLocalExpansionCoefficients(nTerms);
33  //std::cout << "size: " << nTerms << std::endl;
34 
35  //compute angles and distance in new framework
36  //todo: fix this rubble with quaternions
37  Mdouble rho = 1.0;
38  Mdouble alpha = 1.0;
39  Mdouble beta = 1.0;
40 
41 
42  //Compute translated local expansion coefficients
44 
45  for (int j = 0; j <= p_; j++)
46  {
47  for (int k = -j; k <= j; k++)
48  {
49  std::complex<Mdouble> result = {0.0, 0.0};
50  int location = j * j + (k + j);
51  for (int n = j; n <= p_; n++)
52  {
53  for (int m = (k - j + n); m <= (k - n + j); m++)
54  {
55  int location_O = n * n + (m + n);
56  int location_A1 = (n - j) * (n - j) + ((m - k) + (n - j));
57  int location_A2 = location;
58  int location_Y = location_A1;
59  int location_A3 = location_O;
60  std::complex<Mdouble> J = std::pow(constants::i, std::abs(m) - std::abs(m - k) - std::abs(k));
61  /* std::cout << "location_A1: " << location_O << std::endl;
62  std::cout << "locationExpansion: " << localExpansionCoefficients_[location_O] << std::endl;
63  std::cout << "A1: " << (*squaredFactorials_)(location_A1) << std::endl;
64  std::cout << "A2: " << (*squaredFactorials_)(location_A2) << std::endl;
65  std::cout << "A3: " << (*squaredFactorials_)(location_A3) << std::endl;
66  std::cout << "Spherical: " << sphericalHarmonics[location_Y] << std::endl;*/
67  //\todo TW note: a warning says += cannot be done here
68  result += localExpansionCoefficients_[location_O] * J * (*squaredFactorials_)(location_A1) *
69  (*squaredFactorials_)(location_A2) * sphericalHarmonics[location_Y] *
70  std::pow(rho, n - j) / (std::pow(-1, n + j) * (*squaredFactorials_)(location_A3));
71  }
72  }
73  //std::cout << "location: " << location << std::endl;
74  translatedLocalExpansionCoefficients[location] = result;
75  }
76  }
77  return translatedLocalExpansionCoefficients;
78 }
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, localExpansionCoefficients_, m, n, p_, Eigen::bfloat16_impl::pow(), sphericalHarmonics::sphericalHarmonics(), and squaredFactorials_.

Referenced by Panel::translateLocalExpansion().

Member Data Documentation

◆ localExpansionCoefficients_

NumericalVector<std::complex<Mdouble> > LocalExpansion::localExpansionCoefficients_
private

◆ location_

Vec3D LocalExpansion::location_
private

◆ p_

int LocalExpansion::p_
private

◆ squaredFactorials_

NumericalVector* LocalExpansion::squaredFactorials_
private

Referenced by translateLocalExpansion().


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