Skip to content

Commit c89f70f

Browse files
committed
fix the compute_spd_factor for case alpha is exactly one, and simplify implementation.
1 parent 3509020 commit c89f70f

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

include/aspect/utilities.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ namespace aspect
989989
double compute_spd_factor(const double eta,
990990
const SymmetricTensor<2,dim> &strain_rate,
991991
const SymmetricTensor<2,dim> &dviscosities_dstrain_rate,
992-
const double safety_factor);
992+
const double SPD_safety_factor);
993993

994994
/**
995995
* Converts an array of size dim to a Point of size dim.

source/utilities.cc

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,7 +2406,7 @@ namespace aspect
24062406
double compute_spd_factor(const double eta,
24072407
const SymmetricTensor<2,dim> &strain_rate,
24082408
const SymmetricTensor<2,dim> &dviscosities_dstrain_rate,
2409-
const double safety_factor)
2409+
const double SPD_safety_factor)
24102410
{
24112411
// if the strain rate is zero, or the derivative is zero, then
24122412
// the exact choice of alpha factor does not matter because the
@@ -2420,16 +2420,12 @@ namespace aspect
24202420
const double one_minus_part = 1 - (contract_a_b / norm_a_b);
24212421
const double denom = one_minus_part * one_minus_part * norm_a_b;
24222422

2423-
if (denom == 0)
2423+
// the case denom == 0 (smallest eigenvalue is zero), should return one,
2424+
// and it does here, because C_safety * 2.0 * eta is always larger then zero.
2425+
if (denom <= SPD_safety_factor * 2.0 * eta)
24242426
return 1.0;
24252427
else
2426-
{
2427-
const double alpha = (2.0*eta)/denom;
2428-
if (alpha >= 1.0)
2429-
return 1.0;
2430-
else
2431-
return std::max(0.0,safety_factor*alpha);
2432-
}
2428+
return std::max(0.0, SPD_safety_factor * ((2.0 * eta) / denom));
24332429
}
24342430

24352431

0 commit comments

Comments
 (0)