Skip to content

Commit 01a3f5e

Browse files
kernels for boundary conditions are revised to use in boundary_condition.py. It points out that currently kernels in y direction for solving PDE and BC are diffrent. It needs double check in future.
1 parent 1214bb6 commit 01a3f5e

File tree

2 files changed

+61
-12
lines changed

2 files changed

+61
-12
lines changed

source/package/soli3d/boundary_condition.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@
88

99
# import numpy as np
1010
# from numpy.typing import NDArray
11-
from .kernels import kernel_i_jm1, kernel_i_jp1, kernel_im1_j, kernel_ip1_j
11+
from .kernels import (
12+
kernel_i_jm1_boundary,
13+
kernel_i_jp1_boundary,
14+
kernel_im1_j_boundary,
15+
kernel_ip1_j_boundary,
16+
)
1217

1318

1419
def boundary_set(
1520
phi: Any,
1621
boundary_loc: Any,
1722
boundary_type: Any,
18-
Dirichlet_boundary_value: Any,
19-
Neumann_boundary_value: Any,
23+
dirichlet_boundary_value: Any,
24+
neumann_boundary_value: Any,
2025
dx: float,
2126
dz: float,
2227
) -> Any:
@@ -45,11 +50,11 @@ def boundary_set(
4550
# boundary types are defined in "io_data_process.py/default_boundary_type function"
4651

4752
# ---------------------------------------------------------------------------------------------
48-
# phi = lfr.where(
49-
# ((boundary_loc == 1) & (boundary_type == 0)),
50-
# Dirichlet_boundary_value,
51-
# phi,
52-
# )
53+
phi = lfr.where(
54+
((boundary_loc == 1) & (boundary_type == 0)),
55+
dirichlet_boundary_value,
56+
phi,
57+
)
5358

5459
# # kernel_im1_j i-1, j
5560
# kernel_im1_j: NDArray[np.uint8] = np.array(
@@ -121,13 +126,13 @@ def boundary_set(
121126
(boundary_loc == 1)
122127
& ((boundary_type == 1) | (boundary_type == 5) | (boundary_type == 6))
123128
),
124-
lfr.focal_sum(phi, kernel_ip1_j) - (dx * Neumann_boundary_value),
129+
lfr.focal_sum(phi, kernel_ip1_j_boundary) - (dx * neumann_boundary_value),
125130
phi,
126131
)
127132

128133
phi = lfr.where(
129134
((boundary_loc == 1) & (boundary_type == 2)),
130-
lfr.focal_sum(phi, kernel_i_jp1) - (dz * Neumann_boundary_value),
135+
lfr.focal_sum(phi, kernel_i_jp1_boundary) - (dz * neumann_boundary_value),
131136
phi,
132137
)
133138

@@ -136,13 +141,13 @@ def boundary_set(
136141
(boundary_loc == 1)
137142
& ((boundary_type == 3) | (boundary_type == 7) | (boundary_type == 8))
138143
),
139-
lfr.focal_sum(phi, kernel_im1_j) + (dx * Neumann_boundary_value),
144+
lfr.focal_sum(phi, kernel_im1_j_boundary) + (dx * neumann_boundary_value),
140145
phi,
141146
)
142147

143148
phi = lfr.where(
144149
((boundary_loc == 1) & (boundary_type == 4)),
145-
lfr.focal_sum(phi, kernel_i_jm1) + (dz * Neumann_boundary_value),
150+
lfr.focal_sum(phi, kernel_i_jm1_boundary) + (dz * neumann_boundary_value),
146151
phi,
147152
)
148153

source/package/soli3d/kernels.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,47 @@
108108
# ],
109109
# dtype=np.uint8,
110110
# )
111+
112+
# ---- NOTE kernel_i_jm1_boundary and kernel_i_jp1_boundary
113+
# are different kernel_i_jm1 and kernel_i_jp1 -------------
114+
115+
116+
# kernel_im1_j i-1, j
117+
kernel_im1_j_boundary: NDArray[np.uint8] = np.array(
118+
[
119+
[0, 0, 0],
120+
[1, 0, 0],
121+
[0, 0, 0],
122+
],
123+
dtype=np.uint8,
124+
)
125+
126+
# kernel_i_jm1 i, j-1 # Check it. It is changed compared to advection-diffusion test model.
127+
kernel_i_jm1_boundary: NDArray[np.uint8] = np.array(
128+
[
129+
[0, 0, 0],
130+
[0, 0, 0],
131+
[0, 1, 0],
132+
],
133+
dtype=np.uint8,
134+
)
135+
136+
# kernel_ip1_j i+1, j
137+
kernel_ip1_j_boundary: NDArray[np.uint8] = np.array(
138+
[
139+
[0, 0, 0],
140+
[0, 0, 1],
141+
[0, 0, 0],
142+
],
143+
dtype=np.uint8,
144+
)
145+
146+
# kernel_i_jp1 i, j+1 # Check it. It is changed compared to advection-diffusion test model.
147+
kernel_i_jp1_boundary: NDArray[np.uint8] = np.array(
148+
[
149+
[0, 1, 0],
150+
[0, 0, 0],
151+
[0, 0, 0],
152+
],
153+
dtype=np.uint8,
154+
)

0 commit comments

Comments
 (0)