Standard OpenFOAM-v1812 has a module called dynamicRefineFvMesh. This adaptive mesh refinement tool does not seem to be applicable for two dimensional problems. Shonibare and Ahmad Baniabedalruhman recently described how to adapt this adaptive mesh tools for two dimensional problems. However, CFD community struggled to implement their ideas. See this cfd-online forum.
Eventually, Luca Cornolti shared a working for code for adaptive mesh refinement for 2d problems. His initial code were for foam-extend. This repository is simple adaptation Luca's work for OpenFOAM-v1812. The animated screenshot clearly shows that it works.
[Disclaimer: It is to be noted that in the same forum discussion, Luca Cornolti also shared his adaptive mesh refinement for OpenFOAM-v1816. This repository is not a copy of that. Instead, this codes is built on top of Luca's foam-extend codes]
Switch to src directory and run
wmake libso
To run the a dam-break example, switch to tutorial/interFoam/dambreak and then run
./Allrun