# Integration of a gradient of function

**URL:** <https://fenicsproject.discourse.group/t/integration-of-a-gradient-of-function/7428>\
**Category:** I/O\
**Created:** [January 6, 2022, 7:32pm UTC](https://fenicsproject.discourse.group/t/integration-of-a-gradient-of-function/7428 "2022-01-06T19:32:08Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![Alberto\_Lolli](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@Alberto\_Lolli](https://fenicsproject.discourse.group/u/Alberto_Lolli)\
**Post date:** [January 7, 2022, 12:17pm UTC](https://fenicsproject.discourse.group/t/integration-of-a-gradient-of-function/7428/11 "2022-01-07T12:17:28Z")

</div>

```auto
w = Function(W)
solve(a == L, w, bcs)
u, p = w.split()
def symgrad(u, i):
    return sym(grad(u))

K = np.zeros((3,3))
for i in range(3):
    for j in range(3):
        K[i,j] = assemble(2*mu*inner(symgrad(u, i), symgrad(u, j))*dx)
        print("K_ij =", K[i,j])

```

This is the minimal code I think, what i would to do is to use the output u from the solver and then integrate over dx the formula above. You think this way is appropriate for the forum?

---

_[View the full topic](https://fenicsproject.discourse.group/t/integration-of-a-gradient-of-function/7428)._
