fork download
  1. #include <vector>
  2. #include <cmath>
  3. #include <iostream>
  4.  
  5.  
  6.  
  7. class FloodIsolation {
  8. public:
  9. FloodIsolation() :
  10. numberOfCells(20000),
  11. data(numberOfCells)
  12. {
  13. }
  14. ~FloodIsolation(){
  15. }
  16.  
  17. void isUpdateNeeded() {
  18. for (int i = 0; i < numberOfCells; ++i) {
  19. data[i].h = data[i].h + 1;
  20. data[i].floodedCells = !data[i].floodedCells;
  21. data[i].floodedCellsTimeInterval = !data[i].floodedCellsTimeInterval;
  22. data[i].qInflow = data[i].qInflow + 1;
  23. data[i].qStartTime = data[i].qStartTime + 1;
  24. data[i].qEndTime = data[i].qEndTime + 1;
  25. data[i].lowerFloorCells = data[i].lowerFloorCells + 1;
  26. data[i].cellLocationX = data[i].cellLocationX + 1;
  27. data[i].cellLocationY = data[i].cellLocationY + 1;
  28. data[i].cellLocationZ = data[i].cellLocationZ + 1;
  29. data[i].levelOfCell = data[i].levelOfCell + 1;
  30. data[i].valueOfCellIds = data[i].valueOfCellIds + 1;
  31. data[i].h0 = data[i].h0 + 1;
  32. data[i].vU = data[i].vU + 1;
  33. data[i].vV = data[i].vV + 1;
  34. data[i].vUh = data[i].vUh + 1;
  35. data[i].vVh = data[i].vVh + 1;
  36. data[i].vUh0 = data[i].vUh0 + 1;
  37. data[i].vVh0 = data[i].vVh0 + 1;
  38. data[i].ghh = data[i].ghh + 1;
  39. data[i].sfx = data[i].sfx + 1;
  40. data[i].sfy = data[i].sfy + 1;
  41. data[i].qIn = data[i].qIn + 1;
  42.  
  43.  
  44. for(int j = 0; j < nEdges; ++j) {
  45. data[i].flagInterface[j] = !data[i].flagInterface[j];
  46. data[i].typeInterface[j] = data[i].typeInterface[j] + 1;
  47. data[i].neighborIds[j] = data[i].neighborIds[j] + 1;
  48. }
  49. }
  50.  
  51. }
  52.  
  53. private:
  54.  
  55. const int numberOfCells;
  56. static const int nEdges = 6;
  57. struct data_t {
  58. double valueOfCellIds = 0;
  59. double h = 0;
  60.  
  61. double h0 = 0;
  62. double vU = 0;
  63. double vV = 0;
  64. double vUh = 0;
  65. double vVh = 0;
  66. double vUh0 = 0;
  67. double vVh0 = 0;
  68. double ghh = 0;
  69. double sfx = 0;
  70. double sfy = 0;
  71. double qInflow = 0;
  72. double qStartTime = 0;
  73. double qEndTime = 0;
  74. double qIn = 0;
  75. double nx = 0;
  76. double ny = 0;
  77. double floorLevels = 0;
  78. double cellLocationX = 0;
  79. double cellLocationY = 0;
  80. double cellLocationZ = 0;
  81. int lowerFloorCells = 0;
  82. int levelOfCell = 0;
  83. int typeInterface[nEdges] = {};
  84. int neighborIds[nEdges] = {};
  85. bool flagInterface[nEdges] = {};
  86. bool floorCompleteleyFilled = 0;
  87. bool floodedCells = 0;
  88. bool floodedCellsTimeInterval = 0;
  89. };
  90. std::vector<data_t> data;
  91.  
  92. };
  93.  
  94. int main() {
  95. std::ios_base::sync_with_stdio(false);
  96. FloodIsolation isolation;
  97. clock_t start = clock();
  98. for (int i = 0; i < 400; ++i) {
  99. if(i % 100 == 0) {
  100. std::cout << i << "\n";
  101. }
  102. isolation.isUpdateNeeded();
  103. }
  104. clock_t stop = clock();
  105. std::cout << "Time: " << difftime(stop, start) / 1000 << "\n";
  106. }
  107.  
Success #stdin #stdout 1s 3232KB
stdin
Standard input is empty
stdout
0
100
200
300
Time: 997.754