outletPhaseMeanVelocityFvPatchVectorField: New BC for the outlet of a towing-tank to maintain the water level at the same level as the inlet
This commit is contained in:
parent
c5323158ee
commit
9f1a299a5d
@ -0,0 +1,188 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "outletPhaseMeanVelocityFvPatchVectorField.H"
|
||||
#include "volFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "surfaceFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::outletPhaseMeanVelocityFvPatchVectorField
|
||||
::outletPhaseMeanVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<vector, volMesh>& iF
|
||||
)
|
||||
:
|
||||
mixedFvPatchField<vector>(p, iF),
|
||||
Umean_(0),
|
||||
alphaName_("none")
|
||||
{
|
||||
refValue() = vector::zero;
|
||||
refGrad() = vector::zero;
|
||||
valueFraction() = 0.0;
|
||||
}
|
||||
|
||||
|
||||
Foam::outletPhaseMeanVelocityFvPatchVectorField
|
||||
::outletPhaseMeanVelocityFvPatchVectorField
|
||||
(
|
||||
const outletPhaseMeanVelocityFvPatchVectorField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<vector, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
mixedFvPatchField<vector>(ptf, p, iF, mapper),
|
||||
Umean_(ptf.Umean_),
|
||||
alphaName_(ptf.alphaName_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::outletPhaseMeanVelocityFvPatchVectorField
|
||||
::outletPhaseMeanVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<vector, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
mixedFvPatchField<vector>(p, iF),
|
||||
Umean_(readScalar(dict.lookup("Umean"))),
|
||||
alphaName_(dict.lookup("alpha"))
|
||||
{
|
||||
refValue() = vector::zero;
|
||||
refGrad() = vector::zero;
|
||||
valueFraction() = 0.0;
|
||||
|
||||
if (dict.found("value"))
|
||||
{
|
||||
fvPatchVectorField::operator=
|
||||
(
|
||||
vectorField("value", dict, p.size())
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
fvPatchVectorField::operator=(patchInternalField());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::outletPhaseMeanVelocityFvPatchVectorField
|
||||
::outletPhaseMeanVelocityFvPatchVectorField
|
||||
(
|
||||
const outletPhaseMeanVelocityFvPatchVectorField& ptf
|
||||
)
|
||||
:
|
||||
mixedFvPatchField<vector>(ptf),
|
||||
Umean_(ptf.Umean_),
|
||||
alphaName_(ptf.alphaName_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::outletPhaseMeanVelocityFvPatchVectorField
|
||||
::outletPhaseMeanVelocityFvPatchVectorField
|
||||
(
|
||||
const outletPhaseMeanVelocityFvPatchVectorField& ptf,
|
||||
const DimensionedField<vector, volMesh>& iF
|
||||
)
|
||||
:
|
||||
mixedFvPatchField<vector>(ptf, iF),
|
||||
Umean_(ptf.Umean_),
|
||||
alphaName_(ptf.alphaName_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::outletPhaseMeanVelocityFvPatchVectorField::updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
scalarField alphap =
|
||||
patch().lookupPatchField<volScalarField, scalar>(alphaName_);
|
||||
|
||||
alphap = max(alphap, scalar(0));
|
||||
alphap = min(alphap, scalar(1));
|
||||
|
||||
// Get the patchInternalField (zero-gradient field)
|
||||
vectorField Uzg(patchInternalField());
|
||||
|
||||
// Calculate the phase mean zero-gradient velocity
|
||||
scalar Uzgmean =
|
||||
gSum(alphap*(patch().Sf() & Uzg))
|
||||
/gSum(alphap*patch().magSf());
|
||||
|
||||
// Set the refValue and valueFraction to adjust the boundary field
|
||||
// such that the phase mean is Umean_
|
||||
if (Uzgmean >= Umean_)
|
||||
{
|
||||
refValue() = vector::zero;
|
||||
valueFraction() = 1.0 - Umean_/Uzgmean;
|
||||
}
|
||||
else
|
||||
{
|
||||
refValue() = (Umean_ + Uzgmean)*patch().nf();
|
||||
valueFraction() = 1.0 - Uzgmean/Umean_;
|
||||
}
|
||||
|
||||
mixedFvPatchField<vector>::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
void Foam::outletPhaseMeanVelocityFvPatchVectorField::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
fvPatchField<vector>::write(os);
|
||||
|
||||
os.writeKeyword("Umean") << Umean_
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("alpha") << alphaName_
|
||||
<< token::END_STATEMENT << nl;
|
||||
writeEntry("value", os);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makePatchTypeField
|
||||
(
|
||||
fvPatchVectorField,
|
||||
outletPhaseMeanVelocityFvPatchVectorField
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,197 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::outletPhaseMeanVelocityFvPatchVectorField
|
||||
|
||||
Group
|
||||
grpOutletBoundaryConditions
|
||||
|
||||
Description
|
||||
This boundary condition adjusts the velocity for the given phase to achieve
|
||||
the specified mean thus causing the phase-fraction to adjust according to
|
||||
the mass flow rate.
|
||||
|
||||
Typical usage is as the outlet condition for a towing-tank ship simulation
|
||||
to maintain the outlet water level at the level as the inlet.
|
||||
|
||||
\heading Patch usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
Umean | mean velocity normal to the boundary [m/s] | yes |
|
||||
alpha | phase-fraction field | yes |
|
||||
\endtable
|
||||
|
||||
Example of the boundary condition specification:
|
||||
\verbatim
|
||||
myPatch
|
||||
{
|
||||
type outletPhaseMeanVelocity;
|
||||
Umean 1.2;
|
||||
alpha alpha.water;
|
||||
value uniform (1.2 0 0);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
SeeAlso
|
||||
Foam::mixedFvPatchField
|
||||
Foam::variableHeightFlowRateInletVelocityFvPatchVectorField
|
||||
|
||||
SourceFiles
|
||||
outletPhaseMeanVelocityFvPatchVectorField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef outletPhaseMeanVelocityFvPatchVectorField_H
|
||||
#define outletPhaseMeanVelocityFvPatchVectorField_H
|
||||
|
||||
#include "mixedFvPatchFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class outletPhaseMeanVelocityFvPatchVectorField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class outletPhaseMeanVelocityFvPatchVectorField
|
||||
:
|
||||
public mixedFvPatchVectorField
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Inlet integral flow rate
|
||||
scalar Umean_;
|
||||
|
||||
//- Name of the phase-fraction field
|
||||
word alphaName_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("outletPhaseMeanVelocity");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
outletPhaseMeanVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<vector, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
outletPhaseMeanVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<vector, volMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given
|
||||
// outletPhaseMeanVelocityFvPatchVectorField
|
||||
// onto a new patch
|
||||
outletPhaseMeanVelocityFvPatchVectorField
|
||||
(
|
||||
const outletPhaseMeanVelocityFvPatchVectorField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<vector, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
outletPhaseMeanVelocityFvPatchVectorField
|
||||
(
|
||||
const outletPhaseMeanVelocityFvPatchVectorField&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchVectorField> clone() const
|
||||
{
|
||||
return tmp<fvPatchVectorField>
|
||||
(
|
||||
new outletPhaseMeanVelocityFvPatchVectorField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
outletPhaseMeanVelocityFvPatchVectorField
|
||||
(
|
||||
const outletPhaseMeanVelocityFvPatchVectorField&,
|
||||
const DimensionedField<vector, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchVectorField> clone
|
||||
(
|
||||
const DimensionedField<vector, volMesh>& iF
|
||||
) const
|
||||
{
|
||||
return tmp<fvPatchVectorField>
|
||||
(
|
||||
new outletPhaseMeanVelocityFvPatchVectorField
|
||||
(
|
||||
*this,
|
||||
iF
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the flux
|
||||
scalar Umean() const
|
||||
{
|
||||
return Umean_;
|
||||
}
|
||||
|
||||
//- Return reference to the flux to allow adjustment
|
||||
scalar& Umean()
|
||||
{
|
||||
return Umean_;
|
||||
}
|
||||
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
Loading…
Reference in New Issue
Block a user