Confused about the data structure using in Fenics, like what is VectorFunctionSpace really like?


197
views
-1
4 months ago by
Totally a beginner at FEniCs, so I am quite confused about what does FEniCS mean for the following examples

>>> mesh = UnitSquareMesh(2,2)
>>> V = FunctionSpace(mesh,'P',2)
>>> Q = FunctionSpace(mesh,'P',1)
>>> W = VectorFunctionSpace(mesh,"Lagrange",2)
>>> print W
<Function space of dimension 50 (<Lagrange vector element of degree 2 on a <Domain built from <triangle cell in 2D> with label dolfin_mesh_with_id_0>: 2 x <CG2 on a <Domain built from <triangle cell in 2D> with label dolfin_mesh_with_id_0>>>)>
>>> print V
<Function space of dimension 25 (<CG2 on a <Domain built from <triangle cell in 2D> with label dolfin_mesh_with_id_0>>)>
>>> print Q
<Function space of dimension 9 (<CG1 on a <Domain built from <triangle cell in 2D> with label dolfin_mesh_with_id_0>>)>
>>> plot(V)​

I could imagine that Q has dimension 9 is because of 9 vertices? but what about 25 for V and 50 for W?

Also I once  want to found the boundary nodes by

>>> def boundary(x, on_boundary):
...     return on_boundary
... 
>>> bc=boundary
>>> print bc
<function boundary at 0x7fc7104932a8>

when I want to check what information contains in bc, it shows <function boundary at 0x7fc7104932a8>, which I have no idea how to use this information...

As well as other function spaces like when I interpolate, and what I got after solve a PDE, what do those f_12,f_31,v_1,v_0 mean .....Sorry to be troublesome here, and I think there are more similar structure like this that I don't know how to use......

>>> u_D = Expression('1 + x[0]*x[0] + x[1]*x[1]',
...                  degree=2)
>>> print u_D
f_12

>>>solve(self.A1, self.u_.vector(), self.b1, 'bicgstab', 'hypre_amg')
>>> print self.u_
f_31

>>> mesh = UnitSquareMesh(2,2)
>>> V = FunctionSpace(mesh,'P',1)
>>> u = TrialFunction(V)
>>> v = TestFunction(V)
>>> print u 
v_1
>>> print v
v_0


Thanks for reading to here, and the last thing is... after I solve the Navier-Stokes equation with VectorFunctionSpace W mentioned above, and got the output of the velocity like this 
[ 0.13574608 0.13574609 0.08672074 0.0867046 0.08670469 0.08672081
0.16026276 0.16026278 -0.04619293 -0.04619698 -0.04619677 -0.04619277
0.089828 0.08982803 -0.0117363 -0.01173628 0.22652239 0.22652233
0.11595966 0.11603627 -0.17270809 -0.17274629 0.11603613 0.11595949
0.08982807 0.08982807 0.22652242 0.22652243 -0.17274639 -0.17270802
0.08670454 0.08672064 0.11603618 0.11595965 -0.17274629 -0.17270798
0.08672065 0.0867046 0.16026281 0.16026274 0.1159595 0.11603611
-0.17270802 -0.17274634 0.13574614 0.13574608 -0.04619696 -0.04619295
-0.04619293 -0.0461968 ]
what does this means? the first two [ 0.13574608 0.13574609 ] is the velocity of the first element of our mesh?

Thanks....
Community: FEniCS Project

2 Answers


3
4 months ago by
Hello,

I agree with Ovais. It is better if you read the related chapters from the manual.

Regarding of your first question: Q,V and W represents your FE space, so they are degree of freedoms. For Q since you are using linear tetra elements it is 9, for V since the element order is quadratic then you have 25 DOF. W (VectorFunctionSpace) represents the vectorial quantities (not scalar). Since you are dealing with 2D case, it has 50 DOF (25x2).
yeah thanks, I understand that 50 is because of the vectorial quantity so there 25*2, but I just can't imagine why there is 25 DOF for mesh = UnitSquareMesh(2,2)?  and why does dof matters so much here?
written 4 months ago by wanting liu  
1

The dimension 25 for your space Q is the result of your choice of second order, i.e. quadratic shape functions. For quadratic shape functions you need more information than for linear ones.

What do you mean by "why does dof matters so much here?"?
The degrees of freedom essentially determine the size of the linear system you have to solve in the end.

I'd really suggest to read into a book or just lecture notes about the finite element method (but not something written by engineers with only structural mechanics in mind!)

written 4 months ago by klunkean  
make sense...it is just for me, 25 should be 25=f(n), where n is the number of vertices, n=9 here, and I can't imagine what is the f(x) like here, or I don't really need to know how did they get dofs?
written 4 months ago by wanting liu  
@liu:
If you draw your 2x2 unit square with diagonals, you will have 9 node points for the vertices (which is clear), thus the 9 dofs for linear elements.  For quadratic elements, you have additional degrees of freedom, which are the values at midpoints on each line connecting vertices (see any standard FE text, per above), over the set of triangles.  That adds 16 points.  Thus you can draw the triangles and add midpoint dofs to find f(n), or there is maybe a formula.
written 4 months ago by jwinkle  
1
got it now, thanks..
written 3 months ago by wanting liu  
1
4 months ago by
Ovais  
These are too many questions .... regarding your question related to the title/subject of this question , I would recommend that you go through dofs (degree of freedom) and dofmap. A good explanation with code is available in fenics manual (Solving PDEs in minutes) section 5.4.1  page 123
Thanks, I am reading the manual now. but what about the f_12,f_39,v_0,v_1, how to find the information about them, or we don't?
written 4 months ago by wanting liu  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »