Skip to content

Commit

Permalink
[Constraint] Make name of constraints more explicit (sofa-framework#4302
Browse files Browse the repository at this point in the history
)

* Added projective and lagrangian suffix

* Reported changes to Cuda plugin

* Modify rest of the code to avoid warning from compatibility layer

* Add compatibility layer for deprecated header in CUDA

* add alias for compatibility layer in scene construction

* Report name modification to all scenes

* Revert Compat modification...

* [LinearAlgera, Core] Fix linking with LTO on MacOS/Clang (sofa-framework#4293)

Fix linking with LTO on macos

* [LinearSolver] Remove CSparse-based linear solvers (sofa-framework#4258)

* [LinearSolver.Direct] Remove CSparse based solvers

* Remove csparse extlib

* Fetchable CSparseSolvers plugin

* Remove references of SparseLUSolver

* Remove references to SparseCholeskySolver

* Remove csparse

* Try to fix on Linux

* Update the compat

* [LinearSolver.Direct] Remove CSparse based solvers

* Fix direct solver

* [GUI.Qt] Minor single-line cleaning (sofa-framework#4308)

Co-authored-by: erik pernod <erik.pernod@gmail.com>

* [Sofa.GUI.Qt] Add cmake module for QGLViewer (sofa-framework#4290)

* Add cmake module for QGLViewer

* Support library name for apt packages

* Fix qglviewer cmake finder module to first seach for a config cmake file.

* Update cmake/Modules/FindQGLViewer.cmake

Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>

---------

Co-authored-by: Frederick Roy <fredroy@users.noreply.github.com>
Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>

* [MultiThreading] Avoid Static Initialization Order Fiasco (sofa-framework#4307)

* [Core] Minor clean of DefaultAnimationLoop  (sofa-framework#4314)

* Remove unlogical use of visitor

* Delete unused methods

* [LinearSystem] Speedup computation of Jacobian matrices  (sofa-framework#4317)

* [LinearSystem] Speedup computation of Jacobian matrices in case both mstates are the same

* minor reformat to align calls to computeJacobiansFrom

* [SofaCUDA] FIX compilation SofaCUDA along with SparseGrid with Cuda12 (sofa-framework#4319)

* FIX compilation SofaCUDA along with SparseGrid with Cuda12

* Use a multiplication instead

* [Common] Add message to make the fetch mechanism less hidden (sofa-framework#4310)

* Add message to make it more clear

* slight modifications to be even more clear and add an error the dependency cannot be met

* [Collections] Remove reference to non-existing SofaSimulation (sofa-framework#4320)

remove ref to non-existent sofasimu

Co-authored-by: Paul Baksic <30337881+bakpaul@users.noreply.github.com>

* Remove repeating preffix from projective constraints

* Moved alias to original header

* Changed deprecation date

* add component change entry

* Change name following discussion with Hugo

* Change remaining scene with FixedConstraint

* remove last occurences in py files

* Changed the message display of sceneCheckUsingAlias when aliased component is in component change

* Fix factory

* Add alias creation when object in componentRenamed in factory

* Remove precedently added aliases

---------

Co-authored-by: Frederick Roy <fredroy@users.noreply.github.com>
Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com>
Co-authored-by: erik pernod <erik.pernod@gmail.com>
Co-authored-by: Olivier Roussel <olivier.roussel@inria.fr>
Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>
  • Loading branch information
6 people authored Dec 20, 2023
1 parent b1c49a7 commit 026a501
Show file tree
Hide file tree
Showing 564 changed files with 15,086 additions and 13,387 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <sofa/core/collision/Contact.h>
#include <sofa/core/collision/Intersection.h>
#include <sofa/core/behavior/MechanicalState.h>
#include <sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h>
#include <sofa/component/constraint/lagrangian/model/UnilateralLagrangianConstraint.h>
#include <sofa/component/collision/response/mapper/BaseContactMapper.h>
#include <sofa/component/collision/response/contact/ContactIdentifier.h>

Expand Down Expand Up @@ -60,7 +60,7 @@ class FrictionContact : public core::collision::Contact, public ContactIdentifie
mapper::ContactMapper<CollisionModel1,DataTypes1> mapper1;
mapper::ContactMapper<CollisionModel2,DataTypes2> mapper2;

constraint::lagrangian::model::UnilateralInteractionConstraint<sofa::defaulttype::Vec3Types>::SPtr m_constraint;
constraint::lagrangian::model::UnilateralLagrangianConstraint<sofa::defaulttype::Vec3Types>::SPtr m_constraint;
core::objectmodel::BaseContext* parent;

Data<double> mu; ///< friction coefficient (0 for frictionless contacts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void FrictionContact<TCollisionModel1,TCollisionModel2,ResponseDataTypes>::activ
{
mmodel2 = mapper2.createMapping(getName().c_str());
}
m_constraint = sofa::core::objectmodel::New<constraint::lagrangian::model::UnilateralInteractionConstraint<defaulttype::Vec3Types> >(mmodel1, mmodel2);
m_constraint = sofa::core::objectmodel::New<constraint::lagrangian::model::UnilateralLagrangianConstraint<defaulttype::Vec3Types> >(mmodel1, mmodel2);
m_constraint->setName( getName() );
setInteractionTags(mmodel1, mmodel2);
m_constraint->setCustomTolerance( tol.getValue() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include <sofa/core/collision/Contact.h>
#include <sofa/core/collision/Intersection.h>
#include <sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h>
#include <sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.h>
#include <sofa/helper/Factory.h>
#include <sofa/component/collision/response/mapper/BaseContactMapper.h>
#include <sofa/component/collision/response/contact/ContactIdentifier.h>
Expand Down Expand Up @@ -58,7 +58,7 @@ class StickContactConstraint : public core::collision::Contact, public ContactId
mapper::ContactMapper<CollisionModel1,DataTypes1> mapper1;
mapper::ContactMapper<CollisionModel2,DataTypes2> mapper2;

constraint::lagrangian::model::BilateralInteractionConstraint<sofa::defaulttype::Vec3Types>::SPtr m_constraint;
constraint::lagrangian::model::BilateralLagrangianConstraint<sofa::defaulttype::Vec3Types>::SPtr m_constraint;
core::objectmodel::BaseContext* parent;

std::vector< sofa::core::collision::DetectionOutput* > contacts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void StickContactConstraint<TCollisionModel1,TCollisionModel2>::activateMappers(
msg_info() << "Creating StickContactConstraint bilateral constraints";
MechanicalState1* mstate1 = mapper1.createMapping(mapper::GenerateStringID::generate().c_str());
MechanicalState2* mstate2 = mapper2.createMapping(mapper::GenerateStringID::generate().c_str());
m_constraint = sofa::core::objectmodel::New<constraint::lagrangian::model::BilateralInteractionConstraint<defaulttype::Vec3Types> >(mstate1, mstate2);
m_constraint = sofa::core::objectmodel::New<constraint::lagrangian::model::BilateralLagrangianConstraint<defaulttype::Vec3Types> >(mstate1, mstate2);
m_constraint->setName( getName() );
}

Expand Down
23 changes: 18 additions & 5 deletions Sofa/Component/Constraint/Lagrangian/Model/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,30 @@ set(HEADER_FILES
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/StopperConstraint.inl
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UniformConstraint.h
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UniformConstraint.inl
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralConstraintResolution.h
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralInteractionConstraint.h
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralInteractionConstraint.inl

${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/BilateralLagrangianConstraint.h
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/BilateralLagrangianConstraint.inl
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/SlidingLagrangianConstraint.h
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/SlidingLagrangianConstraint.inl
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/StopperLagrangianConstraint.h
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/StopperLagrangianConstraint.inl
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UniformLagrangianConstraint.h
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UniformLagrangianConstraint.inl
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralLagrangianConstraint.h
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralLagrangianConstraint.inl
)

set(SOURCE_FILES
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/init.cpp
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/BilateralInteractionConstraint.cpp
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/SlidingConstraint.cpp
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/StopperConstraint.cpp
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UniformConstraint.cpp
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralInteractionConstraint.cpp
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/BilateralLagrangianConstraint.cpp
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/SlidingLagrangianConstraint.cpp
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/StopperLagrangianConstraint.cpp
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UniformLagrangianConstraint.cpp
${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralLagrangianConstraint.cpp

)

sofa_find_package(Sofa.Simulation.Core REQUIRED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,176 +20,13 @@
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#pragma once
#include <sofa/component/constraint/lagrangian/model/config.h>

#include <sofa/core/topology/TopologySubsetIndices.h>
#include <sofa/core/behavior/PairInteractionConstraint.h>
#include <sofa/core/behavior/MechanicalState.h>
#include <sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.h>

#include <sofa/type/Mat.h>
#include <sofa/defaulttype/RigidTypes.h>
#include <sofa/type/Vec.h>
#include <sofa/defaulttype/VecTypes.h>

#include <deque>

#include <sofa/component/constraint/lagrangian/model/BilateralConstraintResolution.h>
SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.h")

namespace sofa::component::constraint::lagrangian::model
{

/// These 'using' are in a per-file namespace so they will not leak
/// and polluate the standard namespace.
using sofa::core::behavior::BaseConstraint ;
using sofa::core::behavior::ConstraintResolution ;
using sofa::core::behavior::PairInteractionConstraint ;
using sofa::core::objectmodel::Data ;
using sofa::core::ConstraintParams ;
using sofa::core::ConstVecCoordId;

using sofa::linearalgebra::BaseVector ;
using sofa::type::Vec3d;
using sofa::type::Quat ;

using sofa::defaulttype::Rigid3Types ;
using sofa::defaulttype::Vec3Types ;


template<class T>
class BilateralInteractionConstraintSpecialization {};


template<class DataTypes>
class BilateralInteractionConstraint : public PairInteractionConstraint<DataTypes>
{
public:
SOFA_CLASS(SOFA_TEMPLATE(BilateralInteractionConstraint,DataTypes),
SOFA_TEMPLATE(PairInteractionConstraint,DataTypes));

/// That any templates variation of BilateralInteractionConstraintSpecialization are friend.
template<typename>
friend class BilateralInteractionConstraintSpecialization ;

typedef PairInteractionConstraint<DataTypes> Inherit;

typedef typename DataTypes::VecCoord VecCoord;
typedef typename DataTypes::VecDeriv VecDeriv;
typedef typename DataTypes::MatrixDeriv MatrixDeriv;
typedef typename DataTypes::Coord Coord;
typedef typename DataTypes::Deriv Deriv;
typedef typename Coord::value_type Real;
typedef typename DataTypes::MatrixDeriv::RowIterator MatrixDerivRowIterator;

typedef core::behavior::MechanicalState<DataTypes> MechanicalState;
typedef BaseConstraint::PersistentID PersistentID;

typedef Data<VecCoord> DataVecCoord;
typedef Data<VecDeriv> DataVecDeriv;
typedef Data<MatrixDeriv> DataMatrixDeriv;

using SubsetIndices = type::vector<Index>;
using DataSubsetIndices = sofa::core::topology::TopologySubsetIndices;

protected:
std::vector<Deriv> dfree;
Quat<SReal> q;

std::vector<unsigned int> cid;

DataSubsetIndices m1; ///< index of the constraint on the first model
DataSubsetIndices m2; ///< index of the constraint on the second model
Data<VecDeriv> restVector; ///< Relative position to maintain between attached points (optional)
VecCoord initialDifference;

Data<double> d_numericalTolerance; ///< a real value specifying the tolerance during the constraint solving. (default=0.0001
Data<bool> d_activate; ///< bool to control constraint activation
Data<bool> keepOrientDiff; ///< keep the initial difference in orientation (only for rigids)


SingleLink<BilateralInteractionConstraint<DataTypes>, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology1; ///< Link to be set to the first topology container in order to support topological changes
SingleLink<BilateralInteractionConstraint<DataTypes>, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology2; ///< Link to be set to the second topology container in order to support topological changes

std::vector<Vec3d> prevForces;

SOFA_ATTRIBUTE_DISABLED__BILATERALINTERACTIONCONSTRAINTDATA("Data 'activateAtIteration' has been removed, please use the Data d_activate instead and an engine or a script to change the behavior at the right step (see PR #3327).")
sofa::core::objectmodel::lifecycle::RemovedData activateAtIteration{this, "v22.12", "v23.06", "activateAtIteration", "use the boolean data 'activate' instead and an engine or a script to change the behavior at the right step (see PR #3327)."};

SOFA_ATTRIBUTE_DISABLED__BILATERALINTERACTIONCONSTRAINTDATA("Data 'merge' has been removed. Its behavior was unused, undocumented, untested, and unclear (see PR #3328).")
sofa::core::objectmodel::lifecycle::RemovedData merge{this, "v22.12", "v23.06", "merge", "Its behavior was unused, undocumented, untested, and unclear (see PR #3328), please report to sofa-dev if you want the feature back."};

SOFA_ATTRIBUTE_DISABLED__BILATERALINTERACTIONCONSTRAINTDATA("Data 'derivative' has been removed. Its behavior was unused, undocumented, untested, and unclear (see PR #3328).")
sofa::core::objectmodel::lifecycle::RemovedData derivative{this, "v22.12", "v23.06", "derivative", "Its behavior was unused, undocumented, untested, and unclear (see PR #3328), please report to sofa-dev if you want the feature back."};


BilateralInteractionConstraint(MechanicalState* object1, MechanicalState* object2) ;
BilateralInteractionConstraint(MechanicalState* object) ;
BilateralInteractionConstraint();

virtual ~BilateralInteractionConstraint(){}
public:
void init() override;

void bwdInit() override {}

void reinit() override;

void buildConstraintMatrix(const ConstraintParams* cParams,
DataMatrixDeriv &c1, DataMatrixDeriv &c2,
unsigned int &cIndex,
const DataVecCoord &x1, const DataVecCoord &x2) override;

void getConstraintViolation(const ConstraintParams* cParams,
BaseVector *v,
const DataVecCoord &x1, const DataVecCoord &x2,
const DataVecDeriv &v1, const DataVecDeriv &v2) override;

void getVelocityViolation(BaseVector *v,
const DataVecCoord &x1, const DataVecCoord &x2,
const DataVecDeriv &v1, const DataVecDeriv &v2);

void getConstraintResolution(const ConstraintParams* cParams,
std::vector<ConstraintResolution*>& resTab,
unsigned int& offset) override;

void handleEvent(sofa::core::objectmodel::Event *event) override;

void draw(const core::visual::VisualParams* vparams) override;

void clear(int reserve = 0) ;

virtual void addContact(Deriv norm, Coord P, Coord Q, Real contactDistance,
int m1, int m2, Coord Pfree, Coord Qfree,
long id=0, PersistentID localid=0);

void addContact(Deriv norm, Coord P, Coord Q, Real contactDistance,
int m1, int m2, long id=0, PersistentID localid=0) ;

void addContact(Deriv norm, Real contactDistance, int m1, int m2,
long id=0, PersistentID localid=0) ;

/// Method to remove a contact using point @param indices and id of buffer: @sa m1 (resp. @sa 2m) if @param objectId is equal to 0 (resp. to 1)
void removeContact(int objectId, SubsetIndices indices);

virtual type::vector<std::string> getBilateralInteractionIdentifiers() {return {};}

virtual type::vector<std::string> getPairInteractionIdentifiers() override final
{
type::vector<std::string> ids = getBilateralInteractionIdentifiers();
ids.push_back("Bilateral");
return ids;
}

private:
void unspecializedInit() ;

/// Method to get the index position of a @param point Id inside @sa m1 or @sa m2) depending of the value passed in @param cIndices. Return InvalidID if not found.
Index indexOfElemConstraint(const SubsetIndices& cIndices, Index Id);
};


#if !defined(SOFA_COMPONENT_CONSTRAINTSET_BILATERALINTERACTIONCONSTRAINT_CPP)
extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralInteractionConstraint< Vec3Types >;
extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralInteractionConstraint< Rigid3Types >;
#endif

} // namespace sofa::component::constraint::lagrangian::model
using BilateralInteractionConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "BilateralInteractionConstraint has been renamed to BilateralLagrangianConstraint") = BilateralLagrangianConstraint<T>;
}
Loading

0 comments on commit 026a501

Please sign in to comment.