Skip to content

Commit c7b2ece

Browse files
committed
add slope smoothness indicator
1 parent 34f8176 commit c7b2ece

File tree

2 files changed

+291
-173
lines changed

2 files changed

+291
-173
lines changed

src/libcadet/DGSubcellLimiterFV.hpp

Lines changed: 77 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ namespace cadet
4242
Superbee = 2, //!< Superbee slope limiter
4343
vanLeer = 3, //!< van Leer slope limiter
4444
vanAlbada = 4, //!< van Alaba slope limiter
45+
//Koren = 5, //!< Koren slope limiter // todo: can we use a 3rd order approximation, i.e. can we accomodate the MUSCL scheme/k-interpolation(vanLeer) into our setting?
4546
RelaxedVanAlbada = 6, //!< relaxed van Alaba slope limiter
47+
//MonotonizedCentral = 7, //!< Monotonized central slope limiter // interface change required to compute central slope
4648
NoLimiterForward = -1, //!< unlimited forward FD reconstruction
4749
NoLimiterBackward = -2, //!< unlimited backward FD reconstruction
4850
};
@@ -215,6 +217,56 @@ namespace cadet
215217
const double eps = 1e-6; // constant chosen according to https://doi.org/10.2514/3.9465
216218
};
217219

220+
///**
221+
//* @brief Monotonized central slope limiter for reconstruction
222+
//* @todo change interface to compute central slope?
223+
//*/
224+
//class MonotonizedCentral : public SlopeLimiterFV {
225+
226+
//public:
227+
// MonotonizedCentral() {}
228+
229+
// double minmod3(double fwdSlope, double cSlope, double bwdSlope) {
230+
// if (std::signbit(fwdSlope) == std::signbit(cSlope) && std::signbit(fwdSlope) == std::signbit(bwdSlope))
231+
// return std::copysign(std::max(std::abs(fwdSlope), std::abs(cSlope), std::abs(bwdSlope)), fwdSlope);
232+
// else
233+
// return 0.0;
234+
// }
235+
// active minmod3(active fwdSlope, active cSlope, active bwdSlope) {
236+
237+
// if (std::signbit(static_cast<double>(fwdSlope)) == std::signbit(static_cast<double>(cSlope)) && std::signbit(static_cast<double>(fwdSlope)) == std::signbit(static_cast<double>(bwdSlope)))
238+
// {
239+
// if (abs(static_cast<double>(fwdSlope)) < abs(static_cast<double>(bwdSlope)))
240+
// {
241+
// if (abs(static_cast<double>(fwdSlope)) < abs(static_cast<double>(cSlope)))
242+
// {
243+
// return fwdSlope;
244+
// }
245+
// else return cSlope;
246+
// }
247+
// else
248+
// {
249+
// if (abs(static_cast<double>(bwdSlope)) < abs(static_cast<double>(cSlope)))
250+
// {
251+
// return bwdSlope;
252+
// }
253+
// else return cSlope;
254+
// }
255+
// }
256+
// else
257+
// return active(0.0);
258+
// }
259+
260+
// double call(double fwdSlope, double bwdSlope) override {
261+
// return minmod3(2.0 * fwdSlope, cSlope, 2.0 * bwdSlope);
262+
// }
263+
// active call(active fwdSlope, active bwdSlope) override {
264+
// return minmod3(2.0 * fwdSlope, cSlope, 2.0 * bwdSlope);
265+
// }
266+
267+
// SlopeLimiterID getID() override { return SlopeLimiterID::MonotonizedCentral; }
268+
//};
269+
218270
/**
219271
* @brief Implements unlimited forward slope for reconstruction
220272
*/
@@ -247,6 +299,24 @@ namespace cadet
247299
SlopeLimiterID getID() override { return SlopeLimiterID::NoLimiterBackward; }
248300
};
249301

302+
///**
303+
// * @brief Implements unlimited central slope reconstruction
304+
// */
305+
//class NoLimiterCentral : public SlopeLimiterFV {
306+
307+
//public:
308+
// NoLimiterCentral() {}
309+
// double call(double fwdSlope, double bwdSlope) override {
310+
// return fwdSlope;
311+
// }
312+
// active call(active fwdSlope, active bwdSlope) override {
313+
// return fwdSlope;
314+
// }
315+
// SlopeLimiterID getID() override { return SlopeLimiterID::NoLimiterCentral; }
316+
//};
317+
318+
// todo, note: if more slope limiters are added, note that they have to be symmetrical in the current implementation (i.e. in reconstruction function reconstructedUpwindValue)
319+
250320
/**
251321
* @brief Implements the subcell FV limiting scheme for convection
252322
* @details //@TODO.
@@ -335,13 +405,14 @@ namespace cadet
335405

336406
void notifyDiscontinuousSectionTransition(int direction) {
337407

338-
// Forward FD slope reconstruction depends on flow direction // todo: Koren limiter which is also non-symmetrical
339-
if (_slope_limiter->getID() == SlopeLimiterFV::SlopeLimiterID::NoLimiterForward && direction == -1)
340-
_slope_limiter = std::make_unique<NoLimiterBackward>();
341-
342-
else if (_slope_limiter->getID() == SlopeLimiterFV::SlopeLimiterID::NoLimiterBackward && direction == 1)
343-
_slope_limiter = std::make_unique<NoLimiterForward>();
408+
if (_slope_limiter) { // only when subcell limiter is initialized, i.e. used
409+
// Forward FD slope reconstruction depends on flow direction // todo: Koren limiter which is also non-symmetrical
410+
if (_slope_limiter->getID() == SlopeLimiterFV::SlopeLimiterID::NoLimiterForward && direction == -1)
411+
_slope_limiter = std::make_unique<NoLimiterBackward>();
344412

413+
else if (_slope_limiter->getID() == SlopeLimiterFV::SlopeLimiterID::NoLimiterBackward && direction == 1)
414+
_slope_limiter = std::make_unique<NoLimiterForward>();
415+
}
345416
}
346417

347418
/**

0 commit comments

Comments
 (0)