fix(velocities): prevent redundant velocity calculations

This commit is contained in:
Max Lübke 2025-02-06 16:18:04 +01:00
parent d8c8a734aa
commit 16b361c85b
3 changed files with 16 additions and 12 deletions

View File

@ -119,13 +119,17 @@ public:
void run() { void run() {
this->setDomain(velocities.domainX(), velocities.domainY()); this->setDomain(velocities.domainX(), velocities.domainY());
velocities.run(); if constexpr (hyd_mode == HYDRAULIC_MODE::STEADY_STATE) {
if (!velocities.isSteady()) {
velocities.run();
}
}
for (int i = 0; i < this->getIterations(); i++) { for (int i = 0; i < this->getIterations(); i++) {
if constexpr (hyd_mode == HYDRAULIC_MODE::TRANSIENT) { if constexpr (hyd_mode == HYDRAULIC_MODE::TRANSIENT) {
velocities.run(); velocities.run();
} }
adv(); startAdvection();
} }
} }
@ -133,7 +137,7 @@ private:
/** /**
* @brief function calculating material transport for one timestep * @brief function calculating material transport for one timestep
*/ */
void adv() { void startAdvection() {
const std::size_t rows = this->rows(); const std::size_t rows = this->rows();
const std::size_t cols = this->cols(); const std::size_t cols = this->cols();
const T volume = this->deltaCol() * this->deltaRow(); const T volume = this->deltaCol() * this->deltaRow();

View File

@ -43,6 +43,7 @@ private:
T timestep{-1}; T timestep{-1};
T epsilon{1E-5}; T epsilon{1E-5};
int numThreads{omp_get_num_procs()}; int numThreads{omp_get_num_procs()};
bool steady{false};
RowMajMat<T> velocitiesX; RowMajMat<T> velocitiesX;
RowMajMat<T> velocitiesY; RowMajMat<T> velocitiesY;
@ -118,6 +119,8 @@ public:
this->permKY = alphaY; this->permKY = alphaY;
} }
bool isSteady() const { return steady; }
/** /**
* @brief Set the timestep per iteration * @brief Set the timestep per iteration
* *
@ -219,6 +222,9 @@ public:
oldConcentrations = this->getConcentrationMatrix(); oldConcentrations = this->getConcentrationMatrix();
(void)calculate_hydraulic_flow(input); (void)calculate_hydraulic_flow(input);
} while (!checkConvergance(oldConcentrations)); } while (!checkConvergance(oldConcentrations));
steady = true;
} else { } else {
if (timestep == -1) { if (timestep == -1) {
throw_invalid_argument("Timestep is not set"); throw_invalid_argument("Timestep is not set");

View File

@ -20,9 +20,7 @@ VELOCITIES_TEST(SteadyStateCenter) {
tug::RowMajMat<double> hydHeads = tug::RowMajMat<double> hydHeads =
tug::RowMajMat<double>::Constant(rows, cols, 1); tug::RowMajMat<double>::Constant(rows, cols, 1);
tug::RowMajMat<double> permKX = tug::RowMajMat<double> permK =
tug::RowMajMat<double>::Constant(rows, cols, K);
tug::RowMajMat<double> permKY =
tug::RowMajMat<double>::Constant(rows, cols, K); tug::RowMajMat<double>::Constant(rows, cols, K);
tug::Velocities<double, tug::HYDRAULIC_MODE::STEADY_STATE, tug::Velocities<double, tug::HYDRAULIC_MODE::STEADY_STATE,
@ -30,14 +28,10 @@ VELOCITIES_TEST(SteadyStateCenter) {
velo(hydHeads); velo(hydHeads);
velo.setDomain(100, 100); velo.setDomain(100, 100);
velo.setPermKX(permKX); velo.setPermKX(permK);
velo.setPermKY(permKY); velo.setPermKY(permK);
tug::Boundary<double> &bcH = velo.getBoundaryConditions(); tug::Boundary<double> &bcH = velo.getBoundaryConditions();
bcH.setBoundarySideConstant(tug::BC_SIDE_LEFT, 1);
bcH.setBoundarySideConstant(tug::BC_SIDE_RIGHT, 1);
bcH.setBoundarySideConstant(tug::BC_SIDE_TOP, 1);
bcH.setBoundarySideConstant(tug::BC_SIDE_BOTTOM, 1);
bcH.setInnerBoundary(center_row, center_col, 10); bcH.setInnerBoundary(center_row, center_col, 10);