waveSurfacePressureFvPatchScalarField: Moved zeta field construction from potentialFreeSurfaceFoam

The zeta field is cached on the database thus simplifying potentialFreeSurfaceFoam.
This commit is contained in:
Henry Weller
2022-10-11 15:43:38 +01:00
parent fee658b024
commit 778ea7bf89
4 changed files with 46 additions and 29 deletions

View File

@ -38,21 +38,6 @@ autoPtr<incompressible::momentumTransportModel> 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
(

View File

@ -128,12 +128,37 @@ void Foam::waveSurfacePressureFvPatchScalarField::updateCoeffs()
return;
}
if (!db().foundObject<volVectorField>(zetaName_))
{
Info << "Creating field " << zetaName_ << endl;
tmp<volVectorField> 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<volVectorField>(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<volVectorField>(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:

View File

@ -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

View File

@ -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);