From 3a5c3a04bbce04b50c49271a12cc33826305e136 Mon Sep 17 00:00:00 2001 From: Benjamin Bolm <74359358+bennibolm@users.noreply.github.com> Date: Wed, 7 Feb 2024 11:20:27 +0100 Subject: [PATCH] Fix bug in `mesh_basic` (#15) * Fix `mesh_basic`, add comment on number of points * Add empty line --- .gitignore | 1 + src/standard_meshes.jl | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 4c7705c..9f067b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ Manifest.toml LocalPreferences.toml run/ +out/ diff --git a/src/standard_meshes.jl b/src/standard_meshes.jl index 26f65e5..ac3dc37 100644 --- a/src/standard_meshes.jl +++ b/src/standard_meshes.jl @@ -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