From c468a63830fdcdeb3407b26321f536bec33ba39b Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Wed, 9 Feb 2022 11:45:42 +0000 Subject: [PATCH] compressibleInterFoam::VoFSurfaceFilm: Added maxDeltaT to limit the time-step by comparing the film Courant number with the maximum Courant number obtain from the optional maxCo entry in the system//fvSolution file. If maxCo is not provided the film model does not limit the time-step. See tutorials/multiphase/compressibleInterFoam/laminar/cylinder as an example demonstrating this functionality. --- .../VoFSurfaceFilm/VoFSurfaceFilm.C | 8 +++++++- .../VoFSurfaceFilm/VoFSurfaceFilm.H | 5 ++++- .../fvModels/surfaceFilm/surfaceFilm.C | 8 +++++++- .../fvModels/surfaceFilm/surfaceFilm.H | 5 ++++- .../kinematicSingleLayer.C | 20 ++++++++++++++----- .../kinematicSingleLayer.H | 13 ++++++++---- .../cylinder/system/wallFilmRegion/fvSolution | 1 + 7 files changed, 47 insertions(+), 13 deletions(-) diff --git a/applications/solvers/multiphase/compressibleInterFoam/VoFSurfaceFilm/VoFSurfaceFilm.C b/applications/solvers/multiphase/compressibleInterFoam/VoFSurfaceFilm/VoFSurfaceFilm.C index 2bc446b0b9..7304280f09 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/VoFSurfaceFilm/VoFSurfaceFilm.C +++ b/applications/solvers/multiphase/compressibleInterFoam/VoFSurfaceFilm/VoFSurfaceFilm.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2021-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -84,6 +84,12 @@ Foam::wordList Foam::fv::VoFSurfaceFilm::addSupFields() const } +Foam::scalar Foam::fv::VoFSurfaceFilm::maxDeltaT() const +{ + return surfaceFilm_.maxDeltaT(); +} + + void Foam::fv::VoFSurfaceFilm::correct() { if (curTimeIndex_ == mesh().time().timeIndex()) diff --git a/applications/solvers/multiphase/compressibleInterFoam/VoFSurfaceFilm/VoFSurfaceFilm.H b/applications/solvers/multiphase/compressibleInterFoam/VoFSurfaceFilm/VoFSurfaceFilm.H index dbab54836b..b94adb67d5 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/VoFSurfaceFilm/VoFSurfaceFilm.H +++ b/applications/solvers/multiphase/compressibleInterFoam/VoFSurfaceFilm/VoFSurfaceFilm.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2021-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -104,6 +104,9 @@ public: // to the transport equation virtual wordList addSupFields() const; + //- Return the maximum time-step for stable operation + virtual scalar maxDeltaT() const; + // Correct diff --git a/src/regionModels/surfaceFilmModels/fvModels/surfaceFilm/surfaceFilm.C b/src/regionModels/surfaceFilmModels/fvModels/surfaceFilm/surfaceFilm.C index f6d71f3cc7..222b0406ed 100644 --- a/src/regionModels/surfaceFilmModels/fvModels/surfaceFilm/surfaceFilm.C +++ b/src/regionModels/surfaceFilmModels/fvModels/surfaceFilm/surfaceFilm.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2021-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -106,6 +106,12 @@ Foam::wordList Foam::fv::surfaceFilm::addSupFields() const } +Foam::scalar Foam::fv::surfaceFilm::maxDeltaT() const +{ + return surfaceFilm_.maxDeltaT(); +} + + void Foam::fv::surfaceFilm::correct() { if (curTimeIndex_ == mesh().time().timeIndex()) diff --git a/src/regionModels/surfaceFilmModels/fvModels/surfaceFilm/surfaceFilm.H b/src/regionModels/surfaceFilmModels/fvModels/surfaceFilm/surfaceFilm.H index 3a0c1babaf..15f3e27cca 100644 --- a/src/regionModels/surfaceFilmModels/fvModels/surfaceFilm/surfaceFilm.H +++ b/src/regionModels/surfaceFilmModels/fvModels/surfaceFilm/surfaceFilm.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2021-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -107,6 +107,9 @@ public: // to the transport equation virtual wordList addSupFields() const; + //- Return the maximum time-step for stable operation + virtual scalar maxDeltaT() const; + // Correct diff --git a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C index 5413bdb36f..068e2ff73e 100644 --- a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C +++ b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -485,7 +485,7 @@ kinematicSingleLayer::kinematicSingleLayer cumulativeContErr_(0), deltaSmall_("deltaSmall", dimLength, small), - deltaCoLimit_(solution().lookupOrDefault("deltaCoLimit", 1e-4)), + maxCo_(solution().lookupOrDefault("maxCo", 0)), p_ ( @@ -973,10 +973,20 @@ scalar kinematicSingleLayer::CourantNumber() const { const scalarField sumPhi(fvc::surfaceSum(mag(phiU_))().primitiveField()); - const scalar CoNum = - 0.5*gMax(sumPhi/regionMesh().V().field())*time_.deltaTValue(); + return 0.5*gMax(sumPhi/regionMesh().V().field())*time_.deltaTValue(); +} - return CoNum; + +scalar kinematicSingleLayer::maxDeltaT() const +{ + if (maxCo_ > 0) + { + return maxCo_*time_.deltaTValue()/(CourantNumber() + small); + } + else + { + return great; + } } diff --git a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.H b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.H index 034183be7e..bc278527bb 100644 --- a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.H +++ b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -86,8 +86,8 @@ protected: //- Small delta const dimensionedScalar deltaSmall_; - //- Film thickness above which Courant number calculation in valid - scalar deltaCoLimit_; + //- Optional maximum Courant number for stable film solution + scalar maxCo_; // Thermo properties @@ -95,6 +95,7 @@ protected: //- Pressure [Pa] volScalarField p_; + //- Thermo package autoPtr thermo_; @@ -314,9 +315,13 @@ public: // Solution parameters - //- Courant number evaluation + //- Courant number virtual scalar CourantNumber() const; + //- Return the maximum time-step for stable operation + // based on the Courant number + virtual scalar maxDeltaT() const; + //- Return small delta inline const dimensionedScalar& deltaSmall() const; diff --git a/tutorials/multiphase/compressibleInterFoam/laminar/cylinder/system/wallFilmRegion/fvSolution b/tutorials/multiphase/compressibleInterFoam/laminar/cylinder/system/wallFilmRegion/fvSolution index 463eb2245a..58d4fdd6c2 100644 --- a/tutorials/multiphase/compressibleInterFoam/laminar/cylinder/system/wallFilmRegion/fvSolution +++ b/tutorials/multiphase/compressibleInterFoam/laminar/cylinder/system/wallFilmRegion/fvSolution @@ -50,5 +50,6 @@ relaxationFactors } } +maxCo 0.2; // ************************************************************************* //