1 // ============================================================================= 2 // PROJECT CHRONO - http://projectchrono.org 3 // 4 // Copyright (c) 2014 projectchrono.org 5 // All rights reserved. 6 // 7 // Use of this source code is governed by a BSD-style license that can be found 8 // in the LICENSE file at the top level of the distribution and at 9 // http://projectchrono.org/license-chrono.txt. 10 // 11 // ============================================================================= 12 // Authors: Dario Mangoni 13 // ============================================================================= 14 15 #ifndef CHSOLVERPARDISOPROJECT_H 16 #define CHSOLVERPARDISOPROJECT_H 17 18 #include "chrono_pardisoproject/ChApiPardisoProject.h" 19 #include "chrono_pardisoproject/ChPardisoProjectEngine.h" 20 #include "chrono/solver/ChDirectSolverLS.h" 21 22 23 namespace chrono{ 24 25 /// @addtogroup pardisoproject_module 26 /// @{ 27 28 /** \class ChSolverPardisoProject 29 \brief Interface to the Pardiso Project sparse direct solver. 30 31 Sparse linear direct solver. 32 Cannot handle VI and complementarity problems, so it cannot be used with NSC formulations. 33 34 The solver is equipped with two main features: 35 - sparsity pattern lock 36 - sparsity pattern learning 37 38 See ChDirectSolverLS for more details. 39 40 <div class="ce-warning"> 41 If appropriate and warranted by the problem setup, it is \e highly recommended to enable the sparsity pattern \e lock. 42 This can significantly improve performance for more complex problems (larger size and/or problems which include 43 constraints). 44 </div> 45 46 Minimal usage example, to be put anywhere in the code, before starting the main simulation loop: 47 \code{.cpp} 48 auto pardisoproject_solver = chrono_types::make_shared<ChSolverPardisoProject>(); 49 system.SetSolver(pardisoproject_solver); 50 \endcode 51 52 See ChSystemDescriptor for more information about the problem formulation and the data structures passed to the solver. 53 */ 54 class ChApiPardisoProject ChSolverPardisoProject : public ChDirectSolverLS { 55 public: 56 ChSolverPardisoProject(int num_threads = 0, 57 ChPardisoProjectEngine::parproj_SYM symmetry = ChPardisoProjectEngine::parproj_SYM::UNSYMMETRIC); ~ChSolverPardisoProject()58 ~ChSolverPardisoProject() {} GetType()59 virtual Type GetType() const override { return Type::PARDISO_PROJECT; } 60 61 /// Get a handle to the underlying PardisoProject engine. GetPardisoProjectEngine()62 ChPardisoProjectEngine* GetPardisoProjectEngine() { return &m_engine; } 63 64 virtual void SetMatrixSymmetryType(MatrixSymmetryType symmetry) override; 65 66 virtual bool Setup(ChSystemDescriptor& sysd) override; 67 68 private: 69 /// Factorize the current sparse matrix and return true if successful. 70 virtual bool FactorizeMatrix() override; 71 72 /// Solve the linear system using the current factorization and right-hand side vector. 73 /// Load the solution vector (already of appropriate size) and return true if succesful. 74 virtual bool SolveSystem() override; 75 76 /// Display an error message corresponding to the last failure. 77 /// This function is only called if Factorize or Solve returned false. 78 virtual void PrintErrorMessage() override; 79 80 ChPardisoProjectEngine m_engine; 81 82 }; 83 84 /// @} pardisoproject_module 85 86 } // end namespace chrono 87 88 #endif 89