calculating flux using divergence theorem