22from turtleFSI .problems import *
33import numpy as np
44from scipy .integrate import odeint
5- from turtleFSI .utils .Probe import Probe
65import matplotlib .pyplot as plt
76
87"""
@@ -35,8 +34,8 @@ def set_problem_parameters(default_variables, **namespace):
3534 T = 0.1 , # Simulation end time
3635 dt = 0.0005 , # Time step size
3736 theta = 0.501 , # Theta scheme (implicit/explicit time stepping): 0.5 + dt
38- atol = 1e-7 , # Absolute tolerance in the Newton solver
39- rtol = 1e-7 , # Relative tolerance in the Newton solver
37+ atol = 1e-10 , # Absolute tolerance in the Newton solver
38+ rtol = 1e-10 , # Relative tolerance in the Newton solver
4039 mesh_file = "cylinder" , # Mesh file name
4140 inlet_id = 2 , # inlet id
4241 outlet_id1 = 3 , # outlet id
@@ -52,14 +51,14 @@ def set_problem_parameters(default_variables, **namespace):
5251 nu_s = nu_s_val , # Solid Poisson ratio [-]
5352 lambda_s = lambda_s_val , # Solid 1rst Lamé coef. [Pa]
5453 robin_bc = True , # Robin BC
55- k_s = 1.0E5 , # elastic response necesary for RobinBC
56- c_s = 1.0E2 , # viscoelastic response necesary for RobinBC
54+ k_s = [ 1.0E5 ], # elastic response necesary for RobinBC
55+ c_s = [ 1.0E2 ], # viscoelastic response necesary for RobinBC
5756 dx_f_id = 1 , # ID of marker in the fluid domain
5857 dx_s_id = 1002 , # ID of marker in the solid domain
5958 extrapolation = "laplace" , # laplace, elastic, biharmonic, no-extrapolation
6059 extrapolation_sub_type = "constant" , # constant, small_constant, volume, volume_change, bc1, bc2
6160 recompute = 30 , # Number of iterations before recompute Jacobian.
62- recompute_tstep = 10 , # Number of time steps before recompute Jacobian.
61+ recompute_tstep = 100 , # Number of time steps before recompute Jacobian.
6362 save_step = 1 , # Save frequency of files for visualisation
6463 folder = "robinbc_validation" , # Folder where the results will be stored
6564 checkpoint_step = 50 , # checkpoint frequency
@@ -108,7 +107,7 @@ def _mass_spring_damper_system_ode(x, t, params_dict):
108107 dxdt = [dx1dt , dx2dt ]
109108 return dxdt
110109
111- def initiate (dvp_ , mesh , DVP , ** namespace ):
110+ def initiate (mesh , ** namespace ):
112111 # Position to probe
113112 x_coordinate = mesh .coordinates ()[:, 0 ]
114113 y_coordinate = mesh .coordinates ()[:, 1 ]
@@ -119,14 +118,19 @@ def initiate(dvp_, mesh, DVP, **namespace):
119118 z_middle = (z_coordinate .max () + z_coordinate .min ())/ 2
120119
121120 middle_point = np .array ([x_middle , y_middle , z_middle ])
122- d_probe = Probe (middle_point , DVP .sub (0 ))
123- d_probe (dvp_ ["n" ].sub (0 , deepcopy = True ))
124- return dict (d_probe = d_probe )
121+ d_list = []
122+ return dict (d_list = d_list , middle_point = middle_point )
125123
126- def post_solve (d_probe , dvp_ , ** namespace ):
127- d_probe (dvp_ ["n" ].sub (0 , deepcopy = True ))
128124
129- def finished (T , dt , mesh , rho_s , k_s , c_s , boundaries , gravity , d_probe , ** namespace ):
125+ def post_solve (dvp_ , d_list , middle_point , ** namespace ):
126+ d = dvp_ ["n" ].sub (0 , deepcopy = True )
127+ d_eval = d (middle_point )[1 ]
128+ d_list .append (d_eval )
129+
130+ return dict (d_list = d_list )
131+
132+
133+ def finished (T , dt , mesh , rho_s , k_s , c_s , boundaries , gravity , d_list , ** namespace ):
130134 # Define time step and initial conditions
131135 t_analytical = np .linspace (0 , T , int (T / dt ) + 1 )
132136 analytical_solution_init = [0 ,0 ]
@@ -135,15 +139,15 @@ def finished(T, dt, mesh, rho_s, k_s, c_s, boundaries, gravity, d_probe, **names
135139 ds_robin = Measure ("ds" , domain = mesh , subdomain_data = boundaries , subdomain_id = 1033 )
136140 params_dict = dict ()
137141 params_dict ["m" ] = volume * rho_s
138- params_dict ["k" ] = k_s
139- params_dict ["c" ] = c_s
142+ params_dict ["k" ] = k_s [ 0 ]
143+ params_dict ["c" ] = c_s [ 0 ]
140144 params_dict ["A" ] = assemble (1 * ds_robin )
141145 params_dict ["F" ] = - gravity * volume * rho_s
142146 # Solve the ode to compute the analytical solution
143147 analytical_solution = odeint (_mass_spring_damper_system_ode , analytical_solution_init , t_analytical , args = (params_dict ,))
144148 analytical_displacement = analytical_solution [:,0 ]
145149 # Plot both numerical and analytical solutions for a comparison
146- plt .plot (d_probe . get_probe_sub ( 1 ) , label = "turtleFSI" )
150+ plt .plot (d_list , label = "turtleFSI" )
147151 plt .plot (analytical_displacement , label = "analytical" )
148152 plt .legend ()
149153 plt .show ()
0 commit comments