overland.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "overland.hpp"
  2. #include "debug.hpp"
  3. namespace Kernel{
  4. void Overland::run(){
  5. #ifdef MYDEBUG
  6. cout<<" [Overland::run] start"<<endl;
  7. #endif
  8. compute_flux_soil();
  9. total_error=0;
  10. for(size_t ix=0;ix<geometry->nX;++ix){
  11. //TODO :: add rain
  12. hov[ix]=init_hov[ix]-dt*flux_soil[ix];
  13. double e=abs(hov[ix]-previous_hov[ix])/n1_init_hov;
  14. error_x[ix]+=e;
  15. total_error+=e;
  16. Psoil[ix]=Physics::Psoil(geometry->hsoil[ix],hov[ix]);
  17. }
  18. #ifdef MYDEBUG
  19. cout<<" [Overland::run] error : "<<total_error<<endl;
  20. #endif
  21. #ifdef MYDEBUG
  22. cout<<" [Overland::run] end"<<endl;
  23. #endif
  24. }
  25. void Overland::compute_flux_soil(){
  26. for(size_t ix=0;ix<geometry->nX;++ix){
  27. double p1=P[ix][geometry->nZ[ix]-1];
  28. double p2=P[ix][geometry->nZ[ix]-2];
  29. double flux=Physics::k0/2*(Physics::kr(p1)+Physics::kr(p2))*((p1-p2)/(geometry->dZ[ix]*Physics::rho*Physics::g)+1);
  30. if(ix==0) flux-=Physics::k0*Physics::kr(Pl[0]+Physics::rho*Physics::g*(l[0]-geometry->hsoil[0]))*(hydr[1]-hydr[0])*geometry->dhsoil[0]/geometry->dX;
  31. else if(ix==geometry->nX-1) flux-=Physics::k0*Physics::kr(Pl[ix]+Physics::rho*Physics::g*(l[ix]-geometry->hsoil[ix]))*(hydr[ix]-hydr[ix-1])*geometry->dhsoil[ix]/geometry->dX;
  32. //else flux-=Physics::k0*Physics::kr(Pl[ix]+Physics::rho*Physics::g*(l[ix]-geometry->hsoil[ix]))*(hydr[ix+1]-hydr[ix-1])/2*geometry->dhsoil[ix]/geometry->dX;
  33. flux_soil[ix]=flux;
  34. #ifdef MYDEBUG
  35. if(Debug::ix==ix){
  36. cout<<" [Overland::compute_flux_soil] p1 = "<<p1<<endl;
  37. cout<<" [Overland::compute_flux_soil] p2 = "<<p2<<endl;
  38. cout<<" [Overland::compute_flux_soil] flux = "<<flux<<endl;
  39. }
  40. #endif
  41. }
  42. }
  43. }