Skip to content

Commit f703e91

Browse files
committed
bugfix: capillary number search must terminate if no longer changing
1 parent 652a22b commit f703e91

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

models/ColorModel.cpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -819,17 +819,26 @@ double ScaLBL_ColorModel::Run(int returntime) {
819819

820820
if (isSteady && (Ca > maxCa || Ca < minCa) &&
821821
SET_CAPILLARY_NUMBER) {
822-
/* re-run the point if the actual Ca is too far from the target Ca */
823-
isSteady = false;
824-
RESCALE_FORCE = true;
825-
t1 = std::chrono::system_clock::now();
826-
CURRENT_TIMESTEP = 0;
827-
timestep = INITIAL_TIMESTEP;
828-
TRIGGER_FORCE_RESCALE = true;
829-
if (rank == 0)
830-
printf(" Capillary number missed target value = %0.3e "
831-
"(measured value was Ca = %0.3e)\n",
832-
capillary_number, Ca);
822+
if ((fabs(Ca - Ca_bracket_previous) / Ca) < 0.01) {
823+
// Capillary no longer changing. Quit trying to rescale.
824+
if (rank == 0)
825+
printf(" WARNING: Target capillary number (%0.3e) is "
826+
"unreachable. Continuing at current (%0.3e)\n",
827+
capillary_number, Ca);
828+
}
829+
else {
830+
// re-run the point if the actual Ca is too far from the target Ca
831+
isSteady = false;
832+
RESCALE_FORCE = true;
833+
t1 = std::chrono::system_clock::now();
834+
CURRENT_TIMESTEP = 0;
835+
timestep = INITIAL_TIMESTEP;
836+
TRIGGER_FORCE_RESCALE = true;
837+
if (rank == 0)
838+
printf(" Capillary number missed target value = %0.3e "
839+
"(measured value was Ca = %0.3e)\n",
840+
capillary_number, Ca);
841+
}
833842
}
834843

835844
if (RESCALE_FORCE && SET_CAPILLARY_NUMBER && CURRENT_TIMESTEP > RESCALE_FORCE_AFTER_TIMESTEP) {
@@ -1111,6 +1120,7 @@ double ScaLBL_ColorModel::Run(int returntime) {
11111120
// reset bisection search method
11121121
bracket_found = false;
11131122
force_mag_bracket_previous = 0.0;
1123+
Ca_bracket_previous = 0.0;
11141124
} else {
11151125
if (rank == 0) {
11161126
printf("** Continue to simulate steady *** \n");

0 commit comments

Comments
 (0)