# Add a nodal value of unknown in weak form

**URL:** <https://fenicsproject.discourse.group/t/add-a-nodal-value-of-unknown-in-weak-form/7115>\
**Category:** Uncategorized\
**Created:** [November 18, 2021, 8:39am UTC](https://fenicsproject.discourse.group/t/add-a-nodal-value-of-unknown-in-weak-form/7115 "2021-11-18T08:39:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![giannoko](https://avatars.discourse-cdn.com/v4/letter/g/7c8e57/32.png) [@giannoko](https://fenicsproject.discourse.group/u/giannoko)\
**Post date:** [November 18, 2021, 8:39am UTC](https://fenicsproject.discourse.group/t/add-a-nodal-value-of-unknown-in-weak-form/7115/1 "2021-11-18T08:39:42Z")

</div>

Hello,

I have an 1D problem defining in x = [0,1]. The solution of this problem are the velocity u and displacement D along with an extra unknown l defined in space “R”. I concern about the equation of l given by an integral as

l = \int^{1}\_{0} u \ D\_{|x=1} \ dx

where term D\_{|x=1} is the nodal value of D at x = 1.

I made a try by defining the weak form as

`Res = ( l - u*D*ds(1) )*phi*dx`

where ds(1) is integration measurement on x = 1, phi is the basis function and dx is the integration measurement of the whole domain. By writing the above form I get the error

> unsupported operand type(s) for +: ‘Indexed’ and ‘Form’

The question is how can I write this form properly?

---

<div class="post-metadata">

**Author:** ![bleyerj](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/bleyerj/32/6020_2.png) [@bleyerj](https://fenicsproject.discourse.group/u/bleyerj)\
**Post date:** [November 18, 2021, 8:48am UTC](https://fenicsproject.discourse.group/t/add-a-nodal-value-of-unknown-in-weak-form/7115/2 "2021-11-18T08:48:48Z")

</div>

Hi, so you have a mixed function space involving both u, D and an extra scalar l as problem unknowns, is that right ? If so I don’t think that you can easily define the above nonlinear equation as u(x) and D(x=1) involve a product of fields evaluated at different locations. You would have a “non-local” integral kernel which is not natively supported in FEniCS.  
A way around would be to define an extra scalar unknown D1 which we enforce to be equal to D(x=1). Something as follows:

```python
u, D, D1, l = split(Function(V))
u_, D_, D1_, l_ = TestFunctions(V)
# D(x=1)=D1 constraint
c1 = D1_*D*ds(1) - D1_*D1*dx
# l constraint
c2 = l_*(l-u*D1)*dx

```

---

<div class="post-metadata">

**Author:** ![giannoko](https://avatars.discourse-cdn.com/v4/letter/g/7c8e57/32.png) [@giannoko](https://fenicsproject.discourse.group/u/giannoko)\
**Post date:** [November 18, 2021, 9:25am UTC](https://fenicsproject.discourse.group/t/add-a-nodal-value-of-unknown-in-weak-form/7115/3 "2021-11-18T09:25:43Z")

</div>

Thanks for your reply. Yes I use a mixed function space. I will follow your instructions, thanks.
