Extension to more complex structures of a variational formulation of the capacitance problem