finite elements method implementation