Skip to content

Commit

Permalink
PR: sofa-framework#288 add d_projectVelocity data in PartialFixedCons…
Browse files Browse the repository at this point in the history
…traint component
  • Loading branch information
Younesssss authored and guparan committed Aug 23, 2017
1 parent 6c58d66 commit 77341bb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion applications/plugins/SofaTest/Elasticity_test.inl
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ CylinderTractionStruct<DataTypes> Elasticity_test<DataTypes>::createCylinderTra
// FixedConstraint
typename component::projectiveconstraintset::FixedConstraint<DataTypes>::SPtr fc=
modeling::addNew<typename component::projectiveconstraintset::FixedConstraint<DataTypes> >(root);
sofa::modeling::setDataLink(&boxRoi1->d_indices,&fc->f_indices);
sofa::modeling::setDataLink(&boxRoi1->d_indices,&fc->d_indices);
// FixedPlaneConstraint
typename component::projectiveconstraintset::FixedPlaneConstraint<DataTypes>::SPtr fpc=
modeling::addNew<typename component::projectiveconstraintset::FixedPlaneConstraint<DataTypes> >(root);
Expand Down
3 changes: 1 addition & 2 deletions modules/SofaBoundaryCondition/FixedConstraint.inl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ FixedConstraint<DataTypes>::FixedConstraint()
, d_fixAll( initData(&d_fixAll,false,"fixAll","filter all the DOF to implement a fixed object") )
, d_showObject(initData(&d_showObject,true,"showObject","draw or not the fixed constraints"))
, d_drawSize( initData(&d_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") )
, d_projectVelocity( initData(&d_projectVelocity,false,"activate_projectVelocity","activate project velocity to set velocity and free velocity to zero") )
, d_projectVelocity( initData(&d_projectVelocity,false,"activate_projectVelocity","activate project velocity to set velocity") )
, data(new FixedConstraintInternalData<DataTypes>())
{
// default to indice 0
Expand Down Expand Up @@ -251,7 +251,6 @@ void FixedConstraint<DataTypes>::projectVelocity(const core::MechanicalParams* m
if(!d_projectVelocity.getValue()) return;
const SetIndexArray & indices = this->d_indices.getValue();
helper::WriteAccessor<DataVecDeriv> res ( mparams, vData );
helper::WriteAccessor<DataVecDeriv> resFree ( mparams, vData );

if( this->d_fixAll.getValue()==true ) // fix everyting
{
Expand Down
1 change: 1 addition & 0 deletions modules/SofaBoundaryCondition/PartialFixedConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class PartialFixedConstraint : public core::behavior::ProjectiveConstraintSet<Da
enum { NumDimensions = Deriv::total_size };
typedef sofa::helper::fixed_array<bool,NumDimensions> VecBool;
Data<VecBool> fixedDirections; ///< Defines the directions in which the particles are fixed: true (or 1) for fixed, false (or 0) for free.
Data<bool> d_projectVelocity;
protected:
PartialFixedConstraint();

Expand Down
15 changes: 8 additions & 7 deletions modules/SofaBoundaryCondition/PartialFixedConstraint.inl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ PartialFixedConstraint<DataTypes>::PartialFixedConstraint()
, d_fixAll( initData(&d_fixAll,false,"fixAll","filter all the DOF to implement a fixed object") )
, d_drawSize( initData(&d_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") )
, fixedDirections( initData(&fixedDirections,"fixedDirections","for each direction, 1 if fixed, 0 if free") )
, d_projectVelocity( initData(&d_projectVelocity,false,"activate_projectVelocity","activate project velocity to set velocity") )
{
// default to indice 0
d_indices.beginEdit()->push_back(0);
Expand Down Expand Up @@ -172,7 +173,7 @@ void PartialFixedConstraint<DataTypes>::projectResponseT(const core::MechanicalP
}
}
}
// cerr<<"PartialFixedConstraint<DataTypes>::projectResponse is called res = "<<endl<<res<<endl;
// cerr<<"PartialFixedConstraint<DataTypes>::projectResponse is called res = "<<endl<<res<<endl;
}

template <class DataTypes>
Expand All @@ -187,12 +188,13 @@ void PartialFixedConstraint<DataTypes>::projectResponse(const core::MechanicalPa
// When a new fixed point is added while its velocity vector is already null, projectVelocity is not usefull.
// But when a new fixed point is added while its velocity vector is not null, it's necessary to fix it to null. If not, the fixed point is going to drift.
template <class DataTypes>
void PartialFixedConstraint<DataTypes>::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& /*vData*/)
void PartialFixedConstraint<DataTypes>::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData)
{
#if 0 /// @TODO ADD A FLAG FOR THIS
helper::WriteAccessor<DataVecDeriv> res = vData;
if(!d_projectVelocity.getValue()) return;
helper::WriteAccessor<DataVecDeriv> res ( mparams, vData );

//serr<<"PartialFixedConstraint<DataTypes>::projectVelocity, res.size()="<<res.size()<<sendl;
if( f_fixAll.getValue()==true )
if( d_fixAll.getValue()==true )
{
// fix everyting
for( unsigned i=0; i<res.size(); i++ )
Expand All @@ -202,14 +204,13 @@ void PartialFixedConstraint<DataTypes>::projectVelocity(const core::MechanicalPa
}
else
{
const SetIndexArray & indices = f_indices.getValue();
const SetIndexArray & indices = d_indices.getValue();
unsigned i=0;
for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end() && i<res.size(); ++it, ++i)
{
res[*it] = Deriv();
}
}
#endif
}

template <class DataTypes>
Expand Down

0 comments on commit 77341bb

Please sign in to comment.