Commit aafafbd1 authored by Quentin Khan's avatar Quentin Khan

Update Taylor Kernel interface to use the new data organisation

 - Divide the FTaylorCell inner data layout into two sub-types:
   multipole_t and local_expansion_t. Two class attribute are accessible
   through the `getMultipoledata` and `getLocalExpansionData` methods.

 - Change FMM operators signature to take advantage of the new
   layout. The operators only take as parameters the data they may need
   instead of the whole cell. For instance (simplified):

   void M2M(CellClass* parent, CellClass** children);

   becomes

   void M2M(multipole_t*  parent_m,    symbolic_data_t* parent_s,
            multipole_t** children_ms, symbolic_data_t* children_ss);
parent 4b333838
......@@ -4,13 +4,13 @@
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// abiding by the rules of distribution of free software.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
#ifndef FTAYLORCELL_HPP
......@@ -32,53 +32,68 @@
template < class FReal, int P, int order>
class FTaylorCell : public FBasicCell, public FAbstractSendable {
protected:
//Size of Multipole Vector
static const int MultipoleSize = ((P+1)*(P+2)*(P+3))*order/6;
//Size of Local Vector
static const int LocalSize = ((P+1)*(P+2)*(P+3))*order/6;
//Multipole vector
FReal multipole_exp[MultipoleSize];
//Local vector
FReal local_exp[LocalSize];
template<std::size_t S, class Tag>
struct expansion_impl {
enum {Size = S};
FReal exp[Size];
FReal* get() noexcept {
return exp;
}
const FReal* get() const noexcept {
return exp;
}
void reset() noexcept {
for(int idx = 0; idx < Size; ++idx) {
exp[idx].setRealImag(FReal(0.0), FReal(0.0));
}
}
int getSize() const noexcept {
return Size;
}
template<class BufferWriterClass>
void serialize(BufferWriterClass& buffer) const {
buffer.write(exp, Size);
}
template<class BufferReaderClass>
void deserialize(BufferReaderClass& buffer) {
buffer.fillArray(exp, Size);
}
};
public:
/**
*Default Constructor
*/
FTaylorCell(){
FMemUtils::memset(multipole_exp,0,MultipoleSize*sizeof(FReal(0)));
FMemUtils::memset(local_exp,0,LocalSize*sizeof(FReal(0)));
}
//Get multipole Vector for setting
FReal * getMultipole(void)
{
return multipole_exp;
}
using multipole_t = expansion_impl<((P+1)*(P+2)*(P+3))*order/6, class multipole_tag>;
using local_expansion_t = expansion_impl<((P+1)*(P+2)*(P+3))*order/6, class local_expansion_tag>;
//Get multipole Vector for reading
const FReal * getMultipole(void) const
{
return multipole_exp;
}
protected:
//Get local Vector
FReal * getLocal(void)
{
return local_exp;
}
multipole_t m_data;
local_expansion_t l_data;
//Get local Vector for reading
const FReal * getLocal(void) const
{
return local_exp;
public:
const multipole_t& getMultipoleData() const noexcept {
return m_data;
}
multipole_t& getMultipoleData() {
return m_data;
}
const local_expansion_t& getLocalExpansionData() const noexcept {
return l_data;
}
local_expansion_t& getLocalExpansionData() {
return l_data;
}
/** Make it like the begining */
void resetToInitialState(){
FMemUtils::memset(multipole_exp,0,MultipoleSize*sizeof(FReal(0)));
FMemUtils::memset(local_exp,0,LocalSize*sizeof(FReal(0)));
m_data.reset();
l_data.reset();
}
......@@ -87,28 +102,28 @@ public:
///////////////////////////////////////////////////////
template <class BufferWriterClass>
void serializeUp(BufferWriterClass& buffer) const{
buffer.write(multipole_exp, MultipoleSize);
m_data.serialize(buffer);
}
template <class BufferReaderClass>
void deserializeUp(BufferReaderClass& buffer){
buffer.fillArray(multipole_exp, MultipoleSize);
m_data.deserialize(buffer);
}
template <class BufferWriterClass>
void serializeDown(BufferWriterClass& buffer) const{
buffer.write(local_exp, LocalSize);
l_data.serialize(buffer);
}
template <class BufferReaderClass>
void deserializeDown(BufferReaderClass& buffer){
buffer.fillArray(local_exp, LocalSize);
l_data.deserialize(buffer);
}
FSize getSavedSizeUp() const {
return ((FSize) sizeof(FReal) * (MultipoleSize));
return ((FSize) sizeof(FReal)) * (multipole_t::Size);
}
FSize getSavedSizeDown() const {
return ((FSize) sizeof(FReal) * (LocalSize));
return ((FSize) sizeof(FReal)) * (local_expansion_t::Size);
}
///////////////////////////////////////////////////////
......@@ -117,18 +132,18 @@ public:
template <class BufferWriterClass>
void save(BufferWriterClass& buffer) const{
FBasicCell::save(buffer);
buffer.write(multipole_exp, MultipoleSize);
buffer.write(local_exp, LocalSize);
m_data.serialize();
l_data.serialize();
}
template <class BufferReaderClass>
void restore(BufferReaderClass& buffer){
FBasicCell::restore(buffer);
buffer.fillArray(multipole_exp, MultipoleSize);
buffer.fillArray(local_exp, LocalSize);
m_data.deserialize();
l_data.deserialize();
}
FSize getSavedSize() const {
return FSize((sizeof(FReal) * (MultipoleSize + LocalSize)
return FSize((sizeof(FReal) * (multipole_t::Size + local_expansion_t::Size)
+ FBasicCell::getSavedSize()));
}
};
......
This diff is collapsed.
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