# Calculating Divergence in COMSOL

Is it computationally safe and accurate to use the following equation in COMSOL to compute the divergence of the vector quantity J (instead of using its general built-in equations that have $\nabla$ operations):

$$div_J = d(J_x,x)+d(J_y,y)+d(J_z,z)$$

• It is ok as long as you derive the correct weak form (if the divergence term comes from a heat or momentum diffusion equation for instance). However, why would you want to do this ? – SAAD Aug 21 '14 at 11:27