Skip to content

Commit

Permalink
Fix bug in mesh_basic (#15)
Browse files Browse the repository at this point in the history
* Fix `mesh_basic`, add comment on number of points

* Add empty line
  • Loading branch information
bennibolm authored Feb 7, 2024
1 parent 74c9024 commit 3a5c3a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Manifest.toml
LocalPreferences.toml
run/
out/
17 changes: 13 additions & 4 deletions src/standard_meshes.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
"""
mesh_basic(coordinates_min, coordinates_max, n_points_x, n_points_y)
Create points in a regular grid.
"""
function mesh_basic(coordinates_min, coordinates_max, n_points_x, n_points_y)
dx = (coordinates_max[1] - coordinates_min[1]) / n_points_x
dy = (coordinates_max[2] - coordinates_min[2]) / n_points_y
dx = (coordinates_max[1] - coordinates_min[1]) / (n_points_x - 1)
dy = (coordinates_max[2] - coordinates_min[2]) / (n_points_y - 1)

# Number of points:
# Tensorproduct: n_points_x * n_points_y
# Add for half the rows (rounded off) one point each
n_points = n_points_x * n_points_y + div(n_points_y - n_points_y % 2, 2)
points = Matrix{eltype(coordinates_min)}(undef, 2, n_points)

points = Matrix{eltype(coordinates_min)}(undef, 2, n_points_x * n_points_y +
div(n_points_y - n_points_y % 2, 2))
count = 1
for j in 1:n_points_y
for i in 1:n_points_x
Expand Down

0 comments on commit 3a5c3a0

Please sign in to comment.