3D grid?

Hello!

How can I make a grid follow a surface (or set of surfaces) with 90° angles? I tried doing a custom grid on a boundary surface with the divide domian2 and isotrim, but I couldn't make it work.

Thank you for your help! Grasshopper and rhino files attached.