kernel.hpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_iterations_Richards=50;
  21. static constexpr double tolerence_Richards=1e-10;
  22. //For which colum we have to compute Richards
  23. bool* indice_x_Richards;
  24. int scheme_error;
  25. void initSolutions();
  26. void spaceSolution();
  27. double bottomFluxRichards(size_t ix,const Solution& S_k);
  28. Solution* Piccard(Solution* Sin);
  29. bool Richards1dEvolutiveTime(size_t ix,const Solution& S_in,const Solution& S_k,Solution& S_kp);
  30. bool allVerticalRichards(Solution& S_in,Solution& S_k,Solution& S_kp);
  31. void compute_l(Solution& S,double& error);
  32. void compute_Pl(Solution& S,const double* h,double** P);
  33. void compute_mass(Solution& S);
  34. void compute_div_w(size_t ix,const Solution& S);
  35. bool horizontalProblem(Solution& S,double& error);
  36. bool overlandProblem(const Solution& S_in,Solution& S_out,double& error);
  37. void saturationInterface(const Solution& S_in,Solution& S_out);
  38. bool Richards1d(size_t ix,const Solution& S_0,const Solution& S_s,Solution& S_sp,double dt,double flux_bot);
  39. bool weightedRichards1d(size_t ix,double* P0,double* Ps,double* Psp,double dt,double flux_bot,double r,double n_P0);
  40. void solveSystemRichards(size_t ix,double* P0,double* Pin,double* Pout,double flux_bot,double dt,size_t count);
  41. // double computeError(const Solution& S_in,const Solution& S_out,size_t sol_temp);
  42. public:
  43. size_t step;
  44. //Number of sub time intervals of [step,step+1]
  45. size_t m;
  46. Solution* solution;
  47. double** div_w;
  48. double** P_temp;
  49. double** t_sub_A;
  50. double** t_sub_B;
  51. double** t_sub_C;
  52. double** t_diag_A;
  53. double** t_diag_B;
  54. double** t_diag_C;
  55. double** t_sup_A;
  56. double** t_sup_B;
  57. double** t_sup_C;
  58. double** t_F;
  59. double** t_G;
  60. double** t_S;
  61. double** t_H;
  62. double** t_R;
  63. double** t_I;
  64. double** t_BB;
  65. size_t nZ(size_t ix);
  66. double Z(size_t ix,size_t iz);
  67. Kernel(string filename);
  68. void init(fstream& file);
  69. bool next();
  70. };
  71. inline size_t
  72. Kernel::nZ(size_t ix){
  73. return geometry.nZ[ix];
  74. }
  75. inline double
  76. Kernel::Z(size_t ix,size_t iz){
  77. return geometry.Z[ix][iz];
  78. }
  79. #endif