How can I detect the opening in an open polysurface and then make it in a closed polysurface?
Use the ShowEdges tool set for Naked edges to find them.
Here’s an FAQ for sorting the problems:
https://wiki.mcneel.com/rhino/faqclosedsolids
RemoveAllNakedMicroEdges is a little-known command that fixes many of my issues these days.
That’s a handy command if ShowEdges displays little magenta dots.