# Use of nodal coordinate in weak from equation

**URL:** <https://community.freefem.org/t/use-of-nodal-coordinate-in-weak-from-equation/2195>\
**Category:** General Discussion\
**Created:** [December 20, 2022, 10:32am UTC](https://community.freefem.org/t/use-of-nodal-coordinate-in-weak-from-equation/2195 "2022-12-20T10:32:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danmo](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@danmo](https://community.freefem.org/u/danmo)\
**Post date:** [December 20, 2022, 10:32am UTC](https://community.freefem.org/t/use-of-nodal-coordinate-in-weak-from-equation/2195/1 "2022-12-20T10:32:34Z")

</div>

Dear all,

I am solving an elasticity problem, in which a uniform load (Ktensor) is applied to nodal points on the FE mesh. I put a brief version of my code for your reference.  
As you see below, I need to multiply the load (Ktensor) to nodal coordinates. I tried the following options to define nodal coordinates in my weak from equation, and the results are not the same.

```auto
fespace Vh(Th, [P2, P2]);
Vh [u1, u2]; //unknowns (displacement fluctuations)
Vh [v1, v2]; //test functions (virtual displacement)
macro epsilon(u1,u2) [dx(u1), dy(u2), dx(u2)+dy(u1)] //EOM // strain vector

func Ktensor = [[1., 0.], [0., 0.], [0., 0.]]; // applied load

// >>> Option 1:

Vh [X,Y] = [x, y];

solve Elastic([u1, u2], [v1, v2]) = int2d(Th)(epsilon(v1,v2)'*C*epsilon(u1,u2)) + int2d(Th)(epsilon(v1,v2)'*C*(Ktensor*[X,Y])) ;

// >>> Option 2:

macro coord [x, y] // EOM

solve Elastic([u1, u2], [v1, v2]) = int2d(Th)(epsilon(v1,v2)'*C*epsilon(u1,u2)) + int2d(Th)(epsilon(v1,v2)'*C*(Ktensor*coord)) ;

```

In the above, C is the elastic matrix of the material, and the only difference in the problem formulation is the way that nodal coordinates are defined. But the results are different.

Can anyone help me understand what is the proper way of defining nodal coordinates in my problem?

Thank you !

---

<div class="post-metadata">

**Author:** ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)\
**Post date:** [December 20, 2022, 12:49pm UTC](https://community.freefem.org/t/use-of-nodal-coordinate-in-weak-from-equation/2195/2 "2022-12-20T12:49:59Z")

</div>

> [@danmo](#):
>
> `Vh [X,Y] = [x, y];`

Naively I would say that here you use `P2` and not `P1`. `P1` elements are determined by values at the vertices of triangle while `P2` are defined by vertices and mid-edges…

---

<div class="post-metadata">

**Author:** ![miguelpicos](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@miguelpicos](https://community.freefem.org/u/miguelpicos)\
**Post date:** [December 20, 2022, 3:48pm UTC](https://community.freefem.org/t/use-of-nodal-coordinate-in-weak-from-equation/2195/3 "2022-12-20T15:48:43Z")

</div>

In the first case you are using a fespace function that aproximates the [x,y] field and in the second one you are using the exact field so, in the numerical integration, results can differ from one to the other.
