How can I ofstream the values of macros in my code?

I need to be ofstream of the values of the macro following as
macro Gradient(u) [dx(u), dy(u)] //
macro Divergence(ux, uy) (dx(ux) + dy(uy)) //
macro UgradV(ux,uy,vx,vy) [ [ux,uy]'[dx(vx),dy(vx)] , [ux,uy]'[dx(vy),dy(vy)] ]//
macro traction(ux,uy) [(2*dx(ux)-p)*N.x+(dx(uy)+dy(ux))N.y,(2dy(uy)-p)*N.y+(dx(uy)+dy(ux))*N.x]

How can I do it? is it possible?
Thank you


I just want to print the values of traction macros on the boundary of the domain. But it contains N.x and N.y unit outward vectors and it depends on u and p. how can I print out the values of traction vectors? Output of my problem is ux,uy, and p. I want to calculate traction(tx(u,p),ty(u,p)) on the boundary of domain.
problem S ([ux, uy, p ],[vx, vy, q])
= int2d(Th)(Mu * (Gradient(ux)’ * Gradient(vx)
+ Gradient(uy)’ * Gradient(vy))
- p * Divergence(vx, vy)
- Divergence(ux, uy) * q)
-int1d(Th, Inlet, Outlet, Wall)(
+ on(Inlet, ux=uIn, uy=0.)
+ on(Wall, ux=0., uy=0.);

problem LinNS([ux1,uy1,dp],[vx,vy,q]) =
+ Gradient(uy1)‘Gradient(vy))
+ UgradV(ux1,uy1, ux, uy)'
+ UgradV(ux,uy,ux1,uy1)’
- Divergence(ux1,uy1)q - Divergence(vx,vy)dp)
-int2d(Th)(UgradV(ux,uy, ux, uy)'
-int1d(Th, Inlet, Outlet, Wall)(
+on(Inlet, ux1=uIn, uy1=0.)
+on(Wall, ux1=0.,uy1=0.);

Essentially, you want to export the valued of a scalar/vectorial FE space on the boundaries. I think you could use the same method as the one discussed in this post. To calculate the traction vector, you can just specify a FE field with the normal vectors - something similar is explained here.

1 Like