From f05ab894d36c03ec322b422dbf813e36c823b361 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Fri, 26 May 2023 15:25:01 +0100 Subject: [PATCH] waveForcing: Added optional lambdaBoundary specification which allows lambda to set higher in the cells adjacent to the boundary which is particularly useful when solving for waves in a domain with no mean-flow and wave BCs to avoid numerical stability problems where the specified wave flow reverses into the domain. The alternative is to use symmetry rather than wave BCs on the side patches which is stable without using lambdaBoundary but there is modest distortion of the wave profile adjacent to the side patches which does not propagate into the domain due to the wave forcing. --- src/waves/fvModels/forcing/forcing.C | 25 +++++++++++++++++++ src/waves/fvModels/forcing/forcing.H | 3 +++ src/waves/fvModels/waveForcing/waveForcing.H | 4 +++ .../floatingObjectWaves/constant/fvModels | 3 ++- .../floatingObjectWaves/system/controlDict | 2 +- 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/waves/fvModels/forcing/forcing.C b/src/waves/fvModels/forcing/forcing.C index a51c5bc5af..895fd55258 100644 --- a/src/waves/fvModels/forcing/forcing.C +++ b/src/waves/fvModels/forcing/forcing.C @@ -50,6 +50,14 @@ void Foam::fv::forcing::readCoeffs() coeffs().lookup(lambda_.name()) ); + lambdaBoundary_ = + dimensionedScalar + ( + lambdaBoundary_.name(), + lambdaBoundary_.dimensions(), + coeffs().lookupOrDefault(lambdaBoundary_.name(), 0) + ); + const bool foundScale = coeffs().found("scale"); const bool foundOgn = coeffs().found("origin"); const bool foundDir = coeffs().found("direction"); @@ -157,6 +165,22 @@ Foam::tmp Foam::fv::forcing::forceCoeff volScalarField::Internal::New(typedName("forceCoeff"), lambda_*scale) ); + // Damp the cells adjacent to the boundary with lambdaBoundary if specified + if (lambdaBoundary_.value() > 0) + { + const fvBoundaryMesh& bm = mesh().boundary(); + + forAll(bm, patchi) + { + if (!bm[patchi].coupled()) + { + UIndirectList(tforceCoeff.ref(), bm[patchi].faceCells()) + = lambdaBoundary_.value() + *Field(scale, bm[patchi].faceCells()); + } + } + } + // Write out the force coefficient for debugging if (debug && mesh().time().writeTime()) { @@ -185,6 +209,7 @@ Foam::fv::forcing::forcing : fvModel(name, modelType, mesh, dict), lambda_("lambda", dimless/dimTime, NaN), + lambdaBoundary_("lambdaBoundary", dimless/dimTime, 0), scale_(nullptr), origins_(), directions_() diff --git a/src/waves/fvModels/forcing/forcing.H b/src/waves/fvModels/forcing/forcing.H index fb918a8d30..989d18de82 100644 --- a/src/waves/fvModels/forcing/forcing.H +++ b/src/waves/fvModels/forcing/forcing.H @@ -65,6 +65,9 @@ protected: //- Damping coefficient [1/s] dimensionedScalar lambda_; + //- Optional boundary damping coefficient [1/s] + dimensionedScalar lambdaBoundary_; + //- The scaling function autoPtr> scale_; diff --git a/src/waves/fvModels/waveForcing/waveForcing.H b/src/waves/fvModels/waveForcing/waveForcing.H index 12c4e63477..304dcce003 100644 --- a/src/waves/fvModels/waveForcing/waveForcing.H +++ b/src/waves/fvModels/waveForcing/waveForcing.H @@ -63,6 +63,10 @@ Usage } lambda 0.5; // Forcing coefficient + + // lambda 2; // Optional boundary forcing coefficient + // Useful when wave BCs are specified + // without mean flow } \endverbatim diff --git a/tutorials/incompressibleVoF/floatingObjectWaves/constant/fvModels b/tutorials/incompressibleVoF/floatingObjectWaves/constant/fvModels index 24ad7bfbe6..870980f48d 100644 --- a/tutorials/incompressibleVoF/floatingObjectWaves/constant/fvModels +++ b/tutorials/incompressibleVoF/floatingObjectWaves/constant/fvModels @@ -45,7 +45,8 @@ forcing duration 0.5; } - lambda 25; + lambda 5; + lambdaBoundary 25; } diff --git a/tutorials/incompressibleVoF/floatingObjectWaves/system/controlDict b/tutorials/incompressibleVoF/floatingObjectWaves/system/controlDict index edf8b160fa..c3dac56239 100644 --- a/tutorials/incompressibleVoF/floatingObjectWaves/system/controlDict +++ b/tutorials/incompressibleVoF/floatingObjectWaves/system/controlDict @@ -65,7 +65,7 @@ functions0 DebugSwitches { // Write the forcing and damping scale and force fields - // forcing 1; + forcing 1; } // ************************************************************************* //