How to define a 3D vector on a 2D mesh?


107
views
0
3 months ago by
Marcin  
Hello all,
this is rather a newbie question, but what is the correct way of defining a 3D vector on a 2D mesh?
Also, what is the syntax for setting the boundary conditions on such a field? e.g.. if my mesh is in the xy plane and I would like to apply boundary conditions to the tangential components which for a vertical facet would correspond to y and z components?

Thanks for help,
Community: FEniCS Project

2 Answers


1
3 months ago by
Hi,

the following MWE illustrates the functionalities you are looking for

from dolfin import *

mesh = UnitSquareMesh(2,2)

# Use the optional argument 'dim' to specify dimension of vector space
d = 3
V = VectorFunctionSpace(mesh, "CG", 1, dim = d)

# Check if V has correct number of sub-spaces, should be d
print(V.num_sub_spaces())​

# Impose homogeneous Dirichlet BC on y- and z-component of vector
def Gamma(x, on_boundary):
    return on_boundary

bc_y = DirichletBC(V.sub(1), Constant(0), Gamma)
bc_z = DirichletBC(V.sub(2), Constant(0), Gamma)
bcs = [bc_y, bc_z]
Hope this helps.
Thanks,
that is exactly what I needed.
written 12 weeks ago by Marcin  
1
3 months ago by
I'm not sure if I got your question right but
from fenics import *

mesh = UnitSquareMesh(10, 10)
V = VectorFunctionSpace(mesh, 'P', 1, dim=3)

and then

bc = DirichletBC(V.sub(2), Constant(...), 'on_boundary')

hopefully works for you.

Please login to add an answer/comment or follow this question.

Similar posts:
Search »