### Derivatives at nodes

168

views

1

Hi there,

To calculate the derivatives in Fenics I use

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!!

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!!

Community: FEniCS Project

### 1 Answer

0

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

\[

\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!

https://fenicsproject.org/qa/9175/possible-differentiate-expression-respect-user_parameter

for a great example by MiroK!

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

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.

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}$∂

u∂x=u_{1}∂ϕ_{1}∂x+u_{2}∂ϕ_{1}∂x+u_{3}∂ϕ_{1}∂x+u_{4}∂ϕ_{1}∂xAs 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.

https://fenicsproject.org/qa/8394/how-to-evaluate-higher-derivative-of-a-function-at-a-point

once again, thanks MiroK!