The design, implementation and performance of an object-oriented library for representing unstructured grids and performing volume based agglomeration for a multigrid solver is presented. The library provides a modular, flexible and efficient framework for representing three dimensional domains. An unstructured grid is represented using a hierarchy of classes: domain, grid level, cells, faces, edges and vertices. This structure provides the machinery needed to represent physical variables (e.g. variables of a differential equation) directly in the relevant class. It also obviates the need for storing information of a logically independent entity like a cell across several arrays. We use an unstructured volume based agglomeration routine where the agglomeration front propagates inward from the boundaries. Agglomeration occurs across cells sharing a common vertex. Cell fusion rate (number of cells sharing a vertex that get fused into a coarse cell) is parameterized. Aspect ratio is defined so that it captures the degree of cell convexity and gives an indication of direction of cell stretching. This information is useful for performing directional agglomeration. Quality of agglomeration is evaluated using mean and standard deviation of cell aspect ratios, cell volume, and number of finer grid cells forming a coarse cell. We also solve a simple scalar transport equation using the generated coarse grids in order to discriminate the quality of agglomeration and the optimum number of coarse grid levels. An algorithm for improvement of cell quality that fills up cavities between coarse cells by relocating fine cells between coarse cells is also incorporated into the agglomeration library.