Commit 54ebc4bf authored by berenger-bramas's avatar berenger-bramas

Update small class inc method to avoir getter.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@235 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 662825d4
......@@ -82,8 +82,8 @@ protected:
newNode->setMortonIndex(inLeafCellIndex);
newNode->setCoordinate(treePosition.getX() >> bottomToTop,
treePosition.getY() >> bottomToTop,
treePosition.getZ() >> bottomToTop);
treePosition.getY() >> bottomToTop,
treePosition.getZ() >> bottomToTop);
const int realLevel = indexLevel + this->getSubOctreePosition();
const FReal widthAtLevel = inBoxWidthAtLevel[realLevel];
......
......@@ -30,14 +30,10 @@ public:
* @param inY the y
* @param inZ the z
*/
FTreeCoordinate(const long inX,const long inY,const long inZ)
explicit FTreeCoordinate(const long inX,const long inY,const long inZ)
: x(inX), y(inY), z(inZ){
}
/** Default destructor */
virtual ~FTreeCoordinate(){
}
/**
* Copy constructor
* @param other the source class to copy
......
......@@ -42,15 +42,15 @@ public:
}
/** Set Forces */
void setForces(const F3DPosition& inForces) {
this->forces = inForces;
void incForces(const F3DPosition& inForces) {
this->forces += inForces;
}
/** Set Forces with 3 FReals */
void setForces(const FReal inFx, const FReal inFy, const FReal inFz) {
this->forces.setX(inFx);
this->forces.setY(inFy);
this->forces.setZ(inFz);
void incForces(const FReal inFx, const FReal inFy, const FReal inFz) {
this->forces.incX(inFx);
this->forces.incY(inFy);
this->forces.incZ(inFz);
}
};
......
......@@ -44,6 +44,11 @@ public:
this->potential = inPotential;
}
/** To inc the potential */
void incPotential(const FReal inPotential) {
this->potential += inPotential;
}
};
......
......@@ -1269,7 +1269,7 @@ public:
/*printf("[force_vector_tmp] fx = %e \t fy = %e \t fz = %e \n",
force_vector_tmp.getX(),force_vector_tmp.getY(),force_vector_tmp.getZ());*/
iterTarget.data().setForces( iterTarget.data().getForces() + force_vector_tmp );
iterTarget.data().incForces( force_vector_tmp );
iterTarget.data().setPotential(expansion_Evaluate_local_with_Y_already_computed(local->getLocal()));
......@@ -1362,28 +1362,32 @@ public:
void DIRECT_COMPUTATION_MUTUAL_SOFT(ParticleClass& target, ParticleClass& source){
const FReal dx = target.getPosition().getX() - source.getPosition().getX();
const FReal dy = target.getPosition().getY() - source.getPosition().getY();
const FReal dz = target.getPosition().getZ() - source.getPosition().getZ();
FReal dx = target.getPosition().getX() - source.getPosition().getX();
FReal dy = target.getPosition().getY() - source.getPosition().getY();
FReal dz = target.getPosition().getZ() - source.getPosition().getZ();
FReal inv_square_distance = FReal(1.0) / (dx*dx + dy*dy + dz*dz + FReal(FMB_Info_eps_soft_square));
FReal inv_distance = FMath::Sqrt(inv_square_distance);
inv_distance *= target.getPhysicalValue() * source.getPhysicalValue();
inv_square_distance *= inv_distance;
target.setForces(
target.getForces().getX() + dx * inv_square_distance,
target.getForces().getY() + dy * inv_square_distance,
target.getForces().getZ() + dz * inv_square_distance
dx *= inv_square_distance;
dy *= inv_square_distance;
dz *= inv_square_distance;
target.incForces(
dx,
dy,
dz
);
target.setPotential( inv_distance + target.getPotential());
target.incPotential( inv_distance );
source.setForces(
source.getForces().getX() + (-dx) * inv_square_distance,
source.getForces().getY() + (-dy) * inv_square_distance,
source.getForces().getZ() + (-dz) * inv_square_distance
source.incForces(
(-dx),
(-dy),
(-dz)
);
source.setPotential( inv_distance + source.getPotential());
source.incPotential( inv_distance );
}
......@@ -1447,13 +1451,13 @@ public:
inv_distance *= target.getPhysicalValue() * source.getPhysicalValue();
inv_square_distance *= inv_distance;
target.setForces(
target.getForces().getX() + dx * inv_square_distance,
target.getForces().getY() + dy * inv_square_distance,
target.getForces().getZ() + dz * inv_square_distance
target.incForces(
dx * inv_square_distance,
dy * inv_square_distance,
dz * inv_square_distance
);
target.setPotential( inv_distance + target.getPotential());
target.incPotential( inv_distance );
}
};
......
......@@ -1327,7 +1327,7 @@ public:
/*printf("[force_vector_tmp] fx = %e \t fy = %e \t fz = %e \n",
force_vector_tmp.getX(),force_vector_tmp.getY(),force_vector_tmp.getZ());*/
iterTarget.data().setForces( iterTarget.data().getForces() + force_vector_tmp );
iterTarget.data().incForces( force_vector_tmp );
FReal potential;
expansion_Evaluate_local_with_Y_already_computed(local->getLocal(),&potential);
......@@ -1427,28 +1427,32 @@ public:
void DIRECT_COMPUTATION_MUTUAL_SOFT(ParticleClass& FRestrict target, ParticleClass& source){
const FReal dx = target.getPosition().getX() - source.getPosition().getX();
const FReal dy = target.getPosition().getY() - source.getPosition().getY();
const FReal dz = target.getPosition().getZ() - source.getPosition().getZ();
FReal dx = target.getPosition().getX() - source.getPosition().getX();
FReal dy = target.getPosition().getY() - source.getPosition().getY();
FReal dz = target.getPosition().getZ() - source.getPosition().getZ();
FReal inv_square_distance = 1.0/ (dx*dx + dy*dy + dz*dz + FMB_Info_eps_soft_square);
FReal inv_distance = FMath::Sqrt(inv_square_distance);
inv_distance *= target.getPhysicalValue() * source.getPhysicalValue();
inv_square_distance *= inv_distance;
target.setForces(
target.getForces().getX() + dx * inv_square_distance,
target.getForces().getY() + dy * inv_square_distance,
target.getForces().getZ() + dz * inv_square_distance
dx *= inv_square_distance;
dy *= inv_square_distance;
dz *= inv_square_distance;
target.incForces(
dx,
dy,
dz
);
target.setPotential( inv_distance + target.getPotential());
target.incPotential( inv_distance );
source.setForces(
source.getForces().getX() + (-dx) * inv_square_distance,
source.getForces().getY() + (-dy) * inv_square_distance,
source.getForces().getZ() + (-dz) * inv_square_distance
source.incForces(
(-dx),
(-dy),
(-dz)
);
source.setPotential( inv_distance + source.getPotential());
source.incPotential( inv_distance );
}
......@@ -1510,13 +1514,13 @@ public:
inv_distance *= target.getPhysicalValue() * source.getPhysicalValue();
inv_square_distance *= inv_distance;
target.setForces(
target.getForces().getX() + dx * inv_square_distance,
target.getForces().getY() + dy * inv_square_distance,
target.getForces().getZ() + dz * inv_square_distance
target.incForces(
dx * inv_square_distance,
dy * inv_square_distance,
dz * inv_square_distance
);
target.setPotential( inv_distance + target.getPotential());
target.incPotential( inv_distance );
}
};
......
......@@ -1579,7 +1579,7 @@ public:
/*printf("[force_vector_tmp] fx = %.15e \t fy = %.15e \t fz = %.15e \n",
force_vector_tmp.getX(),force_vector_tmp.getY(),force_vector_tmp.getZ());*/
iterTarget.data().setForces( iterTarget.data().getForces() + force_vector_tmp );
iterTarget.data().incForces( force_vector_tmp );
FReal potential;
expansion_Evaluate_local_with_Y_already_computed(local->getLocal(),&potential);
......@@ -1678,28 +1678,32 @@ public:
void DIRECT_COMPUTATION_MUTUAL_SOFT(ParticleClass& FRestrict target, ParticleClass& source){
const FReal dx = target.getPosition().getX() - source.getPosition().getX();
const FReal dy = target.getPosition().getY() - source.getPosition().getY();
const FReal dz = target.getPosition().getZ() - source.getPosition().getZ();
FReal dx = target.getPosition().getX() - source.getPosition().getX();
FReal dy = target.getPosition().getY() - source.getPosition().getY();
FReal dz = target.getPosition().getZ() - source.getPosition().getZ();
FReal inv_square_distance = FReal(1.0) / (dx*dx + dy*dy + dz*dz + FReal(FMB_Info_eps_soft_square));
FReal inv_distance = FMath::Sqrt(inv_square_distance);
inv_distance *= target.getPhysicalValue() * source.getPhysicalValue();
inv_square_distance *= inv_distance;
target.setForces(
target.getForces().getX() + dx * inv_square_distance,
target.getForces().getY() + dy * inv_square_distance,
target.getForces().getZ() + dz * inv_square_distance
dx *= inv_square_distance;
dy *= inv_square_distance;
dz *= inv_square_distance;
target.incForces(
dx,
dy,
dz
);
target.setPotential( inv_distance + target.getPotential());
target.incPotential( inv_distance );
source.setForces(
source.getForces().getX() + (-dx) * inv_square_distance,
source.getForces().getY() + (-dy) * inv_square_distance,
source.getForces().getZ() + (-dz) * inv_square_distance
source.incForces(
(-dx),
(-dy),
(-dz)
);
source.setPotential( inv_distance + source.getPotential());
source.incPotential( inv_distance );
}
......@@ -1761,13 +1765,13 @@ public:
inv_distance *= target.getPhysicalValue() * source.getPhysicalValue();
inv_square_distance *= inv_distance;
target.setForces(
target.getForces().getX() + dx * inv_square_distance,
target.getForces().getY() + dy * inv_square_distance,
target.getForces().getZ() + dz * inv_square_distance
target.incForces(
dx * inv_square_distance,
dy * inv_square_distance,
dz * inv_square_distance
);
target.setPotential( inv_distance + target.getPotential());
target.incPotential( inv_distance );
}
};
......
......@@ -16,213 +16,233 @@
*/
class F3DPosition{
private:
FReal x; //< x position
FReal y; //< y position
FReal z; //< z position
FReal x; //< x position
FReal y; //< y position
FReal z; //< z position
public:
/** Default constructor (sets position to 0/0/0) */
F3DPosition() : x(0.0), y(0.0), z(0.0){
}
/** Constructor from values */
explicit F3DPosition(const FReal inX,const FReal inY,const FReal inZ)
: x(inX), y(inY), z(inZ){
}
/** Default destructor */
virtual ~F3DPosition(){
}
/**
* Copy constructor
* @param other the source class to copy
*/
F3DPosition(const F3DPosition& other): x(other.x), y(other.y), z(other.z){
}
/**
/** Default constructor (sets position to 0/0/0) */
F3DPosition() : x(0.0), y(0.0), z(0.0){
}
/** Constructor from values */
explicit F3DPosition(const FReal inX,const FReal inY,const FReal inZ)
: x(inX), y(inY), z(inZ){
}
/**
* Copy constructor
* @param other the source class to copy
*/
F3DPosition(const F3DPosition& other): x(other.x), y(other.y), z(other.z){
}
/**
* Assignement operator
* @param other the source class to copy
*/
F3DPosition(const F3DPosition& other, const FReal addset)
: x(other.x + addset), y(other.y + addset), z(other.z + addset){
}
/**
* Copy constructor
* @param other the source class to copy
* @return this a reference to the current class
*/
F3DPosition& operator=(const F3DPosition& other){
this->x = other.x;
this->y = other.y;
this->z = other.z;
return *this;
}
/**
* Position setter
* @param other the source class to copy
* @return this a reference to the current class
*/
void setPosition(const FReal inX,const FReal inY,const FReal inZ){
this->x = inX;
this->y = inY;
this->z = inZ;
}
/**
* Get x
* @return this->x
*/
FReal getX() const{
return this->x;
}
/**
* Get y
* @return this->y
*/
FReal getY() const{
return this->y;
}
/**
* Get z
* @return this->z
*/
FReal getZ() const{
return this->z;
}
/**
* Set x
* @param the new x
*/
void setX(const FReal inX){
this->x = inX;
}
/**
* Set y
* @param the new y
*/
void setY(const FReal inY){
this->y = inY;
}
/**
* Set z
* @param the new z
*/
void setZ(const FReal inZ){
this->z = inZ;
}
/**
* Subtract to all dim the inValue
* @param inValue the value to substract
* @return the current object after being subtracted
*/
F3DPosition& operator-=(const FReal inValue){
this->x -= inValue;
this->y -= inValue;
this->z -= inValue;
return *this;
}
/**
* Affect to all dim the inValue
* @param inValue the value to afect
* @return the current object after being affected
*/
F3DPosition& operator+=(const FReal inValue){
this->x += inValue;
this->y += inValue;
this->z += inValue;
return *this;
}
/**
F3DPosition(const F3DPosition& other, const FReal addset)
: x(other.x + addset), y(other.y + addset), z(other.z + addset){
}
/**
* Copy constructor
* @param other the source class to copy
* @return this a reference to the current class
*/
F3DPosition& operator=(const F3DPosition& other){
this->x = other.x;
this->y = other.y;
this->z = other.z;
return *this;
}
/**
* Position setter
* @param other the source class to copy
* @return this a reference to the current class
*/
void setPosition(const FReal inX,const FReal inY,const FReal inZ){
this->x = inX;
this->y = inY;
this->z = inZ;
}
/**
* Get x
* @return this->x
*/
FReal getX() const{
return this->x;
}
/**
* Get y
* @return this->y
*/
FReal getY() const{
return this->y;
}
/**
* Get z
* @return this->z
*/
FReal getZ() const{
return this->z;
}
/**
* Set x
* @param the new x
*/
void setX(const FReal inX){
this->x = inX;
}
/**
* Set y
* @param the new y
*/
void setY(const FReal inY){
this->y = inY;
}
/**
* Set z
* @param the new z
*/
void setZ(const FReal inZ){
this->z = inZ;
}
/**
* Set x
* @param the new x
*/
void incX(const FReal inX){
this->x += inX;
}
/**
* Set y
* @param the new y
*/
void incY(const FReal inY){
this->y += inY;
}
/**
* Set z
* @param the new z
*/
void incZ(const FReal inZ){
this->z += inZ;
}
/**
* Subtract to all dim the inValue
* @param inValue the value to substract
* @return the current object after being subtracted
*/
F3DPosition& operator-=(const FReal inValue){
this->x -= inValue;
this->y -= inValue;
this->z -= inValue;
return *this;
}
/**
* Affect to all dim the inValue
* @param inValue the value to afect
* @return the current object after being affected
*/
F3DPosition& operator+=(const FReal inValue){
this->x += inValue;
this->y += inValue;
this->z += inValue;
return *this;
}
/**
* Subtract to all dim the other position
* @param other the value to substract
* @return the current object after being subtracted
*/
F3DPosition& operator-=(const F3DPosition& other){
this->x -= other.x;
this->y -= other.y;
this->z -= other.z;
return *this;
}
/**
F3DPosition& operator-=(const F3DPosition& other){
this->x -= other.x;
this->y -= other.y;
this->z -= other.z;
return *this;
}
/**
* Affect to all dim the other position
* @param other the value to afect
* @return the current object after being affected
*/
F3DPosition& operator+=(const F3DPosition& other){
this->x += other.x;
this->y += other.y;
this->z += other.z;
return *this;
}
/**
F3DPosition& operator+=(const F3DPosition& other){
this->x += other.x;
this->y += other.y;
this->z += other.z;
return *this;
}
/**
* Affect to all dim the other position
* @param other the value to afect
* @return the current object after being affected
*/
F3DPosition& operator*=(const FReal value){
this->x *= value;
this->y *= value;
this->z *= value;
return *this;
}
/**
F3DPosition& operator*=(const FReal value){
this->x *= value;
this->y *= value;
this->z *= value;
return *this;
}
/**
* Operator F3Position minus FReal
* This substract inValue to all dimensions of the inPosition
* @param inPosition the position to compute
* @param inValue the value to decrease/substract position
* @return the resulting position
*/
friend inline F3DPosition operator-(const F3DPosition& inPosition, const FReal inValue){
return F3DPosition(inPosition, -inValue);
}
friend inline F3DPosition operator-(const F3DPosition& inPosition, const FReal inValue){
return F3DPosition(inPosition, -inValue);
}
/**
/**
* Operator F3Position plus FReal
* This affect from inValue all dimensions of the inPosition
* @param inPosition the position to compute
* @param inValue the value to increase/affect position
* @return the resulting position
*/
friend inline F3DPosition operator+(const F3DPosition& inPosition, const FReal inValue){
return F3DPosition(inPosition, inValue);
}
friend inline F3DPosition operator+(const F3DPosition& inPosition, const FReal inValue){
return F3DPosition(inPosition, inValue);
}
/**
/**
* Operator F3Position minus F3Position
* This substract one from anther
* @param inPosition the position to reduce
* @param inOther the position to decrease/substract inPosition
* @return the resulting position
*/
friend inline F3DPosition operator-(const F3DPosition& inPosition, const F3DPosition& inOther){
return F3DPosition(inPosition.x - inOther.x, inPosition.y - inOther.y, inPosition.z - inOther.z);
}
friend inline F3DPosition operator-(const F3DPosition& inPosition, const F3DPosition& inOther){
return F3DPosition(inPosition.x - inOther.x, inPosition.y - inOther.y, inPosition.z - inOther.z);
}
/**
/**
* Operator F3Position plus F3Position
* This substract one from anther
* @param inPosition the position to reduce
* @param inOther the position to increase inPosition
* @return the resulting position
*/
friend inline F3DPosition operator+(const F3DPosition& inPosition, const F3DPosition& inOther){
return F3DPosition(inPosition.x + inOther.x, inPosition.y + inOther.y, inPosition.z + inOther.z);
}
friend inline F3DPosition operator+(const F3DPosition& inPosition, const F3DPosition& inOther){
return F3DPosition(inPosition.x + inOther.x, inPosition.y + inOther.y, inPosition.z + inOther.z);
}
};
......
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