Hi!
I am trying to simulate the incompressible Navier-Stokes equation throughout a pipe using Chorin's projection method as the solver, so my mesh (generated with Gmsh) consists of two cylinders, one inside the other one, and with a longitude of 1 in the z-axis. I just want to study the velocity and the pressure in the inner cylinder (with radius r2), so I created a subdomain and then defined new measures so later in the solver I could integrate just in that inner cylinder:
r1=1.0 #radius of big cylinder
r2 = 0.5715 #radius of small cylinder
# Set parameter values
dt = 0.001 #time-step
T = 0.1 #length of time interval
nu = 6.602E-7 #kinematic viscosity
# Define pressure boundary conditions
p_in = Constant(10.0)
# Define velocity boundary conditions
noslip = Constant((0.0, 0.0, 0.0)) #With 0 < z < 1
# bottom z=0
bottom = AutoSubDomain(lambda x, on_boundary: on_boundary and near(x[2], 0.) and (x[0]**2 + x[1]**2 < r2**2))
# boundary of inner cylinder
insidewall = AutoSubDomain(lambda x, on_boundary: near(x[0]**2 + x[1]**2, r2**2))
# Define boundary conditions
bc3 = DirichletBC(Q, p_in, bottom)
bc1 = DirichletBC(V, noslip, insidewall, "pointwise")
bcp = [bc3]
bcu = [bc1]
# inner pipe
class Pipe(SubDomain):
def inside(self, x, on_boundary):
return ((x[0]**2 + x[1]**2) < r2**2)
pipe = Pipe()
# Initialize mesh function for interior domains
domains = CellFunction("size_t", mesh)
domains.set_all(0)
pipe.mark(domains, 1)
# Define new measures associated with the interior domains
dx = Measure("dx")[domains]
# Create functions
u0 = Function(V)
u0 = interpolate(Constant((0., 0., 0.)), V)
u1 = Function(V)
p1 = Function(Q)
# Define coefficients
k = Constant(dt)
f = Constant((0., 0., 1.))
# Tentative velocity step
F1 = (1/k)*inner(u - u0, v)*dx(1) + inner(grad(u0)*u0, v)*dx(1)
+ nu*inner(grad(u), grad(v))*dx(1) - inner(f, v)*dx(1)
a1 = lhs(F1)
L1 = rhs(F1)
# Pressure update
a2 = inner(grad(p), grad(q))*dx(1)
L2 = -(1/k)*div(u1)*q*dx(1)
# Velocity update
a3 = inner(u, v)*dx(1)
L3 = inner(u1, v)*dx(1) - k*inner(grad(p1), v)*dx(1)
but I am getting the following error
*** Error: Unable to set given rows to identity matrix.
*** Reason: some diagonal elements not preallocated (try assembler option keep_diagonal).
*** Where: This error was encountered inside PETScMatrix.cpp.
*** Process: unknown
***
*** DOLFIN version: 1.4.0
*** Git changeset: unknown
What am I doing wrong?
Thank you in advance!