2.6 Stokes equation

More
2 years 8 months ago #4207 by csantia4
2.6 Stokes equation was created by csantia4
docu.ngsolve.org/latest/i-tutorials/unit-2.6-stokes/stokes.html

Good morning, 

I was trying to copy this code to run it. But it does not give me the same results. I pinpointed that my problem starts when I "Set inhomogeneous Dirichlet boundary condition only on inlet boundary". I await an answer.

Thank you very much!
More
2 years 8 months ago #4208 by hvwahl
Replied by hvwahl on topic 2.6 Stokes equation
Hi,

could you please specify the issue with a bit more detail? When I download the notebook and run it locally, I get the same results as on the website. Maybe there's just a copy/paste error sliced in somewhere?

Best, Henry
More
2 years 8 months ago - 2 years 8 months ago #4212 by csantia4
Replied by csantia4 on topic 2.6 Stokes equation
Sorry, I keep trying to upload the code or a picture of the result, but it does not allow me. This is the code from the website that I copied over. I ran it in the terminal, but the Netgen solution result was a grey figure, which is not what is displayed in the site. Am I missing something?

I think it might be because of this: "Including OpenCascade geometry kerneloptfile ./ng.opt does not exist - using default values"
Thank you for your time!


from ngsolve import *
from ngsolve.webgui import Draw
from netgen.geom2d import SplineGeometry


geo = SplineGeometry()
geo.AddRectangle( (0, 0), (2, 0.41), bcs = ("wall", "outlet", "wall", "inlet"))
geo.AddCircle ( (0.2, 0.2), r=0.05, leftdomain=0, rightdomain=1, bc="cyl")
mesh = Mesh( geo.GenerateMesh(maxh=0.05))
mesh.Curve(3)
Draw (mesh)


V = H1(mesh, order=2, dirichlet="wall|inlet|cyl")
Q = H1(mesh, order=1) 
X = V*V*Q 


ux,uy,p = X.TrialFunction()
vx,vy,q = X.TestFunction()


div_u = grad(ux)[0]+grad(uy)[1]
div_v = grad(vx)[0]+grad(vy)[1]

a = BilinearForm(X)
a += (grad(ux)*grad(vx)+grad(uy)*grad(vy) + div_u*q + div_v*p) * dx
a.Assemble()


#Set inhomogeneous Dirichlet boundary condition only on inlet boundary:

gfu = GridFunction(X)
uin = 1.5*4*y*(0.41-y)/(0.41*0.41)
gfu.components[0].Set(uin, definedon=mesh.Boundaries("inlet"))
velocity = CoefficientFunction(gfu.components[0:2])
Draw(velocity, mesh, "vel")
SetVisualization(max=2)


res = gfu.vec.CreateVector()
res.data = -a.mat * gfu.vec 
inv = a.mat.Inverse(freedofs=X.FreeDofs(), inverse="umfpack")
gfu.vec.data += inv * res
Draw(velocity, mesh, "vel")
Last edit: 2 years 8 months ago by csantia4.
More
2 years 8 months ago #4213 by hvwahl
Replied by hvwahl on topic 2.6 Stokes equation
Hi,

in line 2 of your code, the Netgen GUI Draw is replaced with webgui.Draw. This was needed in the notebook, to do the visualisation in the browser window. You just need to remove this line so that the Netgen GUI does the visualisation and then in Netgen go Visual->Scalar Function -> func (vel) to see the norm of the vector solution in the Netgen GUI.

Best,
Henry
More
2 years 8 months ago #4215 by csantia4
Replied by csantia4 on topic 2.6 Stokes equation
Great, that worked! Thank you!
Time to create page: 0.102 seconds