This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Mesh boundaries/ gmsh conversion issues

0 votes

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 (:

asked Jun 4, 2015 by Pudge FEniCS Novice (140 points)
reshown Jun 5, 2015 by Pudge

1 Answer

0 votes

Hallo
If you define your geometry in gmsh you generate properly marked physical lines in 2D, or physical surfaces in 3D corresponding to boundaries. Than using dolfin-convert you will obtain .xml files for the mesh and for the boundary regions that you can import as mesh functions.
hallo
Stefano

answered Jun 5, 2015 by Stefano FEniCS Novice (460 points)

I have been using GMSH and gotten hold of the dolfin-converted and saved it to the file directly where the .msh file I want to convert lies

However, when converting I am given an error message that

Missing data, unable to convert
\ Did you use the version 2.0 of the gmsh file format?

I did use the correct version, I am operating on 2.9.3. My .msh file is valid and of appropriate con straits (i.e. tetrahedral shapes, size, ect.)

An .xml file is created in the process, but it is a file of size dwarfed by my .msh and does not function in my script (42 KB to 833 MB).

Any ideas?

...