-
Notifications
You must be signed in to change notification settings - Fork 31
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
Implement segmented ridges with flexible positioning #153
Merged
Merged
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5d5a413
Added two contributions: Contribution_1 with script and text file, an…
adbayonao d71dae1
Added Contribution_1 with script and a text file
adbayonao b6a04b9
Added Contribution_2
adbayonao 5bde19d
Modificaciones en test/runtests.jl
adbayonao 856ad13
Eliminado runtests.jl en Andres_Bayona
adbayonao 1cd3bfa
Restaura runtests.jl desde Andres_Bayona_2
adbayonao 5066b6c
Modification of Setup_Geometry. I added the ridge routine
adbayonao 4b662fe
Add description to the function
adbayonao a25fddd
Add description to Setup_Geometry
adbayonao 495bba2
Added the test
adbayonao 4064404
Test_file
adbayonao 6c53a99
New test
adbayonao 3076d78
Deleted files
adbayonao 704da0f
Modified test
adbayonao ca07645
Remove .swm, .swn, .swo files from the repository
adbayonao bb89174
Remove empty 'git' file
adbayonao d32c62f
Remove empty 'src/git' file from repository
adbayonao 5861130
Modified path of the test
adbayonao 7a3e317
Restore Project.toml
adbayonao a5e05c4
Modified Setup_geometry
adbayonao 42e233f
Merge branch 'main' into Andres_Bayona
aelligp 6284a62
Modification of GMT_utils.jl and test_GMT.jl
adbayonao 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
This file contains 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,67 @@ | ||
# This script creates 3D polygons from "x" and "y" coordinates, and allows you to define a depth range for the polygon. | ||
# It assigns phase and temperature values to the grid within the polygon. | ||
|
||
using GeophysicalModelGenerator | ||
using CSV | ||
using DataFrames | ||
|
||
# Grid parameters | ||
nx, ny, nz = 512, 512, 128 | ||
x = range(-1000, 1000, length=nx) | ||
y = range(-1000, 1000, length=ny) | ||
z = range(-660, 0, length=nz) | ||
Grid = CartData(xyz_grid(x, y, z)) | ||
|
||
# Phases and temperature | ||
Phases = fill(2, nx, ny, nz) | ||
Temp = fill(1350.0, nx, ny, nz) | ||
|
||
# Set the desired depth range for the polygon | ||
z_lower_limit = -80.0 | ||
z_upper_limit = 0.0 | ||
|
||
# Define phase and temperature values for the polygon | ||
phase_poly = 5 | ||
temp_poly = 1000.0 | ||
|
||
# Read polygon using CSV and DataFrame | ||
polygon_file = "Test_block.txt" | ||
df = CSV.read(polygon_file, DataFrame, delim=' ') # Read CSV file with a space as delimiter | ||
xpoly, ypoly = df[:, 1], df[:, 2] # Extract coordinates | ||
|
||
# Function to verify if a point (px, py) is inside a polygon defined by the coordinates (poly_x, poly_y) | ||
function point_in_polygon(px, py, poly_x, poly_y) | ||
n = length(poly_x) | ||
inside = false | ||
j = n | ||
for i in 1:n | ||
if ((poly_y[i] > py) != (poly_y[j] > py)) && | ||
(px < (poly_x[j] - poly_x[i]) * (py - poly_y[i]) / (poly_y[j] - poly_y[i]) + poly_x[i]) | ||
inside = !inside | ||
end | ||
j = i | ||
end | ||
return inside | ||
end | ||
|
||
# Assign phase and temperature for the polygon within a specific depth range | ||
function assign_polygon_properties!(Phases, Temp, x, y, z, xpoly, ypoly, phase_value, temp_value, z_lower_limit, z_upper_limit) | ||
for ix in 1:length(x), iy in 1:length(y), iz in 1:length(z) | ||
px, py, pz = x[ix], y[iy], z[iz] | ||
|
||
# Check if the point is inside the polygon (in 2D projection) and within the z-range | ||
if point_in_polygon(px, py, xpoly, ypoly) && pz >= z_lower_limit && pz <= z_upper_limit | ||
Phases[ix, iy, iz] = phase_value | ||
Temp[ix, iy, iz] = temp_value | ||
end | ||
end | ||
end | ||
|
||
# Assign properties within the specified depth range | ||
assign_polygon_properties!(Phases, Temp, x, y, z, xpoly, ypoly, phase_poly, temp_poly, z_lower_limit, z_upper_limit) | ||
|
||
# Add and save results | ||
Grid = addfield(Grid, (; Phases, Temp)) | ||
write_paraview(Grid, "Polygon3D") | ||
|
||
|
This file contains 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,7 @@ | ||
-750 -400 | ||
-1000 0 | ||
-750 400 | ||
-250 400 | ||
0 0 | ||
-250 -400 | ||
-750 -400 |
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.
if you want this routine to be accessible in the GMG package, this file needs two be loaded in one of the other files with
include("Polygon3D.jl")
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.
I am going to review this.