Parcourir la source

Update to QT6

Jean Fromentin il y a 1 an
Parent
commit
00c505efc5

+ 3 - 3
Makefile

@@ -1,6 +1,6 @@
-QT_FLAGS	=-fPIC `pkg-config --cflags --libs Qt5OpenGL`
-QT_LIB		=`pkg-config --libs Qt5OpenGL` -lGL -lGLU
-QT_MOC		= moc
+QT_FLAGS	=-fPIC `pkg-config --cflags --libs Qt6OpenGLWidgets`
+QT_LIB		=`pkg-config --libs Qt6OpenGLWidgets` -lGL -lGLU
+QT_MOC		= /usr/lib/qt6/moc
 GPP		= g++
 
 FLAGS 		= -g -O3 -Isrc -Wfatal-errors

+ 0 - 72
backup/obsolete/geometry_spline.cpp

@@ -1,72 +0,0 @@
-#include "geometry_spline.hpp"
-
-void
-GeometrySpline::initDefault(){
-  lX=10;
-  nX=100;
-  nX_max=nmax_Qt;
-  dX=lX/(nX-1);
-  hsoil=new double[nmax_Qt];
-  dhsoil=new double[nmax_Qt];
-  hbot=new double[nmax_Qt];
-  dhbot=new double[nmax_Qt];
-  nZ=new size_t[nmax_Qt];
-  dZ=new double[nmax_Qt];
-  Z=new double*[nmax_Qt];
-  for(size_t i=0;i<nmax_Qt;++i){
-    Z[i]=new double[nmax_Qt];
-  }
-  for(size_t i=0;i<nX;++i){
-    hsoil[i]=0.8;
-    hbot[i]=0.2;
-    dhsoil[i]=0;
-    dhbot[i]=0;
-  }
-  depth=5;
-  nZ_max=100;
-  factor=5/0.6;
-  initZ(depth/nZ_max,false);
-}
-
-void
-GeometrySpline::update(double _lX,size_t _nX,double _depth,size_t _nZ_max,Spline& Ssoil,Spline& Sbot){
-  lX=_lX;
-  depth=_depth;
-  nX=_nX;
-  nZ_max=_nZ_max;
-  dX=lX/(nX-1);
-  double hs_max=-inf,hb_min=inf;
-  double v;
-  for(size_t k=0;k<nX;++k){
-    double x=k*dX/lX;
-    v=hsoil[k]=Ssoil(x);
-    hs_max=max(v,hs_max);
-    dhsoil[k]=Ssoil.derivate(x);
-    v=hbot[k]=Sbot(x);
-    hb_min=min(v,hb_min);
-    dhbot[k]=Sbot.derivate(x);
-  }
-  double dZ_avg=depth/_nZ_max;
-  factor=depth/(hs_max-hb_min);
-  for(size_t k=0;k<nX;++k){
-    hsoil[k]*=factor;
-    hbot[k]*=factor;
-  }
-  initZ(dZ_avg,false);
-}
-
-GeometrySpline::~GeometrySpline(){
-  if(hsoil!=nullptr){
-    delete[] hsoil;
-    delete[] dhsoil;
-    delete[] hbot;
-    delete[] dhbot;
-    delete[] dZ;
-    delete[] nZ;
-    for(size_t i=0;i<nX_max;++i){
-      delete[] Z[i];
-    }
-    delete[] Z;
-  }
-  hsoil=nullptr;
-}

+ 0 - 23
backup/obsolete/geometry_spline.hpp

@@ -1,23 +0,0 @@
-#ifndef GEOMETRY_SPLINE_HPP
-#define GEOMETRY_SPLINE_HPP
-
-#include "geometry.hpp"
-
-class GeometrySpline:public Geometry{
-public:
-  size_t nX_max;
-  double factor;
-  static constexpr size_t const nmax_Qt=400;
-  GeometrySpline();
-  ~GeometrySpline();
-  void initDefault(Geometry* ge);
-  void update(double _lX,size_t _nX,double _depth,size_t _nZ_max,Spline& hbot,Spline& hsoil);
-};
-
-inline
-GeometrySpline::GeometrySpline():Geometry(){
-
-}
-
-
-#endif

+ 0 - 26
backup/obsolete/initial_state_spline.cpp

@@ -1,26 +0,0 @@
-#include "initial_state_spline.hpp"
-
-void
-InitialStateSpline::update(Spline* _Ssat){
-  Ssat=_Ssat;
-  if(hsat!=nullptr){
-    delete[] hsat;
-    for(size_t i=0;i<geometry_spline->nX;++i){
-      delete[] Pinit[i];
-    }
-    delete[] Pinit;
-  }
-  size_t nX=geometry_spline->nX;
-  hsat=new double[nX];
-  Pinit=new double*[nX];
-
-  for(size_t i=0;i<nX;++i){
-    size_t nZ=geometry_spline->nZ[i];
-    Pinit[i]=new double[nZ];
-  }
-  for(size_t i=0;i<geometry_spline->nX;++i){
-    double x=double(i)/(geometry_spline->nX-1);
-    hsat[i]=(*Ssat)(x)*geometry_spline->factor;
-  }
-  updatePressure();
-}

+ 0 - 21
backup/obsolete/initial_state_spline.hpp

@@ -1,21 +0,0 @@
-#ifndef INITIAL_STATE_SPLINE_HPP
-#define INITIAL_STATE_SPLINE_HPP
-
-#include "initial_state.hpp"
-#include "geometry_spline.hpp"
-
-class InitialStateSpline:public InitialState{
-private:
-  Spline* Ssat;
-  GeometrySpline* geometry_spline;
-public:
-  InitialStateSpline(GeometrySpline* geometry);
-  void update(Spline* Ssat);
-};
-
-inline
-InitialStateSpline::InitialStateSpline(GeometrySpline* g):InitialState((Geometry*)g){
-  geometry_spline=g;
-}
-
-#endif

+ 0 - 163
backup/obsolete/input_geometry_curves.cpp

@@ -1,163 +0,0 @@
-#include "input_geometry_curves.hpp"
-
-QtInputGeometryCurves::QtInputGeometryCurves(){
-  margin=10;
-  radius=8;
-  min_d=0.01;
-  initPoints();
-  hbot.setPoints(point,np);
-  hbot.compute();
-  hsoil.setPoints(&point[np],np);
-  hsoil.compute();
-}
-
-void
-QtInputGeometryCurves::initPoints(){
-  for(size_t i=0;i<np;++i){
-    double x=double(i)/(np-1);
-    point[i].x=x;
-    point[i].y=0.7;
-    point[i+np].x=x;
-    point[i+np].y=0.3;
-  }
-}
-
-int
-QtInputGeometryCurves::get_x(float x,int w){
-  return margin+x*w;
-}
-
-int
-QtInputGeometryCurves::get_y(float y,int h){
-  return y*h;
-}
-
-void
-QtInputGeometryCurves::paintEvent(QPaintEvent* event){
-  QPainter painter(this);
-  painter.setRenderHint(QPainter::Antialiasing);
-  int w=width()-2*margin;
-  int h=height();
-  // Hbot
-  painter.setBrush(Qt::SolidPattern);
-  painter.setPen(QColor(102,102,102));
-  drawSpline(hbot,painter);
-  painter.setPen(QColor(154,77,0));
-  drawSpline(hsoil,painter);
-  painter.setPen(Qt::black);
-
-  //Control points
-  for(size_t i=0;i<2*np;++i){
-    Point& P=point[i];
-    painter.drawEllipse(get_x(P.x,w)-radius,get_y(P.y,h)-radius,2*radius,2*radius);
-  }
-}
-
-void
-QtInputGeometryCurves::mousePressEvent(QMouseEvent* event){
-  int mx=event->x();
-  int my=event->y();
-  selected=findPoint(mx,my);
-}
-
-void
-QtInputGeometryCurves::mouseMoveEvent(QMouseEvent* event){
-  if(selected<2*np){
-    int w=width()-2*margin;
-    int h=height();
-    float mx=event->x();
-    float my=event->y();
-    float x=(mx-margin)/w;
-    float y=my/h;
-    moveSelected(x,y);
-    update();
-  }
-}
-
-void
-QtInputGeometryCurves::mouseReleaseEvent(QMouseEvent* event){
-  selected=2*np;
-}
-
-size_t
-QtInputGeometryCurves::findPoint(int x,int y){
-  int w=width()-2*margin;
-  int h=height();
-  for(size_t i=0;i<2*np;++i){
-    Point& P=point[i];
-    int px=get_x(P.x,w);
-    int py=get_y(P.y,h);
-    int dx=x-px;
-    int dy=y-py;
-    int d=dx*dx+dy*dy;
-    if(d<=radius*radius) return i;
-  }
-  return 2*np;
-}
-
-void
-QtInputGeometryCurves::moveSelected(float x,float y){
-  double xp=point[selected].x;
-  double yp=point[selected].y;
-  if(selected!=0 and selected!=np-1){
-    float xmin=point[selected-1].x+min_d;
-    float xmax=point[selected+1].x-min_d;
-    if(xmin<=x and x<=xmax){
-      point[selected].x=x;
-    }
-  }
-  if(0<=y and y<=1){
-    point[selected].y=y;
-  }
-  
-  if(selected<np) hbot.compute();
-  else hsoil.compute();
-  double w=width()-2*margin;
-  bool ok=true;
-  for(int i=1;i<=w;++i){
-    double x=i/w;
-    double ybot=hbot(x);
-    double ysoil=hsoil(x);
-    if(ybot<min_d or ybot>1-min_d or ysoil<min_d or ysoil>1-min_d or ybot<ysoil+min_d){
-      point[selected].x=xp;
-      point[selected].y=yp;
-      if(selected<np) hbot.compute();
-      else hsoil.compute();
-      return;
-    }
-  }
-}
-
-void
-QtInputGeometryCurves::drawSpline(Spline& S,QPainter& painter){
-  double w=width()-2*margin;
-  double h=height();
-  double xp=0;
-  double yp=S(0);
-  for(int i=1;i<=w;i+=2){
-    double x=i/w;
-    double y=S(x);
-    painter.drawLine(margin+xp*w,yp*h,margin+x*w,y*h);
-    xp=x;
-    yp=y;
-  }
-}
-
-void
-QtInputGeometryCurves::save(fstream& file){
-  for(size_t i=0;i<2*np;++i){
-    file.write((char*)&point[i].x,sizeof(double));
-    file.write((char*)&point[i].y,sizeof(double));
-  }
-}
-
-void
-QtInputGeometryCurves::load(fstream& file){
-  for(size_t i=0;i<2*np;++i){
-    file.read((char*)&point[i].x,sizeof(double));
-    file.read((char*)&point[i].y,sizeof(double));
-  }
-  hbot.compute();
-  hsoil.compute();
-  update();
-}

+ 0 - 61
backup/obsolete/input_geometry_curves.hpp

@@ -1,61 +0,0 @@
-#ifndef QT_INPUT_GEOMETRY_CURVES_HPP
-#define QT_INPUT_GEOMETRY_CURVES_HPP
-
-#include <iostream>
-#include <fstream>
-#include <QWidget>
-#include <QMouseEvent>
-#include <QPainter>
-
-#include "math/point.hpp"
-#include "math/spline.hpp"
-
-using namespace std;
-
-static const size_t np = 10;
-
-class QtInputGeometryCurves:public QWidget{
-private:
-  int margin;
-  int radius;
-  float min_d;
-  size_t selected;
-  Point point[2*np];
-  Spline hsoil;
-  Spline hbot;
-  
-  size_t findPoint(int x,int y);
-  int get_x(float x,int w);
-  int get_y(float y,int h);
-  void moveSelected(float x,float y);
-  void drawSpline(Spline& S,QPainter& painter);
-public:
-  QtInputGeometryCurves();
-  ~QtInputGeometryCurves();
-  void save(fstream& file);
-  void load(fstream& file);
-  Spline& getSsoil();
-  Spline& getSbot();
-protected:
-  void initPoints();
-  void paintEvent(QPaintEvent* event);
-  void mousePressEvent(QMouseEvent* event) override;
-  void mouseMoveEvent(QMouseEvent* event) override;
-  void mouseReleaseEvent(QMouseEvent* event) override;
-};
-
-inline
-QtInputGeometryCurves::~QtInputGeometryCurves(){
-}
-
-inline Spline&
-QtInputGeometryCurves::getSsoil(){
-  return hsoil;
-}
-
-inline Spline&
-QtInputGeometryCurves::getSbot(){
-  return hbot;
-}
-
-#endif

+ 0 - 1
backup/obsolete/input_overland.hpp

@@ -1 +0,0 @@
-

+ 0 - 7
backup/obsolete/input_sources.cpp

@@ -1,7 +0,0 @@
-#include "input_sources.hpp"
-
-QtInputSources::QtInputSources(){
-}
-
-QtInputSources::~QtInputSources(){
-}

+ 0 - 18
backup/obsolete/input_sources.hpp

@@ -1,18 +0,0 @@
-#ifndef QT_INPUT_SOURCES
-#define QT_INPUT_SOURCES
-
-#include <iostream>
-#include <fstream>
-
-#include <QWidget>
-
-#include "source.hpp"
-
-class QtInputSources:public QWidget{
-private:
-public:
-  QtInputSources();
-  ~QtInputSources();
-};
-
-#endif

+ 0 - 11
backup/obsolete/spline.hpp

@@ -1,11 +0,0 @@
-#ifndef QSPLINE_HPP
-#define QSPLINE_HPP
-
-#include <GL/glut.h>
-
-class QSpline:public Spline{
-public:
-  void QSpline(float z);
-  void draw_points_GL()
-};
-#endif

+ 0 - 111
backup/obsolete/view.cpp

@@ -1,111 +0,0 @@
-#include "view.hpp"
-
-void
-QtView::initializeGL(){
-  glClearColor(1,1,1,1);
-  glEnable(GL_DEPTH_TEST);
-  glEnable(GL_LIGHT0);
-  glEnable(GL_LIGHTING);
-  glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
-  glEnable(GL_COLOR_MATERIAL);
-}
-
-void
-QtView::resizeGL(int w,int h){
-  glViewport(0,0,w,h);
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
-  gluOrtho2D(0,1,0,1);
-  glMatrixMode(GL_MODELVIEW);
-  glLoadIdentity();
-}
-
-void
-QtView::paintGL(){
-  Geometry& G=data->geometry;
-  glBegin(GL_TRIANGLES);
-  for(size_t i=0;i<G.nX-1;++i){
-    size_t max_left=G.nZ[i];
-    size_t max_right=G.nZ[i+1];
-    size_t left=0;
-    size_t right=0;
-      while(left<max_left-1 and right<max_right-1){
-      if(G.Z[i][left+1]<G.Z[i+1][right+1]){
-        drawTriangle(i,left,i+1,right,i,left+1);
-        ++left;
-      }
-      else{
-        drawTriangle(i,left,i+1,right,i+1,right+1);
-        ++right;
-      }
-    }
-    if(left==max_left-1){
-      while(right<max_right-1){
-        drawTriangle(i,left,i+1,right,i+1,right+1);
-        ++right;
-      }
-    }
-    if(right==max_right-1){
-      while(left<max_left-1){
-        drawTriangle(i,left,i+1,right,i,left+1);
-        ++left;
-      }
-    }
-  }
-  glEnd();
-  drawOverland();
-}
-
-void
-QtView::setColor(size_t ix,size_t iz){
-  double p=getP(ix,iz);
-  double s=Physics::s(p);
-  double r=(1-s);
-  double g=0.7*(1-s);
-  double b=0.8*s+0.4*(1-s);
-  glColor3f(r,g,b);
-}
-
-void
-QtView::drawTriangle(size_t ix1,size_t iz1,size_t ix2,size_t iz2,size_t ix3,size_t iz3){
-  Geometry& G=data->geometry;
-  double factor_inv=1/data->factor;
-  double dX=1/double(G.nX-1);
-  double x1=ix1*dX;
-  double x2=ix2*dX;
-  double x3=ix3*dX;
-  double y1=G.Z[ix1][iz1]*factor_inv;
-  double y2=G.Z[ix2][iz2]*factor_inv;
-  double y3=G.Z[ix3][iz3]*factor_inv;
-  setColor(ix1,iz1);
-  glVertex3f(x1,y1,0);
-  setColor(ix2,iz2);
-  glVertex3f(x2,y2,0);
-  setColor(ix3,iz3);
-  glVertex3f(x3,y3,0);
-}
-
-void
-QtView::drawOverland(){
-  Geometry& G=data->geometry;
-  double dX=1/double(G.nX-1);
-  double factor_inv=1/data->factor;
-  glColor3f(0.5,0.5,1);
-  glBegin(GL_QUADS);
-  for(size_t i=0;i<G.nX-1;++i){
-    glVertex3f(i*dX,G.hsoil[i]*factor_inv,0);
-    glVertex3f(i*dX,data->initial_state->hov[i]*factor_inv,0);
-    glVertex3f(i*dX+dX,data->initial_state->hov[i+1]*factor_inv,0);
-    glVertex3f(i*dX+dX,G.hsoil[i+1]*factor_inv,0);
-  }
-  glEnd();
-/*  glColor3f(0.2,0.2,1);
-
-  glLineWidth(2);
-  glBegin(GL_LINE_STRIP);
-  for(size_t i=0;i<G.nX;++i){
-    glVertex2f(i*dX,data->initial_state.hov[i]*factor_inv);
-  }
-  glEnd();*/
-
-}

+ 0 - 39
backup/obsolete/view.hpp

@@ -1,39 +0,0 @@
-#ifndef QT_VIEW_HPP
-#define QT_VIEW_HPP
-
-#include <iostream>
-
-#include <QWidget>
-#include <QPainter>
-#include <QOpenGLWidget>
-#include <QMouseEvent>
-
-#include <GL/glut.h>
-
-#include "input_data.hpp"
-
-using namespace std;
-
-class QtView:public QOpenGLWidget{
-protected:
-  InputData* data;
-  void drawOverland();
-public:
-  QtView(InputData* data);
-  void setGeometry(Geometry* geometry);
-  void initializeGL();
-  void paintGL();
-  void resizeGL(int x,int h);
-  void drawTriangle(size_t ix1,size_t iz1,size_t ix2,size_t iz2,size_t ix3,size_t iz3);
-  virtual double getP(size_t ix,size_t iz)=0;
-  void setColor(size_t ix,size_t iz);
-
-};
-
-inline
-QtView::QtView(InputData* d):QOpenGLWidget(){
-  data=d;
-}
-
-
-#endif

+ 0 - 489
backup/old/kernel.cpp

@@ -1,489 +0,0 @@
-#include "kernel.hpp"
-
-Kernel::Kernel(string filename){
-  fstream file;
-  file.open(filename.c_str(),fstream::in|fstream::binary);
-  InputData::load(file,true);
-
-  initSolutions();
-
-  Solution& S0=*solution[0];
-
-  //Init pressure
-  for(size_t x=0;x<geometry.nX;++x){
-    for(size_t z=0;z<geometry.nZ[x];++z){
-      S0.P[x][z]=initial_state->Pinit[x][z];
-    }
-  }
-  //Init hydraulic head
-  for(size_t x=0;x<geometry.nX;++x){
-    S0.hydr[x]=initial_state->hsat[x]+Psat/(Physics::rho*Physics::g);
-  }
-
-  //Init overland level
-  for(size_t x=0;x<geometry.nX;++x){
-    S0.hov[x]=Physics::invPsol(geometry.hsoil[x],S0.P[x][geometry.nZ[x]-1]); //TODO[Chrisophe] à initiliser
-  }
-
-  //Init l
-  for(size_t x=0;x<geometry.nX;++x){
-    double t=initial_state->hsat[x];
-    S0.l[x]=t;
-    S0.hsat[x]=t;
-  }
-
-  //Init Pl
-  for(size_t x=0;x<geometry.nX;++x){
-    S0.Pl[x]=Psat;
-  }
-
-
-  indice_x_Richards=new bool[geometry.nX];
-
-  div_w=new double*[geometry.nX];
-  P_temp=new double*[geometry.nX];
-  for(size_t i=0;i<geometry.nX;++i){
-    div_w[i]=new double[geometry.nZ[i]];
-    P_temp[i]=new double[geometry.nZ[i]];
-  }
-  t_sub_A=new double*[geometry.nX];
-  t_sub_B=new double*[geometry.nX];
-  t_sub_C=new double*[geometry.nX];
-  t_diag_A=new double*[geometry.nX];
-  t_diag_B=new double*[geometry.nX];
-  t_diag_C=new double*[geometry.nX];
-  t_sup_A=new double*[geometry.nX];
-  t_sup_B=new double*[geometry.nX];
-  t_sup_C=new double*[geometry.nX];
-  t_F=new double*[geometry.nX];
-  t_G=new double*[geometry.nX];
-  t_S=new double*[geometry.nX];
-  t_H=new double*[geometry.nX];
-  t_R=new double*[geometry.nX];
-  t_I=new double*[geometry.nX];
-  t_BB=new double*[geometry.nX];
-
-  for(size_t i=0;i<geometry.nX;++i){
-    size_t nZ=geometry.nZ[i];
-    t_sub_A[i]=new double[nZ-2];
-    t_sub_B[i]=new double[nZ-2];
-    t_sub_C[i]=new double[nZ-2];
-    t_diag_A[i]=new double[nZ-1];
-    t_diag_B[i]=new double[nZ-1];
-    t_diag_C[i]=new double[nZ-1];
-    t_sup_A[i]=new double[nZ-2];
-    t_sup_B[i]=new double[nZ-2];
-    t_sup_C[i]=new double[nZ-2];
-    t_F[i]=new double[nZ-1];
-    t_G[i]=new double[nZ-1];
-    t_S[i]=new double[nZ-1];
-    t_H[i]=new double[nZ-1];
-    t_R[i]=new double[nZ-1];
-    t_I[i]=new double[nZ-1];
-    t_BB[i]=new double[nZ-1];
-  }
-
-  delete initial_state;
-  initial_state=nullptr;
-
-  file.close();
-  step=0;
-  m=1;
-  scheme_error=0;
-}
-
-void
-Kernel::initSolutions(){
-  Solution* S0=new Solution();
-  S0->init(geometry);
-  solution[0]=S0;
-  for(size_t i=1;i<=Time::nT;++i) solution[i]=nullptr;
-  for(size_t i=0;i<Time::nT+2;++i){
-    Solution* S=new Solution();
-    S->init(geometry);
-    pool_solutions.push(S);
-  }
-}
-
-bool
-Kernel::next(){
-  //cout<<"[Kernel::next]"<<endl;
-  if(m>1) m=m/2;
-  spaceSolution();
-  if(scheme_error>0) return false;
-  ++step;
-  //cout<<"[next] done"<<endl;
-  return true;
-}
-
-void
-Kernel::spaceSolution(){
-  //cout<<"[Kernel::spaceSolution]"<<endl;
-  size_t n=step+1; //We want solution at time n
-  size_t k=0; //we work on time interval [n-1+k/m,n-1+(k+1)/m]
-  Solution *S=solution[step];
-  while(m<=max_time_subdivisions){
-    //cout<<" k,m = "<<k<<','<<m<<endl;
-    S=Piccard(S);
-    if(S==nullptr){
-      m*=2;
-      k=0;
-      S=solution[step];
-    }
-    else{
-      ++k;
-      if(k==m) break;
-    }
-  }
-  if(m>max_time_subdivisions){
-    cerr<<"Max time subdivision reached"<<endl;
-    scheme_error=1;
-  }
-  //cout<<"[spaceSolution] done"<<endl;
-}
-
-Solution*
-Kernel::Piccard(Solution* Sin){
-  //Return a valid solution or nullptr if not converge
-  //cout<<"[Kernel::Piccard]"<<endl;
-  memcpy(Sin.l,Sin.hsat,sizeof(double)*geometry.nX);
-  //Compute Pl with l=hsat of input solution and P=pressure of input_solution
-
-  Solution* Spl=pool_solutions.pop();
-  compute_Pl(*Spl,Sin.hsat,Sin.P);
-  double dt=Time::dT/m; // util ????
-
-  size_t count=0;
-
-  //Specicy to compute Richards on all columns
-  for(size_t i=0;i<geometry.nX;++i) indice_x_Richards[i]=true;
-
-  double error=0;
-  Solution* Snew=allVerticalRichards(Sin,Sin,Spl);
-  if(Snew==nullptr) return false; //allVerti... must compute sol_out.P and sol_out.hsat
-  //cout<<"[Piccard] done"<<endl;
-  //Quitte de facon anticipe
-  return true;
-  compute_l(Snew,error);
-  compute_Pl(Snew,Snew.l,Snew.P);
-  if(!horizontalProblem(Sin,Snew,error)) return false; //Set hydr of Snew voir mettre hydr_in
-  if(!overlandProblem(Sin,Sin,Snew,error)) return false; //Set hov of Snew
-
-  //Comput error
-  double error_prev=error;
-
-  while(error>=tolerence_Piccard and count<max_iterations_Piccard and (abs(error_prev-error)>tolerence_Piccard/100 or error<oscilation_Piccard)){
-    Solution* Sold=Snew;
-    error_prev=error;
-    ++count;
-    error=0;
-    Snew=allVerticalRichards(Sin,Sold,Sold);
-    if(Snew==nullptr) return false;
-    compute_l(Snew,error);
-    compute_Pl(Snew,Snew.l,Snew.P);
-    if(!horizontalProblem(Sold,Snew,error)) return false;
-    if(!overlandProblem(Sin,Sold,Snew,error)) return false;
-  }
-
-  compute_mass(Snew);
-  Snew.nstep_Piccard=count;
-  //cout<<"[Piccard] done"<<endl;
-  if(error>=tolerence_Piccard){
-    return nullptr;
-    //Faire attention à la pile -> rempiler des solutions
-  }
-  return Snew;
-}
-
-
-void
-Kernel::compute_l(Solution& S,double& error) {
-  //Update S.l using S.hsat
-  bool e=0;
-  for(size_t ix=0;ix<geometry.nX;++ix){
-    double a=S.l[ix];
-    double b=max(S.hsat[ix],a);
-    S.l[ix]=b;
-    double t=b-a;
-    e+=t*t;
-  }
-  error+=sqrt(e);
-}
-
-void
-Kernel::compute_Pl(Solution& S,const double* h,double** P){
-  //cout<<"[Kernel::compute_Pl]"<<endl;
-  for(size_t ix=0;ix<geometry.nX;++ix){
-    double* Px=P[ix];
-    if(h[ix]==geometry.hsoil[ix]){
-      S.Pl[ix]=Px[geometry.nZ[ix]-1];
-      //if(S.Pl[ix]!=-2000) cout<<"error "<<ix<<endl;
-    }
-    else{
-      size_t a=(h[ix]-geometry.hbot[ix])/geometry.dZ[ix];
-      double p1=Px[a];
-      double p2=Px[a+1];
-      S.Pl[ix]=p1+(p2-p1)/geometry.dZ[ix]*(h[ix]-geometry.Z[ix][a]);
-      //cout<<ix<<" : "<<S.Pl[ix]<<endl;
-
-    }
-  }
-}
-
-bool
-Kernel::allVerticalRichards(Solution& S_0,Solution& S_s,Solution& S_sp){
-  //cout<<"[Kernel::allVerticalRichards]"<<endl;
-  for(size_t ix=0;ix<geometry.nX;++ix){
-    if(indice_x_Richards[ix]){
-      if(!Richards1dEvolutiveTime(ix,S_0,S_s,S_sp)) return false;
-    }
-  }
-  //cout<<"[Kernel::allVerticalRichards] done"<<endl;
-  return true;
-}
-
-bool
-Kernel::Richards1dEvolutiveTime(size_t ix,const Solution& S_0,const Solution& S_s,Solution& S_sp){
-  //cout<<"[Kernel::Richards1dEvolutiveTime]"<<endl;
-  //cout<<" ix = "<<ix<<endl;
-  //Warning flux_bot and div_w are always zero
-  double flux_bot=bottomFluxRichards(ix,S_s);
-  compute_div_w(ix,S_s);
-  size_t q=1;
-  size_t l=0;
-  bool conv;
-  //cout<<"Time::dT "<<Time::dT<<endl;
-  double dt=Time::dT/m*3600; //in second
-  while(l<q and q<=max_Richards_time_subdivisions){
-    //cout<<" l,q = "<<l<<','<<q<<endl;
-    if(l=0){
-      conv=Richards1d(ix,S_0,S_s,S_sp,dt,flux_bot);
-    }
-    else{
-      conv=Richards1d(ix,S_0,S_sp,S_sp,dt,flux_bot);
-    }
-    if(!conv){
-      q*=2;
-      dt/=2;
-      l=0;
-    }
-    else{
-      ++l;
-    }
-  }
-  //{cout<<"Continue ?"<<endl;char a;cin>>a;}
-
-  if(q>max_Richards_time_subdivisions) return false;
-  return true;
-}
-
-void
-Kernel::compute_mass(Solution& S){
-
-}
-
-bool
-Kernel::horizontalProblem(Solution& S,double& error){
-  //Compute hydr from P, l, Pl, sources, time
-  //return error otherwise
-  return true;
-}
-
-bool
-Kernel::overlandProblem(const Solution& S_in,Solution& S_out,double& error){
-  //Compute hov
-  //return error otherwise
-  return true;
-}
-
-void
-Kernel::saturationInterface(const Solution& S_in,Solution& S_out){
-/*  Solution& S_in=*solution[sol_in];
-  Solution& S_out=*solution[sol_out];
-  for(size_t ix=0;ix<geometry.nX;++ix){
-    double* Px_in=S_in.P[ix];
-    size_t iz=0;
-    for(;iz<geometry.nZ[ix] and Px_in[iz]>Psat;++iz);
-    if(iz>0 and Px_in[iz]<=Psat){
-      S_out.hsat[ix]=(Psat-Px_in[iz-1])*geometry.dZ[ix]/(Px_in[iz]-Px_in[iz-1])+geometry.Z[ix][iz-1];
-    }
-    else{
-      S_out.hsat[ix]=(iz==0)?geometry.hbot[ix]:geometry.hsoil[ix];
-    }
-  }*/
-}
-
-double
-Kernel::bottomFluxRichards(size_t ix,const Solution& S){
-  return 0;
-}
-
-void
-Kernel::compute_div_w(size_t ix,const Solution& S){
-  double* div_w_ix=div_w[ix];
-  for(size_t iz=0;iz<geometry.nZ[ix];++iz){
-    div_w_ix[iz]=0;
-  }
-}
-
-bool
-Kernel::Richards1d(size_t ix,const Solution& S_0,const Solution& S_s,Solution& S_sp,double dt,double flux_bot){
-  //cout<<"[Richards1d]"<<endl;
-  size_t nZ=geometry.nZ[ix];
-  double* P0=S_0.P[ix];
-  double* Ps=S_s.P[ix];
-  double* Psp=S_sp.P[ix];
-  double n_P0=norm2(P0,nZ);
-  if(weightedRichards1d(ix,P0,Ps,Psp,dt,flux_bot,1,n_P0)) return true;
-  return weightedRichards1d(ix,P0,Ps,Psp,dt,flux_bot,0.5,n_P0);
-}
-
-bool
-Kernel::weightedRichards1d(size_t ix,double* P0,double* Ps,double* Psp,double dt,double flux_bot,double r,double n_P0){
-//  cout<<"[weightedRichards1d]"<<endl;
-  //cout<<"r = "<<r<<endl;
-  //cout<<"ix = "<<ix<<endl;
-  size_t nZ=geometry.nZ[ix];
-  double n0=norm2(P0,nZ);
-  double* Pi=Ps;
-  double* Po=P_temp[ix];
-  size_t count=0;
-  double e=+inf;
-  while(e>=tolerence_Richards and count<max_iterations_Richards){
-    ++count;
-    solveSystemRichards(ix,P0,Pi,Po,flux_bot,dt,count);
-    e=error2(Pi,Po,nZ)/n0;
-    //cout<<count<<" : "<<e<<" vs "<<tolerence_Richards<<endl;
-    if(count==1){
-      Pi=Po;
-      Po=Psp;
-    }
-    else{
-      swap(Pi,Po);
-    }
-  }
-  if(e<tolerence_Richards){
-    //cout<<"[converge]"<<endl;
-    memcpy(Psp,Pi,nZ*sizeof(double));
-    return true;
-  }
-  //cout<<"[don't converge]"<<endl;
-  return false;
-}
-
-void
-Kernel::solveSystemRichards(size_t ix,double* P0,double* P,double* Pout,double flux_bot,double dt,size_t count){
-  //TODO treat fpump
-  /*cout<<"[solveSystemRichards]"<<endl;
-  cout<<"P0 = "<<P0<<endl;
-  cout<<"Pin = "<<P<<endl;
-  cout<<"Pout = "<<Pout<<endl;*/
-
-  size_t nZ=geometry.nZ[ix];
-  assert(nZ>=3);
-  double dZ=geometry.dZ[ix];
-
-
-
-  double* sup_A=t_sup_A[ix];
-  double* diag_A=t_diag_A[ix];
-  double* sub_A=t_sub_A[ix];
-  double* sup_B=t_sup_B[ix];
-  double* diag_B=t_diag_B[ix];
-  double* sub_B=t_sub_B[ix];
-  double* sup_C=t_sup_C[ix];
-  double* diag_C=t_diag_C[ix];
-  double* sub_C=t_sub_C[ix];
-  double* F=t_F[ix];
-  double* G=t_G[ix];
-  double* S=t_S[ix];
-  double* H=t_H[ix];
-  double* R=t_R[ix];
-  double* I=t_I[ix];
-  double* BB=t_BB[ix];
-
-  //Compute A
-  diag_A[0]=(Physics::phi*dZ*Physics::ds(P[0]))/(2*dt);
-  for(size_t i=1;i<nZ-1;++i){
-    diag_A[i]=(Physics::phi*dZ*Physics::ds(P[i]))/dt;
-  }
-
-
-  //Compute B
-
-  //TODO : A optimiser boucle par rapport aux appels de Kr
-  double alpha=Physics::k0/(2*Physics::rho*Physics::g*dZ);
-  diag_B[0]=alpha*(Physics::kr(P[0])+Physics::kr(P[1]));
-  sup_B[0]=-diag_B[0];
-  diag_B[nZ-2]=alpha*(Physics::kr(P[nZ-3])+2*Physics::kr(P[nZ-2])+Physics::kr(P[nZ-1]));
-  sub_B[nZ-3]=-alpha*(Physics::kr(P[nZ-3])+Physics::kr(P[nZ-2]));
-  for(size_t i=1;i<nZ-2;++i){
-    diag_B[i]=alpha*(Physics::kr(P[i-1])+2*Physics::kr(P[i])+Physics::kr(P[i+1]));
-    sub_B[i-1]=-alpha*(Physics::kr(P[i-1])+Physics::kr(P[i]));
-    sup_B[i]=-alpha*(Physics::kr(P[i])+Physics::kr(P[i+1]));
-  }
-
-
-  //Compute C
-  double hk=Physics::k0/2;
-  double temp=1/(dZ*Physics::rho*Physics::g);
-  diag_C[0]=-hk*Physics::dkr(P[0])*(temp*(P[1]-P[0])+1);
-  sup_C[0]=-hk*Physics::dkr(P[1])*(temp*(P[1]-P[0])+1);
-  diag_C[nZ-2]=hk*Physics::dkr(P[nZ-3])*temp*(-P[nZ-3]+2*P[nZ-2]-P[nZ-1]);
-  sub_C[nZ-3]=hk*Physics::dkr(P[nZ-3])*(temp*(P[nZ-2]-P[nZ-3])+1);
-  for(size_t i=1;i<nZ-2;++i){
-    diag_C[i]=hk*Physics::dkr(P[i])*temp*(-P[i-1]+2*P[i]-P[i+1]);
-    sub_C[i-1]=hk*Physics::dkr(P[i-1])*(temp*(P[i]-P[i-1])+1);
-    sup_C[i]=-hk*Physics::dkr(P[i+1])*(temp*(P[i+1]-P[i])+1);
-  }
-
-  //Compute G
-  clear(G,nZ-1);
-  G[nZ-2]=-alpha*(Physics::kr(P[nZ-2])+Physics::kr(P[nZ-1]))*P[nZ-1];
-
-  //Compute S
-  S[0]=-hk*(Physics::kr(P[0])+Physics::kr(P[1]));
-  for(size_t i=1;i<nZ-1;++i){
-    S[i]=hk*(Physics::kr(P[i-1])-Physics::kr(P[i+1]));
-  }
-
-  //Compute H
-  clear(H,nZ-1);
-  H[nZ-2]=-hk*Physics::dkr(P[nZ-1])*(temp*(P[nZ-1]-P[nZ-2])+1);
-
-  //Compute R
-  clear(R,nZ-1);
-  R[0]=-flux_bot;
-
-  //Compute I
-  I[0]=(Physics::phi*dZ*(Physics::s(P[0])-Physics::s(P0[0])))/(2*dt);
-  for(size_t i=1;i<nZ-1;++i){
-    I[i]=(Physics::phi*dZ*(Physics::s(P[i])-Physics::s(P0[i])))/dt;
-  }
-
-  //Compute BB
-  clear(BB,nZ-1);
-  //TODO : Add BB computation from fpump
-
-  //Compute F
-  F[0]=div_w[ix][0]*dZ+R[0]-G[0]-I[0]-S[0]-H[0]+(diag_A[0]+diag_C[0])*P[0]+sup_C[0]*P[1];
-  for(size_t i=1;i<nZ-2;++i){
-    F[i]=div_w[ix][i]*dZ+R[i]-G[i]-I[i]-S[i]-H[i]+(diag_A[i]+diag_C[i])*P[i]+sub_C[i-1]*P[i-1]+sup_C[i]*P[i+1];
-  }
-  F[nZ-2]=div_w[ix][nZ-2]*dZ+R[nZ-2]-G[nZ-2]-I[nZ-2]-S[nZ-2]-H[nZ-2]+(diag_A[nZ-2]+diag_C[nZ-2])*P[nZ-2]+sub_C[nZ-3]*P[nZ-3];
-
-// /  if(ix==39)  display("F",F,nZ-1);
-  //TODO Add contribution of BB in F
-
-  for(size_t i=0;i<nZ-2;++i){
-    sub_A[i]=(sub_B[i]+sub_C[i]);
-    diag_A[i]+=(diag_B[i]+diag_C[i]);
-    sup_A[i]=(sup_B[i]+sup_C[i]);
-  }
-  diag_A[nZ-2]+=(diag_B[nZ-2]+diag_C[nZ-2]);
-
-
-
- Thomas(nZ-1,sub_A,diag_A,sup_A,F,Pout);
- Pout[nZ-1]=P[nZ-1];
-}

+ 0 - 94
backup/old/kernel.hpp

@@ -1,94 +0,0 @@
-#ifndef KERNEL_HPP
-#define KERNEL_HPP
-#include <cstdio>
-#include <cstring>
-#include <fstream>
-#include <stack>
-#include "physics.hpp"
-#include "geometry.hpp"
-#include "time.hpp"
-#include "input_data.hpp"
-#include "solution.hpp"
-#include "piccard.hpp"
-
-using namespace std;
-
-class Kernel:public InputData{
-private:
-  static constexpr double tolerence_Piccard=1e-6;
-  static constexpr double oscilation_Piccard=1e-4;
-  static constexpr size_t max_iterations_Piccard=50;
-  static constexpr size_t max_time_subdivisions=32;
-
-  static constexpr size_t max_iterations_Richards=50;
-  static constexpr double tolerence_Richards=1e-10;
-
-  //For which colum we have to compute Richards
-  bool* indice_x_Richards;
-  int scheme_error;
-
-
-
-  void initSolutions();
-
-  void spaceSolution();
-
-  double bottomFluxRichards(size_t ix,const Solution& S_k);
-  Solution* Piccard(Solution* Sin);
-  bool Richards1dEvolutiveTime(size_t ix,const Solution& S_in,const Solution& S_k,Solution& S_kp);
-  bool allVerticalRichards(Solution& S_in,Solution& S_k,Solution& S_kp);
-  void compute_l(Solution& S,double& error);
-  void compute_Pl(Solution& S,const double* h,double** P);
-  void compute_mass(Solution& S);
-  void compute_div_w(size_t ix,const Solution& S);
-  bool horizontalProblem(Solution& S,double& error);
-  bool overlandProblem(const Solution& S_in,Solution& S_out,double& error);
-  void saturationInterface(const Solution& S_in,Solution& S_out);
-  bool Richards1d(size_t ix,const Solution& S_0,const Solution& S_s,Solution& S_sp,double dt,double flux_bot);
-  bool weightedRichards1d(size_t ix,double* P0,double* Ps,double* Psp,double dt,double flux_bot,double r,double n_P0);
-  void solveSystemRichards(size_t ix,double* P0,double* Pin,double* Pout,double flux_bot,double dt,size_t count);
-//  double computeError(const Solution& S_in,const Solution& S_out,size_t sol_temp);
-public:
-  size_t step;
-  //Number of sub time intervals of [step,step+1]
-  size_t m;
-  Solution* solution;
-  double** div_w;
-  double** P_temp;
-
-  double** t_sub_A;
-  double** t_sub_B;
-  double** t_sub_C;
-  double** t_diag_A;
-  double** t_diag_B;
-  double** t_diag_C;
-  double** t_sup_A;
-  double** t_sup_B;
-  double** t_sup_C;
-  double** t_F;
-  double** t_G;
-  double** t_S;
-  double** t_H;
-  double** t_R;
-  double** t_I;
-  double** t_BB;
-  size_t nZ(size_t ix);
-  double Z(size_t ix,size_t iz);
-
-  Kernel(string filename);
-  void init(fstream& file);
-  bool next();
-
-};
-
-inline size_t
-Kernel::nZ(size_t ix){
-  return geometry.nZ[ix];
-}
-
-inline double
-Kernel::Z(size_t ix,size_t iz){
-  return geometry.Z[ix][iz];
-}
-
-#endif

+ 0 - 5
src/kernel/geometry.cpp

@@ -224,9 +224,4 @@ void Geometry::compute_basins(){
   }
   runoff_directions[0]=Right;
   runoff_directions[nX-1]=Left;
-  cout<<"Runoff "<<endl;
-  for(size_t ix=1;ix<nX-1;++ix){
-    cout<<ix<<" : "<<runoff_directions[ix]<<endl;
-  }
-  Debug::pause();
 }

+ 0 - 1
src/kernel/overland.cpp

@@ -145,6 +145,5 @@ namespace Kernel{
     for(size_t ix=0;ix<geometry->nX;++ix){
       vol_tot_new+=max(hov[ix]-geometry->hsoil[ix],0.0);
     }
-    cout<<vol_tot-vol_tot_new<<endl;
   }
 }