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 
)
33  :
34  p_(p),
35  squaredFactorials_(squaredFactorials),
36  location_(location)
37 {
38 }
Vec3D location_
Definition: LocalExpansion.h:58
NumericalVector * squaredFactorials_
Definition: LocalExpansion.h:57
int p_
Definition: LocalExpansion.h:56

◆ ~LocalExpansion()

LocalExpansion::~LocalExpansion ( )
virtualdefault

Member Function Documentation

◆ addLocalExpansionCoefficients()

void LocalExpansion::addLocalExpansionCoefficients ( NumericalVector< std::complex< Mdouble >>  localExpansionCoefficients)
101 {
102  if (localExpansionCoefficients.size() > localExpansionCoefficients_.size())
103  {
104  logger(ERROR, "Multipole expansion coefficient sizes are not correct.");
105  }
106 
107  localExpansionCoefficients_ += localExpansionCoefficients;
108 
109 }
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:59
std::size_t size() const
Definition: NumericalVector.h:216

References ERROR, localExpansionCoefficients_, and logger.

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

◆ getExpansionCoefficients()

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

References localExpansionCoefficients_.

Referenced by Panel::computeLocalExpansion().

◆ initialiseLocalExpansion()

void LocalExpansion::initialiseLocalExpansion ( )
44 {
45  size_t nTerms = 0.5 * (p_ + 1) * (2 * p_ + 2);
47 }

References localExpansionCoefficients_, and p_.

Referenced by Panel::Panel().

◆ translateLocalExpansion()

NumericalVector< std::complex< Mdouble > > LocalExpansion::translateLocalExpansion ( Vec3D  location)
50 {
51  int nTerms = 0.5 * (p_ + 1) * (2 * p_ + 2);
52  NumericalVector<std::complex<Mdouble>> translatedLocalExpansionCoefficients(nTerms);
53  //std::cout << "size: " << nTerms << std::endl;
54 
55  //compute angles and distance in new framework
56  //todo: fix this rubble with quaternions
57  Mdouble rho = 1.0;
58  Mdouble alpha = 1.0;
59  Mdouble beta = 1.0;
60 
61 
62  //Compute translated local expansion coefficients
64 
65  for (int j = 0; j <= p_; j++)
66  {
67  for (int k = -j; k <= j; k++)
68  {
69  std::complex<Mdouble> result = {0.0, 0.0};
70  int location = j * j + (k + j);
71  for (int n = j; n <= p_; n++)
72  {
73  for (int m = (k - j + n); m <= (k - n + j); m++)
74  {
75  int location_O = n * n + (m + n);
76  int location_A1 = (n - j) * (n - j) + ((m - k) + (n - j));
77  int location_A2 = location;
78  int location_Y = location_A1;
79  int location_A3 = location_O;
80  std::complex<Mdouble> J = std::pow(constants::i, std::abs(m) - std::abs(m - k) - std::abs(k));
81  /* std::cout << "location_A1: " << location_O << std::endl;
82  std::cout << "locationExpansion: " << localExpansionCoefficients_[location_O] << std::endl;
83  std::cout << "A1: " << (*squaredFactorials_)(location_A1) << std::endl;
84  std::cout << "A2: " << (*squaredFactorials_)(location_A2) << std::endl;
85  std::cout << "A3: " << (*squaredFactorials_)(location_A3) << std::endl;
86  std::cout << "Spherical: " << sphericalHarmonics[location_Y] << std::endl;*/
87  //\todo TW note: a warning says += cannot be done here
88  result += localExpansionCoefficients_[location_O] * J * (*squaredFactorials_)(location_A1) *
89  (*squaredFactorials_)(location_A2) * sphericalHarmonics[location_Y] *
90  std::pow(rho, n - j) / (std::pow(-1, n + j) * (*squaredFactorials_)(location_A3));
91  }
92  }
93  //std::cout << "location: " << location << std::endl;
94  translatedLocalExpansionCoefficients[location] = result;
95  }
96  }
97  return translatedLocalExpansionCoefficients;
98 }
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, localExpansionCoefficients_, n, p_, 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: