# return the K_func # store it to xdmf file to open it paraview # step 1: Take K old K_1 = Expression("(x[0] > w && x[0] < 1- w && x[1] < 0.5 || x[1] >= 0.5 && x[1] < 0.7 )? 0.0:1.0", w=w) # step 2: Send it to Stokes solver U, P, K_Func = stokes_solver(w=w, mesh=mesh, Vspace=Vspace, Pspace=Pspace, Wspace=Wspace, K_array=K_1, n=n) # step 3: calculate the WSS over it and its bdry WSS = WSS(U=U, ShearStressSpace=ShearStressSpace) WSS_bdry = WSS_bdry(K_Func=K_Func, DPspace=DPspace, WSS=WSS) # Step 4: This is the diffucult step. we need to create an indicator function now ind_f = ind_func_expr(WSS_bdry=WSS_bdry) # works!! finally # step 5: add together old and new K functions # ind_f is a function in DG0 space and old K function is inPspace # have to solve this first K_new = K_update(ind_func=ind_f, K_Func=K_Func) plot(K_new, interactive=True, title="K new ") # doesnt look that great, lets try capping # step 6: capping K_capped = capping(K_new) plot(K_capped, interactive=True, title="K capped") # actually looks really good,
mesh = UnitSquareMesh(n,n) Pspace = FunctionSpace(mesh, 'CG',1) Vspace = VectorFunctionSpace(mesh, 'Lagrange', 2) Pspace = FunctionSpace(mesh, 'Lagrange', 1) Wspace = MixedFunctionSpace([Vspace, Pspace]) ShearStressSpace=FunctionSpace(mesh, 'DG', 1) DPspace = FunctionSpace(mesh, 'DG', 0) # strict inequality or not for 0.7 gives different results, but they are infact made the same by capping K_1 = Expression('(x[0] > w && x[0] < 1- w && x[1] < 0.5 || x[1] >= 0.5 && x[1] <= 0.7 )? 0.0:1.0', w=w) #------test 1-------------------------------- ind_func = ind_func_expr(w=w, Pspace=Pspace) # interpolated to CG1 plot(ind_func, interactive = True, title = 'ind func created with an expre') K_Func = interpolate(K_1, Pspace) # control plot(K_Func, interactive = True, title = 'old K ') # old K K_Func_new = K_update(ind_func, K_Func) plot(K_Func_new, interactive = True, title = 'K updated') # updated K capping(K_Func_new) K_capped = capping(K_Func_new) plot(K_capped, interactive = True, title = 'K capped') # Test 1 contionued with more calculations