Commit cd85576d authored by Berenger Bramas's avatar Berenger Bramas

Make the particle type (source, target) strong typed enum

parent 16823939
......@@ -115,12 +115,12 @@ public:
}else{
if(type==SOURCE){
for(FSize idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint<FReal>(&XYZ[3*idPart]),FParticleTypeSource,idPart);
octree->insert(FPoint<FReal>(&XYZ[3*idPart]),FParticleType::FParticleTypeSource,idPart);
}
FScalFMMEngine<FReal>::nbPart += NbPositions;
}else{
for(FSize idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint<FReal>(&XYZ[3*idPart]),FParticleTypeTarget,idPart);
octree->insert(FPoint<FReal>(&XYZ[3*idPart]),FParticleType::FParticleTypeTarget,idPart);
}
FScalFMMEngine<FReal>::nbPart += NbPositions;
}
......@@ -138,12 +138,12 @@ public:
}else{
if(type==SOURCE){
for(FSize idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint<FReal>(X[idPart],Y[idPart],Z[idPart]),FParticleTypeSource,idPart);
octree->insert(FPoint<FReal>(X[idPart],Y[idPart],Z[idPart]),FParticleType::FParticleTypeSource,idPart);
}
FScalFMMEngine<FReal>::nbPart += NbPositions;
}else{
for(FSize idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint<FReal>(X[idPart],Y[idPart],Z[idPart]),FParticleTypeTarget,idPart);
octree->insert(FPoint<FReal>(X[idPart],Y[idPart],Z[idPart]),FParticleType::FParticleTypeTarget,idPart);
}
FScalFMMEngine<FReal>::nbPart += NbPositions;
}
......
......@@ -380,12 +380,12 @@ public:
}else{
if(type==SOURCE){
for(FSize idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint<FReal>(X[idPart],Y[idPart],Z[idPart]),FParticleTypeSource,idPart);
octree->insert(FPoint<FReal>(X[idPart],Y[idPart],Z[idPart]),FParticleType::FParticleTypeSource,idPart);
}
FScalFMMEngine<FReal>::nbPart += NbPositions;
}else{
for(FSize idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint<FReal>(X[idPart],Y[idPart],Z[idPart]),FParticleTypeTarget,idPart);
octree->insert(FPoint<FReal>(X[idPart],Y[idPart],Z[idPart]),FParticleType::FParticleTypeTarget,idPart);
}
FScalFMMEngine<FReal>::nbPart += NbPositions;
}
......@@ -403,12 +403,12 @@ public:
}else{
if(type==SOURCE){
for(FSize idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint<FReal>(&XYZ[3*idPart]),FParticleTypeSource,idPart);
octree->insert(FPoint<FReal>(&XYZ[3*idPart]),FParticleType::FParticleTypeSource,idPart);
}
FScalFMMEngine<FReal>::nbPart += NbPositions;
}else{
for(FSize idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint<FReal>(&XYZ[3*idPart]),FParticleTypeTarget,idPart);
octree->insert(FPoint<FReal>(&XYZ[3*idPart]),FParticleType::FParticleTypeTarget,idPart);
}
FScalFMMEngine<FReal>::nbPart += NbPositions;
}
......
......@@ -85,7 +85,7 @@ public:
const MortonIndex particuleIndex = tree->getMortonFromPosition(currentPart);
if(particuleIndex != currentMortonIndex){
//Need to move this one
interface->removeFromLeafAndKeep(particles,currentPart,idxPart,FParticleTypeSource);
interface->removeFromLeafAndKeep(particles,currentPart,idxPart,FParticleType::FParticleTypeSource);
}
else{
//Need to increment idx;
......@@ -102,7 +102,7 @@ public:
const MortonIndex particuleIndex = tree->getMortonFromPosition(currentPart);
if(particuleIndex != currentMortonIndex){
//Need to move this one
interface->removeFromLeafAndKeep(particleTargets,currentPart,idxPart, FParticleTypeTarget);
interface->removeFromLeafAndKeep(particleTargets,currentPart,idxPart, FParticleType::FParticleTypeTarget);
}
else{
//Need to increment idx;
......
......@@ -33,11 +33,11 @@ public:
for(int idxAttr = 0 ; idxAttr < ContainerClass::NbAttributes ; ++idxAttr){
particleValues[idxAttr] = lf->getAttribute(idxAttr)[idxPart];
}
if(type == FParticleTypeTarget){
toStoreRemovedTargetParts.push(particlePos,FParticleTypeTarget,lf->getIndexes()[idxPart],particleValues);
if(type == FParticleType::FParticleTypeTarget){
toStoreRemovedTargetParts.push(particlePos,FParticleType::FParticleTypeTarget,lf->getIndexes()[idxPart],particleValues);
}
else{
toStoreRemovedSourceParts.push(particlePos,FParticleTypeSource,lf->getIndexes()[idxPart],particleValues);
toStoreRemovedSourceParts.push(particlePos,FParticleType::FParticleTypeSource,lf->getIndexes()[idxPart],particleValues);
}
lf->removeParticles(&idxPart,1);
}
......@@ -53,7 +53,7 @@ public:
const FPoint<FReal> particlePos(toStoreRemovedSourceParts.getPositions()[0][idxToInsert],
toStoreRemovedSourceParts.getPositions()[1][idxToInsert],
toStoreRemovedSourceParts.getPositions()[2][idxToInsert]);
tree->insert(particlePos, FParticleTypeSource, toStoreRemovedSourceParts.getIndexes()[idxToInsert], particleValues);
tree->insert(particlePos, FParticleType::FParticleTypeSource, toStoreRemovedSourceParts.getIndexes()[idxToInsert], particleValues);
}
for(FSize idxToInsert = 0; idxToInsert<toStoreRemovedTargetParts.getNbParticles() ; ++idxToInsert){
......@@ -64,7 +64,7 @@ public:
toStoreRemovedTargetParts.getPositions()[1][idxToInsert],
toStoreRemovedTargetParts.getPositions()[2][idxToInsert]);
tree->insert(particlePos, FParticleTypeTarget, toStoreRemovedTargetParts.getIndexes()[idxToInsert], particleValues);
tree->insert(particlePos, FParticleType::FParticleTypeTarget, toStoreRemovedTargetParts.getIndexes()[idxToInsert], particleValues);
}
toStoreRemovedSourceParts.clear();
......
......@@ -19,7 +19,7 @@
/**
* @brief The FParticleType enum is to make a difference between Target and Source (Tsm)
*/
enum FParticleType {
enum class FParticleType {
FParticleTypeSource = 0,
FParticleTypeTarget = 1
};
......
......@@ -51,8 +51,8 @@ public:
*/
template<typename... Args>
void push(const FPoint<FReal>& inParticlePosition, const FParticleType type, Args ... args){
if(type == FParticleTypeTarget) targets.push(inParticlePosition, FParticleTypeTarget, args...);
else sources.push(inParticlePosition, FParticleTypeSource, args...);
if(type == FParticleType::FParticleTypeTarget) targets.push(inParticlePosition, FParticleType::FParticleTypeTarget, args...);
else sources.push(inParticlePosition, FParticleType::FParticleTypeSource, args...);
}
/**
......
......@@ -131,8 +131,8 @@ public:
inParticlePositions->setPosition(x,y,z);
*inPhysicalValue = data;
if(isTarget) (*particleType) = FParticleTypeTarget;
else (*particleType) = FParticleTypeSource;
if(isTarget) (*particleType) = FParticleType::FParticleTypeTarget;
else (*particleType) = FParticleType::FParticleTypeSource;
}
};
......
......@@ -124,8 +124,8 @@ public:
void fillParticle(FPoint<FReal>*const inParticlePositions, FParticleType*const isTarget){
FRandomLoader<FReal>::fillParticle(inParticlePositions);
if(FRandomLoader<FReal>::getRandom() > 0.5 ) (*isTarget) = FParticleTypeTarget;
else (*isTarget) = FParticleTypeSource;
if(FRandomLoader<FReal>::getRandom() > 0.5 ) (*isTarget) = FParticleType::FParticleTypeTarget;
else (*isTarget) = FParticleType::FParticleTypeSource;
}
};
......
......@@ -98,7 +98,7 @@ int main(int argc, char ** argv){
(BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)),
(BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)),
(BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)));
tree.insert(particleToFill,FParticleTypeSource,idxPart);
tree.insert(particleToFill,FParticleType::FParticleTypeSource,idxPart);
}
for(FSize idxPart = 0 ; idxPart < NbPart_Target; ++idxPart){
......@@ -106,7 +106,7 @@ int main(int argc, char ** argv){
(BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)),
(BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)),
(BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)));
tree.insert(particleToFill,FParticleTypeTarget,idxPart);
tree.insert(particleToFill,FParticleType::FParticleTypeTarget,idxPart);
}
}
......
......@@ -69,7 +69,7 @@ class TestChebyshevDirectTsm : public FUTester<TestChebyshevDirectTsm> {
FPoint<FReal> position;
loader.fillParticle(&position);
// put in tree
tree.insert(position, FParticleTypeTarget, idxPart, physicalValue);
tree.insert(position, FParticleType::FParticleTypeTarget, idxPart, physicalValue);
// get copy
particlesTargets[idxPart].setPosition(position);
*(particlesTargets[idxPart].setPhysicalValue()) = physicalValue;
......@@ -84,7 +84,7 @@ class TestChebyshevDirectTsm : public FUTester<TestChebyshevDirectTsm> {
FPoint<FReal> position;
loader.fillParticle(&position);
// put in tree
tree.insert(position, FParticleTypeSource, idxPart, physicalValue);
tree.insert(position, FParticleType::FParticleTypeSource, idxPart, physicalValue);
// get copy
particlesSources[idxPart].setPosition(position);
*(particlesSources[idxPart].setPhysicalValue()) = physicalValue;
......
......@@ -68,7 +68,7 @@ class TestRotationDirectTsm : public FUTester<TestRotationDirectTsm> {
FPoint<FReal> position;
loader.fillParticle(&position);
// put in tree
tree.insert(position, FParticleTypeTarget, idxPart, physicalValue);
tree.insert(position, FParticleType::FParticleTypeTarget, idxPart, physicalValue);
// get copy
particlesTargets[idxPart].setPosition(position);
*(particlesTargets[idxPart].setPhysicalValue()) = physicalValue;
......@@ -83,7 +83,7 @@ class TestRotationDirectTsm : public FUTester<TestRotationDirectTsm> {
FPoint<FReal> position;
loader.fillParticle(&position);
// put in tree
tree.insert(position, FParticleTypeSource, idxPart, physicalValue);
tree.insert(position, FParticleType::FParticleTypeSource, idxPart, physicalValue);
// get copy
particlesSources[idxPart].setPosition(position);
*(particlesSources[idxPart].setPhysicalValue()) = physicalValue;
......
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