|
5 | 5 | # extension: .py
|
6 | 6 | # format_name: light
|
7 | 7 | # format_version: '1.5'
|
8 |
| -# jupytext_version: 1.16.0 |
| 8 | +# jupytext_version: 1.16.4 |
9 | 9 | # kernelspec:
|
10 | 10 | # display_name: Python 3 (ipykernel)
|
11 | 11 | # language: python
|
|
44 | 44 |
|
45 | 45 | res = 0.05
|
46 | 46 | r_o = 1.0
|
47 |
| -r_int = 0.8 |
48 |
| -r_i = 0.5 |
| 47 | +r_int = 0.2 |
| 48 | +r_i = 0.1 |
49 | 49 |
|
50 | 50 | free_slip_upper = True
|
51 | 51 | free_slip_lower = True
|
|
71 | 71 | filename="tmp_fixedstarsMesh.msh")
|
72 | 72 |
|
73 | 73 |
|
| 74 | +meshball.view() |
| 75 | + |
74 | 76 | # +
|
75 | 77 | norm_v = uw.discretisation.MeshVariable("N", meshball, 2, degree=1, varsymbol=r"{\hat{n}}")
|
76 | 78 |
|
|
125 | 127 |
|
126 | 128 | stokes.constitutive_model = uw.constitutive_models.ViscousFlowModel
|
127 | 129 | stokes.constitutive_model.Parameters.viscosity = 1.0
|
128 |
| -stokes.penalty = 0.0 |
129 |
| -stokes.saddle_preconditioner = sympy.simplify(1 / (stokes.constitutive_model.viscosity + stokes.penalty)) |
| 130 | +stokes.penalty = 1.0 |
| 131 | + |
| 132 | +stokes.tolerance = 1.0e-6 |
130 | 133 |
|
131 | 134 | stokes.petsc_options.setValue("ksp_monitor", None)
|
132 | 135 | stokes.petsc_options.setValue("snes_monitor", None)
|
|
165 | 168 | I0.fn = v_theta_fn_xy.dot(v_theta_fn_xy)
|
166 | 169 | vnorm = I0.evaluate()
|
167 | 170 |
|
168 |
| -print(norm/vnorm, vnorm) |
| 171 | +# print(norm/vnorm, vnorm) |
169 | 172 |
|
170 | 173 | with meshball.access(v_soln):
|
171 | 174 | dv = uw.function.evaluate(norm * v_theta_fn_xy, v_soln.coords) / vnorm
|
|
178 | 181 |
|
179 | 182 | pressure_solver = uw.systems.Projection(meshball, p_cont)
|
180 | 183 | pressure_solver.uw_function = p_soln.sym[0]
|
181 |
| -pressure_solver.smoothing = 1.0e-3 |
| 184 | +pressure_solver.smoothing = 1.0e-6 |
182 | 185 |
|
183 | 186 | # +
|
184 | 187 | ## Now solve with normals from nodal projection
|
|
187 | 190 |
|
188 | 191 | stokes.bodyforce = sympy.Matrix([0,0])
|
189 | 192 | Gamma = meshball.Gamma / sympy.sqrt(meshball.Gamma.dot(meshball.Gamma))
|
190 |
| -Gamma = norm_v.sym |
| 193 | +# Gamma = norm_v.sym |
191 | 194 |
|
192 | 195 | stokes.add_natural_bc(-t_init * unit_rvec, "Internal")
|
193 | 196 |
|
|
201 | 204 | else:
|
202 | 205 | stokes.add_essential_bc((0.0,0.0), "Lower")
|
203 | 206 |
|
204 |
| -stokes.solve(zero_init_guess=False) |
| 207 | +stokes.solve(zero_init_guess=True) |
205 | 208 |
|
206 | 209 | # +
|
207 | 210 | # Null space evaluation
|
|
213 | 216 | dv = uw.function.evaluate(norm * v_theta_fn_xy, v_soln.coords) / vnorm
|
214 | 217 | v_soln.data[...] -= dv
|
215 | 218 |
|
216 |
| -print(norm/vnorm, vnorm) |
| 219 | +# print(norm/vnorm, vnorm) |
217 | 220 | # -9.662093930530614e-09 0.024291704747453444
|
218 | 221 |
|
219 | 222 | norm = I0.evaluate()
|
220 | 223 | # -
|
221 | 224 |
|
222 | 225 | I0 = uw.maths.Integral(meshball, v_theta_fn_xy.dot(v_soln.sym))
|
223 | 226 | norm = I0.evaluate()
|
224 |
| -print(norm/vnorm) |
225 | 227 |
|
| 228 | +# + |
226 | 229 | # Pressure at mesh nodes
|
227 | 230 | pressure_solver.solve()
|
228 | 231 |
|
| 232 | +pstats1 = p_cont.stats() |
| 233 | +pstats0 = p_soln.stats() |
| 234 | + |
| 235 | +if uw.mpi.rank == 0: |
| 236 | + print(f"Pressure (C1): {pstats1}") |
| 237 | + print(f"Pressure (C0): {pstats0}") |
| 238 | + print(f"Velocity: {vnorm}") |
| 239 | + |
229 | 240 | # +
|
230 | 241 | # check the mesh if in a notebook / serial
|
231 | 242 |
|
|
270 | 281 | pvmesh,
|
271 | 282 | cmap="coolwarm",
|
272 | 283 | edge_color="Grey",
|
273 |
| - scalars="Vmag", |
| 284 | + scalars="P", |
274 | 285 | show_edges=True,
|
275 | 286 | use_transparency=False,
|
276 | 287 | opacity=1.0,
|
277 | 288 | show_scalar_bar=True
|
278 | 289 | )
|
279 | 290 |
|
280 |
| - pl.add_arrows(velocity_points.points, velocity_points.point_data["V"], mag=3) |
281 |
| - pl.add_arrows(velocity_points.points, velocity_points.point_data["V0"], mag=3, color="Black") |
| 291 | + pl.add_arrows(velocity_points.points, velocity_points.point_data["V"], mag=4) |
| 292 | + pl.add_arrows(velocity_points.points, velocity_points.point_data["V0"], mag=4, color="Black") |
282 | 293 | # pl.add_arrows(velocity_points.points, velocity_points.point_data["dV"], mag=100, color="Black")
|
283 | 294 | pl.add_mesh(pvstream, opacity=0.3, show_scalar_bar=False)
|
284 | 295 |
|
285 | 296 |
|
286 | 297 | pl.show(cpos="xy")
|
| 298 | + |
| 299 | + vsol_rms = np.sqrt(velocity_points.point_data["V"][:, 0] ** 2 + velocity_points.point_data["V"][:, 1] ** 2).mean() |
| 300 | + print(vsol_rms) |
287 | 301 | # -
|
288 | 302 |
|
289 |
| -vsol_rms = np.sqrt(velocity_points.point_data["V"][:, 0] ** 2 + velocity_points.point_data["V"][:, 1] ** 2).mean() |
290 |
| -vsol_rms |
| 303 | + |
| 304 | + |
| 305 | + |
0 commit comments