Infinite parallel apply

You should interpolate u_n from the first mesh to the second mesh, as shown below:


u_n.set_allow_extrapolation(True)
# Create mesh and define function spaces
mesh = UnitSquareMesh(100, 100)
V = VectorFunctionSpace(mesh, 'P', 1)
Q = FunctionSpace(mesh, 'P', 1)
u_n_2 = interpolate(u_n, V)
# Define boundaries
inflow  = 'near(x[0], 0)'
outflow = 'near(x[0], 1)'
walls   = 'near(x[1], 0) || near(x[1], 1)'

if comm.rank == 0:
    print('Define bc for two work')

# Define boundary conditions
bcu_noslip  = DirichletBC(V, Constant((0, 0)), walls)
bcu_inflow  = DirichletBC(V, u_n_2, inflow)
bcp_outflow = DirichletBC(Q, Constant(0), outflow)
bcu = [bcu_noslip, bcu_inflow]
bcp = [bcp_outflow]

then your code should run in both serial and parallel.

Please note that you should put more effort into reducing your example before you post. For instance, you do not need 500 time steps (one should suffice), and you should stop the code at the point where you obtain an error message.
In general, I would suggest you have a look at the examples of minimal code examples in:

1 Like