1 //============================================================================
2 // Name : ProblemCoreFlows
5 // Copyright : CEA Saclay 2014
6 // Description : Generic class for thermal hydraulics problems
7 //============================================================================
9 /*! \class ProblemFluid ProblemFluid.hxx "ProblemFluid.hxx"
10 * \brief Factorises the methods that are common to the non scalar models (fluid models)
11 * \details Common functions to fluid models
13 #ifndef PROBLEMFLUID_HXX_
14 #define PROBLEMFLUID_HXX_
17 #include "ProblemCoreFlows.hxx"
18 #include "utilitaire_algebre.h"
22 //! enumeration SpaceScheme
23 /*! Several numerical schemes are available */
26 upwind,/**< classical full upwinding scheme (first order in space) */
27 centered,/**< centered scheme (second order in space) */
28 pressureCorrection,/**< include a pressure correction in the upwind scheme to increase precision at low Mach numbers */
29 lowMach,/**< include an upwinding proportional to the Mach numer scheme to increase precision at low Mach numbers */
30 staggered,/**< scheme inspired by staggered discretisations */
33 //! enumeration NonLinearFormulation
34 /*! the formulation used to compute the non viscous fluxes */
35 enum NonLinearFormulation
37 Roe,/**< Ph. Roe non linear formulation is used */
38 VFRoe,/**< Masella, Faille and Gallouet non linear formulation is used */
39 VFFC,/**< Ghidaglia, Kumbaro and Le Coq non linear formulation is used */
40 reducedRoe,/**< compacted formulation of Roe scheme without computation of the fluxes */
43 //! enumeration phaseType
44 /*! The material phase can be Gas or liquid */
47 Liquid,/**< Material considered is Liquid */
48 Gas/**< Material considered is Gas */
51 //! enumeration BoundaryType
52 /*! Boundary condition type */
53 enum BoundaryType {Wall, InnerWall, Inlet, InletPressure, InletRotationVelocity, InletEnthalpy, Outlet, Neumann, NoTypeSpecified};
54 /** \struct LimitField
55 * \brief value of some fields on the boundary */
57 LimitField(){bcType=NoTypeSpecified; p=0; v_x=vector<double> (0,0); v_y=vector<double> (0,0); v_z=vector<double> (0,0); T=0; h=0; alpha=0; conc=0;}
58 LimitField(BoundaryType _bcType, double _p, vector<double> _v_x, vector<double> _v_y, vector<double> _v_z,
59 double _T, double _h, double _alpha, double _conc){
60 bcType=_bcType; p=_p; v_x=_v_x; v_y=_v_y; v_z=_v_z; T=_T; h=_h; alpha=_alpha; conc=_conc;
64 double p;//For outlet (fluid models)
65 vector<double> v_x; vector<double> v_y; vector<double> v_z;//For wall and inlet (fluid models)
66 double T; //for wall and inlet (DriftModel and FiveEqsTwoFluid) and for Dirichlet (DiffusionEquation)
67 double h; //for inlet (TransportEquation)
68 double alpha; //For inlet (IsothermalTwoFluid and FiveEqsTwoFluid)
69 double conc;//For inlet (DriftModel)
72 class ProblemFluid: public ProblemCoreFlows
77 * \brief constructeur de la classe ProblemFluid
79 ProblemFluid(MPI_Comm comm = MPI_COMM_WORLD);
81 //Gestion du calcul (interface ICoCo)
84 * \brief Alocates memory and checks that the mesh, the boundary and the intitial data are set
85 * \Details It is a pure virtual function overloaded y each model.
88 virtual void initialize();
91 * \brief empties the memory
94 virtual void terminate();
97 * \brief Sets a new time step dt to be solved later
98 * @param dt is the value of the time step
99 * \return false if dt <0 et True otherwise
101 bool initTimeStep(double dt);
103 /** \fn computeTimeStep
104 * \brief Proposes a value for the next time step to be solved using mesh data and cfl coefficient
105 * \return double dt the proposed time step
106 * \return bool stop, true if the calculation should not be continued (stationary state, maximum time or time step numer reached)
108 double computeTimeStep(bool & stop);
110 /** \fn abortTimeStep
111 * \brief Reset the time step dt to 0
113 void abortTimeStep();
115 /** \fn iterateTimeStep
116 * \brief calls computeNewtonVariation to perform one Newton iteration and tests the convergence
118 * @return boolean ok is true is the newton iteration gave a physically acceptable result
120 virtual bool iterateTimeStep(bool &ok);
123 * \brief saves the current results in MED or VTK files
124 * \details It is a pure virtual function overloaded in each model
127 virtual void save()=0;
129 /** \fn validateTimeStep
130 * \brief Validates the solution computed y solveTimeStep
131 * \details updates the currens time t=t+dt, save unknown fields, resets the time step dt to 0, tests the stationnarity.
132 * c It is a pure virtual function overloaded in each model
135 virtual void validateTimeStep();
137 /** \fn solveTimeStep
138 * \brief calcule les valeurs inconnues au pas de temps +1 .
139 * \details c'est une fonction virtuelle, qui surcharge celle de la classe ProblemCoreFlows
141 * \return Renvoie false en cas de problème durant le calcul (valeurs non physiques..)
143 virtual bool solveTimeStep();//
145 /* Boundary conditions */
146 /** \fn setNeumannBoundaryCondition
147 * \brief adds a new boundary condition of type Neumann
149 * \param [in] string the name of the boundary
152 void setNeumannBoundaryCondition(string groupName){
153 _limitField[groupName]=LimitField(Neumann,-1,vector<double>(_Ndim,0),vector<double>(_Ndim,0),vector<double>(_Ndim,0),-1,-1,-1,-1);
156 /** \fn setOutletBoundaryCondition
157 * \brief Adds a new boundary condition of type Outlet
159 * \param [in] string : the name of the boundary
160 * \param [in] double : the value of the pressure at the boundary
163 void setOutletBoundaryCondition(string groupName,double Pressure){
164 _limitField[groupName]=LimitField(Outlet,Pressure,vector<double>(_nbPhases,0),vector<double>(_nbPhases,0),vector<double>(_nbPhases,0),-1,-1,-1,-1);
167 /** \fn setOutletBoundaryCondition
168 * \brief Adds a new boundary condition of type Outlet taking into account the hydrostatic pressure variations
169 * \details The pressure is not constant on the boundary but varies linearly with a slope given by the gravity vector
170 * \param [in] string : the name of the boundary
171 * \param [in] double : the value of the pressure at the boundary
172 * \param [in] vector<double> : reference_point position on the boundary where the value Pressure will be imposed
175 void setOutletBoundaryCondition(string groupName,double referencePressure, vector<double> reference_point){
176 /* On the boundary we have P-Pref=rho g\cdot(x-xref) */
177 _gravityReferencePoint=reference_point;
178 _limitField[groupName]=LimitField(Outlet,referencePressure,vector<double>(_nbPhases,0),vector<double>(_nbPhases,0),vector<double>(_nbPhases,0),-1,-1,-1,-1);
181 /** \fn setBoundaryFields
182 * \brief met à jour _limitField ( le type de condition limite )
187 void setBoundaryFields(map<string, LimitField> boundaryFields){
188 _limitField = boundaryFields;
192 * \brief sets the vector of viscosity coefficients
193 * @param viscosite is a vector of size equal to the number of phases and containing the viscosity of each phase
194 * @return throws an exception if the input vector size is not equal to the number of phases
196 void setViscosity(vector<double> viscosite){
197 if(_nbPhases!= viscosite.size())
198 throw CdmathException("ProblemFluid::setViscosity: incorrect vector size vs number of phases");
199 for(int i=0;i<_nbPhases;i++)
200 _fluides[i]->setViscosity(viscosite[i]);
203 /** \fn setConductivity
204 * \brief sets the vector of conductivity coefficients
205 * @param conductivite is a vector of size equal to the number of phases and containing the conductivity of each phase
206 * @return throws an exception if the input vector size is not equal to the number of phases
208 void setConductivity(vector<double> conductivite){
209 if(_nbPhases!= conductivite.size())
210 throw CdmathException("ProblemFluid::setConductivity: incorrect vector size vs number of phases");
211 for(int i=0;i<_nbPhases;i++)
212 _fluides[i]->setConductivity(conductivite[i]);
216 * \brief sets the gravity force in the model
217 * @param gravite is a vector of size equal to the space dimension
219 void setGravity(vector<double> gravite){
220 _GravityField3d = gravite;
223 /** \fn setDragCoeffs
224 * \brief Sets the drag coefficients
225 * @param dragCoeffs is a vector of size equal to the number of phases and containing the value of the friction coefficient of each phase
226 * @return throws an exception if the input vector size is not equal to the numer of phases
228 void setDragCoeffs(vector<double> dragCoeffs){
229 if(_nbPhases!= dragCoeffs.size())
230 throw CdmathException("ProblemFluid::setDragCoeffs: incorrect vector size vs number of phases");
231 for(int i=0;i<_nbPhases;i++)
233 _fluides[i]->setDragCoeffs(dragCoeffs[i]);
234 _dragCoeffs[i]=dragCoeffs[i];
238 /** \fn getNumberOfPhases
239 * \brief The numer of phase (one or two) depending on the model considered
241 * @return the number of phases considered in the model
243 int getNumberOfPhases() const {
247 /** \fn testConservation
248 * \brief Teste et affiche la conservation de masse et de la quantité de mouvement
249 * \Details la fonction est virtuelle pure, on la surcharge dans chacun des modèles
252 virtual void testConservation()=0;
255 * \brief saves the velocity field in a separate 3D file so that paraview can display the streamlines
258 void saveVelocity(bool save_v=true){
259 _saveVelocity=save_v;
262 /** \fn saveConservativeField
263 * \brief saves the conservative fields (density, momentum etc...)
265 void saveConservativeField(bool save=true){
266 _saveConservativeField=save;
268 /** \fn setEntropicCorrection
269 * \brief include an entropy correction to avoid non entropic solutions
270 * @param boolean that is true if entropy correction should be applied
272 void setEntropicCorrection(bool entropyCorr){
273 _entropicCorrection=entropyCorr;
276 /** \fn setPressureCorrectionOrder
277 * \brief In case a pressure correction scheme is set by a call to setNumericalScheme(pressureCorrection) this function allows the setting of the type of pressure correction to be used
278 * @param int the order of the pressure correction
279 * \details The following treatment is applied depending on the value of the input parameter order
280 * \details 1 -> no pressure correction (pressure correction is applied nowhere in the domain), standard upwind scheme instead is used
281 * \details 2 -> standard pressure correction is applied everywhere in the domain, even at the boundary faces
282 * \details 3 -> standard pressure correction is applied only inside the domain (not at the boundary faces)
283 * \details 4 -> no pressure correction (pressure correction is applied nowhere in the domain), no Riemann problem at wall boundaries (boundary pressure = inner pressure)
284 * \details 5 -> standard pressure correction is applied everywhere in the domain, no Riemann problem at the boundary (boundary pressure = inner pressure)
285 * \details 6 -> standard pressure correction is applied inside the domain and a special pressure correction involving gravity is applied at the boundary, no Riemann problem at wall boundaries (boundary pressure = inner pressure+ source term)
287 void setPressureCorrectionOrder(int order){
288 if( order >6 || order <1)
289 throw CdmathException("ProblemFluid::setPressureCorrectionOrder Pressure correction order must be an integer between 1 and 4");
291 _pressureCorrectionOrder=order;
299 /** \fn setLinearSolver
300 * \brief sets the linear solver and preconditioner
301 * \details virtuelle function overloaded by intanciable classes
302 * @param kspType linear solver type (GMRES or BICGSTAB)
303 * @param pcType preconditioner (ILU,LU or NONE)
304 * @param scaling performs a bancing of the system matrix before calling th preconditioner
306 void setLinearSolver(linearSolver kspType, preconditioner pcType, double maxIts=50, bool scaling=false)
308 ProblemCoreFlows::setLinearSolver(kspType, pcType, maxIts);
312 /** \fn setLatentHeat
313 * \brief Sets the value of the latent heat
314 * @param double L, the value of the latent heat
316 void setLatentHeat(double L){
320 /** \fn getLatentHeat
321 * \brief returns the value of the latent heat
322 * @param double L, the value of the latent heat
324 double getLatentHeat() const{
329 * \brief sets the saturation temperature
330 * @param Tsat double corresponds to saturation temperature
332 void setSatTemp(double Tsat){
337 * \brief sets the saturation temperature
338 * @param Tsat double corresponds to saturation temperature
340 double getSatTemp() const {
344 /** \fn setSatPressure
345 * \brief sets the saturation pressure
346 * @param Psat double corresponds to saturation pressure
348 void setSatPressure(double Psat, double dHsatl_over_dp=0.05){
350 _dHsatl_over_dp=dHsatl_over_dp;
353 /** \fn setPorosityField
354 * \brief set the porosity field;
355 * @param [in] Field porosity field (field on CELLS)
357 void setPorosityField(Field Porosity);
359 /** \fn getPorosityField
360 * \brief returns the porosity field;
363 Field getPorosityField() const {
364 return _porosityField;
367 /** \fn setPorosityFieldFile
368 * \brief set the porosity field
370 * \param [in] string fileName (including file path)
371 * \param [in] string fieldName
374 void setPorosityField(string fileName, string fieldName);
376 /** \fn setPressureLossField
377 * \brief set the pressure loss coefficients field;
378 * @param [in] Field pressure loss field (field on FACES)
380 void setPressureLossField(Field PressureLoss);
382 /** \fn setPressureLossField
383 * \brief set the pressure loss coefficient field
384 * \details localised friction force
385 * \param [in] string fileName (including file path)
386 * \param [in] string fieldName
389 void setPressureLossField(string fileName, string fieldName);
391 /** \fn setSectionField
392 * \brief set the cross section field;
393 * @param [in] Field cross section field (field on CELLS)
395 void setSectionField(Field sectionField);
397 /** \fn setSectionField
398 * \brief set the cross section field
399 * \details for variable cross section pipe network
400 * \param [in] string fileName (including file path)
401 * \param [in] string fieldName
404 void setSectionField(string fileName, string fieldName);
406 /** \fn setNonLinearFormulation
407 * \brief sets the formulation used for the computation of non viscous fluxes
408 * \details Roe, VFRoe, VFFC
409 * \param [in] enum NonLinearFormulation
412 void setNonLinearFormulation(NonLinearFormulation nonLinearFormulation){
413 //if(nonLinearFormulation != Roe && nonLinearFormulation != VFRoe && nonLinearFormulation != VFFC && nonLinearFormulation!=reducedRoe)
414 // throw CdmathException("nonLinearFormulation should be either Roe, VFRoe or VFFC");//extra security for swig binding
415 _nonLinearFormulation=nonLinearFormulation;
418 /** \fn getNonLinearFormulation
419 * \brief returns the formulation used for the computation of non viscous fluxes
420 * \details Roe, VFRoe, VFFC
422 * \param [out] enum NonLinearFormulation
424 NonLinearFormulation getNonLinearFormulation() const{
425 return _nonLinearFormulation;
428 /** \fn usePrimitiveVarsInNewton
429 * \brief use Primitive Vars instead of conservative vars In Newton scheme for implicit schemes
432 void usePrimitiveVarsInNewton(bool usePrimitiveVarsInNewton){
433 _usePrimitiveVarsInNewton=usePrimitiveVarsInNewton;
436 /** \fn getSpaceScheme
437 * \brief returns the space scheme name
439 * \param [out] enum SpaceScheme(upwind, centred, pressureCorrection, pressureCorrection, staggered)
441 SpaceScheme getSpaceScheme() const;
443 /** \fn setNumericalScheme
444 * \brief sets the numerical method (upwind vs centered and explicit vs implicit)
446 * \param [in] SpaceScheme
447 * \param [in] TimeScheme
450 void setNumericalScheme(SpaceScheme scheme, TimeScheme method=Explicit);
452 /* ICoCo code coupling interface */
454 virtual Field& getInputFieldTemplate(const string& name)=0;//Renvoie le format de champs attendu (maillage, composantes etc)
455 virtual vector<string> getOutputFieldsNames()=0 ;//liste tous les champs que peut fournir le code pour le postraitement
456 virtual Field& getOutputField(const string& nameField )=0;//Renvoie un champs pour le postraitement
458 /** Set input fields to prepare the simulation or coupling **/
459 vector<string> getInputFieldsNames();
460 void setInputField(const string& nameField, Field& inputField );//supply of a required input field
462 Field getConservativeField() const ;
463 Field getPrimitiveField() const;
466 /** Number of phases in the fluid **/
468 /** Field of conservative variables (the primitive variables are defined in the mother class ProblemCoreFlows **/
470 /** Field of interfacial states of the VFRoe scheme **/
471 Field _UUstar, _VVstar;
473 SpaceScheme _spaceScheme;
474 /** the formulation used to compute the non viscous fluxes **/
475 NonLinearFormulation _nonLinearFormulation;
477 /** PETSc nonlinear solver and line search **/
479 SNESLineSearch _linesearch;
480 PetscViewer _monitorLineSearch;
482 map<string, LimitField> _limitField;
484 /** boolean used to specify that an entropic correction should be used **/
485 bool _entropicCorrection;
486 /** Vector containing the eigenvalue jumps for the entropic correction **/
487 vector<double> _entropicShift;
488 /** In case a pressure correction scheme is used some more option regarding the type of pressure correction **/
489 int _pressureCorrectionOrder;
491 /** Fluid equation of state **/
492 vector< Fluide* > _fluides;
493 //!Viscosity coefficients
494 vector<double> _viscosite;
495 //!Conductivity coefficients
496 vector<double> _conductivite;
499 vector<double> _gravite, _GravityField3d, _gravityReferencePoint, _dragCoeffs;//_GravityField3d has size _Ndim whereas _gravite has size _Nvar and is usefull for dealing with source term and implicitation of gravity vector
500 double _latentHeat, _Tsat,_Psat,_dHsatl_over_dp;
501 Field _porosityField, _pressureLossField, _dp_over_dt, _sectionField;
502 bool _porosityFieldSet, _pressureLossFieldSet, _sectionFieldSet;
503 double _porosityi, _porosityj;//porosity of the left and right states around an interface
507 bool _saveVelocity;/* In order to display streamlines with paraview */
508 bool _saveConservativeField;/* Save conservative fields such as density or momentum for instance */
509 bool _saveInterfacialField;/* Save interfacial fields of the VFRoe scheme */
510 bool _usePrimitiveVarsInNewton;
512 // Variables du schema numerique
513 Vec _conservativeVars, _newtonVariation, _bScaling,_old, _primitiveVars, _Uext,_Uextdiff ,_vecScaling,_invVecScaling, _Vext;
514 //courant state vector, vector computed at next time step, second member of the equation
515 PetscScalar *_AroePlus, *_AroeMinus,*_Jcb,*_JcbDiff, *_a, *_blockDiag, *_invBlockDiag,*_Diffusion, *_GravityImplicitationMatrix;
516 PetscScalar *_Aroe, *_absAroe, *_signAroe, *_invAroe;
517 PetscScalar *_AroeMinusImplicit,*_AroePlusImplicit,*_AroeImplicit,*_absAroeImplicit;//negative part of the roe matrix used in the implicit scheme matrix
518 PetscScalar * _primToConsJacoMat; //Jacobian matrix of the prim-->cons function
519 PetscScalar *_phi, *_Ui, *_Uj, *_Vi, *_Vj, *_Si, *_Sj, * _pressureLossVector, * _porosityGradientSourceVector, *_externalStates;
520 double *_Uroe, *_Udiff, *_temp, *_l, *_r, *_vec_normal;
521 double * _Uij, *_Vij;//Conservative and primitive interfacial states of the VFRoe scheme
523 double _inv_dxi,_inv_dxj;//diametre des cellules i et j autour d'une face
524 double _err_press_max,_part_imag_max,_minm1,_minm2;
525 int _nbMaillesNeg, _nbVpCplx;
526 bool _isBoundary;// la face courante est elle une face de bord ?
529 bool solveNewtonPETSc();//Use PETSc Newton methods to solve time step
531 /** \fn computeNewtonVariation
532 * \brief Builds and solves the linear system to obtain the variation Ukp1-Uk in a Newton scheme
535 virtual void computeNewtonVariation();
537 /** \fn computeNewtonRHS
538 * \brief Builds the right hand side F_X(X) of the linear system in the Newton method to obtain the variation Ukp1-Uk
541 void computeNewtonRHS( Vec X, Vec F_X);
543 /** \fn computeSnesRHS
544 * \brief Static function calling computeNewtonRHS to match PETSc nonlinear solver (SNES) structure
547 static int computeSnesRHS(SNES snes, Vec X, Vec F_X, void *ctx);
549 /** \fn computeNewtonJacobian
550 * \brief Static function calling computeNewtonJacobian to match PETSc nonlinear solver (SNES) structure
553 void computeNewtonJacobian( Vec X, Mat A);
555 /** \fn computeSnesJacobian
556 * \brief Builds the matrix A(X) of the linear system in the Newton method to obtain the variation Ukp1-Uk
559 static int computeSnesJacobian(SNES snes, Vec X, Mat A, Mat Aapprox, void *ctx);
561 /** \fn convectionState
562 * \brief calcule l'etat de Roe entre deux cellules voisinnes
563 * \Details c'ets une fonction virtuelle, on la surcharge dans chacun des modèles
564 * @param i,j : entiers correspondant aux numéros des cellules à gauche et à droite de l'interface
565 * @param IsBord : est un booléen qui nous dit si la cellule voisine est sur le bord ou pas
567 virtual void convectionState(const long &i, const long &j, const bool &IsBord)=0;
569 /** \fn convectionMatrices
570 * \brief calcule la matrice de convection de l'etat interfacial entre deux cellules voisinnes
571 * \Details convectionMatrices est une fonction virtuelle pure, on la surcharge dans chacun des modèles
573 virtual void convectionMatrices()=0;
575 /** \fn diffusionStateAndMatrices
576 * \brief calcule la matrice de diffusion de l'etat interface pour la diffusion
577 * \Details est une fonction virtuelle pure, on la surcharge dans chacun eds modèles
578 * @param i,j : entier correspondent aux indices des cellules à gauche et droite respectivement
579 * @param IsBord: bollean telling if (i,j) is a boundary face
582 virtual void diffusionStateAndMatrices(const long &i,const long &j, const bool &IsBord)=0;
584 /** \fn addSourceTermToSecondMember
585 * \brief Adds the contribution of source terms to the right hand side of the system: gravity,
586 * phase change, heat power and friction
587 * @param i,j : left and right cell number
588 * @param nbNeighboursi, integer giving the number of neighbours of cell i
589 * @param nbNeighboursj, integer giving the number of neighbours of cell j
590 * @param boolean isBoundary is true for a boundary face (i,j) and false otherwise
591 * @param double mesureFace the lenght or area of the face
593 void addSourceTermToSecondMember(const int i, int nbNeighboursi,const int j, int nbNeighboursj,bool isBoundary, int ij, double mesureFace);
596 * \brief Computes the source term (at the exclusion of pressure loss terms)
597 * \Details pure virtual function, overloaded by each model
598 * @param Si output vector containing the source term
599 * @param Ui, Vi input conservative and primitive vectors
600 * @param i the cell number. Used to read the power field
603 virtual void sourceVector(PetscScalar * Si,PetscScalar * Ui,PetscScalar * Vi, int i)=0;
605 /** \fn convectionFlux
606 * \brief Computes the convection flux F(U) projected on a vector n
607 * @param U is the conservative variable vector
608 * @param V is the primitive variable vector
609 * @param normal is a unit vector giving the direction where the convection flux matrix F(U) is projected
610 * @param porosity is the ration of the volume occupied by the fluid in the cell (default value is 1)
611 * @return The convection flux projected in the direction given by the normal vector: F(U)*normal */
612 virtual Vector convectionFlux(Vector U,Vector V, Vector normale, double porosity)=0;
614 /** \fn pressureLossVector
615 * \brief Computes the contribution of pressure loss terms in the source term
616 * \Details pure virtual function, overloaded by each model
617 * @param pressureLoss output vector containing the pressure loss contributions
618 * @param K, input pressure loss coefficient
619 * @param Ui input primitive vectors
620 * @param Vi input conservative vectors
621 * @param Uj input primitive vectors
622 * @param Vj input conservative vectors
625 virtual void pressureLossVector(PetscScalar * pressureLoss, double K, PetscScalar * Ui, PetscScalar * Vi, PetscScalar * Uj, PetscScalar * Vj)=0;
627 /** \fn porosityGradientSourceVector
628 * \brief Computes the contribution of the porosity variation in the source term
629 * \Details pure virtual function, overloaded by each model
630 * @param porosityGradientVector output vector containing the porosity variation contributions to the source term
631 * @param Ui input primitive vectors celli
632 * @param Vi input conservative vectors celli
633 * @param porosityi input porosity value celli
634 * @param deltaxi input diameter celli
635 * @param Uj input primitive vectors cellj
636 * @param Vj input conservative vectors cellj
637 * @param porosityj input porosity value cellj
638 * @param deltaxj input diameter cellj
641 virtual void porosityGradientSourceVector()=0;
644 * \brief Calcule la jacobienne de la ConditionLimite convection
645 * \Details est une fonction virtuelle pure, qu'on surcharge dans chacun des modèles
646 * @param j entier , l'indice de la cellule sur le bord
647 * @param nameOfGroup : chaine de caractères, correspond au type de la condition limite
649 virtual void jacobian(const int &j, string nameOfGroup,double * normale)=0;
652 * \brief Calcule la jacobienne de la CL de diffusion
653 * \Details est une fonction virtuelle pure, qu'on surcharge dans chacun des modèles
654 * @param j entier , l'indice de la cellule sur le bord
655 * @param nameOfGroup : chaine de caractères, correspond au type de la condition limite
657 virtual void jacobianDiff(const int &j, string nameOfGroup)=0;
659 /** \fn setBoundaryState
660 * \brief Calcule l'etat fictif a la frontiere
661 * \Details est une fonction virtuelle pure, qu'on surcharge dans chacun des modèles
662 * @param j entier , l'indice de la cellule sur le bord
663 * @param nameOfGroup : chaine de caractères, correspond au type de la condition limite
664 * @param normale est un vecteur de double correspond au vecteur normal à l'interface
667 virtual void setBoundaryState(string nameOfGroup, const int &j,double *normale)=0;
669 /** \fn addDiffusionToSecondMember
670 * \brief Compute the contribution of the diffusion operator to the right hand side of the system
671 * \Details this function is pure virtual, and overloaded in each physical model class
672 * @param i left cell number
673 * @param j right cell number
674 * @param boolean isBoundary is true for a boundary face (i,j) and false otherwise
676 virtual void addDiffusionToSecondMember(const int &i,const int &j,bool isBoundary)=0;
678 //!Computes the interfacial flux for the VFFC formulation of the staggered upwinding
679 virtual Vector staggeredVFFCFlux()=0;
680 //!Compute the corrected interfacial state for lowMach, pressureCorrection and staggered versions of the VFRoe formulation
681 virtual void applyVFRoeLowMachCorrections(bool isBord, string groupname="")=0;
683 //remplit les vecteurs de scaling
684 /** \fn computeScaling
685 * \brief Special preconditioner based on a matrix scaling strategy
686 * \Details pure virtual function overloaded in every model class
687 * @param offset double , correspond à la plus grande valeur propre
690 virtual void computeScaling(double offset) =0;
692 // Fonctions utilisant la loi d'etat
695 * \brief computes the primitive vector state from a conservative vector state
696 * \Details ure virtual, implemented by each model
697 * @param Ucons : conservative variable vector
698 * @pram Vprim : primitive variable vector
699 * @param porosity is the porosity coefficient in case of a porous modeling
701 virtual void consToPrim(const double *Ucons, double* Vprim,double porosity=1) = 0;
704 * \brief computes the conservative vector state from a primitive vector state
705 * \Details pure virtual, implemented by each model
706 * @param U : conservative variable vector, may contain several states
707 * @pram V : primitive variable vector, may contain several states
708 * @param i : index of the conservative state in the vector U
709 * @param j : index of the primitive state in the vector V
711 virtual void primToCons(const double *V, const int &i, double *U, const int &j)=0;
713 /** \fn primToConsJacobianMatrix
714 * \brief computes the jacobian matrix of the cons->prim function
715 * \Details pure virtual, implemented by each model
716 * @pram V : primitive vector state
718 //void primToConsJacobianMatrix(double *V)=0;
721 * \brief Computes the roots of a polynomial
722 * @param polynome is a vector containing the coefficients of the polynom
723 * @return vector containing the roots (complex numbers)
725 vector< complex<double> > getRacines(vector< double > polynome);
727 // Some supplement functions ---------------------------------------------------------------------------------------------
729 /** \fn addConvectionToSecondMember
730 * \brief Adds the contribution of the convection to the system right hand side for a face (i,j) inside the domain
731 * @param i left cell number
732 * @param j right cell number
733 * @param isBord is a boolean that is true if the interface (i,j) is a boundary interface
734 * @param groupname : is a string that may be used when isBord is true to specify which boundary the face (i,j) belongs to
736 virtual void addConvectionToSecondMember(const int &i,const int &j,bool isBord, string groupname="");
738 /** \fn updatePrimitives
739 * \brief updates the global primitive vector from the global conservative vector
742 void updatePrimitives();
744 /** \fn updateConservatives
745 * \brief updates the global conservative vector from the global primitive vector
748 void updateConservatives();
750 /** \fn AbsMatriceRoe
751 * \brief Computes the absolute value of the Roe matrix
752 * @param valeurs_propres_dist is the vector of distinct eigenvalues of the Roe matrix
754 void AbsMatriceRoe(vector< complex<double> > valeurs_propres_dist);
756 /** \fn SigneMatriceRoe
757 * \brief Computes the sign of the Roe matrix
758 * @param valeurs_propres_dist is the vector of distinct eigenvalues of the Roe matrix
760 void SigneMatriceRoe(vector< complex<double> > valeurs_propres_dist);
762 /** \fn InvMatriceRoe
763 * \brief Computes the inverse of the Roe matrix
764 * @param valeurs_propres_dist is the vector of distinct eigenvalues of the Roe matrix
766 void InvMatriceRoe(vector< complex<double> > valeurs_propres_dist);
768 /** \fn entropicShift
769 * \brief computes the eigenvalue jumps for the entropy correction
770 * @param normal vector n to the interface between the two cells _l and _r
772 virtual void entropicShift(double* n)=0;
776 #endif /* PROBLEMFLUID_HXX_ */