Skip to content

Commit

Permalink
Merge pull request #704 from MFraters/fix_same_min_and_max_depth_line…
Browse files Browse the repository at this point in the history
…ar_temp

Fix crash if the minimum and maximum depth are the same.
  • Loading branch information
MFraters authored May 8, 2024
2 parents dbf0e2c + 4d30f92 commit f08dd07
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest','macos-latest','macos-11']
os: ['ubuntu-latest','macos-12','macos-11']
build_type: ['Release', 'Debug']

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -214,7 +214,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest','macos-latest']
os: ['ubuntu-latest','macos-12']
build_type: ['Release']

runs-on: ${{ matrix.os }}
Expand Down
1 change: 0 additions & 1 deletion cookbooks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ This section contains self-contained cookbooks on how to design different geodyn
3d_cartesian_transform_fault/doc/README
simple_subduction_2d_cartesian/doc/README
simple_subduction_2d_chunk/doc/README
```
2 changes: 1 addition & 1 deletion doc/sphinx/user_manual/basic_starter_tutorial/17_plume.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Adding a mantle plume
===============================

The last feature we will be adding in this tutorial is the `plume`. The plume is defined by a set of coordinates which represent where the plume is at different depths. The depth are set through the `cross section depths` parameter, hich requires as many depths as there are coordinates. Each cross-section is an ellipse, for which the parameters can be set individually. Please see [the plume feature description](part:user_manual:chap:parameter_documentation:sec:features:subsec:plume) for more information on what each of the parameters do. In this case we will increase the eccentricity of the plume at the top.
The last feature we will be adding in this tutorial is the `plume`. The plume is defined by a set of coordinates which represent where the plume is at different depths. The depth are set through the `cross section depths` parameter, which requires as many depths as there are coordinates. Each cross-section is an ellipse, for which the parameters can be set individually. Please see [the plume feature description](part:user_manual:chap:parameter_documentation:sec:features:subsec:plume) for more information on what each of the parameters do. In this case we will increase the eccentricity of the plume at the top.

With the definition of the area the feature plume contains completed, we can now add a temperature and compositional structure. A gaussian is a good first order approximation of the temperature, so we will add that as the temperature model. This temperature model allows you to set change the gaussian distribution parameters for each depth segment. Note that in this case we are not replacing the temperature, but adding to the temperature which was already there.

Expand Down
2 changes: 1 addition & 1 deletion include/doctest/doctest.h
Original file line number Diff line number Diff line change
Expand Up @@ -4151,7 +4151,7 @@ namespace doctest
#define DOCTEST_TO_STRING_OVERLOAD(type, fmt) \
String toString(type in) { \
char buf[64]; \
std::sprintf(buf, fmt, in); \
std::snprintf(buf, sizeof( buf ), fmt, in); \
return buf; \
}

Expand Down
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
2 changes: 1 addition & 1 deletion source/world_builder/features/subducting_plate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ namespace WorldBuilder
grains.sizes[i] = grains_current_section.sizes[i] + section_fraction * (grains_next_section.sizes[i] - grains_current_section.sizes[i]);
}

// average two rotations matrices throu quaternions.
// average two rotations matrices through quaternions.
for (size_t i = 0; i < grains_current_section.rotation_matrices.size(); i++)
{
const glm::quaternion::quat quat_current = glm::quaternion::quat_cast(grains_current_section.rotation_matrices[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ namespace WorldBuilder
distance_along_plane/thickness_local);

// the paper uses `(x_scaled * sin(average_angle) - z_scaled * cos(average_angle))` to compute the
// depth (execpt that you do not use average angles since they only have on angle). On recomputing
// depth (except that you do not use average angles since they only have on angle). On recomputing
// their result it seems to me (Menno) that it should have been `(1-z_scaled)` instead of `z_scaled`.
// To avoid this whole problem we just use the depth directly since we have that.
// todo: get the local thickniss out of H, that prevents an other division.
Expand Down

0 comments on commit f08dd07

Please sign in to comment.