def _prepare_grids(self):
        """
        depending on the type of grid (rectangular or triangle), prepare grids
        or triangle lists

        TODO: We want some nice way of not needing to know in the future if we
              loaded triangles or quadratic elements.
        """
        if(self.header['element_infos'][0, 2] == 3):
            print('Triangular grid found')
            self.grid_is_rectangular = False

            triangles = self.element_data[3]
            triangles = [x.nodes for x in triangles]
            # python starts arrays with 0, but elem.dat with 1
            triangles = np.array(triangles) - 1
            self.elements = triangles
            tri_x = self.nodes['presort'][triangles, 1]
            tri_z = self.nodes['presort'][triangles, 2]
            self.grid = {}
            self.grid['x'] = tri_x
            self.grid['z'] = tri_z

        else:
            print('Rectangular grid found')
            self.grid_is_rectangular = True
            quads_raw = [x.nodes for x in self.element_data[8]]
            quads = np.array(quads_raw) - 1
            self.elements = quads
            quads_x = self.nodes['presort'][quads, 1]
            quads_z = self.nodes['presort'][quads, 2]
            self.grid = {}
            self.grid['x'] = quads_x
            self.grid['z'] = quads_z

            # calculate the dimensions of the grid
            try:
                self.calculate_dimensions()
            except Exception as e:
                self.nr_nodes_x = None
                self.nr_nodes_z = None
                self.nr_elements_x = None
                self.nr_elements_z = None
        self.nr_of_elements = self.grid['x'].shape[0]