From 30ddac7b31cfdb8077909fb9182876120e30feff Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Wed, 18 Sep 2024 16:42:46 +0200 Subject: [PATCH 1/2] Fix parameters usage and some deleted attributes --- .../MORUnilateralInteractionConstraint.h | 2 -- .../MORUnilateralInteractionConstraint.inl | 35 ++++--------------- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/src/ModelOrderReduction/component/contact/MORUnilateralInteractionConstraint.h b/src/ModelOrderReduction/component/contact/MORUnilateralInteractionConstraint.h index 1511049..004844a 100644 --- a/src/ModelOrderReduction/component/contact/MORUnilateralInteractionConstraint.h +++ b/src/ModelOrderReduction/component/contact/MORUnilateralInteractionConstraint.h @@ -101,11 +101,9 @@ class MORUnilateralInteractionConstraint : public UnilateralLagrangianConstraint protected: using UnilateralLagrangianConstraint::contacts; - using UnilateralLagrangianConstraint::epsilon; using UnilateralLagrangianConstraint::yetIntegrated; using UnilateralLagrangianConstraint::customTolerance; - using UnilateralLagrangianConstraint::prevForces; using UnilateralLagrangianConstraint::contactsStatus; // /// Computes constraint violation diff --git a/src/ModelOrderReduction/component/contact/MORUnilateralInteractionConstraint.inl b/src/ModelOrderReduction/component/contact/MORUnilateralInteractionConstraint.inl index 687a366..8c3b4ea 100644 --- a/src/ModelOrderReduction/component/contact/MORUnilateralInteractionConstraint.inl +++ b/src/ModelOrderReduction/component/contact/MORUnilateralInteractionConstraint.inl @@ -76,7 +76,7 @@ void MORUnilateralInteractionConstraint::buildConstraintMatrix(const c1_it.addCol(c.m1, -c.norm); c1_it.addCol(c.m2, c.norm); - if (c.mu > 0.0) + if (c.parameters.hasTangentialComponent()) { c1_it = c1.writeLine(c.id + 1); c1_it.setCol(c.m1, -c.t); @@ -108,16 +108,16 @@ void MORUnilateralInteractionConstraint::buildConstraintMatrix(const for (unsigned int i = 0; i < contacts.size(); i++) { auto& c = contacts[i]; - myMuForAllContacts = c.mu; + myMuForAllContacts = c.parameters.mu; c.id = i; - if (c.mu == 0.0) + if (!c.parameters.hasTangentialComponent()) if (contactIndices(c.m2) != -1 && lambdaModes(contactIndices(c.m2),numMode)!=0.0){ c1_it.addCol(c.m1, -lambdaModes(contactIndices(c.m2),numMode)*c.norm); c2_it.addCol(c.m2, lambdaModes(contactIndices(c.m2),numMode)*c.norm); somethingAdded = true; } - if (c.mu > 0.0) + if (c.parameters.hasTangentialComponent()) { if (contactIndices(3*c.m2) != -1 && lambdaModes(contactIndices(3*c.m2),numMode)!=0.0){ c1_it.addCol(c.m1, -lambdaModes(contactIndices(3*c.m2),numMode)*c.norm); @@ -176,27 +176,6 @@ void MORUnilateralInteractionConstraint::buildConstraintMatrix(const // contactId = contactId - 3; } -template -void MORUnilateralInteractionConstraint::getConstraintViolation(const core::ConstraintParams *cparams, linearalgebra::BaseVector *v, const DataVecCoord &, const DataVecCoord & - , const DataVecDeriv &, const DataVecDeriv &) -{ - switch (cparams->constOrder()) - { - case core::ConstraintParams::POS_AND_VEL : - case core::ConstraintParams::POS : - getPositionViolation(v); - break; - - case core::ConstraintParams::ACC : - case core::ConstraintParams::VEL : - UnilateralLagrangianConstraint::getVelocityViolation(v); - break; - - default : - msg_error() << this->getClassName() << " doesn't implement " << cparams->getName() << " constraint violation"; - break; - } -} template void MORUnilateralInteractionConstraint::getPositionViolation(linearalgebra::BaseVector *v) @@ -265,7 +244,7 @@ void MORUnilateralInteractionConstraint::getPositionViolation(lineara } // Sets dfree in global violation vector - if (c.mu == 0.0){ + if (!c.parameters.hasTangentialComponent()){ for (int k=0;k::getConstraintResolution(cons for(unsigned int i=0; i 0.0) + if(c.parameters.hasTangentialComponent()) { i = i+2; - UnilateralConstraintResolutionWithFriction* ucrwf = new UnilateralConstraintResolutionWithFriction(c.mu, nullptr, &contactsStatus[i]); + UnilateralConstraintResolutionWithFriction* ucrwf = new UnilateralConstraintResolutionWithFriction(c.parameters.mu, nullptr, &contactsStatus[i]); ucrwf->setTolerance(customTolerance); resTab[offset] = ucrwf; // TODO : cette méthode de stockage des forces peu mal fonctionner avec 2 threads quand on utilise l'haptique From f27d45d4973b128984fd2ef2140e9f5e31d099c5 Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Wed, 18 Sep 2024 17:33:16 +0200 Subject: [PATCH 2/2] Remove getConstraintViolaiton from class declaration --- .../component/contact/MORUnilateralInteractionConstraint.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/ModelOrderReduction/component/contact/MORUnilateralInteractionConstraint.h b/src/ModelOrderReduction/component/contact/MORUnilateralInteractionConstraint.h index 004844a..a437016 100644 --- a/src/ModelOrderReduction/component/contact/MORUnilateralInteractionConstraint.h +++ b/src/ModelOrderReduction/component/contact/MORUnilateralInteractionConstraint.h @@ -123,10 +123,6 @@ class MORUnilateralInteractionConstraint : public UnilateralLagrangianConstraint void buildConstraintMatrix(const core::ConstraintParams* cParams, DataMatrixDeriv &c1, DataMatrixDeriv &c2, unsigned int &cIndex , const DataVecCoord &x1, const DataVecCoord &x2) override; - void getConstraintViolation(const core::ConstraintParams* cParams, linearalgebra::BaseVector *v, const DataVecCoord &x1, const DataVecCoord &x2 - , const DataVecDeriv &v1, const DataVecDeriv &v2) override; - - // void getConstraintInfo(const core::ConstraintParams* cParams, VecConstraintBlockInfo& blocks, VecPersistentID& ids, VecConstCoord& positions, VecConstDeriv& directions, VecConstArea& areas) override; virtual void getConstraintResolution(const core::ConstraintParams *,std::vector& resTab, unsigned int& offset) override;