Although this question has been asked before, my formatting of boundary conditions did not match that of my peers.
I formulated the boundaries for a Stokes-Navier solver in a box, using mesh generated by the BoxMesh function. The region is 1 x 1 x 5. My boundary conditions for no-slip and constant pressure on one face are as follows:
# Load mesh from file
mesh = BoxMesh(0,0,0,1,1,5,12,12,60)
# Define function spaces (P2-P1)
V = VectorFunctionSpace(mesh, "CG", 1, dim=3)
Q = FunctionSpace(mesh, "CG", 1)
# Define trial and test functions
u = TrialFunction(V)
p = TrialFunction(Q)
v = TestFunction(V)
q = TestFunction(Q)
# Set parameter values
dt = 0.01
T = 0.25
nu = 0.01
# Define time-dependent pressure boundary condition
#p_in = Expression("sin(2*pi*t)", t=0.0)
#p_out = Expression("-cos(2*pi*t)", t=0.0)
# Define time-independent pressure boundary condition
p_in = 1
p_out = 0
# Define boundary conditions
noslip = DirichletBC(V,(0, 0, 0),
"on_boundary | \
(x[0] < DOLFIN_EPS | x[1] < DOLFIN_EPS | x[2] < DOLFIN_EPS |\
(x[0] > 1.0 - DOLFIN_EPS | x[1] > 1.0 - DOLFIN_EPS | x[2] > 5.0 - DOLFIN_EPS))")
inflow = DirichletBC(Q, p_in, "x[2] > 5.0 - DOLFIN_EPS")
outflow = DirichletBC(Q, p_out, "x[2] < DOLFIN_EPS")
bcu = [noslip]
bcp = [inflow, outflow]
When I sent the boundary condition to describe pressure, 5.0 is the only value that gives me trouble. I can place a 4 with an inumerable ammount of 9's after it with no problem.
But this is not a solution.
Where am I going wrong?
Is there a way to have just an initial value of that pressure by redefining my function for time-dependent pressure?
Is there a better where to describe my BC's that could be modular for other geometries such as a pipe or a duct from an imported mesh?
I appreciate any advice you can give me!
I have only been coding a couple weeks with only two python tutorials and the FEniCS tutorial under my belt, so please bare with me (: