From 1fd10f81e62f0e63f0c6151ddfc8201860460438 Mon Sep 17 00:00:00 2001 From: Andrea Pisa Date: Wed, 30 Jun 2021 19:33:39 +0200 Subject: [PATCH] maxAlphaCo added --- .../openInjMoldSim/alphaCourantNo.H | 57 +++++++++++++++++++ .../multiphase/openInjMoldSim/mojSetDeltaT.H | 2 +- .../openInjMoldSim/openInjMoldSim.C | 1 + 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 applications/solvers/multiphase/openInjMoldSim/alphaCourantNo.H diff --git a/applications/solvers/multiphase/openInjMoldSim/alphaCourantNo.H b/applications/solvers/multiphase/openInjMoldSim/alphaCourantNo.H new file mode 100644 index 0000000..7ff28ce --- /dev/null +++ b/applications/solvers/multiphase/openInjMoldSim/alphaCourantNo.H @@ -0,0 +1,57 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Global + alphaCourantNo + +Description + Calculates and outputs the mean and maximum Courant Numbers. + +\*---------------------------------------------------------------------------*/ + +scalar maxAlphaCo +( + readScalar(runTime.controlDict().lookup("maxAlphaCo")) +); + +scalar alphaCoNum = 0.0; +scalar meanAlphaCoNum = 0.0; + +if (mesh.nInternalFaces()) +{ + scalarField sumPhi + ( + pos0(alpha1 - 0.01)*pos0(0.99 - alpha1) + *fvc::surfaceSum(mag(phi))().primitiveField() + ); + + alphaCoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaTValue(); + + meanAlphaCoNum = + 0.5*(gSum(sumPhi)/gSum(mesh.V().field()))*runTime.deltaTValue(); +} + +Info<< "Interface Courant Number mean: " << meanAlphaCoNum + << " max: " << alphaCoNum << endl; + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/openInjMoldSim/mojSetDeltaT.H b/applications/solvers/multiphase/openInjMoldSim/mojSetDeltaT.H index 904d6f3..ea2d723 100644 --- a/applications/solvers/multiphase/openInjMoldSim/mojSetDeltaT.H +++ b/applications/solvers/multiphase/openInjMoldSim/mojSetDeltaT.H @@ -33,7 +33,7 @@ Description if (adjustTimeStep) { - scalar maxDeltaTFact = min(maxCo/(CoNum + small), maxSolidCo/(solidCoNum + small)); + scalar maxDeltaTFact = min(maxCo/(CoNum + small), min( maxSolidCo/(solidCoNum + small), maxAlphaCo/(alphaCoNum + small) ) ); //Andrea - add maxAlphaCo/(alphaCoNum + small) scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2); runTime.setDeltaT diff --git a/applications/solvers/multiphase/openInjMoldSim/openInjMoldSim.C b/applications/solvers/multiphase/openInjMoldSim/openInjMoldSim.C index e1b7de6..a723ce5 100644 --- a/applications/solvers/multiphase/openInjMoldSim/openInjMoldSim.C +++ b/applications/solvers/multiphase/openInjMoldSim/openInjMoldSim.C @@ -82,6 +82,7 @@ int main(int argc, char *argv[]) { #include "mojCreateTimeControls.H" #include "mojCourantNo.H" + #include "alphaCourantNo.H" //Andrea #include "mojSetDeltaT.H" runTime++;