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