- Thank you received: 0
High RAM usage
4 years 2 weeks ago - 4 years 2 weeks ago #3304
by rgs
High RAM usage was created by rgs
Hello,
I am trying to run what should be a fairly simple simulation. My code is given below:
This is a modified version of the Stokes part of the Navier-Stokes tutorial ( ngsolve.org/docu/latest/i-tutorials/unit...es/navierstokes.html ). I am not trying to simulate a flow - this is a corollary for an acoustic problem.
The script runs, but if I increase the order (k) beyond 3 or if I decrease the element size any further, my workstation (which has 96GB RAM) runs out of memory and NGSolve closes with the message "Killed". I am able to run the same simulation with the same geometry on OpenFOAM without it requiring nearly as much RAM. I know that OpenFOAM uses FVM and so this is an apples to oranges comparison, but surely, the simulation shouldn't be taking so much RAM. Am I doing something wrong?
I am trying to run what should be a fairly simple simulation. My code is given below:
Code:
from netgen.csg import *
# Defining solid
sphere=Sphere(Pnt(0,0,0),0.55).bc('FSI')
pX=Plane(Pnt(0.5,0,0),Vec(1,0,0))
nX=Plane(Pnt(-0.5,0,0),Vec(-1,0,0))
pY=Plane(Pnt(0,0.5,0),Vec(0,1,0))
nY=Plane(Pnt(0,-0.5,0),Vec(0,-1,0))
pZ=Plane(Pnt(0,0,0.5),Vec(0,0,1))
nZ=Plane(Pnt(0,0,-0.5),Vec(0,0,-1))
Zielinski=sphere*pX*nX*pY*nY*pZ*nZ
# Making geometry from solid
geo=CSGeometry()
geo.Add(Zielinski.mat("domain"), bcmod=[(pX,"xplus"),(nX,"xminus"),(pY,"yplus"),(nY,"yminus"),(pZ,"zplus"),(nZ,"zminus")])
# Marking periodic surfaces
geo.PeriodicSurfaces(pX,nX)
geo.PeriodicSurfaces(pY,nY)
geo.PeriodicSurfaces(pZ,nZ)
# Meshing
from ngsolve.comp import Mesh
netgenMesh=geo.GenerateMesh(maxh=0.05)
mesh = Mesh(netgenMesh) # Converting netgen mesh to ngsolve mesh
Draw (mesh)
k = 3
velocityFiniteElementSpace = Periodic(VectorH1(mesh, order=k, dirichlet="FSI")) #discrete velocity space
pressureFiniteElementSpace = Periodic(H1(mesh, order=(k-1), dirichlet="FSI")) #discrete pressure space
productSpace = FESpace([velocityFiniteElementSpace,pressureFiniteElementSpace])
(trialFunction1,trialFunction2), (testFunction1,testFunction2) = productSpace.TnT()
e = CoefficientFunction( (1,0,0) ) # conservative source flux in COMSOL
LHS = BilinearForm(productSpace)
LHS += (InnerProduct(grad(trialFunction1),grad(testFunction1))-div(trialFunction1)*testFunction2-div(testFunction1)*trialFunction2)*dx
LHS.Assemble()
RHS = LinearForm(productSpace)
RHS += SymbolicLFI(e*testFunction1)
RHS.Assemble()
gfu = GridFunction(productSpace)
inv = LHS.mat.Inverse(freedofs=productSpace.FreeDofs(), inverse="umfpack")
res = RHS.vec.CreateVector()
res.data = RHS.vec - LHS.mat*gfu.vec
gfu.vec.data += inv * res
Redraw()
velocity = CoefficientFunction(gfu.components[0:2][0])
This is a modified version of the Stokes part of the Navier-Stokes tutorial ( ngsolve.org/docu/latest/i-tutorials/unit...es/navierstokes.html ). I am not trying to simulate a flow - this is a corollary for an acoustic problem.
The script runs, but if I increase the order (k) beyond 3 or if I decrease the element size any further, my workstation (which has 96GB RAM) runs out of memory and NGSolve closes with the message "Killed". I am able to run the same simulation with the same geometry on OpenFOAM without it requiring nearly as much RAM. I know that OpenFOAM uses FVM and so this is an apples to oranges comparison, but surely, the simulation shouldn't be taking so much RAM. Am I doing something wrong?
Last edit: 4 years 2 weeks ago by rgs.
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
4 years 2 weeks ago #3305
by christopher
Replied by christopher on topic High RAM usage
Hi,
With order 3 you already have ~500k dofs on this mesh and direct solvers will get expensive. With order 4 you get ~1.1 mio dofs and a denser matrix . This is the region where you have to start using iterative methods.
You could save dofs and increase accuracy by curving the mesh though:
Best
Christopher
With order 3 you already have ~500k dofs on this mesh and direct solvers will get expensive. With order 4 you get ~1.1 mio dofs and a denser matrix . This is the region where you have to start using iterative methods.
You could save dofs and increase accuracy by curving the mesh though:
Code:
mesh.Curve(5)
Christopher
The following user(s) said Thank You: rgs
Time to create page: 0.108 seconds