#ifndef PHYSICS_HPP
#define PHYSICS_HPP

#include <cmath>
#include <cassert>

//! The Physics namespace contains all physical parameters characterising the soil.
namespace Physics{

  enum Model{BrooksCorey};
  
  //! Set physics model
  void setModel(Model model);
  
  //! Gravity acceleration (m.s^-2)
  extern double g;
  //! Fluid density (g.l^(-1))
  extern double rho;
  
  //! Porosity of the soil
  extern double phi;
  //! Conductivity of the saturated soil
  extern double k0;

  //! Characterise the water pressure at the bottom of the overland water
  extern double nivrivsat;

   //! Return the saturation in function of the pressure
  extern double (*s)(double);
  //! Return the derivtive of the saturation in function of the pressure
  extern double (*ds)(double);
  //! Set the saturation and its derivative in function of the pressure
  extern void (*s_ds)(double,double&,double&);
  
  //! Return the relative conductivity in function of the pressure
  extern double(*kr)(double);
  //! Return the derivtive of the relative conductivity in function of the pressure
  extern double (*dkr)(double);
  //! Set the relative conductivity and its derivative in function of the pressure
  extern void (*kr_dkr)(double,double&,double&);
  

  //---------------------
  // Models descriptions 
  //---------------------
  
  //! Datas used to define the model
  extern double model_data[6];

  //------------------------
  // Brooks and Corey model
  //------------------------
  
  //model_data[0] -> psat : minimal pressure such that s(psat)=1
  //model_data[1] -> sres : residual pressure
  //model_data[2] -> lambda 
  //model_data[3] -> alpha
  
  //! Brooks and Corey saturation map
  double s_BC(double P);
  //! Brooks and Corey derivative of the saturation map
  double ds_BC(double P);
  //! Brooks and Corey saturation and its derivative setter
  void (s_ds_BC)(double P,double& v,double& dv);

  //! Brooks and Corey relative conductivity map
  double kr_BC(double P);
  //! Brooks and Corey derivative of the relative conductivity map
  double dkr_BC(double P);
  //! Brooks and Corey relative conductivity and its derivative setter
  void (kr_dkr_BC)(double P,double& v,double& dv);
}
#endif
