implement mirror_grid
implement mirror_stand
major refactor: move initialization code into capi.c

This change helps to cement the purpose of capi: it handles all the functions
and data used to communicate with the C# frontend. It splits the
initialization routines into smaller subroutines, and allows the formally global
types main_grid, main_domain, and main_assembly to be the static property
of capi.c.