-
Notifications
You must be signed in to change notification settings - Fork 50
along interface velocity for subducting slab #903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lhy11009
wants to merge
1
commit into
GeodynamicWorldBuilder:main
Choose a base branch
from
lhy11009:along_surface_velocity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
include/world_builder/features/subducting_plate_models/velocity/along_surface.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| /* | ||
| Copyright (C) 2018-2026 by the authors of the World Builder code. | ||
|
|
||
| This file is part of the World Builder. | ||
|
|
||
| This program is free software: you can redistribute it and/or modify | ||
| it under the terms of the GNU Lesser General Public License as published | ||
| by the Free Software Foundation, either version 2 of the License, or | ||
| (at your option) any later version. | ||
|
|
||
| This program is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| GNU Lesser General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU Lesser General Public License | ||
| along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #ifndef WORLD_BUILDER_FEATURES_SUBDUCTING_PLATE_MODELS_VELOCITY_ALONG_SURFACE_H | ||
| #define WORLD_BUILDER_FEATURES_SUBDUCTING_PLATE_MODELS_VELOCITY_ALONG_SURFACE_H | ||
|
|
||
|
|
||
| #include "world_builder/features/subducting_plate_models/velocity/interface.h" | ||
| #include "world_builder/features/feature_utilities.h" | ||
|
|
||
|
|
||
| namespace WorldBuilder | ||
| { | ||
|
|
||
| namespace Features | ||
| { | ||
| namespace SubductingPlateModels | ||
| { | ||
| namespace Velocity | ||
| { | ||
| /** | ||
| * This class represents a subducting plate and can implement submodules | ||
| * for velocity and composition. These submodules determine what | ||
| * the returned velocity or composition of the velocity and composition | ||
| * functions of this class will be. | ||
| */ | ||
| class AlongSurface final: public Interface | ||
| { | ||
| public: | ||
| /** | ||
| * constructor | ||
| */ | ||
| AlongSurface(WorldBuilder::World *world); | ||
|
|
||
| /** | ||
| * Destructor | ||
| */ | ||
| ~AlongSurface() override final; | ||
|
|
||
| /** | ||
| * declare and read in the world builder file into the parameters class | ||
| */ | ||
| static | ||
| void declare_entries(Parameters &prm, const std::string &parent_name = ""); | ||
|
|
||
| /** | ||
| * declare and read in the world builder file into the parameters class | ||
| */ | ||
| void parse_entries(Parameters &prm) override final; | ||
|
|
||
|
|
||
| /** | ||
| * Returns a velocity based on the given position, depth in the model, | ||
| * gravity and current velocity. | ||
| */ | ||
| std::array<double,3> get_velocity(const Point<3> &position, | ||
| const double depth, | ||
| const double gravity, | ||
| std::array<double,3> velocity, | ||
| const double feature_min_depth, | ||
| const double feature_max_depth, | ||
| const WorldBuilder::Utilities::PointDistanceFromCurvedPlanes &distance_from_planes, | ||
| const AdditionalParameters &additional_parameters) const override final; | ||
|
|
||
|
|
||
| private: | ||
| // uniform raw velocity submodule parameters | ||
| double min_depth; | ||
| double max_depth; | ||
| double velocity_magnitude; | ||
| Operations operation; | ||
|
|
||
| }; | ||
| } // namespace Velocity | ||
| } // namespace SubductingPlateModels | ||
| } // namespace Features | ||
| } // namespace WorldBuilder | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
source/world_builder/features/subducting_plate_models/velocity/along_surface.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| /* | ||
| Copyright (C) 2018-2026 by the authors of the World Builder code. | ||
|
|
||
| This file is part of the World Builder. | ||
|
|
||
| This program is free software: you can redistribute it and/or modify | ||
| it under the terms of the GNU Lesser General Public License as published | ||
| by the Free Software Foundation, either version 2 of the License, or | ||
| (at your option) any later version. | ||
|
|
||
| This program is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| GNU Lesser General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU Lesser General Public License | ||
| along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #include "world_builder/features/subducting_plate_models/velocity/along_surface.h" | ||
|
|
||
|
|
||
| #include "world_builder/nan.h" | ||
| #include "world_builder/types/array.h" | ||
| #include "world_builder/types/double.h" | ||
| #include "world_builder/types/object.h" | ||
| #include "world_builder/utilities.h" | ||
|
|
||
|
|
||
| namespace WorldBuilder | ||
| { | ||
|
|
||
| using namespace Utilities; | ||
|
|
||
| namespace Features | ||
| { | ||
| namespace SubductingPlateModels | ||
| { | ||
| namespace Velocity | ||
| { | ||
| AlongSurface::AlongSurface(WorldBuilder::World *world_) | ||
| : | ||
| min_depth(NaN::DSNAN), | ||
| max_depth(NaN::DSNAN), | ||
| velocity_magnitude(NaN::DSNAN), | ||
| operation(Operations::REPLACE) | ||
| { | ||
| this->world = world_; | ||
| this->name = "along surface"; | ||
| } | ||
|
|
||
| AlongSurface::~AlongSurface() | ||
| = default; | ||
|
|
||
| void | ||
| AlongSurface::declare_entries(Parameters &prm, const std::string & /*unused*/) | ||
| { | ||
| // Document plugin and require entries if needed. | ||
| // Add `velocity magnitude` and to the required parameters. | ||
| prm.declare_entry("", Types::Object({"velocity magnitude"}), | ||
| "Uniform velocity model. Set the velocity to a constant value."); | ||
|
|
||
| // Declare entries of this plugin | ||
| prm.declare_entry("min distance slab top", Types::Double(0), | ||
| "todo The depth in meters from which the composition of this feature is present."); | ||
|
|
||
| prm.declare_entry("max distance slab top", Types::Double(std::numeric_limits<double>::max()), | ||
| "todo The depth in meters to which the composition of this feature is present."); | ||
|
|
||
| prm.declare_entry("velocity magnitude", Types::Double(0), | ||
| "The velocity in meter per year"); | ||
|
|
||
| } | ||
|
|
||
| void | ||
| AlongSurface::parse_entries(Parameters &prm) | ||
| { | ||
|
|
||
| min_depth = prm.get<double>("min distance slab top"); | ||
| max_depth = prm.get<double>("max distance slab top"); | ||
| operation = string_operations_to_enum(prm.get<std::string>("operation")); | ||
| velocity_magnitude = prm.get<double>("velocity magnitude"); | ||
| } | ||
|
|
||
|
|
||
| std::array<double,3> | ||
| AlongSurface::get_velocity(const Point<3> & /*position_in_cartesian_coordinates*/, | ||
| const double /*depth*/, | ||
| const double /*gravity*/, | ||
| std::array<double,3> velocity_, | ||
| const double /*feature_min_depth*/, | ||
| const double /*feature_max_depth*/, | ||
| const WorldBuilder::Utilities::PointDistanceFromCurvedPlanes &distance_from_plane, | ||
| const AdditionalParameters & /*additional_parameters*/) const | ||
| { | ||
|
|
||
| if (distance_from_plane.distance_from_plane <= max_depth && distance_from_plane.distance_from_plane >= min_depth) | ||
| { | ||
| const double angle = distance_from_plane.angle; | ||
|
|
||
| const double sign_vx = -1.0; // place holder for modify vx direction | ||
| const double vx = sign_vx * velocity_magnitude * std::cos(angle); | ||
| const double vy = 0.0; | ||
| const double vz = -velocity_magnitude * std::sin(angle); | ||
|
|
||
| return {{ | ||
| apply_operation(operation,velocity_[0],vx), | ||
| apply_operation(operation,velocity_[1],vy), | ||
| apply_operation(operation,velocity_[2],vz) | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| return velocity_; | ||
| } | ||
|
|
||
| WB_REGISTER_FEATURE_SUBDUCTING_PLATE_VELOCITY_MODEL(AlongSurface, along surface) | ||
| } // namespace Velocity | ||
| } // namespace SubductingPlateModels | ||
| } // namespace Features | ||
| } // namespace WorldBuilder | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
tests/gwb-grid/oceanic_subduction_along_surface_velocity.grid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Grid File for creating vtk files to view in Paraview or Visit | ||
| grid_type = cartesian | ||
| dim = 2 | ||
| compositions = 1 | ||
|
|
||
| # domain of the grid (x and y are the surface, z is vertical with 0 at the bottom) | ||
| x_min = 0e3 | ||
| x_max = 3000e3 | ||
| z_min = 0e3 | ||
| z_max = 1000e3 | ||
|
|
||
| # grid properties | ||
| n_cell_x = 30 | ||
| n_cell_z = 10 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MFraters. Now the question is how to figure out when sign_vx should be 1.0 versus -1.0. -1.0 is required to fix the Vx when the query point is left to the trench point with a smaller X coordinate. I wonder this could be figured out from the distance_from_plane object, or we have to pass the reference point to this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think
reference_on_side_of_lineis the variable you are looking for to add to the structure.