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

**URL:** <https://community.freefem.org/t/how-can-i-ofstream-the-values-of-macros-in-my-code/2076>\
**Category:** General Discussion\
**Created:** [October 21, 2022, 12:11pm UTC](https://community.freefem.org/t/how-can-i-ofstream-the-values-of-macros-in-my-code/2076 "2022-10-21T12:11:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gnaganlu](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@gnaganlu](https://community.freefem.org/u/gnaganlu)\
**Post date:** [October 21, 2022, 12:11pm UTC](https://community.freefem.org/t/how-can-i-ofstream-the-values-of-macros-in-my-code/2076/1 "2022-10-21T12:11:23Z")

</div>

I need to be ofstream of the values of the macro following as  
//Macro  
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,(2_dy(uy)-p)\*N.y+(dx(uy)+dy(ux))\*N.x]

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

---

<div class="post-metadata">

**Author:** ![gnaganlu](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@gnaganlu](https://community.freefem.org/u/gnaganlu)\
**Post date:** [October 21, 2022, 1:23pm UTC](https://community.freefem.org/t/how-can-i-ofstream-the-values-of-macros-in-my-code/2076/2 "2022-10-21T13:23:31Z")

</div>

Actually,

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  
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)(   
-Mu\*(traction(ux,uy)'\*[vx,vy]))  
+ on(Inlet, ux=uIn, uy=0.)  
+ on(Wall, ux=0., uy=0.);

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

---

<div class="post-metadata">

**Author:** ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)\
**Post date:** [October 21, 2022, 1:33pm UTC](https://community.freefem.org/t/how-can-i-ofstream-the-values-of-macros-in-my-code/2076/3 "2022-10-21T13:33:27Z")

</div>

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](https://community.freefem.org/t/exporting-boundary-value/2028) post. To calculate the traction vector, you can just specify a FE field with the normal vectors - something similar is explained [here](https://community.freefem.org/t/normal-boundary-condition/341/6).
