From 778ea7bf89ff46de3fea1b904245d8e2d126e0c4 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Tue, 11 Oct 2022 15:43:38 +0100 Subject: [PATCH] waveSurfacePressureFvPatchScalarField: Moved zeta field construction from potentialFreeSurfaceFoam The zeta field is cached on the database thus simplifying potentialFreeSurfaceFoam. --- .../potentialFreeSurfaceFoam/createFields.H | 15 --------- .../waveSurfacePressureFvPatchScalarField.C | 31 +++++++++++++++++-- .../waveSurfacePressureFvPatchScalarField.H | 8 ++--- .../oscillatingBox/0/U | 21 ++++++++----- 4 files changed, 46 insertions(+), 29 deletions(-) diff --git a/applications/solvers/multiphase/potentialFreeSurfaceFoam/createFields.H b/applications/solvers/multiphase/potentialFreeSurfaceFoam/createFields.H index b06e8ae63a..7929e63c38 100644 --- a/applications/solvers/multiphase/potentialFreeSurfaceFoam/createFields.H +++ b/applications/solvers/multiphase/potentialFreeSurfaceFoam/createFields.H @@ -38,21 +38,6 @@ autoPtr turbulence #include "readGravitationalAcceleration.H" -Info<< "Creating field zeta\n" << endl; -volVectorField zeta -( - IOobject - ( - "zeta", - runTime.timeName(), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE - ), - mesh, - dimensionedVector(dimLength, Zero) -); - Info<< "Creating field p_gh\n" << endl; volScalarField p_gh ( diff --git a/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C index 3c6f35ae99..7a7b8594b7 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C @@ -128,12 +128,37 @@ void Foam::waveSurfacePressureFvPatchScalarField::updateCoeffs() return; } + if (!db().foundObject(zetaName_)) + { + Info << "Creating field " << zetaName_ << endl; + + tmp tzeta + ( + new volVectorField + ( + IOobject + ( + "zeta", + db().time().timeName(), + db(), + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + patch().boundaryMesh().mesh(), + dimensionedVector(dimLength, Zero) + ) + ); + + regIOobject::store(tzeta.ptr()); + } + + // Retrieve non-const access to zeta field from the database + volVectorField& zeta = db().lookupObjectRef(zetaName_); + const label patchi = patch().index(); const scalar dt = db().time().deltaTValue(); - // Retrieve non-const access to zeta field from the database - volVectorField& zeta = db().lookupObjectRef(zetaName_); vectorField& zetap = zeta.boundaryFieldRef()[patchi]; // Lookup d/dt scheme from database for zeta @@ -160,6 +185,8 @@ void Foam::waveSurfacePressureFvPatchScalarField::updateCoeffs() const volVectorField& zeta0 = zeta.oldTime(); + Info << zeta0 << endl; + switch (ddtScheme) { case tsEuler: diff --git a/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.H index a3eb678682..7b0e246820 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,11 +25,11 @@ Class Foam::waveSurfacePressureFvPatchScalarField Description - This is a pressure boundary condition, whose value is calculated as + This is a pressure boundary condition, the value of which is calculated as the hydrostatic pressure based on a given displacement: \f[ - p = -\rho*g*\zeta + p_rgh = pref - \rho*g*\zeta \f] \vartable @@ -57,7 +57,7 @@ Usage phi phi; rho rho; zeta zeta; - value uniform 0; // place holder + value uniform 0; // Initial value } \endverbatim diff --git a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/0/U b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/0/U index 8b50564554..2fa6555bd8 100644 --- a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/0/U +++ b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/0/U @@ -36,22 +36,27 @@ boundaryField normalVelocity { type uniformFixedValue; - uniformValue scale; - uniformValueCoeffs + + uniformValue { - scale linearRamp; - scaleCoeffs + type scale; + + scale { + type linearRamp; + start 0; duration 10; } - value sine; - valueCoeffs + + value { - amplitude constant (0 0.025 0); + type sine; + + amplitude (0 0.025 0); frequency 1; start 0; - level constant (0 0 0); + level (0 0 0); } } value uniform (0 0 0);