Commit 09223297 authored by Quentin Khan's avatar Quentin Khan

FCountKernel: adapt to new kernel interface

parent ff1a2ea1
#ifndef _FGENERICCELL_HPP_
#define _FGENERICCELL_HPP_
#include "Components/FBasicCell.hpp"
template<class Multipole, class LocalExpansion>
class FGenericData : public FBasicCell {
public:
using multipole_t = Multipole;
using local_expansion_t = LocalExpansion;
private:
multipole_t m_data;
local_expansion_t l_data;
public:
multipole_t* up = &m_data;
local_expansion_t* down = &l_data;
bool hasMultipoleData() const noexcept {
return up != nullptr;
}
bool hasLocalExpansionData() const noexcept {
return up != nullptr;
}
multipole_t& getMultipoleData() noexcept {
return *up;
}
const multipole_t& getMultipoleData() const noexcept {
return *up;
}
local_expansion_t& getLocalExpansionData() noexcept {
return *down;
}
const local_expansion_t& getLocalExpansionData() const noexcept {
return *down;
}
///////////////////////////////////////////////////////
// to extend FAbstractSendable
///////////////////////////////////////////////////////
template <class BufferWriterClass>
void serializeUp(BufferWriterClass& buffer) const{
up->serialize(buffer);
}
template <class BufferReaderClass>
void deserializeUp(BufferReaderClass& buffer){
up->deserialize(buffer);
}
template <class BufferWriterClass>
void serializeDown(BufferWriterClass& buffer) const{
down->serialize(buffer);
}
template <class BufferReaderClass>
void deserializeDown(BufferReaderClass& buffer){
down->deserialize(buffer);
}
};
#endif /* _FGENERICCELL_HPP_ */
......@@ -16,7 +16,8 @@
#include "Containers/FTreeCoordinate.hpp"
#include "Components/FBasicParticle.hpp"
#include "Components/FBasicCell.hpp"
#include "Kernels/Generic/FGenericData.hpp"
/**
* \brief Particle with a count attribute for use with FCountKernel
......@@ -39,7 +40,7 @@ struct TestCountParticle : public FBasicParticle<FReal, Dim, std::size_t, std::s
* Holds two members that count the interactions that the node multipole and
* local development represent.
*/
struct TestCountNodeData : FBasicCell {
namespace test_count_data {
/// FMM operators names
enum {P2P, P2M, M2M, M2L, L2L, L2P, P2L, M2P, OP_COUNT};
......@@ -55,10 +56,10 @@ struct TestCountNodeData : FBasicCell {
std::size_t dummy = 0;
} l_data;
multipole_t* up;
local_expansion_t* down;
};
using TestCountNodeData = FGenericData<test_count_data::multipole_t, test_count_data::local_expansion_t>;
/** \brief Test Kernel to count particles */
......@@ -118,19 +119,6 @@ struct FCountKernel {
}
/** \brief Particle to multipole operator
*
* Creates a leaf multipole expantion from its particles.
*
* \param leaf_data Leaf data
* \param source_particle_container Leaf particle container
*/
void P2M(CellClass* const leaf_data,
const ContainerClass* const source_particle_container)
{
this->P2M(leaf_data->up, (void*)nullptr, source_particle_container);
}
/** \brief Particle to multipole operator
*
* Creates a leaf multipole expantion from its particles.
......@@ -153,24 +141,6 @@ struct FCountKernel {
/** \brief Multipole to multipole
*
* Propagates children multipoles to their father.
*
* \param node_data Parent multipole node data
* \param child_data Array of pointer to children node data
* \param unnamed Unused, level of the parent
*/
void M2M(CellClass* const node_data,
const CellClass * const * const child_data,
const int level)
{
std::array<const typename CellClass::multipole_t*, child_count> child_multipoles;
std::transform(child_data, child_data+child_count, child_multipoles.data(),
[](const CellClass * data) {return data ? data->up : nullptr;});
return this->M2M(node_data->up, child_multipoles.data(), level);
}
void M2M(typename CellClass::multipole_t * const node_multipole,
const typename CellClass::multipole_t * const * const children_multipole,
const int level)
......@@ -192,36 +162,6 @@ struct FCountKernel {
}
/** \brief Multipole to local development
*
* Computes a multipole influence on a far field local development.
*
* \param node_data Local development node data
* \param v_item_data Multipole node data pointer array
* \param unnamed Multipole nodes offsets relative to node_data in terms
* of boxes at nodes level
* \param v_item_data_size Size of v_item_data
* \param unnamed Unused, level of the nodes
*
* \note All nodes are at the same level
*/
void M2L(CellClass* const node_data,
const CellClass* v_item_data[],
const int /*position*/[],
const int v_item_data_size,
const int /*level*/)
{
this->call_count["M2L"] += v_item_data_size;
for(int idx = 0 ; idx < v_item_data_size ; ++idx) {
if(v_item_data[idx]) {
if(v_item_data[idx]->up->dummy) {
std::cerr << "M2M/M2L parallelism overlap...\n";
}
node_data->down->down += v_item_data[idx]->up->up;
}
}
}
void M2L(typename CellClass::local_expansion_t* const node_local_expansion,
const typename CellClass::multipole_t* const v_item_multipoles[],
const int /*position*/[],
......@@ -238,23 +178,6 @@ struct FCountKernel {
}
}
/** \brief Local development to local development
*
* Transfers a parent local development to it children.
*
* \param node_data Parent node data
* \param child_data Child node data pointer array
* \param unnamed Unused, level of the parent node
*/
void L2L(const CellClass* const node_data,
CellClass** const child_data,
const int level)
{
std::array<typename CellClass::local_expansion_t*, child_count> child_local_exps;
std::transform(child_data, child_data+child_count, child_local_exps.data(),
[](CellClass * data) {return data ? data->down : nullptr;});
this->L2L(node_data->down, child_local_exps.data(), level);
}
void L2L(const typename CellClass::local_expansion_t* const node_local_exp,
typename CellClass::local_expansion_t** const child_local_exps,
......@@ -271,19 +194,6 @@ struct FCountKernel {
}
/** \brief Particle to local development
*
* Direct computation of a particle influence on a local development.
*
* \param node_data Local development node data
* \param source_particle_container Particle container
*/
void P2L(CellClass* const node_data,
const ContainerClass* const source_particle_container)
{
this->P2L(node_data->down, (void*)nullptr, source_particle_container);
}
template<class Symb>
void P2L(typename CellClass::local_expansion_t* const node_local_expansion,
const Symb* const /* node_symbolic_data */,
......@@ -295,18 +205,6 @@ struct FCountKernel {
node_local_expansion->down += source_particle_container->size();
}
/** \brief Local development to particle
*
* Transfer of a local development to the underlying particles.
*
* \param leaf_data Leaf node data
* \param target_particle_container Leaf particle container
*/
void L2P(const CellClass* const leaf_data,
ContainerClass* const target_particle_container)
{
this->L2P(leaf_data->down,(void*)nullptr, target_particle_container);
}
template<class Symb>
void L2P(const typename CellClass::local_expansion_t* const leaf_local_exp,
......@@ -321,18 +219,6 @@ struct FCountKernel {
}
}
/** \brief Multipole to particle
*
* Direct computation of a multipole interaction with particles.
*
* \param node_data Multipole node data
* \param target_particle_container Target particle container
*/
void M2P(const CellClass* const node_data,
ContainerClass* const target_particle_container)
{
this->M2P(node_data->up, (void*)nullptr, target_particle_container);
}
template<class Symb>
void M2P(const typename CellClass::multipole_t* const node_multipole,
......
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