Mechanisms of sand production in oil and water wells