how to apply Neumann and Dirichlet BCs on the same part of the boundary for a vector problem?

11 weeks ago by
K D  
I have a vector problem and I'd like to apply Dirichlet for one component and Neumann for the other component on the same part of the boundary.  The physical context is linear elasticity.  For example, a standard BC is to constrain the displacement in the normal direction while setting the tangential traction to $0$.  In my understanding, once I specify Dirichlet BCs on the boundary, the test function is set to $0$ there and hence I cannot do this.  Can anyone help me with a code snippet showing how to do this or point me to examples?  Thanks.
Community: FEniCS Project

1 Answer

11 weeks ago by
BCs can be applied to individual components of vector function spaces or mixed elements.  For example, it sounds like the following might be what you're thinking of:

from dolfin import *

mesh = UnitSquareMesh(10,10)
VE = VectorElement("Lagrange",mesh.ufl_cell(),1)
V = FunctionSpace(mesh,VE)

# Constrain normal displacement on two sides:
def boundary1(x, on_boundary):
    return on_boundary and near(x[1],0.0)
bc1 = DirichletBC(V.sub(1), Constant(0.0), boundary1)

def boundary2(x, on_boundary):
    return on_boundary and near(x[0],0.0)
bc2 = DirichletBC(V.sub(0), Constant(0.0), boundary2)

# Solve linear elasticity under gravity loading:
u = TrialFunction(V)
v = TestFunction(V)

eps = 0.5*(grad(u) + grad(u).T)
BULK_MOD = 1.0
I = Identity(2)
sigma = BULK_MOD*tr(eps)*I + 2.0*SHEAR_MOD*(eps - tr(eps)*I/3.0)
f = Constant((0.0,-2.0))

u = Function(V)
solve(inner(sigma,grad(v))*dx == inner(f,v)*dx,

# Plot results:
import matplotlib.pyplot as plt
Thanks!  That's exactly what I wanted (and very quick).
written 11 weeks ago by K D  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »