Salome HOME
Tested mesh fast equivalence when giving an input field
[tools/solverlab.git] / CoreFlows / Models / inc / ProblemFluid.hxx
index 00e92cae6cb68b02be282914224f20cf2c2b44b0..b0cd6255a6d82763eeb74734c12f2def5625147a 100755 (executable)
@@ -84,7 +84,7 @@ public :
        /**\fn
         * \brief constructeur de la classe ProblemFluid
         */
-       ProblemFluid(void);
+       ProblemFluid(MPI_Comm comm = MPI_COMM_WORLD);
 
        //Gestion du calcul (interface ICoCo)
 
@@ -142,6 +142,14 @@ public :
         *  */
        virtual void validateTimeStep();
 
+       /** \fn solveTimeStep
+        * \brief calcule les valeurs inconnues au pas de temps +1 .
+        *  \details c'est une fonction virtuelle, qui surcharge  celle de la classe ProblemCoreFlows
+        *  @param  void
+        *  \return Renvoie false en cas de problème durant le calcul (valeurs non physiques..)
+        *  */
+       virtual bool solveTimeStep();//
+
        /* Boundary conditions */
        /** \fn setNeumannBoundaryCondition
         * \brief adds a new boundary condition of type Neumann
@@ -244,12 +252,6 @@ public :
                return _nbPhases;
        };
 
-       /** \fn computeNewtonVariation
-        * \brief Builds and solves the linear system to obtain the variation Ukp1-Uk in a Newton scheme
-        * @param void
-        * */
-       virtual void computeNewtonVariation();
-
        /** \fn testConservation
         * \brief Teste et affiche la conservation de masse et de la quantité de mouvement
         * \Details la fonction est virtuelle pure, on la surcharge dans chacun des modèles
@@ -309,9 +311,9 @@ public :
         * @param pcType preconditioner (ILU,LU or NONE)
         * @param scaling performs a bancing of the system matrix before calling th preconditioner
         */
-       void setLinearSolver(linearSolver kspType, preconditioner pcType, bool scaling=false)
+       void setLinearSolver(linearSolver kspType, preconditioner pcType, double maxIts=50, bool scaling=false)
        {
-               ProblemCoreFlows::setLinearSolver(kspType, pcType);
+               ProblemCoreFlows::setLinearSolver(kspType, pcType, maxIts);
                _isScaling= scaling;
        };
 
@@ -360,10 +362,7 @@ public :
         * \brief set the porosity field;
         * @param [in] Field porosity field (field on CELLS)
         * */
-       void setPorosityField(Field Porosity){
-               _porosityField=Porosity;
-               _porosityFieldSet=true;
-       }
+       void setPorosityField(Field Porosity);
 
        /** \fn getPorosityField
         * \brief returns the porosity field;
@@ -380,19 +379,14 @@ public :
         * \param [in] string fieldName
         * \param [out] void
         *  */
-       void setPorosityField(string fileName, string fieldName){
-               _porosityField=Field(fileName, CELLS,fieldName);
-               _porosityFieldSet=true;
-       }
+       void setPorosityField(string fileName, string fieldName);
 
        /** \fn setPressureLossField
         * \brief set the pressure loss coefficients field;
         * @param [in] Field pressure loss field (field on FACES)
         * */
-       void setPressureLossField(Field PressureLoss){
-               _pressureLossField=PressureLoss;
-               _pressureLossFieldSet=true;
-       }
+       void setPressureLossField(Field PressureLoss);
+       
        /** \fn setPressureLossField
         * \brief set the pressure loss coefficient field
         * \details localised friction force
@@ -400,19 +394,14 @@ public :
         * \param [in] string fieldName
         * \param [out] void
         *  */
-       void setPressureLossField(string fileName, string fieldName){
-               _pressureLossField=Field(fileName, FACES,fieldName);
-               _pressureLossFieldSet=true;
-       }
+       void setPressureLossField(string fileName, string fieldName);
 
        /** \fn setSectionField
         * \brief set the cross section field;
         * @param [in] Field cross section field (field on CELLS)
         * */
-       void setSectionField(Field sectionField){
-               _sectionField=sectionField;
-               _sectionFieldSet=true;
-       }
+       void setSectionField(Field sectionField);
+       
        /** \fn setSectionField
         * \brief set the cross section field
         * \details for variable cross section pipe network
@@ -420,10 +409,7 @@ public :
         * \param [in] string fieldName
         * \param [out] void
         *  */
-       void setSectionField(string fileName, string fieldName){
-               _sectionField=Field(fileName, CELLS,fieldName);
-               _sectionFieldSet=true;
-       }
+       void setSectionField(string fileName, string fieldName);
 
        /** \fn setNonLinearFormulation
         * \brief sets the formulation used for the computation of non viscous fluxes
@@ -471,15 +457,16 @@ public :
         *  */
        void setNumericalScheme(SpaceScheme scheme, TimeScheme method=Explicit);
 
-       //données initiales
+       /* ICoCo code coupling interface */
        /*
-       virtual vector<string> getInputFieldsNames()=0 ;//Renvoie les noms des champs dont le problème a besoin (données initiales)
        virtual  Field& getInputFieldTemplate(const string& name)=0;//Renvoie le format de champs attendu (maillage, composantes etc)
-       virtual void setInputField(const string& name, const Field& afield)=0;//enregistre les valeurs d'une donnée initiale
        virtual vector<string> getOutputFieldsNames()=0 ;//liste tous les champs que peut fournir le code pour le postraitement
        virtual Field& getOutputField(const string& nameField )=0;//Renvoie un champs pour le postraitement
         */
-
+       /** Set input fields to prepare the simulation or coupling **/
+       vector<string> getInputFieldsNames();
+       void setInputField(const string& nameField, Field& inputField );//supply of a required input field
+       
        Field getConservativeField() const ;
        Field getPrimitiveField() const;
 
@@ -495,6 +482,11 @@ protected :
        /** the formulation used to compute the non viscous fluxes **/
        NonLinearFormulation _nonLinearFormulation;
 
+       /** PETSc nonlinear solver and line search **/
+       SNES _snes;
+       SNESLineSearch _linesearch;
+       PetscViewer _monitorLineSearch;
+
        map<string, LimitField> _limitField;
 
        /** boolean used to specify that an entropic correction should be used **/
@@ -542,6 +534,38 @@ protected :
        bool _isBoundary;// la face courante est elle une face de bord ?
        double _maxvploc;
 
+       bool solveNewtonPETSc();//Use PETSc Newton methods to solve time step
+
+       /** \fn computeNewtonVariation
+        * \brief Builds and solves the linear system to obtain the variation Ukp1-Uk in a Newton scheme
+        * @param void
+        * */
+       virtual void computeNewtonVariation();
+
+       /** \fn computeNewtonRHS
+        * \brief Builds the right hand side F_X(X) of the linear system in the Newton method to obtain the variation Ukp1-Uk
+        * @param void
+        * */
+       void computeNewtonRHS( Vec X, Vec F_X);
+
+       /** \fn computeSnesRHS
+        * \brief Static function calling computeNewtonRHS to match PETSc nonlinear solver (SNES) structure
+        * @param void
+        * */
+       static int computeSnesRHS(SNES snes, Vec X, Vec F_X, void *ctx);
+
+       /** \fn computeNewtonJacobian
+        * \brief Static function calling computeNewtonJacobian to match PETSc nonlinear solver (SNES) structure
+        * @param void
+        * */
+       void computeNewtonJacobian( Vec X, Mat A);
+
+       /** \fn computeSnesJacobian
+        * \brief Builds the matrix A(X) of the linear system in the Newton method to obtain the variation Ukp1-Uk
+        * @param void
+        * */
+       static int computeSnesJacobian(SNES snes, Vec X, Mat A, Mat Aapprox, void *ctx);
+
        /** \fn convectionState
         * \brief calcule l'etat de Roe entre deux cellules voisinnes
         * \Details c'ets une fonction virtuelle, on la surcharge dans chacun des modèles
@@ -624,8 +648,6 @@ protected :
         * */
        virtual void porosityGradientSourceVector()=0;
 
-       //matrice de gravite
-
        /** \fn jacobian
         * \brief Calcule la jacobienne de la ConditionLimite convection
         * \Details est une fonction virtuelle pure, qu'on surcharge dans chacun des modèles