9 #include "Components/FParticleType.hpp"
10 #include "Components/FTypedLeaf.hpp"
11 #include "Containers/FOctree.hpp"
12 #include "Core/FFmmAlgorithmThreadTsm.hpp"
13 #include "Kernels/P2P/FP2PParticleContainerIndexed.hpp"
14 #include "Kernels/Rotation/FRotationCell.hpp"
15 #include "Kernels/Rotation/FRotationKernel.hpp"
31 typedef FTypedRotationCell<FReal, P>
34 typedef FP2PParticleContainerIndexed<FReal>
37 typedef FTypedLeaf<FReal, ContainerClass>
40 typedef FOctree<FReal, CellClass, ContainerClass, LeafClass>
43 typedef FRotationKernel<FReal, CellClass, ContainerClass, P>
46 typedef FFmmAlgorithmThreadTsm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>
63 std::vector<Tetra::prm> & prmTet ,
64 std::vector<Facette::prm> & prmFac ,
65 const int ScalfmmNbThreads )
69 omp_set_num_threads(ScalfmmNbThreads);
70 norm = 2. / msh.
l.maxCoeff();
73 for (idxPart = 0; idxPart <
NOD; ++idxPart)
76 tree.insert(FPoint<FReal>(pTarget.x(), pTarget.y(), pTarget.z()),
77 FParticleType::FParticleTypeTarget, idxPart);
80 insertCharges<Tetra::Tet, Tetra::NPI>(msh.
tet, idxPart, msh.
c);
81 insertCharges<Facette::Fac, Facette::NPI>(msh.
fac, idxPart, msh.
c);
122 template<
class T, const
int NPI>
123 void insertCharges(std::vector<T>
const &container, FSize &idx, Eigen::Ref<Eigen::Vector3d>
const c)
125 std::for_each(container.begin(), container.end(),
126 [
this, c, &idx](T
const &elem)
128 Eigen::Matrix<double,Nodes::DIM,NPI> gauss;
129 elem.getPtGauss(gauss);
131 for (int j = 0; j < NPI; j++, idx++)
133 double x = norm*(gauss(0,j) - c.x());
134 double y = norm*(gauss(1,j) - c.y());
135 double z = norm*(gauss(2,j) - c.z());
136 tree.insert(FPoint<FReal>(x,y,z), FParticleType::FParticleTypeSource, idx, 0.0);
146 std::fill(srcDen.begin(),srcDen.end(),0);
148 std::for_each(msh.
tet.begin(), msh.
tet.end(),
150 { tet.charges(prmTetra[tet.idxPrm], getter, srcDen, nsrc); });
151 std::fill(corr.begin(),corr.end(),0);
152 std::for_each(msh.
fac.begin(), msh.
fac.end(),
154 { fac.charges(prmFacette[fac.idxPrm], getter, srcDen, nsrc, corr); });
164 calc_charges(getter, msh);
170 const int nbParticlesInLeaf = leaf->getSrc()->getNbParticles();
171 const auto &indexes = leaf->getSrc()->getIndexes();
172 FReal *
const physicalValues = leaf->getSrc()->getPhysicalValues();
173 for (
int idxPart = 0; idxPart < nbParticlesInLeaf; ++idxPart)
175 physicalValues[idxPart] = srcDen[indexes[idxPart] - NOD];
178 std::fill_n(leaf->getTargets()->getPotentials(),
179 leaf->getTargets()->getNbParticles(), 0);
182 tree.forEachCell([](
CellClass *cell) { cell->resetToInitialState(); });
189 const FReal *
const potentials = leaf->getTargets()->getPotentials();
190 const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles();
191 const auto &indexes = leaf->getTargets()->getIndexes();
192 for (
int idxPart = 0; idxPart < nbParticlesInLeaf; ++idxPart)
194 const int indexPartOrig = indexes[idxPart];
195 msh.
set(indexPartOrig, setter,
196 (potentials[idxPart] * norm + corr[indexPartOrig]) / (4 * M_PI));
const Eigen::Vector3d getNode_p(const int i) const
Definition: mesh.h:83
Eigen::Vector3d l
Definition: mesh.h:128
int getNbFacs(void) const
Definition: mesh.h:77
Eigen::Vector3d c
Definition: mesh.h:125
std::vector< Tetra::Tet > tet
Definition: mesh.h:137
int getNbTets(void) const
Definition: mesh.h:80
std::vector< Facette::Fac > fac
Definition: mesh.h:134
void set(const int i, std::function< void(Nodes::Node &, const double)> what_to_set, const double val)
Definition: mesh.h:178
Definition: fmm_demag.h:58
const int NOD
Definition: fmm_demag.h:109
double norm
Definition: fmm_demag.h:115
fmm(Mesh::mesh &msh, std::vector< Tetra::prm > &prmTet, std::vector< Facette::prm > &prmFac, const int ScalfmmNbThreads)
Definition: fmm_demag.h:62
void insertCharges(std::vector< T > const &container, FSize &idx, Eigen::Ref< Eigen::Vector3d > const c)
Definition: fmm_demag.h:123
std::vector< double > corr
Definition: fmm_demag.h:100
void calc_demag(Mesh::mesh &msh)
Definition: fmm_demag.h:90
std::vector< double > srcDen
Definition: fmm_demag.h:97
void calc_charges(std::function< const Eigen::Vector3d(Nodes::Node)> getter, Mesh::mesh &msh)
Definition: fmm_demag.h:143
std::vector< Facette::prm > prmFacette
Definition: fmm_demag.h:106
OctreeClass tree
Definition: fmm_demag.h:111
void demag(std::function< const Eigen::Vector3d(Nodes::Node)> getter, std::function< void(Nodes::Node &, const double)> setter, Mesh::mesh &msh)
Definition: fmm_demag.h:160
std::vector< Tetra::prm > prmTetra
Definition: fmm_demag.h:103
KernelClass kernels
Definition: fmm_demag.h:113
class mesh, readMesh is expecting a mesh file in gmsh format either text or binary,...
const int NPI
Definition: facette.h:18
void set_phiv(Node &n, double val)
Definition: node.h:174
void set_phi(Node &n, double val)
Definition: node.h:171
const int NPI
Definition: tetra.h:23
const FPoint< FReal > boxCenter(0., 0., 0.)
FRotationKernel< FReal, CellClass, ContainerClass, P > KernelClass
Definition: fmm_demag.h:44
FP2PParticleContainerIndexed< FReal > ContainerClass
Definition: fmm_demag.h:35
FTypedRotationCell< FReal, P > CellClass
Definition: fmm_demag.h:32
FTypedLeaf< FReal, ContainerClass > LeafClass
Definition: fmm_demag.h:38
FOctree< FReal, CellClass, ContainerClass, LeafClass > OctreeClass
Definition: fmm_demag.h:41
const int P
Definition: fmm_demag.h:25
const double boxWidth
Definition: fmm_demag.h:50
const int SizeSubLevels
Definition: fmm_demag.h:27
const int NbLevels
Definition: fmm_demag.h:26
double FReal
Definition: fmm_demag.h:29
FFmmAlgorithmThreadTsm< OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass
Definition: fmm_demag.h:47