Skip to content

Commit

Permalink
Fix crash if the minimum and maximum depth are the same.
Browse files Browse the repository at this point in the history
  • Loading branch information
MFraters committed Apr 27, 2024
1 parent 261c22b commit 6bd7dea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ namespace WorldBuilder
this->world->specific_heat) * max_depth_local_local);
}

const double new_temperature = top_temperature_local +
(depth - min_depth_local) *
((bottom_temperature_local - top_temperature_local) / (max_depth_local_local - min_depth_local_local));
const double new_temperature = top_temperature_local + (max_depth_local_local - min_depth_local_local < 10.0*std::numeric_limits<double>::epsilon() ? 0.0 :
(depth - min_depth_local) *
((bottom_temperature_local - top_temperature_local) / (max_depth_local_local - min_depth_local_local)));

WBAssert(!std::isnan(new_temperature), "Temperature is not a number: " << new_temperature
<< ", based on a temperature model with the name " << this->name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ namespace WorldBuilder

}

const double new_temperature = top_temperature_local +
(depth - min_depth_local_local) *
((bottom_temperature_local - top_temperature_local) / (max_depth_local_local - min_depth_local_local));
const double new_temperature = top_temperature_local + (max_depth_local_local - min_depth_local_local < 10.0*std::numeric_limits<double>::epsilon() ? 0.0 :
(depth - min_depth_local_local) *
((bottom_temperature_local - top_temperature_local) / (max_depth_local_local - min_depth_local_local)));

return apply_operation(operation,temperature_,new_temperature);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ namespace WorldBuilder
this->world->specific_heat) * max_depth_local_local);
}

const double new_temperature = top_temperature_local +
(depth - min_depth_local_local) *
((bottom_temperature_local - top_temperature_local) / (max_depth_local_local - min_depth_local_local));
const double new_temperature = top_temperature_local + (max_depth_local_local - min_depth_local_local < 10.0*std::numeric_limits<double>::epsilon() ? 0.0 :
(depth - min_depth_local_local) *
((bottom_temperature_local - top_temperature_local) / (max_depth_local_local - min_depth_local_local)));

return apply_operation(operation,temperature_,new_temperature);
}
Expand Down

0 comments on commit 6bd7dea

Please sign in to comment.