@@ -33,7 +33,7 @@ def main(inflow=10., viscosity=1., density=1., theta=.5, timestepsize=.01, npoin
3333
3434 # time approximations
3535 t0 = lambda f : function .replace_arguments (f , {arg : function .Argument (arg + '0' , shape = shape , dtype = dtype )
36- for arg , (shape , dtype ) in f .arguments .items ()})
36+ for arg , (shape , dtype ) in f .arguments .items () if arg in ( 'lhs' , 'meshdofs' , 'F' ) })
3737 # TR interpolation
3838 tθ = lambda f : theta * f + (1 - theta ) * t0 (f )
3939 # 1st order FD
@@ -47,7 +47,7 @@ def main(inflow=10., viscosity=1., density=1., theta=.5, timestepsize=.01, npoin
4747 ns .x0 = geom # reference geometry
4848 ns .dbasis = domain .basis ('std' , degree = 1 ).vector (2 )
4949 ns .d_i = 'dbasis_ni ?meshdofs_n'
50- ns .umesh = δt ( ns . d ) # mesh velocity
50+ ns .umesh_i = 'dbasis_ni ?umesh_n' # mesh velocity
5151 ns .x_i = 'x0_i + d_i' # moving geometry
5252 ns .ubasis , ns .pbasis = function .chain ([domain .basis ('std' , degree = 2 ).vector (2 ), domain .basis ('std' , degree = 1 ), ])
5353 ns .F_i = 'ubasis_ni ?F_n' # stress field
@@ -98,10 +98,7 @@ def main(inflow=10., viscosity=1., density=1., theta=.5, timestepsize=.01, npoin
9898 precice_dt = interface .initialize ()
9999
100100 timestep = 0
101- arguments = dict (lhs = numpy .zeros (len (ns .ubasis )), meshdofs = numpy .zeros (len (ns .dbasis )), dt = timestepsize )
102-
103- nhist = 2 # history length required by the formulation
104- arguments .update ((k + '0' * i , v ) for k , v in tuple (arguments .items ()) for i in range (nhist ))
101+ arguments = dict (lhs = numpy .zeros (len (ns .ubasis )), meshdofs = numpy .zeros (len (ns .dbasis )))
105102
106103 while interface .is_coupling_ongoing ():
107104 with treelog .context (f'timestep { timestep } ' ):
@@ -120,9 +117,10 @@ def main(inflow=10., viscosity=1., density=1., theta=.5, timestepsize=.01, npoin
120117
121118 # advance variables
122119 timestep += 1
123- arguments = {k + '0' * ( i + 1 ) : arguments [k + '0' * i ] for k in ('lhs' , 'meshdofs' , 'dt' ) for i in range ( nhist )}
120+ arguments = {k + '0' : arguments [k ] for k in ('lhs' , 'meshdofs' )}
124121 arguments ['dt' ] = dt = min (precice_dt , timestepsize )
125122 arguments ['meshdofs' ] = solver .optimize ('meshdofs' , meshsqr , constrain = meshcons ) # solve mesh deformation
123+ arguments ['umesh' ] = (arguments ['meshdofs' ] - arguments ['meshdofs0' ]) / dt
126124 arguments ['lhs' ] = arguments ['lhs0' ] # initial guess for newton
127125 arguments ['lhs' ] = solver .newton ('lhs' , res , arguments = arguments , constrain = cons ).solve (tol = 1e-6 ) # solve fluid equations
128126 arguments ['F' ] = solver .solve_linear ('F' , resF , constrain = consF , arguments = arguments )
0 commit comments