Salome HOME
Added more options for the nonlinear solver
[tools/solverlab.git] / CoreFlows / Models / inc / ProblemCoreFlows.hxx
index af168699870e23e768597927ec81230555fe29a8..253e1bedb7089ab359306223895230964d6aa4b8 100755 (executable)
@@ -54,6 +54,21 @@ enum preconditioner
        CHOLESKY/**< preconditioner is actually a direct solver for symmetric matrices (CHOLESKY factorisation)*/
 };
 
+//! enumeration nonLinearSolver
+/*! the nonLinearSolver can be Newton_SOLVERLAB or using PETSc, Newton_PETSC_LINESEARCH, Newton_PETSC_TRUSTREGION (see Petsc documentation) */
+enum nonLinearSolver
+{
+       Newton_SOLVERLAB,/**< nonLinearSolver is Newton_SOLVERLAB */
+       Newton_PETSC_LINESEARCH,/**< nonLinearSolver is Newton_PETSC_LINESEARCH */
+       Newton_PETSC_LINESEARCH_BASIC,/**< nonLinearSolver is Newton_PETSC_LINESEARCH_BASIC */
+       Newton_PETSC_LINESEARCH_BT,/**< nonLinearSolver is Newton_PETSC_LINESEARCH_BT */
+       Newton_PETSC_LINESEARCH_SECANT,/**< nonLinearSolver is Newton_PETSC_LINESEARCH_SECANT */
+       Newton_PETSC_LINESEARCH_NLEQERR,/**< nonLinearSolver is Newton_PETSC_LINESEARCH_LEQERR */
+       Newton_PETSC_TRUSTREGION,/**< nonLinearSolver is Newton_PETSC_TRUSTREGION */
+       Newton_PETSC_NGMRES,/**< nonLinearSolver is Newton_PETSC_NGMRES */
+       Newton_PETSC_ASPIN/**< nonLinearSolver is Newton_PETSC_ASPIN */
+};
+
 //! enumeration saveFormat
 /*! the numerical results are saved using MED, VTK or CSV format */
 enum saveFormat
@@ -78,7 +93,7 @@ public :
        ProblemCoreFlows();
        virtual ~ProblemCoreFlows();
        
-       // -*-*-*- Gestion du calcul (interface ICoCo -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
+       // -*-*-*- Gestion du calcul (interface ICoCo) -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
 
        /** \fn initialize
         * \brief Alloue la mémoire et vérifie que  le maillage et les conditions limites/initiales sont bien définis
@@ -116,7 +131,7 @@ public :
 
        /** \fn solveTimeStep
         * \brief calcule les valeurs inconnues au pas de temps +1 .
-        *  \details c'est une fonction virtuelle ,
+        *  \details c'est une fonction virtuelle
         *  @param  void
         *  \return Renvoie false en cas de problème durant le calcul (valeurs non physiques..)
         *  */
@@ -418,6 +433,16 @@ public :
                return _ksptype;
        };
 
+       /** \fn getNonLinearSolver
+        * \brief renvoie _nonLinearSolver (le type du solveur de Newton utilisé)
+        * \details
+        * \param [in] void
+        * \param [out] string
+        *  */
+       nonLinearSolver getNonLinearSolver() {
+               return _nonLinearSolver;
+       };
+
        /** \fn getNumberOfVariables
         * \brief le nombre d'inconnues du problème
         * \details
@@ -445,16 +470,13 @@ public :
        void setLinearSolver(linearSolver solverName, preconditioner pcType);
 
        /** \fn setNewtonSolver
-        * \brief set the Newton algorithm parameters
-        * \param [in] int maximum number of newton iterations
-        * \param [in] double precision required for the convergence of the newton scheme
+        * \brief sets the Newton type algorithm for solving the nonlinear algebraic system arising from the discretisation of the PDE
+        * \param [in] double : precision required for the convergence of the newton scheme
+        * \param [in] int : maximum number of newton iterations
+        * \param [in] nonLinearSolver : the algorithm to be used to solve the nonlinear system
         * \param [out] void
         *  */
-       void setNewtonSolver(double precision,int iterations=20)
-       {
-               _maxNewtonIts=iterations;
-               _precision_Newton=precision;
-       };
+       void setNewtonSolver(double precision, int iterations=20, nonLinearSolver solverName=Newton_SOLVERLAB);
 
        /** \fn displayConditionNumber
         * \brief display the condition number of the preconditioned linear systems
@@ -483,6 +505,21 @@ public :
                _path=resultsPath;
        }
 
+       /** \fn getTimeScheme
+        * \brief returns the  time scheme name
+        * \param [in] void
+        * \param [out] enum TimeScheme (explicit or implicit)
+        *  */
+       TimeScheme getTimeScheme();
+
+       /** \fn setNumericalScheme
+        * \brief sets the numerical method ( explicit vs implicit )
+        * \details
+        * \param [in] TimeScheme
+        * \param [out] void
+        *  */
+       void setTimeScheme( TimeScheme method);
+
        //Couplages Thermohydraulique-thermique-neutronique *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
 
        /** \fn setHeatPowerField
@@ -582,11 +619,13 @@ public :
                _system = system;
        };
 
-    //Spectrum analysis
+    //Spectral analysis
     double getConditionNumber(bool isSingular=false, double tol=1e-6) const;
     std::vector< double > getEigenvalues (int nev, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6) const;
     std::vector< Vector > getEigenvectors(int nev, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6) const;
     Field getEigenvectorsField(int nev, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6) const;
+    std::vector< double > getSingularValues( int nsv, SVDWhich which=SVD_SMALLEST, double tol=1e-6) const;
+    std::vector< Vector > getSingularVectors(int nsv, SVDWhich which=SVD_SMALLEST, double tol=1e-6) const;
 
        //  some supplementary functions
 
@@ -597,7 +636,7 @@ public :
         * @param name, string, name or description of the matrix
         * @return displays the matrix on the terminal
         *  */
-       void displayMatrix(double *matrix, int size, string name);
+       static void displayMatrix(double *matrix, int size, string name="Vector coefficients :");
 
        /** \fn displayMatrix
         * \brief displays a vector of size "size" for profiling
@@ -606,23 +645,7 @@ public :
         * @param name, string, name or description of the vector
         * @return displays the vector on the terminal
         *  */
-       void displayVector(double *vector, int size, string name);
-
-       /** \fn getTimeScheme
-        * \brief returns the  time scheme name
-        * \param [in] void
-        * \param [out] enum TimeScheme (explicit or implicit)
-        *  */
-       TimeScheme getTimeScheme();
-
-       /** \fn setNumericalScheme
-        * \brief sets the numerical method ( explicit vs implicit )
-        * \details
-        * \param [in] TimeScheme
-        * \param [out] void
-        *  */
-       void setTimeScheme( TimeScheme method);
-
+       static void displayVector(double *vector, int size, string name="Matrix coefficients :");
 
 protected :
 
@@ -655,11 +678,12 @@ protected :
        PC _pc;
        PCType _pctype;
        string _pc_hypre;
+       nonLinearSolver _nonLinearSolver;
        int _maxPetscIts;//nombre maximum d'iteration gmres autorise au cours d'une resolution de systeme lineaire
        int _PetscIts;//the number of iterations of the linear solver
        int _maxNewtonIts;//nombre maximum d'iteration de Newton autorise au cours de la resolution d'un pas de temps
        int _NEWTON_its;
-       Mat  _A;//Linear system matrix
+       Mat _A;//Linear system matrix
        Vec _b;//Linear system right hand side
        double _MaxIterLinearSolver;//nombre maximum d'iteration gmres obtenu au cours par les resolution de systemes lineaires au cours d'un pas de tmeps
        bool _conditionNumber;//computes an estimate of the condition number
@@ -691,6 +715,7 @@ protected :
 
        string _path;//path to execution directory used for saving results
        saveFormat _saveFormat;//file saving format : MED, VTK or CSV
+       
 };
 
 #endif /* PROBLEMCOREFLOWS_HXX_ */