Problem with totalFlux calculation in adjustPhi
The variable totalFlux in cfdTools/general/adjustPhi/adjustPhi.C is calculated like this:
scalar totalFlux = VSMALL + sum(mag(phi)).value();
If I understand this correctly, the sum is over all internal faces. At least in my case floating2Dbox.zip, the sum is initially zero, and I get totalFlux = 1e-300 although on the boundaries I have matching in- and outflow fluxes. For the attached case, this results in crash with:
--> FOAM FATAL ERROR: (openfoam-2012) Continuity error cannot be removed by adjusting the outflow. Please check the velocity boundary conditions and/or run potentialFoam to initialise the outflow. Total flux : 1.0000000000000000251e-300 Specified mass inflow : 1.0000000000000059952 Specified mass outflow : 1.0000000000000064393 Adjustable mass outflow : 0 [floating2Dbox.zip](/uploads/eaba426b2041929d8e0787cc7a877d0d/floating2Dbox.zip)
The culprit is the line:
else if (mag(fixedMassOut - massIn)/totalFlux > 1e-8)
triggering the error.
My suggestion is to redefine totalFlux to also include the fixed boundary flux:
scalar totalFlux = VSMALL + sum(mag(phi)).value() + mag(fixedMassOut) + mag(massIn);
It could also be considered to replace the hardcoded 1e-8 in the error condition above by for instance the
tolerance of pFinal or p_rghFinal specified by the user in fvSolution.