Commit 0b382003 authored by COULAUD Olivier's avatar COULAUD Olivier

Remove Obsolete files

parent 6751069f
#ifndef FABSTRACTADAPTIVEKERNEL
#define FABSTRACTADAPTIVEKERNEL
// Keep in private GIT
// @SCALFMM_PRIVATE
/**
* This class represent the method that an adaptive kernel must implement.
* There are two kinds of operators, the first one represent computation and the others
* should return the cretiria to know when the P2M should be performed.
*/
template <class CellClass, class ContainerClass>
class FAbstractAdaptiveKernel {
public:
virtual ~FAbstractAdaptiveKernel(){
}
virtual void P2M(CellClass* const pole, const int cellLevel, const ContainerClass* const particles) = 0;
virtual void M2M(CellClass* const pole, const int poleLevel, const CellClass* const subCell, const int subCellLevel) = 0;
virtual void P2L(CellClass* const local, const int localLevel, const ContainerClass* const particles) = 0;
virtual void M2L(CellClass* const local, const int localLevel, const CellClass* const aNeighbor, const int neighborLevel) = 0;
virtual void M2P(const CellClass* const pole, const int poleLevel, ContainerClass* const particles) = 0;
virtual void L2L(const CellClass* const local, const int localLevel, CellClass* const subCell, const int subCellLevel) = 0;
virtual void L2P(const CellClass* const local, const int cellLevel, ContainerClass* const particles) = 0;
virtual void P2P(ContainerClass* target, const ContainerClass* sources) = 0;
virtual bool preferP2M(const ContainerClass* const particles) = 0;
virtual bool preferP2M(const int atLevel, const ContainerClass*const particles[], const int nbContainers) = 0;
};
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef FAdaptiveCELL
#define FAdaptiveCELL
// Keep in private GIT
// @SCALFMM_PRIVATE
#include "Components/FBasicCell.hpp"
/**
* This class is a wrapper to work with adaptive kernel
* It contains a pointer to the real computation cell but use it only if
* the cell is adaptive AND has been use for development.
*
* A cell is adaptive if:
* - it has more than one child
* - it used for development
* - it is use to store the leaves
* Else it stores a pointer to the lower adaptive cell.
*/
template <class RealCell, class ContainerClass>
class FAdaptiveCell : public FBasicCell {
/** The cell used for the computation */
RealCell* realCell;
/** To keep track of the cell state */
bool IamAdaptive;
/** If not adaptive then we need to know the lower adaptive cell */
FAdaptiveCell<RealCell, ContainerClass>* subAdaptiveCell;
/** The lower adaptive cell level */
int subAdaptiveLevel;
/** The leaves that have been skiped for the P2M/M2M... */
FVector<ContainerClass*> subLeaves;
//
// Global Index of the cell in the octree (This id is unique)
FSize gID;
public:
/** Set has not Adaptive by default */
FAdaptiveCell() : realCell(nullptr), IamAdaptive(false), subAdaptiveCell(nullptr), subAdaptiveLevel(0),gID(0){
}
~FAdaptiveCell(){
if (realCell) delete realCell;
}
void resetToInitialState(){
subLeaves.clear();
if(realCell){
realCell->resetToInitialState();
}
}
////////////////////////////////////////////////////////////////////////////////
/// Get the real cell
////////////////////////////////////////////////////////////////////////////////
/** To say if it is used for development or not */
void setHaveDevelopment(const bool inHaveDevelopment) {
if(inHaveDevelopment && !realCell){
// alloc and init the real cell
realCell = new RealCell;
realCell->setMortonIndex(this->getMortonIndex());
realCell->setCoordinate(this->getCoordinate());
// clean other information
subAdaptiveCell = nullptr;
subAdaptiveLevel = 0;
subLeaves.clear();
}
else if(!inHaveDevelopment && realCell){
// clean real cell if needed
delete realCell;
realCell = nullptr;
}
}
void resetSubLeaves() {
subLeaves.clear();
}
bool hasDevelopment() const{
return realCell != nullptr;
}
RealCell* getRealCell(){
return realCell;
}
const RealCell* getRealCell() const {
return realCell;
}
////////////////////////////////////////////////////////////////////////////////
/// Set Adaptive
////////////////////////////////////////////////////////////////////////////////
bool isAdaptive() const {
return IamAdaptive;
}
void setAdaptive(const bool inIsAdaptive) {
IamAdaptive = inIsAdaptive;
}
////////////////////////////////////////////////////////////////////////////////
/// Manage the sub leaves
////////////////////////////////////////////////////////////////////////////////
void addSubLeaf(const ContainerClass* aLeaf){
subLeaves.push(const_cast<ContainerClass*>(aLeaf));
}
void addSubLeaf(ContainerClass* aLeaf){
subLeaves.push(aLeaf);
}
void addSubLeaves(const ContainerClass*const* aLeavesToInsert, const int nbLeavesToInsert){
subLeaves.memocopy(const_cast<ContainerClass*const*>(aLeavesToInsert),nbLeavesToInsert);
}
int getNbSubLeaves() const {
return int(subLeaves.getSize());
}
ContainerClass* const * getSubLeaves() {
return subLeaves.data();
}
const ContainerClass * const * getSubLeaves() const{
return subLeaves.data();
}
ContainerClass* getSubLeaf(const int leafIdx) const{
return subLeaves[leafIdx];
}
////////////////////////////////////////////////////////////////////////////////
/// Manage the sub cell
////////////////////////////////////////////////////////////////////////////////
void setSubAdaptiveCell(FAdaptiveCell<RealCell,ContainerClass>* inSubAdaptiveCell, const int inSubAdaptiveLevel){
subAdaptiveCell = inSubAdaptiveCell;
subAdaptiveLevel = inSubAdaptiveLevel;
}
void setSubAdaptiveCell(const FAdaptiveCell<RealCell,ContainerClass>* inSubAdaptiveCell, const int inSubAdaptiveLevel){
subAdaptiveCell = const_cast<FAdaptiveCell<RealCell,ContainerClass>*>(inSubAdaptiveCell);
subAdaptiveLevel = inSubAdaptiveLevel;
}
FAdaptiveCell<RealCell,ContainerClass>* getSubAdaptiveCell() {
return subAdaptiveCell;
}
FAdaptiveCell<RealCell,ContainerClass>* getSubAdaptiveCell() const {
return subAdaptiveCell;
}
int getSubAdaptiveLevel() const {
return subAdaptiveLevel;
}
//#ifdef DEBUG_ADAPTIVE
////////////////////////////////////////////////////////////////////////////////
/// Manage a global IG DEBUG PURPOSE
////////////////////////////////////////////////////////////////////////////////
//! Return the global Id of the cell in the octree
const FSize getGlobalId(){
return this->gID ;
}
const FSize getGlobalId( ) const{
return this->gID ;
}
//! Set he global Id of the cell in the octree to id
void setGlobalId(const FSize & id){
this->gID = id; ;
}
//#endif
/**
* Operator stream FAdaptCell to std::ostream
*
* @param[in,out] output where to write the adaptive cell
* @param[in] inPosition the cell to write out
* @return the output for multiple << operators
*/
template <class StreamClass>
friend StreamClass& operator<<(StreamClass& output, const FAdaptiveCell<RealCell, ContainerClass>& cell){
output << "( Cell Id " << cell.getGlobalId() << " Adaptive " << std::boolalpha << cell.isAdaptive()
<< " sminM " << " cell.isSminMCriteria() "<< " "<< cell.getNbSubLeaves() ;
if(cell.getNbSubLeaves() >0){
output << " LF = { " ;
for (int i=0; i <cell.getNbSubLeaves() ; ++i){
output <<cell.getSubLeaf(i)->getNbParticles() << " ";
}
output << "}" ;
}
// output <<" CA={ ";
// const FVector<FExtACell> * v =cell.getadaptiveChild() ;
// if (cell.sizeofadaptiveChild()> 0 ){
// for (int i=0; i < v->getSize() ; ++i){
// output << v->operator [](i).cell->getGlobalId() << " ";
// }
// }
// output << "} " ;
// if(cell.getadaptiveFather().cell){
// output << " FA={" << (cell.getadaptiveFather()).cell->getGlobalId() << "} " ;
// }
// else
// {
// output << " FA={} " ;
// }
if(cell.hasDevelopment()){
output <<*(cell.getRealCell()) ;
}
// output << std::endl << " Multipoles " << *(cell.getRealCell()) << std::endl;
output << " )" <<std::endl;
return output; // for multiple << operators.
}
};
#endif
This diff is collapsed.
#ifndef FADAPTIVEPRINTKERNEL_HPP
#define FADAPTIVEPRINTKERNEL_HPP
// Keep in private GIT
// @SCALFMM_PRIVATE
#include <iostream>
#include "FAbstractAdaptiveKernel.hpp"
#include "../Components/FAbstractKernels.hpp"
/**
* This class simply print the interactions
*/
template <class CellClass, class ContainerClass>
class FAdaptivePrintKernel : public FAbstractKernels<CellClass,ContainerClass>, public FAbstractAdaptiveKernel<CellClass,ContainerClass> {
const int p2mTresh;
public:
FAdaptivePrintKernel(const int inP2mTresh = 10)
: p2mTresh(inP2mTresh) {
}
virtual ~FAdaptivePrintKernel(){
}
void P2M(CellClass* const pole, const ContainerClass* const particles) override {
std::cout << "Usual] P2M Idx = " << pole->getMortonIndex() << " and @" << particles << " with " << particles->getNbParticles() << "\n";
}
void M2M(CellClass* const FRestrict pole, const CellClass*const FRestrict *const FRestrict child , const int level) override {
std::cout << "Usual] M2M Idx = " << pole->getMortonIndex() << " at level " << level << " with\n";
for(int idxChild = 0 ; idxChild < 8 ; ++idxChild){
if(child[idxChild]){
std::cout << "\t Idx " << child[idxChild]->getMortonIndex() << "\n";
}
}
}
void M2L(CellClass* const FRestrict local, const CellClass* interactions[], const int /*positions*/[], const int counter, const int level) override {
std::cout << "Usual] M2L Idx = " << local->getMortonIndex() << " at level " << level << " with\n";
for(int idxInter = 0 ; idxInter < counter ; ++idxInter){
std::cout << "\t Idx " << interactions[idxInter]->getMortonIndex() << "\n";
}
}
void L2L(const CellClass* const FRestrict local, CellClass* FRestrict *const FRestrict child , const int level) override {
std::cout << "Usual] L2L Idx = " << local->getMortonIndex() << " at level " << level << " with\n";
for(int idxChild = 0 ; idxChild < 8 ; ++idxChild){
if(child[idxChild]){
std::cout << "\t Idx " << child[idxChild]->getMortonIndex() << "\n";
}
}
}
void L2P(const CellClass* const local, ContainerClass* const particles) override {
std::cout << "Usual] L2P Idx = " << local->getMortonIndex() << " and @" << particles << " with " << particles->getNbParticles() << "\n";
}
void P2P(const FTreeCoordinate& ,
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict ,
ContainerClass* const neighs[], const int /*positions*/[], const int size) override {
std::cout << "Usual] P2P @" << targets << " has " << targets->getNbParticles() << " with\n";
for(int idxNeigh = 0 ; idxNeigh < size ; ++idxNeigh){
std::cout << "\t @" << neighs[idxNeigh]<< " has " << neighs[idxNeigh]->getNbParticles() << "\n";
}
}
void P2PRemote(const FTreeCoordinate& ,
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict ,
const ContainerClass* const neighs[], const int /*positions*/[], const int size) override {
std::cout << "Usual] P2P remote @" << targets << " has " << targets->getNbParticles() << " with\n";
for(int idxNeigh = 0 ; idxNeigh < size ; ++idxNeigh){
std::cout << "\t @" << neighs[idxNeigh]<< " has " << neighs[idxNeigh]->getNbParticles() << "\n";
}
}
void P2M(CellClass* const pole, const int cellLevel, const ContainerClass* const particles) override{
std::cout << "Adaptive] P2M Idx = " << pole->getMortonIndex() << " and @" << particles << " with " << particles->getNbParticles() << ", cell at level " << cellLevel << "\n";
}
void M2M(CellClass* const pole, const int poleLevel, const CellClass* const subCell, const int subCellLevel) override{
std::cout << "Adaptive] M2M Idx = " << pole->getMortonIndex() << " at level " << poleLevel
<< " with " << subCell->getMortonIndex() << " from level " << subCellLevel << "\n";
}
void P2L(CellClass* const local, const int localLevel, const ContainerClass* const particles) override{
std::cout << "Adaptive] P2L Local Idx = " << local->getMortonIndex() << " with " << particles->getNbParticles() << ", cell at level " << localLevel << "\n";
}
void M2L(CellClass* const local, const int localLevel, const CellClass* const aNeighbor, const int neighborLevel) override{
std::cout << "Adaptive] L2L Idx = " << local->getMortonIndex() << " at level " << localLevel
<< " with " << aNeighbor->getMortonIndex() << " from level " << neighborLevel << "\n";
}
void M2P(const CellClass* const pole, const int poleLevel, ContainerClass* const particles) override{
std::cout << "Adaptive] M2P Idx = " << pole->getMortonIndex() << " with " << particles->getNbParticles() << ", cell at level " << poleLevel << "\n";
}
void L2L(const CellClass* const local, const int localLevel, CellClass* const subCell, const int subCellLevel) override{
std::cout << "Adaptive] L2L Idx = " << local->getMortonIndex() << " at level " << localLevel
<< " with " << subCell->getMortonIndex() << " from level " << subCellLevel << "\n";
}
void L2P(const CellClass* const local, const int cellLevel, ContainerClass* const particles) override{
std::cout << "Adaptive] L2P Idx = " << local->getMortonIndex() << " with " << particles->getNbParticles() << ", cell at level " << cellLevel << "\n";
}
void P2P(ContainerClass* targets, const ContainerClass* sources) override{
std::cout << "Adaptive] P2P between @" << targets << " with " << targets->getNbParticles()
<< " and @" << sources << " with " << sources->getNbParticles() << "\n";
}
bool preferP2M(const ContainerClass* const particles) override{
return particles->getNbParticles() > p2mTresh ;
}
bool preferP2M(const int atLevel, const ContainerClass*const particles[], const int nbContainers) override{
int count = 0;
for(int idx = 0 ; idx < nbContainers ; ++idx){
count += particles[idx]->getNbParticles();
}
return count > p2mTresh;
}
};
#endif // FADAPTIVEPRINTKERNEL_HPP
#ifndef FADAPTIVETESTKERNEL_HPP
#define FADAPTIVETESTKERNEL_HPP
// Keep in private GIT
// @SCALFMM_PRIVATE
#include "FAbstractAdaptiveKernel.hpp"
#include "../Components/FTestKernels.hpp"
template< class CellClass, class ContainerClass>
class FAdaptiveTestKernel : public FTestKernels<CellClass, ContainerClass>, public FAbstractAdaptiveKernel<CellClass, ContainerClass> {
const int p2mThresh;
public:
FAdaptiveTestKernel(const int inP2mThresh = 10)
: p2mThresh(inP2mThresh){
}
using FTestKernels<CellClass, ContainerClass>::P2M;
using FTestKernels<CellClass, ContainerClass>::M2M;
using FTestKernels<CellClass, ContainerClass>::M2L;
using FTestKernels<CellClass, ContainerClass>::L2L;
using FTestKernels<CellClass, ContainerClass>::L2P;
using FTestKernels<CellClass, ContainerClass>::P2P;
void P2M(CellClass* const pole, const int /*cellLevel*/, const ContainerClass* const particles) override {
pole->setDataUp(pole->getDataUp() + particles->getNbParticles());
}
void M2M(CellClass* const pole, const int /*poleLevel*/, const CellClass* const subCell, const int /*subCellLevel*/) override {
pole->setDataUp(pole->getDataUp() + subCell->getDataUp());
}
void P2L(CellClass* const local, const int /*localLevel*/, const ContainerClass* const particles) override {
local->setDataDown(local->getDataDown() + particles->getNbParticles());
}
void M2L(CellClass* const local, const int /*localLevel*/, const CellClass* const aNeighbor, const int /*neighborLevel*/) override {
local->setDataDown(local->getDataDown() + aNeighbor->getDataUp());
}
void M2P(const CellClass* const pole, const int /*poleLevel*/, ContainerClass* const particles) override {
long long int*const particlesAttributes = particles->getDataDown();
for(FSize idxPart = 0 ; idxPart < particles->getNbParticles() ; ++idxPart){
particlesAttributes[idxPart] += pole->getDataUp();
}
}
void L2L(const CellClass* const local, const int /*localLevel*/, CellClass* const subCell, const int /*subCellLevel*/) override {
subCell->setDataDown(local->getDataDown() + subCell->getDataDown());
}
void L2P(const CellClass* const local, const int /*cellLevel*/, ContainerClass* const particles) override {
long long int*const particlesAttributes = particles->getDataDown();
for(FSize idxPart = 0 ; idxPart < particles->getNbParticles() ; ++idxPart){
particlesAttributes[idxPart] += local->getDataDown();
}
}
void P2P(ContainerClass* target, const ContainerClass* sources) override {
long long int*const particlesAttributes = target->getDataDown();
for(FSize idxPart = 0 ; idxPart < target->getNbParticles() ; ++idxPart){
particlesAttributes[idxPart] += sources->getNbParticles();
}
}
bool preferP2M(const ContainerClass* const particles) override {
return particles->getNbParticles() > p2mThresh;
}
bool preferP2M(const int /*atLevel*/, const ContainerClass*const particles[], const int nbContainers) override {
FSize counterParticles = 0;
for(int idxContainer = 0 ; idxContainer < nbContainers ; ++idxContainer){
counterParticles += particles[idxContainer]->getNbParticles();
}
return counterParticles > p2mThresh;
}
};
#endif // FADAPTIVETESTKERNEL_HPP
This diff is collapsed.
This diff is collapsed.
// ==== CMAKE ====
// Keep in private GIT
// @SCALFMM_PRIVATE
#ifndef _FCOORDCOLOUR_HPP_
#define _FCOORDCOLOUR_HPP_
class FCoordColour {
public:
enum {range = 3*3*3};
static int coord2colour(const FTreeCoordinate& coord) {
return (coord.getX() % 3) * 9
+ (coord.getY() % 3) * 3
+ (coord.getZ() % 3);
}
};
#endif
// ==== CMAKE ====
// Keep in private GIT
// @SCALFMM_PRIVATE
#ifndef _FCOSTCELL_HPP_
#define _FCOSTCELL_HPP_
#include <type_traits>
/**
* \brief Empty trait class.
* \author Quentin Khan
*
* This class is used to check whether a cell class has FCostCell in its
* inheritance tree.
*/
class FCostCellTypeTrait {};
namespace scalfmm {
namespace detail {
template<class CostType>
class symbolic_data_t {
/// The far-field cost of the cell.
/** Declared mutable because the existing algorithms use const cells.*/
mutable CostType _cost = 0;
/// The near-field cost of the cell.
/** Declared mutable because the existing algorithms use const cells.*/
mutable CostType _leafCost = 0;
public:
/// Type definition that can be retrieved by other classes
using cost_t = CostType;
/// Debug member, used to check whether the cell was already visited.
bool _visited = false;
/**
* \brief Gets the far-field cost of the cell.
* \return The far-field cost of the cell
*/
CostType getCost() const {
return _cost;
}
/**
* \brief Gets the near-field cost of the cell.
* \return The near-field cost of the cell
*/
CostType getNearCost() const {
return _leafCost;
}
/**
* \brief Sets the cost of the cell.
*/
void setCost(CostType newCost) {
_cost = newCost;
}
/**
* \brief Sets the near-field cost of the cell.
*/
void setNearCost(CostType newCost) {
_leafCost = newCost;
}
/**
* \brief Add a far-field cost to the cell.
* \return The cost of the cell
* \warning Can be used on const cells !
*/
CostType addCost(CostType cost) const {
_cost += cost;
return _cost;
}
/**
* \brief Add a near-field cost to the cell.
* \return The cost of the cell
* \warning Can be used on const cells !
*/
CostType addNearCost(CostType cost) const {
_leafCost += cost;
return _leafCost;
}
};
}
}
/**
* \brief Cell with a cost memory for balance computations.
* \author Quentin Khan
*
* This class extends BaseClass to add simple computation cost memory.
*
* \tparam BaseClass The base cell class to extend. The constructors are
* inherited automatically.
* \tparam CostType The type to use in order to store the cost. Defaults to
* `std::size_t`.
*/
template<typename BaseClass, typename CostType = std::size_t>
class FCostCell : public BaseClass, public scalfmm::detail::symbolic_data_t<CostType> {
static_assert(std::is_arithmetic<CostType>::value,
"The cell cost type must be an arithmetic type.");
public:
/// Type definition that can be retrieved by other classes
using cost_t = CostType;
using BaseClass::BaseClass;
};
#endif
This diff is collapsed.
// ===================================================================================
// Copyright ScalFmm 2016 INRIA, Olivier Coulaud, Bérenger Bramas,
// Matthias Messner olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// 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.
// An extension to the license is given to allow static linking of scalfmm
// inside a proprietary application (no matter its license).
// See the main license file for more details.
//
// 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.gnu.org/licenses".
// ===================================================================================
// ==== CMAKE ====
// Keep in private GIT
// @SCALFMM_PRIVATE
#ifndef DUMBCOSTKERNEL_HPP
#define DUMBCOSTKERNEL_HPP
#include <stdexcept>
#include "Utils/FGlobal.hpp"
#include "Utils/FSmartPointer.hpp"
#include "Components/FAbstractKernels.hpp"
class FTreeCoordinate;
/**
* \author Quentin Khan, Matthias Messner (original file: FChebFlopsSymKernel)
* \brief Dumb cost computation for FMM.
*
* Please read the license
*
* This kernel implements a dumb cost the cost computation for FMM operators
* exploiting the symmetries in the far-field. It implements all interfaces
* (P2P, P2M, M2M, M2L, L2L, L2P) which are required by the
* FFmmAlgorithm and FFmmAlgorithmThread.
*
* \tparam Freal Type of real number representation
* \tparam CellClass Type of cell
* \tparam ContainerClass Type of container to store particles
* \tparam OctreeClass Class of the octree to work on.
*/
template < typename FReal, class CellClass, class ContainerClass, class OctreeClass>
class FDumbCostKernel : public FAbstractKernels<CellClass, ContainerClass>
{
public:
// Class types available to the rest of the world
/// Type of real number representation
using _FReal = FReal;
/// Type of cell
using _CellClass = CellClass;
/// Type of container to store particles
using _ContainerClass = ContainerClass;
/// Class of the octree to work on
using _OctreeClass = OctreeClass;
/// The tree the kernel is working on. Needed to attain cells in the P2P
/// operator (we only get the particles containers otherwise)
<