Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SofaBoundaryCondition] Fix ProjectToLineConstraint_RemovingMeshTest.scn #2241

Merged
merged 1 commit into from
Jul 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ protected :

SparseMatrix jacobian; ///< projection matrix in local state
SparseMatrix J; ///< auxiliary variable

/// Resize/update Jacobian matrix according to the linked mechanical state and the direction
void updateJacobian();

};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,17 @@ void ProjectToLineConstraint<DataTypes>::init()
}
}

reinit();
updateJacobian();
}

template <class DataTypes>
void ProjectToLineConstraint<DataTypes>::reinit()
{
updateJacobian();
}

template <class DataTypes>
void ProjectToLineConstraint<DataTypes>::updateJacobian()
{
// normalize the normal vector
CPos n = f_direction.getValue();
Expand Down Expand Up @@ -208,8 +214,13 @@ template <class DataTypes>
void ProjectToLineConstraint<DataTypes>::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData)
{
SOFA_UNUSED(mparams);

helper::WriteAccessor<DataVecDeriv> res(resData);
if( (jacobian.colSize() / DataTypes::deriv_total_size) != res.size())
{
updateJacobian();
}

helper::WriteAccessor<DataVecDeriv> res ( resData );
jacobian.mult(res.wref(),res.ref());
}

Expand Down