# Elasticity Matrix

Is it possible to use a matrix for the E value in Elasticity problem where the value at each cell of the matrix corresponds to the value of E of a single node of the designed mesh?

No problem, You have just to set E is a FE element function P0

``````mesh Th= ...
fespace Ph(Th,P0); // constant par triangle
Ph E;
// def E on each element
real sigma = 0.29;
real gravity = -0.05;
func  mu = E/(2*(1 + sigma));
func  lambda = E*sigma/((1 + sigma)*(1 - 2*sigma));

// Fespace
fespace Vh(Th, [P2, P2]);
Vh [uu, vv], [w, s];

// Macro
real sqrt2 = sqrt(2.);
macro epsilon(u1, u2) [dx(u1), dy(u2), (dy(u1) + dx(u2))/sqrt2] // EOM
macro div(u, v) (dx(u) + dy(v)) // EOM

solve Elasticity ([uu, vv], [w, s], solver=sparsesolver)
= int2d(th)(
lambda*div(w, s)*div(uu, vv)
+ 2.*mu*(epsilon(w, s)' * epsilon(uu, vv))
)
- int2d(th)(gravity*s)
+ on(1, uu=0, vv=0)
;

``````
1 Like

It works great but I have one more issue. I’m gonna use this code inside a loop and I want to be able to change the E value on certain nodes with each loop. I don’t have the equation with which the Elasticity change will be decided yet but the issues that I see will come forward soon are that I need to extract the E space at the end of the program and change some values of the E space at the start of the program.

Defined the problem in the loop and change E in the loop no problem !!!

Which command to you suggest using to change the node values? I tried using real or func and as I was certain it didn’t work.

You can change the finite element function E in the loop

reset all E with

``````for (int i = 0 ; i< niter;++i)
{
E= abs(x*i+y); // stupide exemple
``````

or

``````E[][i] = 35; // change the value in element i => niter <= Th.nt;

``````

}

1 Like