Read the nodes from an opened elem.dat file. Correct for CutMcK
        transformations.

        We store three typed of nodes in the dict 'nodes':

            * "raw" : as read from the elem.dat file
            * "presort" : pre-sorted so we can directly read node numbers from
              a elec.dat file and use them as indices.
            * "sorted" : completely sorted as in the original grid (before any
                       CutMcK)

        For completeness, we also store the following keys:

            * "cutmck_index" : Array containing the indices in "presort" to
              obtain the "sorted" values:
              nodes['sorted'] = nodes['presort'] [nodes['cutmck_index'], :]
            * "rev_cutmck_index" : argsort(cutmck_index)

def _read_elem_nodes(self, fid):
        """ Read the nodes from an opened elem.dat file. Correct for CutMcK
        transformations.

        We store three typed of nodes in the dict 'nodes':

            * "raw" : as read from the elem.dat file
            * "presort" : pre-sorted so we can directly read node numbers from
              a elec.dat file and use them as indices.
            * "sorted" : completely sorted as in the original grid (before any
                       CutMcK)

        For completeness, we also store the following keys:

            * "cutmck_index" : Array containing the indices in "presort" to
              obtain the "sorted" values:
              nodes['sorted'] = nodes['presort'] [nodes['cutmck_index'], :]
            * "rev_cutmck_index" : argsort(cutmck_index)
        """
        nodes = {}

        #   # prepare nodes
        #   nodes_sorted = np.zeros((number_of_nodes, 3), dtype=float)
        #   nodes = np.zeros((number_of_nodes, 3), dtype=float)

        # read in nodes
        nodes_raw = np.empty((self.header['nr_nodes'], 3), dtype=float)
        for nr in range(0, self.header['nr_nodes']):
            node_line = fid.readline().lstrip()
            nodes_raw[nr, :] = np.fromstring(
                node_line, dtype=float, sep='    ')

        # round node coordinates to 5th decimal point. Sometimes this is
        # important when we deal with mal-formatted node data
        nodes_raw[:, 1:3] = np.round(nodes_raw[:, 1:3], 5)

        # check for CutMcK
        # The check is based on the first node, but if one node was renumbered,
        # so were all the others.
        if(nodes_raw[:, 0] != list(range(1, nodes_raw.shape[0]))):
            self.header['cutmck'] = True
            print(
                'This grid was sorted using CutMcK. The nodes were resorted!')
        else:
            self.header['cutmck'] = False

        # Rearrange nodes when CutMcK was used.
        if(self.header['cutmck']):
            nodes_cutmck = np.empty_like(nodes_raw)
            nodes_cutmck_index = np.zeros(nodes_raw.shape[0], dtype=int)
            for node in range(0, self.header['nr_nodes']):
                new_index = np.where(nodes_raw[:, 0].astype(int) == (node + 1))
                nodes_cutmck[new_index[0], 1:3] = nodes_raw[node, 1:3]
                nodes_cutmck[new_index[0], 0] = new_index[0]
                nodes_cutmck_index[node] = new_index[0]
            # sort them
            nodes_sorted = nodes_cutmck[nodes_cutmck_index, :]
            nodes['presort'] = nodes_cutmck
            nodes['cutmck_index'] = nodes_cutmck_index
            nodes['rev_cutmck_index'] = np.argsort(nodes_cutmck_index)
        else:
            nodes_sorted = nodes_raw
            nodes['presort'] = nodes_raw

        # prepare node dict
        nodes['raw'] = nodes_raw
        nodes['sorted'] = nodes_sorted

        self.nodes = nodes
        self.nr_of_nodes = nodes['raw'].shape[0]