On Sat, 7 Nov 2015 15:02:06 +0800 zheng li <[email protected]> wrote: > Dear developer, > > I am using FEniCS to do mixed finite element case. There are > five element spaces in my case and the boundary conditions for space > Vqp and Vu are homogeneous Dirichlet condition. I define the BCs in > my code like following way: > > # Define function spaces > Vqp = VectorFunctionSpace(mesh, "CG", 2) > Vu = FunctionSpace(mesh, "CG", 2) > Vp = VectorFunctionSpace(mesh, "CG", 1) > Vr = FunctionSpace(mesh, "CG", 2) > Vy = VectorFunctionSpace(mesh, "CG", 1) > > W = Vqp * Vu * Vp * Vr * Vy
Here's the problem. In Python FunctionSpace.__mul__ operator cannot be flattened so W is not what you expect but W = (((( Vqp * Vu ) * Vp ) * Vr ) * Vy ) You should do rather W = MixedFunctionSpace([Vqp, Vu, Vp, Vr, Vy]) This will work with DOLFIN <= 1.6. But MixedFunctionSpace is deprecated from future release of DOLFIN 1.7.0, see http://fenicsproject.org/documentation/dolfin/dev/python/demo/documented/stokes-iterative/python/documentation.html for a correct solution. Jan > > # Define boundary conditions > u0 = Constant((0.0,0.0)) > u1 = Constant(0.0) > bc0 = DirichletBC(W.sub(0), u0, "on_boundary") > bc1 = DirichletBC(W.sub(1), u1, "on_boundary") > > # Collect boundary conditions > bcs = [bc0, bc1] > > However, error occurred when my code is running. The detail error > infos are > > Traceback (most recent call last): > File "demo_stokes-taylorhood.py", line 49, in <module> > bc0 = DirichletBC(W.sub(0), u0, "on_boundary") > File > "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/fem/bcs.py", > line 128, in __init__ cpp.DirichletBC.__init__(self, *args) File > "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/cpp/fem.py", > line 1140, in __init__ > _fem.DirichletBC_swiginit(self,_fem.new_DirichletBC(*args)) > RuntimeError: > > *** > ------------------------------------------------------------------------- > *** DOLFIN encountered an error. If you are not able to resolve this > issue *** using the information listed below, you can ask for help at > *** *** [email protected] > *** > *** Remember to include the error message listed below and, if > possible, *** include a *minimal* running example to reproduce the > error. *** > *** > ------------------------------------------------------------------------- > *** Error: Unable to create Dirichlet boundary condition. *** > Reason: Illegal value dimension (2), expecting (6). *** Where: > This error was encountered inside DirichletBC.cpp. *** Process: > unknown > > I don’t know what caused this. Is there any wrong with my definition > of BCs? Looking forward to your reply. Thanks a lot. > > > Best wishes, > > > —Zheng > > > _______________________________________________ fenics mailing list [email protected] http://fenicsproject.org/mailman/listinfo/fenics
