Example #1
0
# 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,

# step 7: run fluid trough it
U, P, K_Funcs = stokes_solver(w=w, mesh=mesh, Vspace=Vspace, Pspace=Pspace, Wspace=Wspace, K_array=K_capped, n=n)
Example #2
0
def iterative(K_1):

	U, P, K_Func = stokes_solver(w=w, mesh=mesh, Vspace=Vspace, Pspace=Pspace, Wspace=Wspace, DG1=Pspace, K_array=K_1, n=n )


	# Verification: 

	# alternative 1:
	# construct an analytical solution 
	# method of manufactored solutions 
	# first come up with a random slution
	# plut into PDE 
	# doesnt solve original homogeneous PDE exactly 
	# residual is then considered the source term 
	
		
	# alternative 2:
	# really fine mesh , solve a blind model on that mesh 
	# this is reference(considered exact) solution
	
		
		
	# actual convergence test(after alt 1 or 2):
	# mesh refinement test refining the mesh see if rate of convergence goes to 2.
	# mesh.refine() OR refine(mesh)
	# give a mesh, creates new mesh that is finer. 
	# for each mesh solve PDE
	# compute difference of u_e - u
	# in a norm 
	# for each mesh 

	# start with a very coarse one 
	# after halfin 4 times,gives a really fine mesh and solving will get slow. 

	# example:
	# for p2, half the mesh size 
	# error reduction of factor 4 

	# do it at the beginning

	# Magne: 
	# WSS skal naturlig veare i DG1.
	# og det fungerte aa bytte Pspace m DG1 
	
	wss = WSS(U=U, DG1= DG1) #Pspace) #,interesting_domain = interesting_domain_proj)
	bdry_ = bdry(K_Func = K_Func, DG1 = DG1)

	# Simon: 
	# DG1 osgaa inneholder CG1 


	ind_f = ind_func(bdry=bdry_, WSS = project(wss, DG1), DG1 = DG0, interesting_domain = interesting_domain_proj)
	K_new = K_update(ind_func = ind_f, K_Func = K_Func)
	
	#wss_bdry = WSS_bdry(K_Func, DG0, WSS)


	plot(K_new, interactive = True, title = 'K new ')
	K_capped = capping(K_new)
	plot(K_capped, interactive = False, title = 'K capped')
	stokes_solver(w=w, mesh=mesh, Vspace=Vspace, Pspace=Pspace, Wspace=Wspace, K_array=K_capped, n=n )

	return K_capped 
Example #3
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 
U, P, K_Func = stokes_solver(w=w, mesh=mesh, Vspace=Vspace, Pspace=Pspace, Wspace=Wspace, K_array=K_capped, n=n )
WSS = WSS(U=U, ShearStressSpace= ShearStressSpace)


WSS_bdry = WSS_bdry(K_Func=K_Func, DPspace=DPspace, WSS=WSS)