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

Refining the mesh with prescribed vertices

0 votes

Hi, I have realized that when I am creating meshes (using mshr.generate_mesh) I have then problem with description of boundary. I mean, for example, I am not able to generate such mesh that have a vertex exactly in a point where inlet part of boundary and noslip part of boundary are crossing. The consequence is that I have between those part one element that is without any condition (i.e. there is implicitly a zero Neumann).

Let me ilustrate it with the following simple code

from dolfin import *
from mshr import *

# Define Domain
geo = Rectangle(Point(0.0,0.0),Point(5.0,5.0))

# Prepare domain labels    
inletRadius     = 0.5
INmid       = Point(2.5,5.0)

def dist(mid,x):
    dx = mid[0] - x[0]
    dy = mid[1] - x[1]
    return sqrt(dx*dx + dy*dy)

def inlet(x):   
    if ( near(x[1],5.0) and  dist(INmid,x) < inletRadius+DOLFIN_EPS ): 
        return True
    else:
        return False

def noslip(x):
    if ( not inlet(x) ) \
    and (   near(x[0],0.0) or near(x[0],5.0)\
        or near(x[1],0.0) or near(x[1],5.0) ):
        return True
    else:
        return False

# Build mesh    
mesh = generate_mesh(geo, 10)

# Boundary description
bndry   = FacetFunction("size_t", mesh)

noV     = AutoSubDomain(lambda x,bndry: bndry and noslip(x) )
inletV      = AutoSubDomain(lambda x,bndry: inlet(x) )

noV     .mark(bndry,1)
inletV      .mark(bndry,2)

plot(bndry,interactive=True)

I.e. in this example I would like to somehow enforce the mesh generator to use a vertex (2.0,5.0) and (3.0,5.0). Then I would have (at least i hope) a complete description of boundary in a way I wanted it to be.

Any suggestions please?

asked Jun 26, 2015 by Ianx86 FEniCS User (1,050 points)
...