VM2D 1.14
Vortex methods for 2D flows simulation
Loading...
Searching...
No Matches
multipole3d.h
Go to the documentation of this file.
1#pragma once
2
3#include "morton_tree.h"
4#include <oneapi/tbb/enumerable_thread_specific.h>
5#include <oneapi/tbb/concurrent_unordered_map.h>
6#include "../common/utils.h"
7
8namespace fmm {
9
10template <typename value>
12{
13public:
14 using complex_value = std::conditional_t<std::is_same_v<value, double>, std::complex<double>, Vector3cd>;
17 using TreeCell_t = typename MortonTree_t::TreeCell_t;
18
19 FastMultipole3d(const std::vector<particle_t>& particles, double eps = 1.e-8, int N = FMM_AUTO, int tree_depth = FMM_AUTO);
20 FastMultipole3d(std::vector<particle_t>&& particles, double eps = 1.e-8, int N = FMM_AUTO, int tree_depth = FMM_AUTO);
21 FastMultipole3d(const std::vector<particle_t>& source_particles, const std::vector<particle_t>& target_particles, double eps = 1.e-8, int N = FMM_AUTO, int tree_depth = FMM_AUTO);
22
23 std::vector<Vector3d> forces;
24 std::vector<Vector3d> moments;
25 std::vector<double> potentials;
26 std::vector<Vector3d> dipolevelocities;
27private:
28 void Solve(std::vector<particle_t>&& particles, double eps = 1.e-8, int N = FMM_AUTO, int tree_depth = FMM_AUTO);
29 void Multipole(complex_value* a, const std::pair<size_t, size_t>& particle_range, const Vector3d& z0, double* Pnm, std::complex<double>* eim);
30 void M2M(const complex_value* a, const Vector3d& p0, complex_value* b, std::vector<complex_value>& work1, std::vector<complex_value>& work2);
31 void M2L(const complex_value* a, const Vector3d& p0, complex_value* b, std::vector<complex_value>& work1, std::vector<complex_value>& work2);
32 void L2L(const complex_value* a, const Vector3d& p0, complex_value* b, std::vector<complex_value>& work1, std::vector<complex_value>& work2);
33
34 void RotateY(const complex_value* a, const std::vector<double>& dmatrix, complex_value* res);
35 void RotateZ(const complex_value* a, const std::vector<std::complex<double>>& rotation_exp, complex_value* b);
36 void RotateZ(complex_value* a, const std::vector<std::complex<double>>& rotation_exp);
37
38 void Upward();
39 void Downward();
41
42
43 void Prepare();
44
45 std::shared_ptr<MortonTree_t> tree;
46 std::vector<std::vector<complex_value>> outer_expansions; // for all tree levels
47 std::vector<std::vector<complex_value>> inner_expansions; // for all tree levels
48
49 size_t tree_depth;
50 int N; // multipole_num
51 int Nx2;
54 //std::vector<double> m2lcoef;
55
56 tbb::enumerable_thread_specific<std::vector<complex_value>> local_work1;
57 tbb::enumerable_thread_specific<std::vector<complex_value>> local_work2;
58
59};
60
61}
void Multipole(complex_value *a, const std::pair< size_t, size_t > &particle_range, const Vector3d &z0, double *Pnm, std::complex< double > *eim)
std::vector< std::vector< complex_value > > outer_expansions
Definition multipole3d.h:46
tbb::enumerable_thread_specific< std::vector< complex_value > > local_work2
Definition multipole3d.h:57
void Solve(std::vector< particle_t > &&particles, double eps=1.e-8, int N=FMM_AUTO, int tree_depth=FMM_AUTO)
void M2L(const complex_value *a, const Vector3d &p0, complex_value *b, std::vector< complex_value > &work1, std::vector< complex_value > &work2)
std::vector< Vector3d > dipolevelocities
Definition multipole3d.h:26
std::vector< std::vector< complex_value > > inner_expansions
Definition multipole3d.h:47
void L2L(const complex_value *a, const Vector3d &p0, complex_value *b, std::vector< complex_value > &work1, std::vector< complex_value > &work2)
std::vector< Vector3d > moments
Definition multipole3d.h:24
void RotateZ(const complex_value *a, const std::vector< std::complex< double > > &rotation_exp, complex_value *b)
MortonTree< 3, point3d, value > MortonTree_t
Definition multipole3d.h:16
std::vector< Vector3d > forces
Definition multipole3d.h:23
void M2M(const complex_value *a, const Vector3d &p0, complex_value *b, std::vector< complex_value > &work1, std::vector< complex_value > &work2)
std::conditional_t< std::is_same_v< value, double >, std::complex< double >, Vector3cd > complex_value
Definition multipole3d.h:14
std::vector< double > potentials
Definition multipole3d.h:25
std::shared_ptr< MortonTree_t > tree
Definition multipole3d.h:45
typename MortonTree_t::TreeCell_t TreeCell_t
Definition multipole3d.h:17
tbb::enumerable_thread_specific< std::vector< complex_value > > local_work1
Definition multipole3d.h:56
void RotateY(const complex_value *a, const std::vector< double > &dmatrix, complex_value *res)
std::unordered_map< int, std::vector< double > > dmatrix
Definition avx.h:5
Vector3< std::complex< double > > Vector3cd
Definition utils.h:65
const int FMM_AUTO
Definition defs.h:26