Commit d046dd55 authored by BLANCHARD Pierre's avatar BLANCHARD Pierre

Modified interpolation based kernels such that matrix kernel is passed to ctor.

parent 72b93562
...@@ -122,6 +122,7 @@ int main(int argc, char* argv[]) ...@@ -122,6 +122,7 @@ int main(int argc, char* argv[])
typedef FOctree<CellClass,ContainerClass,LeafClass> OctreeClass; typedef FOctree<CellClass,ContainerClass,LeafClass> OctreeClass;
// //
typedef FInterpMatrixKernelR MatrixKernelClass; typedef FInterpMatrixKernelR MatrixKernelClass;
const MatrixKernelClass MatrixKernel;
typedef FChebSymKernel<CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; typedef FChebSymKernel<CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass;
// //
#ifdef _OPENMP #ifdef _OPENMP
...@@ -161,7 +162,7 @@ int main(int argc, char* argv[]) ...@@ -161,7 +162,7 @@ int main(int argc, char* argv[])
time.tic(); time.tic();
// //
KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox()); KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox(),&MatrixKernel);
// //
FmmClass algorithm(&tree, &kernels); FmmClass algorithm(&tree, &kernels);
// //
......
...@@ -49,8 +49,6 @@ protected: ...@@ -49,8 +49,6 @@ protected:
/// Needed for P2M, M2M, L2L and L2P operators /// Needed for P2M, M2M, L2L and L2P operators
const FSmartPointer<InterpolatorClass,FSmartPointerMemory> Interpolator; const FSmartPointer<InterpolatorClass,FSmartPointerMemory> Interpolator;
/// Needed for P2P operator
/*const*/ FSmartPointer<MatrixKernelClass,FSmartPointerMemory> MatrixKernel;
/// Height of the entire oct-tree /// Height of the entire oct-tree
const unsigned int TreeHeight; const unsigned int TreeHeight;
/// Corner of oct-tree box /// Corner of oct-tree box
...@@ -61,9 +59,6 @@ protected: ...@@ -61,9 +59,6 @@ protected:
const FReal BoxWidthLeaf; const FReal BoxWidthLeaf;
/// Extension of the box width ( same for all level! ) /// Extension of the box width ( same for all level! )
const FReal BoxWidthExtension; const FReal BoxWidthExtension;
/// Parameter to pass to matrix kernel (material specific or anything)
const FReal MatParam;
/** /**
* Compute center of leaf cell from its tree coordinate. * Compute center of leaf cell from its tree coordinate.
...@@ -86,18 +81,15 @@ public: ...@@ -86,18 +81,15 @@ public:
FAbstractChebKernel(const int inTreeHeight, FAbstractChebKernel(const int inTreeHeight,
const FReal inBoxWidth, const FReal inBoxWidth,
const FPoint& inBoxCenter, const FPoint& inBoxCenter,
const FReal inBoxWidthExtension = 0.0, const FReal inBoxWidthExtension = 0.0)
const FReal inMatParam = 0.0)
: Interpolator(new InterpolatorClass(inTreeHeight, : Interpolator(new InterpolatorClass(inTreeHeight,
inBoxWidth, inBoxWidth,
inBoxWidthExtension)), inBoxWidthExtension)),
MatrixKernel(new MatrixKernelClass(inMatParam)),
TreeHeight(inTreeHeight), TreeHeight(inTreeHeight),
BoxCorner(inBoxCenter - inBoxWidth / FReal(2.)), BoxCorner(inBoxCenter - inBoxWidth / FReal(2.)),
BoxWidth(inBoxWidth), BoxWidth(inBoxWidth),
BoxWidthLeaf(BoxWidth / FReal(FMath::pow(2, inTreeHeight - 1))), BoxWidthLeaf(BoxWidth / FReal(FMath::pow(2, inTreeHeight - 1))),
BoxWidthExtension(inBoxWidthExtension), BoxWidthExtension(inBoxWidthExtension)
MatParam(inMatParam)
{ {
/* empty */ /* empty */
} }
...@@ -109,10 +101,6 @@ public: ...@@ -109,10 +101,6 @@ public:
const InterpolatorClass * getPtrToInterpolator() const const InterpolatorClass * getPtrToInterpolator() const
{ return Interpolator.getPtr(); } { return Interpolator.getPtr(); }
MatrixKernelClass * getPtrMatrixKernel()
{return MatrixKernel; }
virtual void P2M(CellClass* const LeafCell, virtual void P2M(CellClass* const LeafCell,
const ContainerClass* const SourceParticles) = 0; const ContainerClass* const SourceParticles) = 0;
......
...@@ -51,6 +51,9 @@ class FChebKernel ...@@ -51,6 +51,9 @@ class FChebKernel
typedef FAbstractChebKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS> typedef FAbstractChebKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>
AbstractBaseClass; AbstractBaseClass;
/// Needed for P2P and M2L operators
const MatrixKernelClass *const MatrixKernel;
/// Needed for M2L operator /// Needed for M2L operator
FSmartPointer< M2LHandlerClass,FSmartPointerMemory> M2LHandler; FSmartPointer< M2LHandlerClass,FSmartPointerMemory> M2LHandler;
...@@ -60,20 +63,21 @@ public: ...@@ -60,20 +63,21 @@ public:
* precomputed and compressed M2L operators from a binary file (an * precomputed and compressed M2L operators from a binary file (an
* runtime_error is thrown if the required file is not valid). * runtime_error is thrown if the required file is not valid).
*/ */
FChebKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter, FChebKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter, const MatrixKernelClass *const inMatrixKernel,
const FReal Epsilon) const FReal Epsilon)
: FAbstractChebKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight, : FAbstractChebKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight,
inBoxWidth, inBoxWidth,
inBoxCenter), inBoxCenter),
M2LHandler(new M2LHandlerClass(Epsilon)) MatrixKernel(inMatrixKernel),
M2LHandler(new M2LHandlerClass(MatrixKernel,Epsilon))
{ {
// read precomputed compressed m2l operators from binary file // read precomputed compressed m2l operators from binary file
//M2LHandler->ReadFromBinaryFileAndSet(); //M2LHandler->ReadFromBinaryFileAndSet();
M2LHandler->ComputeAndCompressAndSet(); M2LHandler->ComputeAndCompressAndSet();
} }
FChebKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter) FChebKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter, const MatrixKernelClass *const inMatrixKernel)
: FChebKernel(inTreeHeight, inBoxWidth,inBoxCenter,FMath::pow(10.0,static_cast<FReal>(-ORDER))) : FChebKernel(inTreeHeight, inBoxWidth,inBoxCenter,inMatrixKernel,FMath::pow(10.0,static_cast<FReal>(-ORDER)))
{ {
} }
...@@ -212,14 +216,14 @@ public: ...@@ -212,14 +216,14 @@ public:
ContainerClass* const NeighborSourceParticles[27], ContainerClass* const NeighborSourceParticles[27],
const int /* size */) const int /* size */)
{ {
DirectInteractionComputer<MatrixKernelClass::Identifier, NVALS>::P2P(TargetParticles,NeighborSourceParticles,AbstractBaseClass::MatrixKernel.getPtr()); DirectInteractionComputer<MatrixKernelClass::Identifier, NVALS>::P2P(TargetParticles,NeighborSourceParticles,MatrixKernel);
} }
void P2PRemote(const FTreeCoordinate& /*inPosition*/, void P2PRemote(const FTreeCoordinate& /*inPosition*/,
ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/,
ContainerClass* const inNeighbors[27], const int /*inSize*/){ ContainerClass* const inNeighbors[27], const int /*inSize*/){
DirectInteractionComputer<MatrixKernelClass::Identifier, NVALS>::P2PRemote(inTargets,inNeighbors,27,AbstractBaseClass::MatrixKernel.getPtr()); DirectInteractionComputer<MatrixKernelClass::Identifier, NVALS>::P2PRemote(inTargets,inNeighbors,27,MatrixKernel);
} }
}; };
......
...@@ -70,7 +70,7 @@ class FChebM2LHandler : FNoCopyable ...@@ -70,7 +70,7 @@ class FChebM2LHandler : FNoCopyable
nnodes = TensorTraits<ORDER>::nnodes, nnodes = TensorTraits<ORDER>::nnodes,
ninteractions = 316}; // 7^3 - 3^3 (max num cells in far-field) ninteractions = 316}; // 7^3 - 3^3 (max num cells in far-field)
const MatrixKernelClass MatrixKernel; const MatrixKernelClass *const MatrixKernel;
FReal *U, *C, *B; FReal *U, *C, *B;
const FReal epsilon; //<! accuracy which determines trucation of SVD const FReal epsilon; //<! accuracy which determines trucation of SVD
...@@ -88,8 +88,8 @@ class FChebM2LHandler : FNoCopyable ...@@ -88,8 +88,8 @@ class FChebM2LHandler : FNoCopyable
public: public:
FChebM2LHandler(const FReal _epsilon) FChebM2LHandler(const MatrixKernelClass *const inMatrixKernel, const FReal _epsilon)
: MatrixKernel(), U(nullptr), C(nullptr), B(nullptr), epsilon(_epsilon), rank(0) : MatrixKernel(inMatrixKernel), U(nullptr), C(nullptr), B(nullptr), epsilon(_epsilon), rank(0)
{} {}
~FChebM2LHandler() ~FChebM2LHandler()
...@@ -108,7 +108,7 @@ public: ...@@ -108,7 +108,7 @@ public:
FTic time; time.tic(); FTic time; time.tic();
// check if aready set // check if aready set
if (U||C||B) throw std::runtime_error("Compressed M2L operator already set"); if (U||C||B) throw std::runtime_error("Compressed M2L operator already set");
rank = ComputeAndCompress(epsilon, U, C, B); rank = ComputeAndCompress(MatrixKernel, epsilon, U, C, B);
unsigned long sizeM2L = 343*rank*rank*sizeof(FReal); unsigned long sizeM2L = 343*rank*rank*sizeof(FReal);
...@@ -135,13 +135,13 @@ public: ...@@ -135,13 +135,13 @@ public:
* @param[out] C matrix of size \f$r\times 316 r\f$ storing \f$[C_1,\dots,C_{316}]\f$ * @param[out] C matrix of size \f$r\times 316 r\f$ storing \f$[C_1,\dots,C_{316}]\f$
* @param[out] B matrix of size \f$\ell^3\times r\f$ * @param[out] B matrix of size \f$\ell^3\times r\f$
*/ */
static unsigned int ComputeAndCompress(const FReal epsilon, FReal* &U, FReal* &C, FReal* &B); static unsigned int ComputeAndCompress(const MatrixKernelClass *const MatrixKernel, const FReal epsilon, FReal* &U, FReal* &C, FReal* &B);
/** /**
* Computes, compresses and stores the matrices \f$Y, C_t, B\f$ in a binary * Computes, compresses and stores the matrices \f$Y, C_t, B\f$ in a binary
* file * file
*/ */
static void ComputeAndCompressAndStoreInBinaryFile(const FReal epsilon); static void ComputeAndCompressAndStoreInBinaryFile(const MatrixKernelClass *const MatrixKernel, const FReal epsilon);
/** /**
* Reads the matrices \f$Y, C_t, B\f$ from the respective binary file * Reads the matrices \f$Y, C_t, B\f$ from the respective binary file
...@@ -182,19 +182,19 @@ public: ...@@ -182,19 +182,19 @@ public:
{ {
const unsigned int idx const unsigned int idx
= (transfer[0]+3)*7*7 + (transfer[1]+3)*7 + (transfer[2]+3); = (transfer[0]+3)*7*7 + (transfer[1]+3)*7 + (transfer[2]+3);
const FReal scale(MatrixKernel.getScaleFactor(CellWidth)); const FReal scale(MatrixKernel->getScaleFactor(CellWidth));
FBlas::gemva(rank, rank, scale, C + idx*rank*rank, const_cast<FReal*>(Y), X); FBlas::gemva(rank, rank, scale, C + idx*rank*rank, const_cast<FReal*>(Y), X);
} }
void applyC(const unsigned int idx, FReal CellWidth, void applyC(const unsigned int idx, FReal CellWidth,
const FReal *const Y, FReal *const X) const const FReal *const Y, FReal *const X) const
{ {
const FReal scale(MatrixKernel.getScaleFactor(CellWidth)); const FReal scale(MatrixKernel->getScaleFactor(CellWidth));
FBlas::gemva(rank, rank, scale, C + idx*rank*rank, const_cast<FReal*>(Y), X); FBlas::gemva(rank, rank, scale, C + idx*rank*rank, const_cast<FReal*>(Y), X);
} }
void applyC(FReal CellWidth, void applyC(FReal CellWidth,
const FReal *const Y, FReal *const X) const const FReal *const Y, FReal *const X) const
{ {
const FReal scale(MatrixKernel.getScaleFactor(CellWidth)); const FReal scale(MatrixKernel->getScaleFactor(CellWidth));
FBlas::gemva(rank, rank * 343, scale, C, const_cast<FReal*>(Y), X); FBlas::gemva(rank, rank * 343, scale, C, const_cast<FReal*>(Y), X);
} }
...@@ -229,7 +229,8 @@ public: ...@@ -229,7 +229,8 @@ public:
template <int ORDER, class MatrixKernelClass> template <int ORDER, class MatrixKernelClass>
unsigned int unsigned int
FChebM2LHandler<ORDER, MatrixKernelClass>::ComputeAndCompress(const FReal epsilon, FChebM2LHandler<ORDER, MatrixKernelClass>::ComputeAndCompress(const MatrixKernelClass *const MatrixKernel,
const FReal epsilon,
FReal* &U, FReal* &U,
FReal* &C, FReal* &C,
FReal* &B) FReal* &B)
...@@ -241,8 +242,6 @@ FChebM2LHandler<ORDER, MatrixKernelClass>::ComputeAndCompress(const FReal epsilo ...@@ -241,8 +242,6 @@ FChebM2LHandler<ORDER, MatrixKernelClass>::ComputeAndCompress(const FReal epsilo
FPoint X[nnodes], Y[nnodes]; FPoint X[nnodes], Y[nnodes];
// set roots of target cell (X) // set roots of target cell (X)
FChebTensor<order>::setRoots(FPoint(0.,0.,0.), FReal(2.), X); FChebTensor<order>::setRoots(FPoint(0.,0.,0.), FReal(2.), X);
// init matrix kernel
const MatrixKernelClass MatrixKernel;
// allocate memory and compute 316 m2l operators // allocate memory and compute 316 m2l operators
FReal *_U, *_C, *_B; FReal *_U, *_C, *_B;
...@@ -260,7 +259,7 @@ FChebM2LHandler<ORDER, MatrixKernelClass>::ComputeAndCompress(const FReal epsilo ...@@ -260,7 +259,7 @@ FChebM2LHandler<ORDER, MatrixKernelClass>::ComputeAndCompress(const FReal epsilo
for (unsigned int n=0; n<nnodes; ++n) for (unsigned int n=0; n<nnodes; ++n)
for (unsigned int m=0; m<nnodes; ++m) for (unsigned int m=0; m<nnodes; ++m)
_C[counter*nnodes*nnodes + n*nnodes + m] _C[counter*nnodes*nnodes + n*nnodes + m]
= MatrixKernel.evaluate(X[m], Y[n]); = MatrixKernel->evaluate(X[m], Y[n]);
// increment interaction counter // increment interaction counter
counter++; counter++;
} }
...@@ -330,14 +329,14 @@ FChebM2LHandler<ORDER, MatrixKernelClass>::ComputeAndCompress(const FReal epsilo ...@@ -330,14 +329,14 @@ FChebM2LHandler<ORDER, MatrixKernelClass>::ComputeAndCompress(const FReal epsilo
template <int ORDER, class MatrixKernelClass> template <int ORDER, class MatrixKernelClass>
void void
FChebM2LHandler<ORDER, MatrixKernelClass>::ComputeAndCompressAndStoreInBinaryFile(const FReal epsilon) FChebM2LHandler<ORDER, MatrixKernelClass>::ComputeAndCompressAndStoreInBinaryFile(const MatrixKernelClass *const MatrixKernel, const FReal epsilon)
{ {
// measure time // measure time
FTic time; time.tic(); FTic time; time.tic();
// start computing process // start computing process
FReal *U, *C, *B; FReal *U, *C, *B;
U = C = B = nullptr; U = C = B = nullptr;
const unsigned int rank = ComputeAndCompress(epsilon, U, C, B); const unsigned int rank = ComputeAndCompress(MatrixKernel, epsilon, U, C, B);
// store into binary file // store into binary file
const std::string filename(getFileName(epsilon)); const std::string filename(getFileName(epsilon));
std::ofstream stream(filename.c_str(), std::ofstream stream(filename.c_str(),
......
...@@ -56,6 +56,9 @@ class FChebSymKernel ...@@ -56,6 +56,9 @@ class FChebSymKernel
typedef SymmetryHandler<ORDER, MatrixKernelClass::Type> SymmetryHandlerClass; typedef SymmetryHandler<ORDER, MatrixKernelClass::Type> SymmetryHandlerClass;
enum {nnodes = AbstractBaseClass::nnodes}; enum {nnodes = AbstractBaseClass::nnodes};
/// Needed for P2P and M2L operators
const MatrixKernelClass *const MatrixKernel;
/// Needed for handling all symmetries /// Needed for handling all symmetries
const FSmartPointer<SymmetryHandlerClass,FSmartPointerMemory> SymHandler; const FSmartPointer<SymmetryHandlerClass,FSmartPointerMemory> SymHandler;
...@@ -105,11 +108,13 @@ public: ...@@ -105,11 +108,13 @@ public:
* runtime_error is thrown if the required file is not valid). * runtime_error is thrown if the required file is not valid).
*/ */
FChebSymKernel(const int inTreeHeight, FChebSymKernel(const int inTreeHeight,
const FReal inBoxWidth, const FReal inBoxWidth,
const FPoint& inBoxCenter, const FPoint& inBoxCenter,
const FReal Epsilon) const MatrixKernelClass *const inMatrixKernel,
const FReal Epsilon)
: AbstractBaseClass(inTreeHeight, inBoxWidth, inBoxCenter), : AbstractBaseClass(inTreeHeight, inBoxWidth, inBoxCenter),
SymHandler(new SymmetryHandlerClass(AbstractBaseClass::MatrixKernel.getPtr(), Epsilon, inBoxWidth, inTreeHeight)), MatrixKernel(inMatrixKernel),
SymHandler(new SymmetryHandlerClass(MatrixKernel, Epsilon, inBoxWidth, inTreeHeight)),
Loc(nullptr), Mul(nullptr), countExp(nullptr) Loc(nullptr), Mul(nullptr), countExp(nullptr)
{ {
this->allocateMemoryForPermutedExpansions(); this->allocateMemoryForPermutedExpansions();
...@@ -126,8 +131,9 @@ public: ...@@ -126,8 +131,9 @@ public:
* runtime_error is thrown if the required file is not valid). * runtime_error is thrown if the required file is not valid).
*/ */
FChebSymKernel(const int inTreeHeight, FChebSymKernel(const int inTreeHeight,
const FReal inBoxWidth, const FReal inBoxWidth,
const FPoint& inBoxCenter) :FChebSymKernel(inTreeHeight,inBoxWidth, inBoxCenter,FMath::pow(10.0,static_cast<FReal>(-ORDER))) const FPoint& inBoxCenter,
const MatrixKernelClass *const inMatrixKernel) :FChebSymKernel(inTreeHeight,inBoxWidth, inBoxCenter,inMatrixKernel,FMath::pow(10.0,static_cast<FReal>(-ORDER)))
{} {}
...@@ -135,6 +141,7 @@ public: ...@@ -135,6 +141,7 @@ public:
/** Copy constructor */ /** Copy constructor */
FChebSymKernel(const FChebSymKernel& other) FChebSymKernel(const FChebSymKernel& other)
: AbstractBaseClass(other), : AbstractBaseClass(other),
MatrixKernel(other.MatrixKernel),
SymHandler(other.SymHandler), SymHandler(other.SymHandler),
Loc(nullptr), Mul(nullptr), countExp(nullptr) Loc(nullptr), Mul(nullptr), countExp(nullptr)
{ {
...@@ -264,7 +271,7 @@ public: ...@@ -264,7 +271,7 @@ public:
// multiply (mat-mat-mul) // multiply (mat-mat-mul)
FReal Compressed [nnodes * 24]; FReal Compressed [nnodes * 24];
const FReal scale = AbstractBaseClass::MatrixKernel->getScaleFactor(AbstractBaseClass::BoxWidth, TreeLevel); const FReal scale = MatrixKernel->getScaleFactor(AbstractBaseClass::BoxWidth, TreeLevel);
for (unsigned int pidx=0; pidx<343; ++pidx) { for (unsigned int pidx=0; pidx<343; ++pidx) {
const unsigned int count = countExp[pidx]; const unsigned int count = countExp[pidx];
if (count) { if (count) {
...@@ -462,14 +469,14 @@ public: ...@@ -462,14 +469,14 @@ public:
ContainerClass* const NeighborSourceParticles[27], ContainerClass* const NeighborSourceParticles[27],
const int /* size */) const int /* size */)
{ {
DirectInteractionComputer<MatrixKernelClass::Identifier, NVALS>::P2P(TargetParticles,NeighborSourceParticles,AbstractBaseClass::MatrixKernel.getPtr()); DirectInteractionComputer<MatrixKernelClass::Identifier, NVALS>::P2P(TargetParticles,NeighborSourceParticles,MatrixKernel);
} }
void P2PRemote(const FTreeCoordinate& /*inPosition*/, void P2PRemote(const FTreeCoordinate& /*inPosition*/,
ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/,
ContainerClass* const inNeighbors[27], const int /*inSize*/){ ContainerClass* const inNeighbors[27], const int /*inSize*/){
DirectInteractionComputer<MatrixKernelClass::Identifier, NVALS>::P2PRemote(inTargets,inNeighbors,27,AbstractBaseClass::MatrixKernel.getPtr()); DirectInteractionComputer<MatrixKernelClass::Identifier, NVALS>::P2PRemote(inTargets,inNeighbors,27,MatrixKernel);
} }
}; };
......
...@@ -303,7 +303,7 @@ static void precompute(const MatrixKernelClass *const MatrixKernel, const FReal ...@@ -303,7 +303,7 @@ static void precompute(const MatrixKernelClass *const MatrixKernel, const FReal
FChebTensor<ORDER>::setRootOfWeights(weights); FChebTensor<ORDER>::setRootOfWeights(weights);
// now the entry-computer is responsible for weighting the matrix entries // now the entry-computer is responsible for weighting the matrix entries
EntryComputer<MatrixKernelClass> Computer(nnodes, X, nnodes, Y, weights); EntryComputer<MatrixKernelClass> Computer(MatrixKernel, nnodes, X, nnodes, Y, weights);
// start timer // start timer
time.tic(); time.tic();
......
...@@ -59,6 +59,9 @@ protected://PB: for OptiDis ...@@ -59,6 +59,9 @@ protected://PB: for OptiDis
typedef FAbstractChebKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS> typedef FAbstractChebKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>
AbstractBaseClass; AbstractBaseClass;
/// Needed for P2P and M2L operators
const MatrixKernelClass *const MatrixKernel;
/// Needed for M2L operator /// Needed for M2L operator
FSmartPointer< M2LHandlerClass,FSmartPointerMemory> M2LHandler; FSmartPointer< M2LHandlerClass,FSmartPointerMemory> M2LHandler;
...@@ -71,11 +74,12 @@ public: ...@@ -71,11 +74,12 @@ public:
FChebTensorialKernel(const int inTreeHeight, FChebTensorialKernel(const int inTreeHeight,
const FReal inBoxWidth, const FReal inBoxWidth,
const FPoint& inBoxCenter, const FPoint& inBoxCenter,
const MatrixKernelClass *const inMatrixKernel,
const FReal inBoxWidthExtension, const FReal inBoxWidthExtension,
const FReal Epsilon, const FReal Epsilon)
const double inMatParam = 0.0) : FAbstractChebKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight,inBoxWidth,inBoxCenter,inBoxWidthExtension),
: FAbstractChebKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight,inBoxWidth,inBoxCenter,inBoxWidthExtension,inMatParam), MatrixKernel(inMatrixKernel),
M2LHandler(new M2LHandlerClass(AbstractBaseClass::MatrixKernel.getPtr(), M2LHandler(new M2LHandlerClass(MatrixKernel,
inTreeHeight, inTreeHeight,
inBoxWidth, inBoxWidth,
inBoxWidthExtension, inBoxWidthExtension,
...@@ -143,7 +147,7 @@ public: ...@@ -143,7 +147,7 @@ public:
// scale factor for homogeneous case // scale factor for homogeneous case
const FReal CellWidth(AbstractBaseClass::BoxWidth / FReal(FMath::pow(2, TreeLevel))); const FReal CellWidth(AbstractBaseClass::BoxWidth / FReal(FMath::pow(2, TreeLevel)));
const FReal ExtendedCellWidth(CellWidth + AbstractBaseClass::BoxWidthExtension); const FReal ExtendedCellWidth(CellWidth + AbstractBaseClass::BoxWidthExtension);
const FReal scale(AbstractBaseClass::MatrixKernel.getPtr()->getScaleFactor(ExtendedCellWidth)); const FReal scale(MatrixKernel->getScaleFactor(ExtendedCellWidth));
for(int idxV = 0 ; idxV < NVALS ; ++idxV){ for(int idxV = 0 ; idxV < NVALS ; ++idxV){
for (int idxLhs=0; idxLhs < nLhs; ++idxLhs){ for (int idxLhs=0; idxLhs < nLhs; ++idxLhs){
...@@ -158,8 +162,7 @@ public: ...@@ -158,8 +162,7 @@ public:
const int idxMul = idxV*nRhs + idxRhs; const int idxMul = idxV*nRhs + idxRhs;
// get index in matrix kernel // get index in matrix kernel
const unsigned int d const unsigned int d = MatrixKernel->getPosition(idxLhs);
= AbstractBaseClass::MatrixKernel.getPtr()->getPosition(idxLhs);
for (int idx=0; idx<343; ++idx){ for (int idx=0; idx<343; ++idx){
if (SourceCells[idx]){ if (SourceCells[idx]){
...@@ -237,14 +240,14 @@ public: ...@@ -237,14 +240,14 @@ public:
ContainerClass* const NeighborSourceParticles[27], ContainerClass* const NeighborSourceParticles[27],
const int /* size */) const int /* size */)
{ {
DirectInteractionComputer<MatrixKernelClass::Identifier, NVALS>::P2P(TargetParticles,NeighborSourceParticles,AbstractBaseClass::MatrixKernel.getPtr()); DirectInteractionComputer<MatrixKernelClass::Identifier, NVALS>::P2P(TargetParticles,NeighborSourceParticles,MatrixKernel);
} }
void P2PRemote(const FTreeCoordinate& /*inPosition*/, void P2PRemote(const FTreeCoordinate& /*inPosition*/,
ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/,
ContainerClass* const inNeighbors[27], const int /*inSize*/){ ContainerClass* const inNeighbors[27], const int /*inSize*/){
DirectInteractionComputer<MatrixKernelClass::Identifier, NVALS>::P2PRemote(inTargets,inNeighbors,27,AbstractBaseClass::MatrixKernel.getPtr()); DirectInteractionComputer<MatrixKernelClass::Identifier, NVALS>::P2PRemote(inTargets,inNeighbors,27,MatrixKernel);
} }
}; };
......
...@@ -82,8 +82,6 @@ class FChebTensorialM2LHandler<ORDER,MatrixKernelClass,HOMOGENEOUS> : FNoCopyabl ...@@ -82,8 +82,6 @@ class FChebTensorialM2LHandler<ORDER,MatrixKernelClass,HOMOGENEOUS> : FNoCopyabl
ninteractions = 316,// 7^3 - 3^3 (max num cells in far-field) ninteractions = 316,// 7^3 - 3^3 (max num cells in far-field)
ncmp = MatrixKernelClass::NCMP}; ncmp = MatrixKernelClass::NCMP};
// const MatrixKernelClass MatrixKernel;
// FReal *U, *C, *B; // FReal *U, *C, *B;
FReal *U, *B; FReal *U, *B;
FReal** C; FReal** C;
......
...@@ -80,7 +80,11 @@ struct FInterpMatrixKernelR : FInterpAbstractMatrixKernel ...@@ -80,7 +80,11 @@ struct FInterpMatrixKernelR : FInterpAbstractMatrixKernel
static const unsigned int NRHS = 1; //< dim of mult exp static const unsigned int NRHS = 1; //< dim of mult exp