We present a generalised framework for the numerical simulation of the evolution of rock microstructures during deformation and metamorphism. This approach is based upon a data structure that describes a polycrystalline material using a two-dimensional network of nodes and connecting boundaries that allows micro-processes to be analysed at a range of scales. The nodes may possess attributes of position, topology and chemistry; and polygonal domains defined by these nodes may possess attributes of mineralogy, rheology and lattice orientation. We represent the complex behaviour of deforming and metamorphosing rocks at the grain scale as the interaction of a set of locally-defined driving forces and micro-processes, calculated for small time steps. A central program controls the evolution of extrinsic variables such as temperature and defines the history of deformation or metamorphic processes. The central program then passes the data structure to distinct process algorithms, which interact with this data structure, both by using it to determine the local values of driving forces, and by altering the attributes to simulate the progress of the process. We outline the function of the different aspects of the modelling task, provide simple examples showing porphyroblast growth during deformation and static grain growth, and describe the data structure that we have developed which enables us to handle multi-process simulations.