|
5 | 5 | -\Delta u = f |
6 | 6 | with source term f=1. |
7 | 7 |
|
8 | | -First, homogeneous Dirichlet boundary conditions are applied. Then, inhomogeneous ones |
9 | | -are applied. |
| 8 | +First, homogeneous Dirichlet boundary conditions are applied. Then, homogeneous |
| 9 | +and inhomogeneous Dirichlet boundary conditions are applied on 3 of 4 boundaries. |
10 | 10 | """ |
11 | 11 |
|
12 | 12 | import numpy as np |
13 | 13 |
|
14 | 14 | import splinepy as sp |
15 | 15 |
|
16 | | -# Test Case |
| 16 | +# Number of refinements for the solution field |
17 | 17 | n_refine = 15 |
18 | 18 |
|
19 | 19 |
|
@@ -130,18 +130,26 @@ def show_solution(geometry, solution_field): |
130 | 130 | fi.assemble_vector(poisson_rhs) |
131 | 131 |
|
132 | 132 | # Homogeneous Dirichlet boundary conditions |
133 | | - fi.assign_homogeneous_dirichlet_boundary_conditions() |
| 133 | + fi.apply_homogeneous_dirichlet_boundary_conditions() |
134 | 134 | fi.solve_linear_system() |
135 | 135 | # Plot geometry and field |
136 | 136 | show_solution(geometry, solution_field) |
137 | 137 |
|
138 | 138 | # Inhomogeneous Dirichlet boundary conditions |
139 | 139 | def dirichlet_function(points): |
140 | 140 | """ |
141 | | - On the boundary apply: g(x,y) = x/10 |
| 141 | + On the boundary apply: g(x,y) = x/4 |
142 | 142 | """ |
143 | | - return points[:, 0] / 10 |
| 143 | + return points[:, 0] / 4 |
144 | 144 |
|
145 | | - fi.apply_dirichlet_boundary_conditions(dirichlet_function) |
| 145 | + # Assemble again to override previous boundary conditions |
| 146 | + fi.assemble_matrix(poisson_lhs) |
| 147 | + fi.assemble_vector(poisson_rhs) |
| 148 | + |
| 149 | + # Apply boundary conditions on 3 boundaries |
| 150 | + fi.apply_homogeneous_dirichlet_boundary_conditions(west=True) |
| 151 | + fi.apply_dirichlet_boundary_conditions( |
| 152 | + dirichlet_function, south=True, north=True |
| 153 | + ) |
146 | 154 | fi.solve_linear_system() |
147 | 155 | show_solution(geometry, solution_field) |
0 commit comments