Commit 6121b3bd authored by BRAMAS Berenger's avatar BRAMAS Berenger
Browse files

add typed for all cells to enable TSM

parent ebaf0476
......@@ -30,57 +30,62 @@
*/
class FExtendCellType {
protected:
/** Particle potential type */
static const int Neither = 0;
static const int ContainsSrc = 1;
static const int ContainsTargets = 2;
/** Current type */
int type;
bool containsTargets;
bool containsSources;
public:
/** Default constructor */
FExtendCellType() : type(Neither) {
FExtendCellType() : containsTargets(false), containsSources(false) {
}
/** Copy constructor */
FExtendCellType(const FExtendCellType& other) : type(other.type) {
FExtendCellType(const FExtendCellType& other) : containsTargets(other.containsTargets),
containsSources(other.containsSources){
}
/** Copy operator */
FExtendCellType& operator=(const FExtendCellType& other) {
this->type = other.type;
this->containsTargets = other.containsTargets;
this->containsSources = other.containsSources;
return *this;
}
/** To know if a cell has sources */
bool hasSrcChild() const {
return this->type & ContainsSrc;
return containsSources;
}
/** To know if a cell has targets */
bool hasTargetsChild() const {
return this->type & ContainsTargets;
return containsTargets;
}
/** To set cell as sources container */
void setSrcChildTrue() {
this->type |= ContainsSrc;
containsSources = true;
}
/** To set cell as targets container */
void setTargetsChildTrue() {
this->type |= ContainsTargets;
containsTargets = true;
}
public:
/** Save current object */
void save(FBufferWriter& buffer) const {
buffer << type;
buffer << containsTargets;
buffer << containsSources;
}
/** Retrieve current object */
void restore(FBufferReader& buffer) {
buffer >> type;
buffer >> containsTargets;
buffer >> containsSources;
}
/** reset to unknown type */
void resetToInitialState(){
containsTargets = false;
containsSources = false;
}
};
......
......@@ -21,6 +21,7 @@
#include "../../Extensions/FExtendCoordinate.hpp"
#include "./FChebTensor.hpp"
#include "../../Extensions/FExtendCellType.hpp"
/**
* @author Matthias Messner (matthias.messner@inria.fr)
......@@ -76,6 +77,22 @@ public:
}
};
template <int ORDER, int NVALS = 1>
class FTypedChebCell : public FChebCell<ORDER,NVALS>, public FExtendCellType {
public:
void save(FBufferWriter& buffer) const{
FChebCell<ORDER,NVALS>::save(buffer);
FExtendCellType::save(buffer);
}
void restore(FBufferReader& buffer){
FChebCell<ORDER,NVALS>::restore(buffer);
FExtendCellType::restore(buffer);
}
void resetToInitialState(){
FChebCell<ORDER,NVALS>::resetToInitialState();
FExtendCellType::resetToInitialState();
}
};
#endif //FCHEBCELL_HPP
......
......@@ -138,4 +138,21 @@ public:
}
};
template <int P>
class FTypedRotationCell : public FRotationCell<P>, public FExtendCellType {
public:
void save(FBufferWriter& buffer) const{
FRotationCell<P>::save(buffer);
FExtendCellType::save(buffer);
}
void restore(FBufferReader& buffer){
FRotationCell<P>::restore(buffer);
FExtendCellType::restore(buffer);
}
void resetToInitialState(){
FRotationCell<P>::resetToInitialState();
FExtendCellType::resetToInitialState();
}
};
#endif // FROTATIONCELL_HPP
......@@ -171,6 +171,10 @@ public:
FSphericalCell::restore(buffer);
FExtendCellType::restore(buffer);
}
void resetToInitialState(){
FSphericalCell::resetToInitialState();
FExtendCellType::resetToInitialState();
}
};
......
......@@ -19,6 +19,7 @@
#include "../../Components/FBasicCell.hpp"
#include "../../Containers/FVector.hpp"
#include "../../Utils/FMemUtils.hpp"
#include "../../Extensions/FExtendCellType.hpp"
/**
*@author Cyrille Piacibello
......@@ -82,4 +83,21 @@ public:
};
template <int P, int order>
class FTypedTaylorCell : public FTaylorCell<P,order>, public FExtendCellType {
public:
void save(FBufferWriter& buffer) const{
FTaylorCell<P,order>::save(buffer);
FExtendCellType::save(buffer);
}
void restore(FBufferReader& buffer){
FTaylorCell<P,order>::restore(buffer);
FExtendCellType::restore(buffer);
}
void resetToInitialState(){
FTaylorCell<P,order>::resetToInitialState();
FExtendCellType::resetToInitialState();
}
};
#endif
......@@ -188,13 +188,9 @@ class TestRotationDirectTsm : public FUTester<TestRotationDirectTsm> {
static const int P = 9;
template <const int P>
class CustomTypedRotationCell : public FRotationCell<P>, public FExtendCellType{
};
/** Rotation */
void TestRotation(){
typedef CustomTypedRotationCell<P> CellClass;
typedef FTypedRotationCell<P> CellClass;
typedef FP2PParticleContainerIndexed ContainerClass;
typedef FRotationKernel<CellClass, ContainerClass, P > KernelClass;
......@@ -208,7 +204,7 @@ class TestRotationDirectTsm : public FUTester<TestRotationDirectTsm> {
}
void TestRotationThread(){
typedef CustomTypedRotationCell<P> CellClass;
typedef FTypedRotationCell<P> CellClass;
typedef FP2PParticleContainerIndexed ContainerClass;
typedef FRotationKernel<CellClass, ContainerClass, P > KernelClass;
......
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