From 7a823de58037c10e83fba22842a1fcc599403ae7 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Fri, 27 May 2011 20:53:20 +0100 Subject: [PATCH] File moved --- .../general/include/checkVolContinuity.H | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/finiteVolume/cfdTools/general/include/checkVolContinuity.H diff --git a/src/finiteVolume/cfdTools/general/include/checkVolContinuity.H b/src/finiteVolume/cfdTools/general/include/checkVolContinuity.H new file mode 100644 index 000000000..8cf0882fe --- /dev/null +++ b/src/finiteVolume/cfdTools/general/include/checkVolContinuity.H @@ -0,0 +1,52 @@ +if (mesh.moving()) +{ + // The ddt term constructed by hand because it must be Euler + const scalar dt = runTime.deltaT().value(); + + const scalarField& V = mesh.V().field(); + const scalarField& V0 = mesh.V0().field(); + scalar sumV = gSum(V); + scalar sumV0 = gSum(V0); + + scalarField volChange = (1.0 - V0/V)/dt; + + scalarField divFlux = + - fvc::div(mesh.phi())().internalField(); + + scalarField conserve = volChange + divFlux; + + scalar sumLocalContErr = dt*gSum(mag(conserve*mesh.V()))/sumV; + scalar globalContErr = dt*gSum(conserve*mesh.V())/sumV; + + label nMotionErrors = 0; + scalar maxMotionError = 0; + + forAll (conserve, cellI) + { + maxMotionError = Foam::max(maxMotionError, mag(conserve[cellI])); + + if (mag(conserve[cellI]) > 1e-8) + { + Info<< "Motion conservation error in cell " << cellI << ": " + << conserve[cellI] + << " V: " << V[cellI] << " V0: " << V0[cellI] + << " volume change: " << volChange[cellI] + << " div flux: " << divFlux[cellI] << endl; + + nMotionErrors++; + } + } + + if (nMotionErrors > 0) + { + Info<< "Number of motion errors: " << nMotionErrors + << " out of nCells = " << mesh.nCells() << endl; + } + + Info<< "volume continuity errors : " + << "volume = " << sumV + << ", old volume = " << sumV0 + << ", max error = " << maxMotionError + << ", sum local = " << sumLocalContErr + << ", global = " << globalContErr << endl; +}