kernel.hpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #ifndef KERNEL_HPP
  2. #define KERNEL_HPP
  3. #include <cstdio>
  4. #include <cstring>
  5. #include <fstream>
  6. #include <stack>
  7. #include "physics.hpp"
  8. #include "geometry.hpp"
  9. #include "time.hpp"
  10. #include "input_data.hpp"
  11. #include "solution.hpp"
  12. #include "piccard.hpp"
  13. using namespace std;
  14. class Kernel:public InputData{
  15. private:
  16. static constexpr double tolerence_Piccard=1e-6;
  17. static constexpr double oscilation_Piccard=1e-4;
  18. static constexpr size_t max_iterations_Piccard=50;
  19. static constexpr size_t max_time_subdivisions=32;
  20. static constexpr size_t max_Richards_time_subdivisions=256;
  21. static constexpr size_t max_iterations_Richards=50;
  22. static constexpr double tolerence_Richards=1e-10;
  23. //For which colum we have to compute Richards
  24. bool* indice_x_Richards;
  25. int scheme_error;
  26. void initSolutions();
  27. void spaceSolution();
  28. /*double bottomFluxRichards(size_t ix,const Solution& S_k);
  29. Solution* Piccard(Solution* Sin);
  30. bool Richards1dEvolutiveTime(size_t ix,const Solution& S_in,const Solution& S_k,Solution& S_kp);
  31. bool allVerticalRichards(Solution& S_in,Solution& S_k,Solution& S_kp);
  32. void compute_l(Solution& S,double& error);
  33. void compute_Pl(Solution& S,const double* h,double** P);
  34. void compute_mass(Solution& S);
  35. void compute_div_w(size_t ix,const Solution& S);
  36. bool horizontalProblem(Solution& S,double& error);
  37. bool overlandProblem(const Solution& S_in,Solution& S_out,double& error);
  38. void saturationInterface(const Solution& S_in,Solution& S_out);
  39. bool Richards1d(size_t ix,const Solution& S_0,const Solution& S_s,Solution& S_sp,double dt,double flux_bot);
  40. bool weightedRichards1d(size_t ix,double* P0,double* Ps,double* Psp,double dt,double flux_bot,double r,double n_P0);
  41. void solveSystemRichards(size_t ix,double* P0,double* Pin,double* Pout,double flux_bot,double dt,size_t count);*/
  42. // double computeError(const Solution& S_in,const Solution& S_out,size_t sol_temp);
  43. public:
  44. size_t step;
  45. //Number of sub time intervals of [step,step+1]
  46. size_t m;
  47. stack<Solution*> pool_solutions;
  48. Solution** solution;
  49. /* double** div_w;
  50. double** P_temp;
  51. double** t_sub_A;
  52. double** t_sub_B;
  53. double** t_sub_C;
  54. double** t_diag_A;
  55. double** t_diag_B;
  56. double** t_diag_C;
  57. double** t_sup_A;
  58. double** t_sup_B;
  59. double** t_sup_C;
  60. double** t_F;
  61. double** t_G;
  62. double** t_S;
  63. double** t_H;
  64. double** t_R;
  65. double** t_I;
  66. double** t_BB;*/
  67. //size_t nZ(size_t ix);
  68. //double Z(size_t ix,size_t iz);
  69. Kernel(string filename);
  70. void init(fstream& file);
  71. bool next();
  72. };
  73. inline size_t
  74. Kernel::nZ(size_t ix){
  75. return geometry.nZ[ix];
  76. }
  77. inline double
  78. Kernel::Z(size_t ix,size_t iz){
  79. return geometry.Z[ix][iz];
  80. }
  81. #endif