Implementation of a wetting and drying algorithm in a finite element model