XY平面を nx*ny 分割し、各セルを2三角形へ分割したメッシュを生成する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_type), | intent(out) | :: | mesh |
生成した平面三角形メッシュ。 |
||
| real(kind=dp), | intent(in), | optional | :: | size_x |
X方向の平面サイズ [m](省略時 1.0)。 |
|
| real(kind=dp), | intent(in), | optional | :: | size_y |
X方向の平面サイズ [m](省略時 1.0)。 Y方向の平面サイズ [m](省略時 1.0)。 |
|
| integer(kind=i32), | intent(in), | optional | :: | nx |
X方向分割数(省略時 1)。 |
|
| integer(kind=i32), | intent(in), | optional | :: | ny |
X方向分割数(省略時 1)。 Y方向分割数(省略時 1)。 |
|
| real(kind=dp), | intent(in), | optional | :: | center(3) |
subroutine make_plane(mesh, size_x, size_y, nx, ny, center) type(mesh_type), intent(out) :: mesh real(dp), intent(in), optional :: size_x, size_y integer(i32), intent(in), optional :: nx, ny real(dp), intent(in), optional :: center(3) real(dp) :: sx, sy, c(3), x0, y0, dx, dy integer(i32) :: nx0, ny0, ix, iy, itri, nelem real(dp), allocatable :: v0(:, :), v1(:, :), v2(:, :) sx = 1.0d0; sy = 1.0d0; nx0 = 1; ny0 = 1; c = 0.0d0 if (present(size_x)) sx = size_x if (present(size_y)) sy = size_y if (present(nx)) nx0 = nx if (present(ny)) ny0 = ny if (present(center)) c = center if (nx0 <= 0 .or. ny0 <= 0) error stop "nx and ny must be positive" nelem = 2*nx0*ny0 allocate (v0(3, nelem), v1(3, nelem), v2(3, nelem)) dx = sx/real(nx0, dp); dy = sy/real(ny0, dp) x0 = c(1) - 0.5d0*sx; y0 = c(2) - 0.5d0*sy itri = 0 do ix = 0, nx0 - 1 do iy = 0, ny0 - 1 itri = itri + 1 v0(:, itri) = [x0 + dx*ix, y0 + dy*iy, c(3)] v1(:, itri) = [x0 + dx*(ix + 1), y0 + dy*iy, c(3)] v2(:, itri) = [x0 + dx*(ix + 1), y0 + dy*(iy + 1), c(3)] itri = itri + 1 v0(:, itri) = [x0 + dx*ix, y0 + dy*iy, c(3)] v1(:, itri) = [x0 + dx*(ix + 1), y0 + dy*(iy + 1), c(3)] v2(:, itri) = [x0 + dx*ix, y0 + dy*(iy + 1), c(3)] end do end do call init_mesh(mesh, v0, v1, v2) end subroutine make_plane