Skip to content

Commit f36a442

Browse files
committed
use blending threshold in both directions
1 parent b716c91 commit f36a442

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/libcadet/model/parts/ConvectionDispersionOperatorDG.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ bool AxialConvectionDispersionOperatorBaseDG::configureModelDiscretization(IPara
115115

116116
paramProvider.pushScope("discretization");
117117
_OSmode = 0;
118-
_maxBlending = 0.0;
118+
_maxBlending = 1.0;
119119
_blendingThreshold = 0.0;
120120
_troubledCells = nullptr;
121121

@@ -128,7 +128,10 @@ bool AxialConvectionDispersionOperatorBaseDG::configureModelDiscretization(IPara
128128

129129
const bool write_smoothness_indicator = paramProvider.exists("RETURN_SMOOTHNESS_INDICATOR") ? static_cast<bool>(paramProvider.getInt("RETURN_SMOOTHNESS_INDICATOR")) : false;
130130
if (write_smoothness_indicator)
131+
{
131132
_troubledCells = new double[nCells * nComp];
133+
std::fill(_troubledCells, _troubledCells + nCells * nComp, 0.0);
134+
}
132135

133136
std::string smoothness_indicator = paramProvider.exists("SMOOTHNESS_INDICATOR") ? paramProvider.getString("SMOOTHNESS_INDICATOR") : "MODAL_ENERGY_LEGENDRE";
134137

@@ -501,7 +504,9 @@ int AxialConvectionDispersionOperatorBaseDG::residualImpl(const IModel& model, d
501504
_troubledCells[comp + cell * _nComp] = std::min(_maxBlending, _smoothnessIndicator->calcSmoothness(y + offsetC() + comp + cell * _strideCell, _strideNode, _nComp, cell));
502505
if (_troubledCells[comp + cell * _nComp] < _blendingThreshold)
503506
_troubledCells[comp + cell * _nComp] = 0.0;
504-
else if (_smoothnessIndicator->timeRelaxation()) // note: 0.0 <-> no relaxation
507+
else if (1.0 - _troubledCells[comp + cell * _nComp] < _blendingThreshold)
508+
_troubledCells[comp + cell * _nComp] = 1.0;
509+
else if (_smoothnessIndicator->timeRelaxation()) // note: 0.0 <-> no time relaxation
505510
_troubledCells[comp + cell * _nComp] = std::max(_smoothnessIndicator->timeRelaxation() * oldIndicator, _troubledCells[comp + cell * _nComp]);
506511
}
507512
//if (_OSmode == 1) // WENO
@@ -559,14 +564,19 @@ int AxialConvectionDispersionOperatorBaseDG::residualImpl(const IModel& model, d
559564
// ========================================//
560565

561566
// Calculate the substitute h(g(c), c) and apply inverse mapping jacobian (reference space)
562-
if (DGblending < 1.0)
567+
if (_OSmode != 0)
563568
{
564-
for (int cell = 0; cell < _nCells; cell++)
565-
_h.segment(cell * _nNodes, _nNodes) = 2.0 / static_cast<ParamType>(_deltaZ) * (-u * _C.segment(cell * _nNodes, _nNodes) * (1.0 - _troubledCells[comp + cell * _nComp])).template cast<ResidualType>();
566-
_h += (2.0 / static_cast<ParamType>(_deltaZ) * d_ax * (-2.0 / static_cast<ParamType>(_deltaZ)) * _g).template cast<ResidualType>();
569+
if (DGblending < 1.0)
570+
{
571+
for (int cell = 0; cell < _nCells; cell++)
572+
_h.segment(cell * _nNodes, _nNodes) = 2.0 / static_cast<ParamType>(_deltaZ) * (-u * _C.segment(cell * _nNodes, _nNodes) * (1.0 - _troubledCells[comp + cell * _nComp])).template cast<ResidualType>();
573+
_h += (2.0 / static_cast<ParamType>(_deltaZ) * d_ax * (-2.0 / static_cast<ParamType>(_deltaZ)) * _g).template cast<ResidualType>();
574+
}
575+
else
576+
_h = 2.0 / static_cast<ParamType>(_deltaZ) * (-u * _C * DGblending + d_ax * (-2.0 / static_cast<ParamType>(_deltaZ)) * _g).template cast<ResidualType>();
567577
}
568578
else
569-
_h = 2.0 / static_cast<ParamType>(_deltaZ) * (-u * _C * DGblending + d_ax * (-2.0 / static_cast<ParamType>(_deltaZ)) * _g).template cast<ResidualType>();
579+
_h = 2.0 / static_cast<ParamType>(_deltaZ) * (-u * _C + d_ax * (-2.0 / static_cast<ParamType>(_deltaZ)) * _g).template cast<ResidualType>();
570580

571581
// DG volume integral in strong form
572582
volumeIntegral<ResidualType, ResidualType>(_h, _resC);

src/libcadet/model/parts/ConvectionDispersionOperatorDG.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ namespace cadet
192192
// non-linear oscillation prevention mechanism
193193
int _OSmode; //!< oscillation suppression mode; 0 : none, 1 : WENO, 2 : Subcell limiting
194194
double _maxBlending; //!< maximal blending coefficient of oscillation suppression mechanism
195-
double _blendingThreshold; //!< Threshold to clip-off blending coefficient
195+
double _blendingThreshold; //!< Threshold to clip-off blending coefficient (in both directions)
196196
WenoDG _weno; //!< WENO operator
197197
DGSubcellLimiterFV _subcellLimiter; //!< FV subcell limiting operator
198198
std::unique_ptr<SmoothnessIndicator> _smoothnessIndicator; //!< smoothness/troubled-element indicator

0 commit comments

Comments
 (0)