From a536a402958535510f348142c46cace126738524 Mon Sep 17 00:00:00 2001 From: duriez Date: Fri, 30 Nov 2018 15:41:13 +0100 Subject: [PATCH] Cleaning the file GraphScatteredTypes Signed-off-by: duriez --- .../GraphScatteredTypes.cpp | 49 ++++++++----------- .../GraphScatteredTypes.h | 38 +++----------- 2 files changed, 28 insertions(+), 59 deletions(-) diff --git a/SofaKernel/modules/SofaBaseLinearSolver/GraphScatteredTypes.cpp b/SofaKernel/modules/SofaBaseLinearSolver/GraphScatteredTypes.cpp index d1e997073f2..7104dc9626c 100644 --- a/SofaKernel/modules/SofaBaseLinearSolver/GraphScatteredTypes.cpp +++ b/SofaKernel/modules/SofaBaseLinearSolver/GraphScatteredTypes.cpp @@ -20,12 +20,8 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #include -#include #include #include -#include -#include -#include #include #include @@ -44,38 +40,35 @@ using sofa::core::objectmodel::BaseContext; void GraphScatteredMatrix::apply(GraphScatteredVector& res, GraphScatteredVector& x) { - // matrix-vector product -#if 1 - // new more powerful visitors + // matrix-vector product through visitors parent->propagateDxAndResetDf(x,res); parent->addMBKdx(res,parent->mparams.mFactor(),parent->mparams.bFactor(),parent->mparams.kFactor(), false); // df = (m M + b B + k K) dx -#else - parent->propagateDx(x); // dx = p - parent->computeDf(res); // q = K p - - if (parent->mparams.kFactor() != 1.0) - res *= parent->mparams.kFactor(); // q = k K p - - // apply global Rayleigh damping - if (parent->mparams.mFactor() == 1.0) - { - parent->addMdx(res); // no need to propagate p as dx again - } - else if (parent->mparams.mFactor() != 0.0) - { - parent->addMdx(res,core::MultiVecDerivId(),parent->mparams.mFactor()); // no need to propagate p as dx again - } - // q = (m M + k K) p - - /// @TODO: any damping (i.e. the B factor & rayleigh) -#endif - // filter the product to take the constraints into account // parent->projectResponse(res); // q is projected to the constrained space } +unsigned int GraphScatteredMatrix::rowSize() +{ + unsigned int nbRow=0, nbCol=0; + this->parent->getMatrixDimension(&nbRow, &nbCol); + return nbRow; + +} + +unsigned int GraphScatteredMatrix::colSize() +{ + unsigned int nbRow=0, nbCol=0; + this->parent->getMatrixDimension(&nbRow, &nbCol); + return nbCol; +} + + +void GraphScatteredVector::operator=(const MultExpr& expr) +{ + expr.a.apply(*this,expr.b); +} } // namespace linearsolver diff --git a/SofaKernel/modules/SofaBaseLinearSolver/GraphScatteredTypes.h b/SofaKernel/modules/SofaBaseLinearSolver/GraphScatteredTypes.h index 24fe4bb80f2..aaa019eab3b 100644 --- a/SofaKernel/modules/SofaBaseLinearSolver/GraphScatteredTypes.h +++ b/SofaKernel/modules/SofaBaseLinearSolver/GraphScatteredTypes.h @@ -26,8 +26,7 @@ #include #include #include -#include -#include + namespace sofa { @@ -53,19 +52,14 @@ class SOFA_BASE_LINEAR_SOLVER_API GraphScatteredMatrix { public: typedef SReal Real; - //simulation::SolverImpl* parent; - //double mFact, bFact, kFact; core::MechanicalParams mparams; simulation::common::MechanicalOperations* parent; public: GraphScatteredMatrix() - : parent(NULL) //, mFact(0.0), bFact(0.0), kFact(0.0) - { - } - void setMBKFacts(const core::MechanicalParams* mparams) + : parent(nullptr) { - this->mparams = *mparams; } + void setMBKFacts(const core::MechanicalParams* mparams){ this->mparams = *mparams;} MultExpr operator*(GraphScatteredVector& v) { return MultExpr(*this, v); @@ -74,21 +68,9 @@ class SOFA_BASE_LINEAR_SOLVER_API GraphScatteredMatrix // compatibility with baseMatrix - unsigned int rowSize() - { - unsigned int nbRow=0, nbCol=0; - this->parent->getMatrixDimension(&nbRow, &nbCol); - return nbRow; + unsigned int rowSize(); /// provides the number of rows of the Graph Scattered Matrix - } - int colSize() - { - unsigned int nbRow=0, nbCol=0; - this->parent->getMatrixDimension(&nbRow, &nbCol); - return nbCol; - } - - //void papply(GraphScatteredVector& res, GraphScatteredVector& x); + unsigned int colSize(); /// provides the number of columns of the Graph Scattered Matrix static const char* Name() { return "GraphScattered"; } }; @@ -141,15 +123,9 @@ class SOFA_BASE_LINEAR_SOLVER_API GraphScatteredVector : public sofa::core::beha friend class GraphScatteredMatrix; - void operator=(const MultExpr& expr) - { - expr.a.apply(*this,expr.b); - } + void operator=(const MultExpr& expr); + - //void operator+=(const MultExpr& expr) - //{ - // expr.a.papply(*this,expr.b); - //} static const char* Name() { return "GraphScattered"; } };