The a posteriori finite element method (APFEM), a framework for efficient parametric study and Bayesian inferences