I'm trying to compute something called the "Drying Ratio" following: Eidhammer, 2018
The drying ratio is the ratio of the precipitation to the incoming vapor flux. So,
$DR = \frac{F_{in} - F_{out}}{F_{in}} = \frac{P}{F_{in}}$
This makes some assumptions about sources/sinks (minimal evaporation for example). The vapor flux can be expressed as:
$\vec{F} = \frac{-1}{g} \int_{P_{sfc}}^{P_{top}} q\vec{V}dp$
Integrating the vapor transport field along a particular control volume grid-box, and over time yields, length units (same as precipitation).
When the wind component U and V are always coming from the same direction (same sign), the incoming flux into a particular control volume is found by summing up the V components for i,j and i+1, and the U components for i,j and i,j+1.
How can this be done when the vector field changes direction? In this case the opposite side of the control volume would then be the location of the incoming flux.
One could go grid-cell by grid cell and find the sign of the wind direction, and then sum the incoming flux from the upwind cell using an "if" to find the direction.
Is there another method? I wonder if there is a vector calc identity I am missing. This also seems like a much more general problem and I know it must be addressed in many other situations.
Thanks