Commit 8f6e2d0d authored by Quentin Khan's avatar Quentin Khan
Browse files

FAdaptUnifKernel: comply with StarPU interface

parent 5c34fb3f
......@@ -9,6 +9,15 @@
#include "FComputeClassDescriptor.hpp"
#include <fstream>
/**
* \brief Adaptive FMM Lagrange kernel adaptor.
*
* Inherits from the original Lagrange kernel and adds the needed operators to
* make it adaptive.
*/
template<
class FReal,
class CellClass,
......@@ -31,31 +40,50 @@ public:
using FBase::L2L;
using FBase::P2P;
void P2M(CellClass* const LeafCell,
/**
* \brief Adaptive P2M
*
* Computes the leaf box width for every leaf. The uniform one relies on the
* fact that all leaves are at the same level to pre-compute this width.
*/
template<class SymbolicData>
void P2M(typename CellClass::multipole_t* const LeafMultipole,
const SymbolicData* const LeafSymbData,
const ContainerClass* const SourceParticles)
{
FReal leafBoxWidth = FBase::BoxWidth / FReal(1 << LeafCell->getLevel());
FReal leafBoxWidth = FBase::BoxWidth / FReal(1 << LeafSymbData->depth);
const FPoint<FReal> LeafCellCenter(
FBase::getCellCenter(LeafCell->getCoordinate(), static_cast<int>(LeafCell->getLevel())));
// 1) apply Sy
FBase::getCellCenter(LeafSymbData->getCoordinate(),
static_cast<int>(LeafSymbData->depth)));
FBase::Interpolator->applyP2M(LeafCellCenter, leafBoxWidth,
LeafCell->getMultipole(0), SourceParticles);
LeafMultipole->getMultipole(0), SourceParticles);
for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){
// 2) apply Discrete Fourier Transform
FBase::M2LHandler.applyZeroPaddingAndDFT(LeafCell->getMultipole(idxRhs),
LeafCell->getTransformedMultipole(idxRhs));
this->M2LHandler.applyZeroPaddingAndDFT(LeafMultipole->getMultipole(idxRhs),
LeafMultipole->getTransformedMultipole(idxRhs));
}
}
void L2P(const CellClass* const LeafCell,
/**
* \brief Adaptive L2P
*
* Computes the leaf box width for every leaf. The uniform one relies on the
* fact that all leaves are at the same level to pre-compute this width.
*/
template<class SymbolicData>
void L2P(const typename CellClass::local_expansion_t* const LeafCell,
const SymbolicData* const LeafSymbData,
ContainerClass* const TargetParticles)
{
FReal leafBoxWidth = FBase::BoxWidth / FReal(1 << LeafCell->getLevel());
FReal leafBoxWidth = FBase::BoxWidth / FReal(1 << LeafSymbData->depth);
const FPoint<FReal> LeafCellCenter(
FBase::getCellCenter(LeafCell->getCoordinate(), static_cast<int>(LeafCell->getLevel())));
FBase::getCellCenter(LeafSymbData->getCoordinate(),
static_cast<int>(LeafSymbData->depth)));
FReal localExp[NVALS*FBase::nnodes];
for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){
......@@ -72,15 +100,24 @@ public:
localExp, TargetParticles);
}
void P2L(CellClass* const local, const ContainerClass* const particles) {
/**
* \brief P2L operator
*
* Computes interactions from a leaf particles to a neighbouring local
* expansion.
*/
template<class SymbolicData>
void P2L(typename CellClass::local_expansion_t* const local,
const SymbolicData * const symb,
const ContainerClass* const particles)
{
using ComputeClass = typename ComputeClassDescriptor<FReal>::type;
constexpr std::size_t FRealCount = ComputeClassDescriptor<FReal>::count;
// Target cell: local
const FReal localCellWidth(FBase::BoxWidth / FReal(1 << local->getLevel()));
const FPoint<FReal> localCellCenter(
FBase::getCellCenter(local->getCoordinate(),static_cast<int>(local->getLevel())));
const FReal localCellWidth(FBase::BoxWidth / FReal(1 << symb->getLevel()));
const FPoint<FReal> localCellCenter =
FBase::getCellCenter(symb->getCoordinate(),static_cast<int>(symb->getLevel()));
// interpolation points of target (X) cell
FPoint<FReal> X[FBase::nnodes];
......@@ -140,16 +177,23 @@ public:
}// NVALS
}
void M2P(const CellClass* const pole, ContainerClass* const particles) {
/**
* \brief M2P operator
*
* Computes interactions from a multipole to a leaf.
*/
template<class SymbolicData>
void M2P(const typename CellClass::multipole_t* const pole,
const SymbolicData* const symb,
ContainerClass* const particles)
{
using ComputeClass = typename ComputeClassDescriptor<FReal>::type;
constexpr std::size_t FRealCount = ComputeClassDescriptor<FReal>::count;
// Source cell: pole
const FReal poleCellWidth(FBase::BoxWidth / FReal(1 << pole->getLevel()));
const FReal poleCellWidth(FBase::BoxWidth / FReal(1 << symb->getLevel()));
const FPoint<FReal> poleCellCenter(
FBase::getCellCenter(pole->getCoordinate(),static_cast<int>(pole->getLevel())));
FBase::getCellCenter(symb->getCoordinate(),static_cast<int>(symb->getLevel())));
// interpolation points of source (Y) cell
FPoint<FReal> Y[FBase::nnodes];
......@@ -204,6 +248,50 @@ public:
}// NVALS
}
// Previous interface starts here ////////////////////////////////
/**
* \brief Node symbolic data fill-in structure for compatibility with older interface
*/
struct CellData {
std::size_t depth;
std::size_t m_idx;
std::size_t getLevel() const noexcept {
return depth;
}
std::size_t getMortonIndex() const noexcept {
return m_idx;
}
FTreeCoordinate getCoordinate() const noexcept {
return FTreeCoordinate(this->m_idx);
}
};
void P2M(CellClass* const LeafCell,
const ContainerClass* const SourceParticles)
{
CellData symb {LeafCell->getLevel(), static_cast<std::size_t>(LeafCell->getMortonIndex())};
this->P2M(&LeafCell->multipole, &symb, SourceParticles);
}
void L2P(const CellClass* const LeafCell,
ContainerClass* const TargetParticles)
{
CellData symb {LeafCell->getLevel(), static_cast<std::size_t>(LeafCell->getMortonIndex())};
this->L2P(&LeafCell->local_expansion, &symb, TargetParticles);
}
void P2L(CellClass* const local, const ContainerClass* const particles) {
CellData symb {local->getLevel(), static_cast<std::size_t>(local->getMortonIndex())};
return this->P2L(&local->local_expansion, &symb , particles);
}
void M2P(const CellClass* const pole, ContainerClass* const particles) {
CellData symb {pole->getLevel(), static_cast<std::size_t>(pole->getMortonIndex())};
return this->M2P(&pole->multipole, &symb , particles);
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment