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

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