@@ -33,7 +33,7 @@ def main(inflow=10., viscosity=1., density=1., theta=.5, timestepsize=.01, npoin
33
33
34
34
# time approximations
35
35
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' ) })
37
37
# TR interpolation
38
38
tθ = lambda f : theta * f + (1 - theta ) * t0 (f )
39
39
# 1st order FD
@@ -47,7 +47,7 @@ def main(inflow=10., viscosity=1., density=1., theta=.5, timestepsize=.01, npoin
47
47
ns .x0 = geom # reference geometry
48
48
ns .dbasis = domain .basis ('std' , degree = 1 ).vector (2 )
49
49
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
51
51
ns .x_i = 'x0_i + d_i' # moving geometry
52
52
ns .ubasis , ns .pbasis = function .chain ([domain .basis ('std' , degree = 2 ).vector (2 ), domain .basis ('std' , degree = 1 ), ])
53
53
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
98
98
precice_dt = interface .initialize ()
99
99
100
100
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 )))
105
102
106
103
while interface .is_coupling_ongoing ():
107
104
with treelog .context (f'timestep { timestep } ' ):
@@ -120,9 +117,10 @@ def main(inflow=10., viscosity=1., density=1., theta=.5, timestepsize=.01, npoin
120
117
121
118
# advance variables
122
119
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' )}
124
121
arguments ['dt' ] = dt = min (precice_dt , timestepsize )
125
122
arguments ['meshdofs' ] = solver .optimize ('meshdofs' , meshsqr , constrain = meshcons ) # solve mesh deformation
123
+ arguments ['umesh' ] = (arguments ['meshdofs' ] - arguments ['meshdofs0' ]) / dt
126
124
arguments ['lhs' ] = arguments ['lhs0' ] # initial guess for newton
127
125
arguments ['lhs' ] = solver .newton ('lhs' , res , arguments = arguments , constrain = cons ).solve (tol = 1e-6 ) # solve fluid equations
128
126
arguments ['F' ] = solver .solve_linear ('F' , resF , constrain = consF , arguments = arguments )
0 commit comments