From 36938ee12c8a90212b3aef841ca290093fdd854c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Schm=C3=B6lder?= Date: Tue, 17 Aug 2021 09:39:11 +0200 Subject: [PATCH] included review --- .../model/parts/ConvectionDispersionOperator.cpp | 16 ++++++++++------ .../model/parts/ConvectionDispersionOperator.hpp | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/libcadet/model/parts/ConvectionDispersionOperator.cpp b/src/libcadet/model/parts/ConvectionDispersionOperator.cpp index e5d62509a..fcd11158c 100644 --- a/src/libcadet/model/parts/ConvectionDispersionOperator.cpp +++ b/src/libcadet/model/parts/ConvectionDispersionOperator.cpp @@ -187,20 +187,24 @@ bool ConvectionDispersionOperatorBase::configure(UnitOpIdx unitOpIdx, IParameter bool ConvectionDispersionOperatorBase::notifyDiscontinuousSectionTransition(double t, unsigned int secIdx) { // If we don't have cross section area, velocity is given by parameter - double _dir_old = _dir; + double dir_old = _dir; if (_crossSection <= 0.0) - _dir = static_cast(getSectionDependentScalar(_velocity, secIdx)); + { + double dir_new = static_cast(getSectionDependentScalar(_velocity, secIdx)); + _dir = (dir_new >= 0); + } else if (!_velocity.empty()) { // We have both cross section area and interstitial flow rate // _curVelocity has already been set to the network flow rate in setFlowRates() // the direction of the flow (i.e., sign of _curVelocity) is given by _velocity - _dir = static_cast(getSectionDependentScalar(_velocity, secIdx)); - if (_dir_old * static_cast(_dir) < 0.0) - _curVelocity *= -1.0; + double dir_new = static_cast(getSectionDependentScalar(_velocity, secIdx)); + _dir = (dir_new >= 0); } + if (dir_old * _dir < 0.0) + _curVelocity *= -1.0; - return (_dir_old * static_cast(_dir) < 0.0); + return (dir_old * _dir < 0.0); } /** diff --git a/src/libcadet/model/parts/ConvectionDispersionOperator.hpp b/src/libcadet/model/parts/ConvectionDispersionOperator.hpp index c46715cf1..5970f7292 100644 --- a/src/libcadet/model/parts/ConvectionDispersionOperator.hpp +++ b/src/libcadet/model/parts/ConvectionDispersionOperator.hpp @@ -121,7 +121,7 @@ class ConvectionDispersionOperatorBase std::vector _colDispersion; //!< Column dispersion (may be section dependent) \f$ D_{\text{ax}} \f$ std::vector _velocity; //!< Interstitial velocity (may be section dependent) \f$ u \f$ active _curVelocity; //!< Current interstitial velocity \f$ u \f$ in this time section - double _dir; //!< Current flow direction in this time section + int _dir; //!< Current flow direction in this time section ArrayPool _stencilMemory; //!< Provides memory for the stencil double* _wenoDerivatives; //!< Holds derivatives of the WENO scheme