Hi,
Variable initialization:
fespace Nh(Th, [P1, P1]);
// FEM variables.
Nh [u1, u2], [v1, v2];
So elasticity problem can be solved like this
problem elas([u1,u2],[v1,v2]) =
int2d(Th)(
lam*div(u1,u2)*div(v1,v2)
+2.*mu*( epsilon(u1,u2)'*epsilon(v1,v2) )
)
- int1d(Th, 2)(p * v1)
+ on(4, u1 = 0)
+ on(1, u2 = 0)
;
or equivalently using the variational definition like
varf elas([u1, u2], [v1, v2]) =
int2d(Th)(
lam * div(u1, u2) * div(v1, v2)
+ 2. * mu * ( epsilon(u1, u2)' * epsilon(v1, v2)))
+ on(4, u1 = 0)
+ on(1, u2 = 0)
;
varf l([u1, u2], [v1, v2]) = int1d(Th, 2)(loadFraction * p * v1)
+ on(4, u1 = 0)
+ on(1, u2 = 0)
;
matrix K = elas(Nh, Nh); // Stiffness matrix.
real[int] b = l(0, Nh); // External forces and boundary conditions.
real[int] U(K.n);
U = K^-1 * b;
Problem
The first solution results in u1
and u2
being the displacements in x
and y
directions. While the second solution returns a large array with displacements in the form U = [ux1, uy1, .... , uxn, uyn]
.
Running macro over the displacements
macro e(u1, u2) [dx(u1), dy(u2), dy(u1) + dx(u2)] // EOM
works with the displacements u1
and u2
, but not with the array U
.
Question
How can I convert array U
into types of u1
and u2
? Is that possible?