Commit c4021679 authored by Quentin Khan's avatar Quentin Khan

FCostCell : Added cost for the near field.

FChebBalanceSymKernel : Added FReal type to template.
FChebBalanceSymKernel : Takes care of near field.
parent 1a505a9b
......@@ -52,7 +52,7 @@ class FTreeCoordinate;
* \tparam MatrixKernelClass Type of matrix kernel function
* \tparam ORDER Chebyshev interpolation order
*/
template < class CellClass, class ContainerClass, class MatrixKernelClass, int ORDER, class OctreeClass>
template < typename FReal, class CellClass, class ContainerClass, class MatrixKernelClass, int ORDER, class OctreeClass>
class FChebBalanceSymKernel
: public FAbstractKernels<CellClass, ContainerClass>
{
......@@ -305,7 +305,7 @@ public:
LeafCellCoordinate.getMortonIndex(_treeHeight - 1),
_treeHeight - 1);
cell->addCost(tmpCost);
cell->addNearCost(tmpCost);
countP2P++;
}
};
......@@ -316,9 +316,9 @@ public:
* Handler to deal with all symmetries: Stores permutation indices and vectors
* to reduce 343 different interactions to 16 only.
*/
template < class CellClass, class ContainerClass, class MatrixKernelClass,
int ORDER, class OctreeClass>
struct FChebBalanceSymKernel<CellClass, ContainerClass, MatrixKernelClass, ORDER, OctreeClass>
template < typename FReal, class CellClass, class ContainerClass,
class MatrixKernelClass, int ORDER, class OctreeClass>
struct FChebBalanceSymKernel<FReal, CellClass, ContainerClass, MatrixKernelClass, ORDER, OctreeClass>
::SymmetryHandler
{
// M2L operators
......
......@@ -5,6 +5,8 @@
#ifndef _FCOSTCELL_HPP_
#define _FCOSTCELL_HPP_
#include <type_traits>
/**
* \brief Cell with a cost memory for balance computations.
* \author Quentin Khan
......@@ -13,27 +15,46 @@
*
* \tparam BaseClass The base cell class to extend. The constructors are
* inherited automatically.
* \tparam The type to use in order to store the cost. Defaults to FSize.
* \tparam CostType The type to use in order to store the cost. Defaults to FSize.
*/
template<typename BaseClass, typename CostType = FSize>
class FCostCell : public BaseClass {
/// The cost of the cell. It is declared mutable because the existing
/// algorithms use const cells.
static_assert(std::is_arithmetic<CostType>::value,
"The cell cost type must be an arithmetic type.");
/// 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 costtype = CostType;
using BaseClass::BaseClass;
/// Debug member, used to check whether the cell was already visited.
bool _visited = false;
/**
* \brief Gets the cost of the cell.
* \return The cost of the cell
* \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.
*/
......@@ -41,8 +62,15 @@ public:
_cost = newCost;
}
/**
* \brief Sets the near-field cost of the cell.
*/
void setNearCost(CostType newCost) {
_leafCost = newCost;
}
/**
* \brief Add a cost to the cell.
* \brief Add a far-field cost to the cell.
* \return The cost of the cell
* \warning Can be used on const cells !
*/
......@@ -50,6 +78,16 @@ public:
_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;
}
};
#endif
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