Derivatives at nodes

10 months ago by
Hi there,

To calculate the derivatives in Fenics I use
f = Expression('exp(-x[0]-t)',t=1,degree=1)

f_fun = interpolate(f,V)
df_num = Function(V)
df_num = project(Dx(f_fun,0),V)

Does somebody know how to get the function derivatives at the nodes in a non Fenics language? I'm asking because multiplying the nodal values by the derivative of the shape functions is not working in my case. I really appreciate your comments!!

1. FEniCS isn't a language,

2. "multiplying the nodal values by the derivative of the shape functions" doesn't seem to make any sense, and

3. "get[ing] the function derivatives at the nodes" is the only place that we can "get" any calculation on a finite-element mesh.

However, I don't believe the post deserves a down vote, because we all want to learn and some of us want to help.  So, sorry Ruben for the person who down voted you, and keep up the good work cause this website would be nothing without people just like you.
written 10 months ago by pf4d 
Thank you so much for your answer, maybe if I explain a little better what I need, someone would help me.

In FEM if you need the derivative of a function

$\frac{\partial u}{\partial x}=u_1\frac{\partial\phi_1}{\partial x}+u_2\frac{\partial\phi_1}{\partial x}+u_3\frac{\partial\phi_1}{\partial x}+u_4\frac{\partial\phi_1}{\partial x}$ux =u1ϕ1x +u2ϕ1x +u3ϕ1x +u4ϕ1x

As I'm using isoparametric elements, then first, I calculate the derivative of the shape functions in the gaussian points and multiply by the jacobian to transform to physical coordiantes.

That gives me the derivative at the gaussian points, but if I want the derivatives at the nodes should I have to do the calculation at points [-1,-1], [-1,1],  [1,1], [1,-1]?

I'm aware that Fenics is a language, a very powerful one, but I can not see every step and I need to do the calculations in Fortran. The above is just an example, my idea is to get the numerical values as input, calculate the derivative and then compare with the analytical.

This one is a community very knowledgeable in FEM so maybe someone could give me advice, a reference or something.

written 10 months ago by Ruben Gonzalez 
can you explain the difference between a Gauss point and a node?  And also, when quadrature is required?
written 10 months ago by pf4d 
hold the phone, i'm reading chapter 9 of zienkiewicz and taylor (2005).
written 10 months ago by pf4d 
So, let me get this straight:  you are wanting to code the finite-element method by hand, and want to verify your answers against FEniCS (which isn't a language btw, its just software; however, UFL, which is the backbone of FEniCS, is a language)?
written 10 months ago by pf4d 
Yes, I'm using fenics to ver ify my code. But I'm having troubles with the derivative.
written 10 months ago by Ruben Gonzalez 
perhaps this will help you:

once again, thanks MiroK!
written 10 months ago by pf4d 

1 Answer

10 months ago by
sure, that's easy!
  \frac{\mathrm{d}}{\mathrm{d} x} \exp\left( - x - t \right) = - \exp\left(-x -t\right),
so the code you want is

f        = Expression('exp(-x[0]-t)',  t=1, degree=1)
dfdx     = Expression('-exp(-x[0]-t)', t=1, degree=1)

f_fun    = interpolate(f,    V)
dfdx_fun = interpolate(dfdx, V)

if you want to automate it, take a look at SymPy!

for a great example by MiroK!

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

Similar posts:
Search »