Removed old immersed boundary wall functions

This commit is contained in:
Hrvoje Jasak 2018-05-24 11:49:49 +01:00
parent c6fefa324c
commit bd806d3d2b
10 changed files with 0 additions and 2230 deletions

View file

@ -1,393 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "immersedBoundaryEpsilonWallFunctionFvPatchScalarField.H"
#include "immersedBoundaryVelocityWallFunctionFvPatchVectorField.H"
#include "RASModel.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
immersedBoundaryEpsilonWallFunctionFvPatchScalarField::
immersedBoundaryEpsilonWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
immersedBoundaryWallFunctionFvPatchScalarField(p, iF),
UName_("U"),
kName_("k"),
GName_("RASModel::G"),
nuName_("nu"),
nutName_("nut"),
Cmu_(0.09),
kappa_(0.41),
E_(9.8)
{}
immersedBoundaryEpsilonWallFunctionFvPatchScalarField::
immersedBoundaryEpsilonWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
immersedBoundaryWallFunctionFvPatchScalarField(p, iF, dict),
UName_(dict.lookupOrDefault<word>("U", "U")),
kName_(dict.lookupOrDefault<word>("k", "k")),
GName_(dict.lookupOrDefault<word>("G", "RASModel::G")),
nuName_(dict.lookupOrDefault<word>("nu", "nu")),
nutName_(dict.lookupOrDefault<word>("nut", "nut")),
Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
E_(dict.lookupOrDefault<scalar>("E", 9.8))
{}
immersedBoundaryEpsilonWallFunctionFvPatchScalarField::
immersedBoundaryEpsilonWallFunctionFvPatchScalarField
(
const immersedBoundaryEpsilonWallFunctionFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
immersedBoundaryWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
UName_(ptf.UName_),
kName_(ptf.kName_),
GName_(ptf.GName_),
nuName_(ptf.nuName_),
nutName_(ptf.nutName_),
Cmu_(ptf.Cmu_),
kappa_(ptf.kappa_),
E_(ptf.E_)
{}
immersedBoundaryEpsilonWallFunctionFvPatchScalarField::
immersedBoundaryEpsilonWallFunctionFvPatchScalarField
(
const immersedBoundaryEpsilonWallFunctionFvPatchScalarField& ewfpsf
)
:
immersedBoundaryWallFunctionFvPatchScalarField(ewfpsf),
UName_(ewfpsf.UName_),
kName_(ewfpsf.kName_),
GName_(ewfpsf.GName_),
nuName_(ewfpsf.nuName_),
nutName_(ewfpsf.nutName_),
Cmu_(ewfpsf.Cmu_),
kappa_(ewfpsf.kappa_),
E_(ewfpsf.E_)
{}
immersedBoundaryEpsilonWallFunctionFvPatchScalarField::
immersedBoundaryEpsilonWallFunctionFvPatchScalarField
(
const immersedBoundaryEpsilonWallFunctionFvPatchScalarField& ewfpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
immersedBoundaryWallFunctionFvPatchScalarField(ewfpsf, iF),
UName_(ewfpsf.UName_),
kName_(ewfpsf.kName_),
GName_(ewfpsf.GName_),
nuName_(ewfpsf.nuName_),
nutName_(ewfpsf.nutName_),
Cmu_(ewfpsf.Cmu_),
kappa_(ewfpsf.kappa_),
E_(ewfpsf.E_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void immersedBoundaryEpsilonWallFunctionFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
// If G field is not present, execute zero gradient evaluation
// HJ, 20/Mar/2011
if (!db().foundObject<volScalarField>(GName_))
{
InfoIn
(
"void immersedBoundaryEpsilonWallFunctionFvPatchScalarField::"
"updateCoeffs()"
) << "Cannot access " << GName_ << " field. for patch "
<< patch().name() << ". Evaluating as regular immersed boundary"
<< endl;
immersedBoundaryWallFunctionFvPatchScalarField::evaluate();
return;
}
const vectorField& n = ibPatch().ibNormals();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalar Cmu25 = pow(Cmu_, 0.25);
const scalar Cmu50 = sqrt(Cmu_);
const scalar Cmu75 = pow(Cmu_, 0.75);
volScalarField& G = const_cast<volScalarField&>
(db().lookupObject<volScalarField>(GName_));
// Grab values of other fields required for wall functions
// Velocity
const fvPatchVectorField& Uwg =
patch().lookupPatchField<volVectorField, vector>(UName_);
const immersedBoundaryVelocityWallFunctionFvPatchVectorField& Uw =
refCast<const immersedBoundaryVelocityWallFunctionFvPatchVectorField>
(
Uwg
);
// Calculate tangential component, taking into account wall velocity
const vectorField UtanOld =
(I - sqr(n)) & (Uw.ibSamplingPointValue() - Uw.ibValue());
const scalarField magUtanOld = mag(UtanOld);
// Tangential velocity component
scalarField& UTangentialNew = Uw.wallTangentialValue();
// Wall shear stress
vectorField& tauWall = Uw.tauWall();
// Turbulence kinetic energy
const fvPatchScalarField& kg =
patch().lookupPatchField<volScalarField, scalar>(kName_);
const immersedBoundaryWallFunctionFvPatchScalarField& kw =
refCast<const immersedBoundaryWallFunctionFvPatchScalarField>(kg);
// Current and new values of k at sampling point
scalarField k = kw.ibSamplingPointValue();
scalarField& kNew = kw.wallValue();
// Laminar viscosity
const fvPatchScalarField& nuwg =
patch().lookupPatchField<volScalarField, scalar>(nuName_);
const immersedBoundaryFvPatchScalarField& nuw =
refCast<const immersedBoundaryFvPatchScalarField>(nuwg);
scalarField nu = nuw.ibCellValue();
// Turbulent viscosity
const fvPatchScalarField& nutwg =
patch().lookupPatchField<volScalarField, scalar>(nutName_);
const immersedBoundaryWallFunctionFvPatchScalarField& nutw =
refCast<const immersedBoundaryWallFunctionFvPatchScalarField>(nutwg);
// New values of nut
scalarField nutOld = nutw.ibCellValue();
scalarField& nutNew = nutw.wallValue();
const scalarField magGradUw = mag(Uw.ibGrad());
// Get the IB addressing and distance
const labelList& ibc = ibPatch().ibCells();
// Distance to sampling point
const scalarField& ySample = ibPatch().ibSamplingPointDelta();
// Distance from wall to IB point
const scalarField& y = ibPatch().ibDelta();
// Epsilon: store IB cell values for direct insertion
scalarField epsilonSample = this->ibSamplingPointValue();
scalarField& epsilonNew = this->wallValue();
// Mark values to be fixed
boolList wf(ibc.size(), false);
// Calculate yPlus for sample points
scalarField ypd = Cmu25*ySample*sqrt(k)/nu;
// Calculate wall function conditions
forAll (ibc, ibCellI)
{
const scalar nuLam = nu[ibCellI];
// Calculate yPlus from k and laminar viscosity for the IB point
const scalar yPlusSample = ypd[ibCellI];
scalar uTau;
if (yPlusSample > yPlusLam)
{
// Calculate uTau from log-law, knowing sampled k and U
uTau = magUtanOld[ibCellI]*kappa_/log(E_*yPlusSample);
}
else
{
// Sampling point is in laminar sublayer
// Bug fix: HJ, 11/Aug/2014
uTau = yPlusSample;
}
// Set wall shear stress
tauWall[ibCellI] = sqr(uTau)*UtanOld[ibCellI]/(magUtanOld[ibCellI] + SMALL);
// Calculate yPlus for IB point
// scalar yPlusIB = uTau*y[ibCellI]/nuLam;
scalar yPlusIB = yPlusSample*y[ibCellI]/ySample[ibCellI];
// Calculate wall function data in the immersed boundary point
if (yPlusIB > yPlusLam)
{
// Logarithmic region
wf[ibCellI] = true;
scalar nutw = nuLam*(yPlusIB*kappa_/log(E_*yPlusIB) - 1);
// Fix generation even though it if is not used
G[ibc[ibCellI]] =
sqr((nutw + nuLam)*magGradUw[ibCellI])/
(Cmu25*sqrt(k[ibCellI])*kappa_*y[ibCellI]);
// Log-Law for tangential velocity
UTangentialNew[ibCellI] =
min
(
magUtanOld[ibCellI],
uTau/kappa_*log(E_*yPlusIB)
);
// Calculate turbulent viscosity
nutNew[ibCellI] = nutw;
// Calculate k in the IB cell from G = epsilon
kNew[ibCellI] = (nutw + nuLam)*magGradUw[ibCellI]/Cmu50;
// Calculate epsilon from yPlus and set it
epsilonNew[ibCellI] =
Cmu75*pow(kNew[ibCellI], 1.5)/(kappa_*y[ibCellI]);
}
else
{
// Laminar sub-layer
wf[ibCellI] = false;
// G is zero
G[ibc[ibCellI]] = 0;
// Laminar sub-layer for tangential velocity: uPlus = yPlus
UTangentialNew[ibCellI] = min(magUtanOld[ibCellI], uTau*yPlusIB);
// Turbulent viscosity is zero
nutNew[ibCellI] = SMALL;
// k is zero gradient: use the sampled value
kNew[ibCellI] = k[ibCellI];
// Calculate epsilon from yPlus and set it.
// Note: calculating equilibrium epsilon in the sub-layer creates
// an unrealistic oscillation: use sampled value
// HJ, 27/Jul/2012
epsilonNew[ibCellI] = epsilonSample[ibCellI];
}
}
// Info<< "UTangentialNew " << min(UTangentialNew) << " " << max(UTangentialNew) << endl;
// Info<< "nutNew " << min(nutNew) << " " << max(nutNew) << endl;
// Info<< "kNew " << min(kNew) << " " << max(kNew) << endl;
// Info<< "epsilonNew " << min(epsilonNew) << " " << max(epsilonNew) << endl;
// Set the fields to calculated wall function values
Uw.wallMask() = true;
kw.wallMask() = wf;
nutw.wallMask() = true;
this->wallMask() = true;
// Insert epsilon values into the internal field
immersedBoundaryWallFunctionFvPatchScalarField::updateCoeffs();
}
void immersedBoundaryEpsilonWallFunctionFvPatchScalarField::evaluate
(
const Pstream::commsTypes commsType
)
{
// Insert epsilon values into the internal field
this->setIbCellValues(this->wallValue());
fvPatchScalarField::evaluate(commsType);
}
void immersedBoundaryEpsilonWallFunctionFvPatchScalarField::
write(Ostream& os) const
{
immersedBoundaryWallFunctionFvPatchScalarField::write(os);
writeEntryIfDifferent<word>(os, "U", "U", UName_);
writeEntryIfDifferent<word>(os, "k", "k", kName_);
writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_);
writeEntryIfDifferent<word>(os, "nu", "nu", nuName_);
writeEntryIfDifferent<word>(os, "nut", "nut", nutName_);
os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField
(
fvPatchScalarField,
immersedBoundaryEpsilonWallFunctionFvPatchScalarField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,201 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressible::RASModels::
immersedBoundaryEpsilonWallFunctionFvPatchScalarField
Description
Boundary condition for epsilon when using wall functions
- calculates y+, G, tangential velocity, nut and k
- each of calculated values is handled separately by the appropriate
boundary condition
- epsilon values added directly into the field to act as a constraint
SourceFiles
immersedBoundaryEpsilonWallFunctionFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef immersedBoundaryEpsilonWallFunctionFvPatchScalarField_H
#define immersedBoundaryEpsilonWallFunctionFvPatchScalarField_H
#include "immersedBoundaryWallFunctionFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
/*---------------------------------------------------------------------------*\
Class immersedBoundaryEpsilonWallFunctionFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class immersedBoundaryEpsilonWallFunctionFvPatchScalarField
:
public immersedBoundaryWallFunctionFvPatchScalarField
{
// Private data
//- Name of velocity field
word UName_;
//- Name of turbulence kinetic energy field
word kName_;
//- Name of turbulence generation field
word GName_;
//- Name of laminar viscosity field
word nuName_;
//- Name of turbulent viscosity field
word nutName_;
//- Cmu coefficient
scalar Cmu_;
//- Von Karman constant
scalar kappa_;
//- E coefficient
scalar E_;
public:
//- Runtime type information
TypeName("immersedBoundaryEpsilonWallFunction");
// Constructors
//- Construct from patch and internal field
immersedBoundaryEpsilonWallFunctionFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
immersedBoundaryEpsilonWallFunctionFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// immersedBoundaryEpsilonWallFunctionFvPatchScalarField
// onto a new patch
immersedBoundaryEpsilonWallFunctionFvPatchScalarField
(
const immersedBoundaryEpsilonWallFunctionFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
immersedBoundaryEpsilonWallFunctionFvPatchScalarField
(
const immersedBoundaryEpsilonWallFunctionFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new immersedBoundaryEpsilonWallFunctionFvPatchScalarField
(
*this
)
);
}
//- Construct as copy setting internal field reference
immersedBoundaryEpsilonWallFunctionFvPatchScalarField
(
const immersedBoundaryEpsilonWallFunctionFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new immersedBoundaryEpsilonWallFunctionFvPatchScalarField
(
*this,
iF
)
);
}
//- Destructor
virtual ~immersedBoundaryEpsilonWallFunctionFvPatchScalarField()
{}
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Evaluate the patchField
virtual void evaluate
(
const Pstream::commsTypes = Pstream::blocking
);
// I-O
//- Write
void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,401 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "immersedBoundaryOmegaWallFunctionFvPatchScalarField.H"
#include "immersedBoundaryVelocityWallFunctionFvPatchVectorField.H"
#include "RASModel.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
immersedBoundaryOmegaWallFunctionFvPatchScalarField::
immersedBoundaryOmegaWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
immersedBoundaryWallFunctionFvPatchScalarField(p, iF),
UName_("U"),
kName_("k"),
GName_("RASModel::G"),
nuName_("nu"),
nutName_("nut"),
Cmu_(0.09),
kappa_(0.41),
E_(9.8),
beta1_(0.075)
{}
immersedBoundaryOmegaWallFunctionFvPatchScalarField::
immersedBoundaryOmegaWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
immersedBoundaryWallFunctionFvPatchScalarField(p, iF, dict),
UName_(dict.lookupOrDefault<word>("U", "U")),
kName_(dict.lookupOrDefault<word>("k", "k")),
GName_(dict.lookupOrDefault<word>("G", "RASModel::G")),
nuName_(dict.lookupOrDefault<word>("nu", "nu")),
nutName_(dict.lookupOrDefault<word>("nut", "nut")),
Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
E_(dict.lookupOrDefault<scalar>("E", 9.8)),
beta1_(dict.lookupOrDefault<scalar>("beta1", 0.075))
{}
immersedBoundaryOmegaWallFunctionFvPatchScalarField::
immersedBoundaryOmegaWallFunctionFvPatchScalarField
(
const immersedBoundaryOmegaWallFunctionFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
immersedBoundaryWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
UName_(ptf.UName_),
kName_(ptf.kName_),
GName_(ptf.GName_),
nuName_(ptf.nuName_),
nutName_(ptf.nutName_),
Cmu_(ptf.Cmu_),
kappa_(ptf.kappa_),
E_(ptf.E_),
beta1_(ptf.beta1_)
{}
immersedBoundaryOmegaWallFunctionFvPatchScalarField::
immersedBoundaryOmegaWallFunctionFvPatchScalarField
(
const immersedBoundaryOmegaWallFunctionFvPatchScalarField& owfpsf
)
:
immersedBoundaryWallFunctionFvPatchScalarField(owfpsf),
UName_(owfpsf.UName_),
kName_(owfpsf.kName_),
GName_(owfpsf.GName_),
nuName_(owfpsf.nuName_),
nutName_(owfpsf.nutName_),
Cmu_(owfpsf.Cmu_),
kappa_(owfpsf.kappa_),
E_(owfpsf.E_),
beta1_(owfpsf.beta1_)
{}
immersedBoundaryOmegaWallFunctionFvPatchScalarField::
immersedBoundaryOmegaWallFunctionFvPatchScalarField
(
const immersedBoundaryOmegaWallFunctionFvPatchScalarField& owfpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
immersedBoundaryWallFunctionFvPatchScalarField(owfpsf, iF),
UName_(owfpsf.UName_),
kName_(owfpsf.kName_),
GName_(owfpsf.GName_),
nuName_(owfpsf.nuName_),
nutName_(owfpsf.nutName_),
Cmu_(owfpsf.Cmu_),
kappa_(owfpsf.kappa_),
E_(owfpsf.E_),
beta1_(owfpsf.beta1_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void immersedBoundaryOmegaWallFunctionFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
// If G field is not present, execute zero gradient evaluation
// HJ, 20/Mar/2011
if (!db().foundObject<volScalarField>(GName_))
{
InfoIn
(
"void immersedBoundaryOmegaWallFunctionFvPatchScalarField::"
"updateCoeffs()"
) << "Cannot access " << GName_ << " field. for patch "
<< patch().name() << ". Evaluating as regular immersed boundary"
<< endl;
immersedBoundaryWallFunctionFvPatchScalarField::evaluate();
return;
}
const vectorField& n = ibPatch().ibNormals();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalar Cmu25 = pow(Cmu_, 0.25);
const scalar Cmu50 = sqrt(Cmu_);
volScalarField& G = const_cast<volScalarField&>
(db().lookupObject<volScalarField>(GName_));
// Grab values of other fields required for wall functions
// Velocity
const fvPatchVectorField& Uwg =
patch().lookupPatchField<volVectorField, vector>(UName_);
const immersedBoundaryVelocityWallFunctionFvPatchVectorField& Uw =
refCast<const immersedBoundaryVelocityWallFunctionFvPatchVectorField>
(
Uwg
);
// Calculate tangential component, taking into account wall velocity
const vectorField UtanOld =
(I - sqr(n)) & (Uw.ibSamplingPointValue() - Uw.ibValue());
const scalarField magUtanOld = mag(UtanOld);
// Tangential velocity component
scalarField& UTangentialNew = Uw.wallTangentialValue();
// Wall shear stress
vectorField& tauWall = Uw.tauWall();
// Turbulence kinetic energy
const fvPatchScalarField& kg =
patch().lookupPatchField<volScalarField, scalar>(kName_);
const immersedBoundaryWallFunctionFvPatchScalarField& kw =
refCast<const immersedBoundaryWallFunctionFvPatchScalarField>(kg);
// Current and new values of k at sampling point
scalarField k = kw.ibSamplingPointValue();
scalarField& kNew = kw.wallValue();
// Laminar viscosity
const fvPatchScalarField& nuwg =
patch().lookupPatchField<volScalarField, scalar>(nuName_);
const immersedBoundaryFvPatchScalarField& nuw =
refCast<const immersedBoundaryFvPatchScalarField>(nuwg);
scalarField nu = nuw.ibCellValue();
// Turbulent viscosity
const fvPatchScalarField& nutwg =
patch().lookupPatchField<volScalarField, scalar>(nutName_);
const immersedBoundaryWallFunctionFvPatchScalarField& nutw =
refCast<const immersedBoundaryWallFunctionFvPatchScalarField>(nutwg);
// New values of nut
scalarField nutOld = nutw.ibCellValue();
scalarField& nutNew = nutw.wallValue();
const scalarField magGradUw = mag(Uw.ibGrad());
// Get the IB addressing and distance
const labelList& ibc = ibPatch().ibCells();
// Distance to sampling point
const scalarField& ySample = ibPatch().ibSamplingPointDelta();
// Distance from wall to IB point
const scalarField& y = ibPatch().ibDelta();
// Omega: store IB cell values for direct insertion
scalarField omegaSample = this->ibSamplingPointValue();
scalarField& omegaNew = this->wallValue();
// Mark values to be fixed
boolList wf(ibc.size(), false);
// Calculate yPlus for sample points
scalarField ypd = Cmu25*ySample*sqrt(k)/nu;
// Calculate wall function conditions
forAll (ibc, ibCellI)
{
// Calculate yPlus from k and laminar viscosity for the IB point
const scalar yPlusSample = ypd[ibCellI];
scalar tauW, uTau; // wall-shear and friction velocity from LOW
if (yPlusSample > yPlusLam)
{
// Calculate tauW from log-law using k and U at sampling point
tauW = magUtanOld[ibCellI]*Cmu25*sqrt(k[ibCellI])*kappa_
/log(E_*yPlusSample);
}
else
{
// Sampling point is in laminar sublayer
tauW = magUtanOld[ibCellI]*Cmu25*sqrt(k[ibCellI])/yPlusSample;
}
// friction velocity computed from k and U at sampling point
uTau = sqrt(tauW);
tauWall[ibCellI] = tauW*UtanOld[ibCellI]/(magUtanOld[ibCellI] + SMALL);
// Calculate yPlus for IB point
scalar yPlusIB = yPlusSample*y[ibCellI]/ySample[ibCellI];
// Calculate wall function data in the immersed boundary point
if (yPlusIB > yPlusLam)
{
const scalar nuLam = nu[ibCellI];
// Logarithmic region
wf[ibCellI] = true;
// turbulent viscosity at IB cell and at wall
scalar nutw = nuLam*(yPlusIB*kappa_/log(E_*yPlusIB) - 1);
// Fix generation even though it if is not used
G[ibc[ibCellI]] =
sqr((nutw + nuLam)*magGradUw[ibCellI])/
(Cmu25*sqrt(k[ibCellI])*kappa_*y[ibCellI]);
// Compute k at the IB cell
kNew[ibCellI] = tauW/Cmu50; // equilibrium boundary layer
// kNew[ibCellI] = k[ibCellI]; // zero-Gradient (less stable)
// Compute omega at the IB cell
omegaNew[ibCellI] = sqrt(kNew[ibCellI])/(Cmu25*kappa_*y[ibCellI]);
// Log-Law for tangential velocity - uTau = Cmu25*sqrt(kNew)
UTangentialNew[ibCellI] = uTau/kappa_*log(E_*yPlusIB);
// Calculate turbulent viscosity
nutNew[ibCellI] = nutw;
}
else
{
// Laminar sub-layer
wf[ibCellI] = false;
// G is zero - immaterial!
// G[ibc[ibCellI]] = 0;
// quadratic fit
kNew[ibCellI] = k[ibCellI]*sqr(yPlusIB/yPlusLam);
// Compute omega at the IB cell
omegaNew[ibCellI] = 6.0*nu[ibCellI]/(beta1_*sqr(y[ibCellI]));
// Bugfix - set zeroGradient bc for large omega values at ib boundary
// to avoid k unboundedness (IG 30/OCT/2015), not
// sure if this is a good criteria
if(omegaNew[ibCellI] > 10.0)
{
wf[ibCellI] = true;
}
// Laminar sub-layer for tangential velocity: uPlus = yPlus
UTangentialNew[ibCellI] = uTau*yPlusIB;
// Turbulent viscosity is zero
nutNew[ibCellI] = SMALL;
}
}
// Info<< "UTangentialNew " << min(UTangentialNew) << " " << max(UTangentialNew) << endl;
// Info<< "nutNew " << min(nutNew) << " " << max(nutNew) << endl;
// Info<< "kNew " << min(kNew) << " " << max(kNew) << endl;
// Info<< "epsilonNew " << min(epsilonNew) << " " << max(epsilonNew) << endl;
// Set the fields to calculated wall function values
Uw.wallMask() = true;
kw.wallMask() = wf;
nutw.wallMask() = true;
this->wallMask() = true;
// Insert epsilon values into the internal field
immersedBoundaryWallFunctionFvPatchScalarField::updateCoeffs();
}
void immersedBoundaryOmegaWallFunctionFvPatchScalarField::evaluate
(
const Pstream::commsTypes commsType
)
{
// Insert epsilon values into the internal field
this->setIbCellValues(this->wallValue());
fvPatchScalarField::evaluate(commsType);
}
void immersedBoundaryOmegaWallFunctionFvPatchScalarField::
write(Ostream& os) const
{
immersedBoundaryWallFunctionFvPatchScalarField::write(os);
writeEntryIfDifferent<word>(os, "U", "U", UName_);
writeEntryIfDifferent<word>(os, "k", "k", kName_);
writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_);
writeEntryIfDifferent<word>(os, "nu", "nu", nuName_);
writeEntryIfDifferent<word>(os, "nut", "nut", nutName_);
os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
os.writeKeyword("beta1") << beta1_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField
(
fvPatchScalarField,
immersedBoundaryOmegaWallFunctionFvPatchScalarField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,216 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressible::RASModels::
immersedBoundaryOmegaWallFunctionFvPatchScalarField
Description
Provides a wall function boundary condition/constraint on omega
Computed value is:
omega = sqrt(omega_vis^2 + omega_log^2)
where
omega_vis = omega in viscous region
omega_log = omega in logarithmic region
Model described by Eq.(15) of:
@verbatim
Menter, F., Esch, T.
"Elements of Industrial Heat Transfer Prediction"
16th Brazilian Congress of Mechanical Engineering (COBEM),
Nov. 2001
@endverbatim
SourceFiles
immersedBoundaryOmegaWallFunctionFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef immersedBoundaryOmegaWallFunctionFvPatchScalarField_H
#define immersedBoundaryOmegaWallFunctionFvPatchScalarField_H
#include "immersedBoundaryWallFunctionFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
/*---------------------------------------------------------------------------*\
Class immersedBoundaryOmegaWallFunctionFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class immersedBoundaryOmegaWallFunctionFvPatchScalarField
:
public immersedBoundaryWallFunctionFvPatchScalarField
{
// Private data
//- Name of velocity field
word UName_;
//- Name of turbulence kinetic energy field
word kName_;
//- Name of turbulence generation field
word GName_;
//- Name of laminar viscosity field
word nuName_;
//- Name of turbulent viscosity field
word nutName_;
//- Cmu coefficient
scalar Cmu_;
//- Von Karman constant
scalar kappa_;
//- E coefficient
scalar E_;
//- beta1 coefficient
scalar beta1_;
public:
//- Runtime type information
TypeName("immersedBoundaryOmegaWallFunction");
// Constructors
//- Construct from patch and internal field
immersedBoundaryOmegaWallFunctionFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
immersedBoundaryOmegaWallFunctionFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// immersedBoundaryOmegaWallFunctionFvPatchScalarField
// onto a new patch
immersedBoundaryOmegaWallFunctionFvPatchScalarField
(
const immersedBoundaryOmegaWallFunctionFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
immersedBoundaryOmegaWallFunctionFvPatchScalarField
(
const immersedBoundaryOmegaWallFunctionFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new immersedBoundaryOmegaWallFunctionFvPatchScalarField
(
*this
)
);
}
//- Construct as copy setting internal field reference
immersedBoundaryOmegaWallFunctionFvPatchScalarField
(
const immersedBoundaryOmegaWallFunctionFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new immersedBoundaryOmegaWallFunctionFvPatchScalarField
(
*this,
iF
)
);
}
//- Destructor
virtual ~immersedBoundaryOmegaWallFunctionFvPatchScalarField()
{}
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Evaluate the patchField
virtual void evaluate
(
const Pstream::commsTypes = Pstream::blocking
);
// I-O
//- Write
void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,294 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "immersedBoundaryVelocityWallFunctionFvPatchVectorField.H"
#include "immersedBoundaryWallFunctionFvPatchFields.H"
#include "RASModel.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
void immersedBoundaryVelocityWallFunctionFvPatchVectorField::setIbCellValues
(
const vectorField& ibcValues
) const
{
const labelList& ibc = ibPatch().ibCells();
if (ibcValues.size() != ibc.size())
{
FatalErrorIn
(
"void immersedBoundaryVelocityWallFunctionFvPatchVectorField::"
"setIbCellValues\n"
"(\n"
" const vectorField& ibcValues\n"
") const"
) << "Size of ibcValues field not equal to the number of IB cells."
<< nl << "ibcValues: " << ibcValues.size()
<< " ibc: " << ibc.size()
<< abort(FatalError);
}
// Get non-const access to internal field
vectorField& psiI = const_cast<vectorField&>(this->internalField());
immersedBoundaryFvPatchVectorField::setIbCellValues(ibcValues);
if (wallTangentialValue_.empty() || wallMask_.empty())
{
immersedBoundaryFvPatchVectorField::setIbCellValues(ibcValues);
}
else
{
const vectorField& n = ibPatch().ibNormals();
// Calculate tangential component taking into account wall velocity
scalarField UtanOld = mag((I - sqr(n)) & this->ibCellValue());
vectorField Uwall = this->ibValue();
forAll (ibcValues, cellI)
{
// If mask is set, correct the velocity for the
// tangential wall value, otherwise use the fitted value
if (wallMask_[cellI])
{
// Decompose fitted velocity into the normal and
// tangential components
const vector& curN = n[cellI];
const vector curU = psiI[ibc[cellI]];
scalar ibcNormal = curN & ibcValues[cellI];
// Get tangential velocity and direction
vector ibcTangential = (I - sqr(curN)) & curU;
ibcTangential /= mag(ibcTangential) + SMALL;
// Reconstruct the velocity, imposing the magnitude of
// tangential value and add wall velocity
psiI[ibc[cellI]] = curN*ibcNormal
+ ibcTangential*wallTangentialValue_[cellI]
+ Uwall[cellI];
}
else
{
psiI[ibc[cellI]] = ibcValues[cellI];
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
immersedBoundaryVelocityWallFunctionFvPatchVectorField::
immersedBoundaryVelocityWallFunctionFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
immersedBoundaryFvPatchVectorField(p, iF),
wallTangentialValue_(),
tauWall_(),
wallMask_()
{}
immersedBoundaryVelocityWallFunctionFvPatchVectorField::
immersedBoundaryVelocityWallFunctionFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
immersedBoundaryFvPatchVectorField(p, iF, dict),
wallTangentialValue_(),
tauWall_(),
wallMask_()
{}
immersedBoundaryVelocityWallFunctionFvPatchVectorField::
immersedBoundaryVelocityWallFunctionFvPatchVectorField
(
const immersedBoundaryVelocityWallFunctionFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
immersedBoundaryFvPatchVectorField(ptf, p, iF, mapper),
wallTangentialValue_(),
tauWall_(),
wallMask_()
{}
immersedBoundaryVelocityWallFunctionFvPatchVectorField::
immersedBoundaryVelocityWallFunctionFvPatchVectorField
(
const immersedBoundaryVelocityWallFunctionFvPatchVectorField& ewfpsf
)
:
immersedBoundaryFvPatchVectorField(ewfpsf),
wallTangentialValue_(),
tauWall_(),
wallMask_()
{}
immersedBoundaryVelocityWallFunctionFvPatchVectorField::
immersedBoundaryVelocityWallFunctionFvPatchVectorField
(
const immersedBoundaryVelocityWallFunctionFvPatchVectorField& ewfpsf,
const DimensionedField<vector, volMesh>& iF
)
:
immersedBoundaryFvPatchVectorField(ewfpsf, iF),
wallTangentialValue_(),
tauWall_(),
wallMask_()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const vectorField&
immersedBoundaryVelocityWallFunctionFvPatchVectorField::wallShearStress() const
{
if (tauWall_.empty())
{
FatalErrorIn
(
"const vectorField& "
"immersedBoundaryVelocityWallFunctionFvPatchVectorField::"
"wallShearStress() const"
) << "tauWall not set for IB patch " << patch().name()
<< " for field " << dimensionedInternalField().name()
<< abort(FatalError);
}
return tauWall_;
}
Foam::scalarField&
immersedBoundaryVelocityWallFunctionFvPatchVectorField::wallTangentialValue() const
{
// Bugfix 30/OCT/2015 - check if the mesh is moving
const immersedBoundaryFvPatch& ibFvP =
immersedBoundaryFvPatchVectorField::ibPatch();
if
(
wallTangentialValue_.empty()
|| (ibFvP.movingIb() || ibFvP.boundaryMesh().mesh().moving())
)
{
wallTangentialValue_.setSize
(
this->ibPatch().ibCells().size(),
0
);
}
return wallTangentialValue_;
}
Foam::vectorField&
immersedBoundaryVelocityWallFunctionFvPatchVectorField::tauWall() const
{
// Bugfix 30/OCT/2015 - check if the mesh is moving
const immersedBoundaryFvPatch& ibFvP =
immersedBoundaryFvPatchVectorField::ibPatch();
if
(
tauWall_.empty()
|| (ibFvP.movingIb() || ibFvP.boundaryMesh().mesh().moving())
)
{
tauWall_.setSize
(
this->ibPatch().ibCells().size(),
vector::zero
);
}
return tauWall_;
}
Foam::boolList&
immersedBoundaryVelocityWallFunctionFvPatchVectorField::wallMask() const
{
// Bugfix 30/OCT/2015 - check if the mesh is moving
const immersedBoundaryFvPatch& ibFvP =
immersedBoundaryFvPatchVectorField::ibPatch();
if
(
wallMask_.empty()
|| (ibFvP.movingIb() || ibFvP.boundaryMesh().mesh().moving())
)
{
wallMask_.setSize
(
this->ibPatch().ibCells().size(),
false
);
}
return wallMask_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField
(
fvPatchVectorField,
immersedBoundaryVelocityWallFunctionFvPatchVectorField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,192 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressible::RASModels::
immersedBoundaryVelocityWallFunctionFvPatchVectorField
Description
Boundary condition for velocity when using wall functions
- uses tangential velocity as prescribed by the epsilon boundary condition
to enforce into the fit
SourceFiles
immersedBoundaryVelocityWallFunctionFvPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef immersedBoundaryVelocityWallFunctionFvPatchVectorField_H
#define immersedBoundaryVelocityWallFunctionFvPatchVectorField_H
#include "fvPatchFields.H"
#include "immersedBoundaryFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
/*---------------------------------------------------------------------------*\
Class immersedBoundaryVelocityWallFunctionFvPatchVectorField Declaration
\*---------------------------------------------------------------------------*/
class immersedBoundaryVelocityWallFunctionFvPatchVectorField
:
public immersedBoundaryFvPatchVectorField
{
// Private data
//- Tangential velocity value to fix in IB cell
mutable scalarField wallTangentialValue_;
//- Wall shear stress
mutable vectorField tauWall_;
//- Indicator on values to fix
mutable boolList wallMask_;
protected:
// Protected Member Functions
//- Set IB cell values: contains data manipulation
virtual void setIbCellValues(const vectorField&) const;
public:
//- Runtime type information
TypeName("immersedBoundaryVelocityWallFunction");
// Constructors
//- Construct from patch and internal field
immersedBoundaryVelocityWallFunctionFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&
);
//- Construct from patch, internal field and dictionary
immersedBoundaryVelocityWallFunctionFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// immersedBoundaryVelocityWallFunctionFvPatchVectorField
// onto a new patch
immersedBoundaryVelocityWallFunctionFvPatchVectorField
(
const immersedBoundaryVelocityWallFunctionFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
immersedBoundaryVelocityWallFunctionFvPatchVectorField
(
const immersedBoundaryVelocityWallFunctionFvPatchVectorField&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new immersedBoundaryVelocityWallFunctionFvPatchVectorField
(
*this
)
);
}
//- Construct as copy setting internal field reference
immersedBoundaryVelocityWallFunctionFvPatchVectorField
(
const immersedBoundaryVelocityWallFunctionFvPatchVectorField&,
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 immersedBoundaryVelocityWallFunctionFvPatchVectorField
(
*this,
iF
)
);
}
//- Destructor
virtual ~immersedBoundaryVelocityWallFunctionFvPatchVectorField()
{}
// Member functions
// Access
//- Access to tangential velocity value to fix in IB cell
// Note non-const access
scalarField& wallTangentialValue() const;
//- Return wall shear stress
const vectorField& wallShearStress() const;
//- Access to wall shear stress in IB cell
// Note non-const access
vectorField& tauWall() const;
//- Access to indicator on fixed values. Note non-const access
boolList& wallMask() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,233 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "immersedBoundaryWallFunctionFvPatchField.H"
#include "fvPatchFieldMapper.H"
#include "addToRunTimeSelectionTable.H"
#include "wallFvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
template<class Type>
void immersedBoundaryWallFunctionFvPatchField<Type>::setIbCellValues
(
const Field<Type>& ibcValues
) const
{
const labelList& ibc = this->ibPatch().ibCells();
if (ibcValues.size() != ibc.size())
{
FatalErrorIn
(
"template<class Type>\n"
"void immersedBoundaryWallFunctionFvPatchField<Type>::"
"setIbCellValues\n"
"(\n"
" const Field<Type>& ibcValues\n"
") const"
) << "Size of ibcValues field not equal to the number of IB cells."
<< nl << "ibcValues: " << ibcValues.size()
<< " ibc: " << ibc.size()
<< abort(FatalError);
}
// Get non-const access to internal field
Field<Type>& psiI = const_cast<Field<Type>&>(this->internalField());
if (wallValue_.empty() || wallMask_.empty())
{
immersedBoundaryFvPatchField<Type>::setIbCellValues(ibcValues);
}
else
{
forAll (ibcValues, cellI)
{
// If mask is set use the wall value, otherwise use the
// fitted value
if (wallMask_[cellI])
{
psiI[ibc[cellI]] = wallValue_[cellI];
}
else
{
psiI[ibc[cellI]] = ibcValues[cellI];
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
immersedBoundaryWallFunctionFvPatchField<Type>::
immersedBoundaryWallFunctionFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF
)
:
immersedBoundaryFvPatchField<Type>(p, iF),
wallValue_(),
wallMask_()
{}
template<class Type>
immersedBoundaryWallFunctionFvPatchField<Type>::
immersedBoundaryWallFunctionFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const dictionary& dict
)
:
immersedBoundaryFvPatchField<Type>(p, iF, dict),
wallValue_(),
wallMask_()
{}
template<class Type>
immersedBoundaryWallFunctionFvPatchField<Type>::
immersedBoundaryWallFunctionFvPatchField
(
const immersedBoundaryWallFunctionFvPatchField& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
immersedBoundaryFvPatchField<Type>(ptf, p, iF, mapper),
wallValue_(),
wallMask_()
{}
template<class Type>
immersedBoundaryWallFunctionFvPatchField<Type>::
immersedBoundaryWallFunctionFvPatchField
(
const immersedBoundaryWallFunctionFvPatchField& tkqrwfpf
)
:
immersedBoundaryFvPatchField<Type>(tkqrwfpf),
wallValue_(),
wallMask_()
{}
template<class Type>
immersedBoundaryWallFunctionFvPatchField<Type>::
immersedBoundaryWallFunctionFvPatchField
(
const immersedBoundaryWallFunctionFvPatchField& tkqrwfpf,
const DimensionedField<Type, volMesh>& iF
)
:
immersedBoundaryFvPatchField<Type>(tkqrwfpf, iF),
wallValue_(),
wallMask_()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::Field<Type>& immersedBoundaryWallFunctionFvPatchField<Type>::wallValue() const
{
// Note: on a moving mesh, the intersection has changed and
// wallValue fields should be cleared and recalculated.
// This should happen only once, but I cannot see the mechanism
// HJ, 17/Oct/2012
// Bugfix 30/OCT/2015 - check if the mesh is moving
const immersedBoundaryFvPatch& ibFvP =
immersedBoundaryFvPatchField<Type>::ibPatch();
if
(
wallValue_.empty()
|| (ibFvP.movingIb() || ibFvP.boundaryMesh().mesh().moving())
)
{
wallValue_.setSize
(
this->ibPatch().ibCells().size(),
pTraits<Type>::zero
);
}
return wallValue_;
}
template<class Type>
Foam::boolList& immersedBoundaryWallFunctionFvPatchField<Type>::wallMask() const
{
// Note: on a moving mesh, the intersection has changed and
// wallValue fields should be cleared and recalculated.
// This should happen only once, but I cannot see the mechanism
// HJ, 17/Oct/2012
// Bugfix 30/OCT/2015 - check if the mesh is moving
const immersedBoundaryFvPatch& ibFvP =
immersedBoundaryFvPatchField<Type>::ibPatch();
if
(
wallMask_.empty()
|| (ibFvP.movingIb() || ibFvP.boundaryMesh().mesh().moving())
)
{
wallMask_.setSize
(
this->ibPatch().ibCells().size(),
false
);
}
return wallMask_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,195 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressible::RASModels::immersedBoundaryWallFunctionFvPatchField
Description
Boundary condition for passive turbulence variables (U, k, q, R, nut)
when using wall functions on an immersed boundary patch
Apart form standard immersed boundary capability, the patch field allows
only some values to be fixed, as defined by the wall function calculation.
This is handled using the ibWallValue and ibWallMask arrays, corresponding
to the number of ibCells
The implementation of wall functions on an immersed boundary will fix
the values of k, epsilon, nut and tangential velocity in cells within
the log-law layer. For the cells in the laminar sublayer, k and epsilon
(omega) will be calculated using a zero gradient condition,
nut will be set to zero and the tangential component of the
velocity will be corrected.
Author
Hrvoje Jasak, Wikki Ltd. All rights reserved
SourceFiles
immersedBoundaryWallFunctionFvPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef immersedBoundaryWallFunctionFvPatchField_H
#define immersedBoundaryWallFunctionFvPatchField_H
#include "fvPatchFields.H"
#include "immersedBoundaryFvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
/*---------------------------------------------------------------------------*\
Class immersedBoundaryWallFunctionFvPatchField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class immersedBoundaryWallFunctionFvPatchField
:
public immersedBoundaryFvPatchField<Type>
{
// Private data
//- Value to fix in IB cell
mutable Field<Type> wallValue_;
//- Indicator on values to fix
mutable boolList wallMask_;
protected:
// Protected Member Functions
//- Set IB cell values: contains data manipulation
virtual void setIbCellValues(const Field<Type>&) const;
public:
//- Runtime type information
TypeName("immersedBoundaryWallFunction");
// Constructors
//- Construct from patch and internal field
immersedBoundaryWallFunctionFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&
);
//- Construct from patch, internal field and dictionary
immersedBoundaryWallFunctionFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// immersedBoundaryWallFunctionFvPatchField
// onto a new patch
immersedBoundaryWallFunctionFvPatchField
(
const immersedBoundaryWallFunctionFvPatchField&,
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
immersedBoundaryWallFunctionFvPatchField
(
const immersedBoundaryWallFunctionFvPatchField&
);
//- Construct and return a clone
virtual tmp<fvPatchField<Type> > clone() const
{
return tmp<fvPatchField<Type> >
(
new immersedBoundaryWallFunctionFvPatchField(*this)
);
}
//- Construct as copy setting internal field reference
immersedBoundaryWallFunctionFvPatchField
(
const immersedBoundaryWallFunctionFvPatchField&,
const DimensionedField<Type, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchField<Type> > clone
(
const DimensionedField<Type, volMesh>& iF
) const
{
return tmp<fvPatchField<Type> >
(
new immersedBoundaryWallFunctionFvPatchField(*this, iF)
);
}
//- Destructor
virtual ~immersedBoundaryWallFunctionFvPatchField()
{}
// Member functions
// Access
//- Access to value to fix in IB cell. Note non-const access
Field<Type>& wallValue() const;
//- Access to indicator on fixed values. Note non-const access
boolList& wallMask() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "immersedBoundaryWallFunctionFvPatchField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,50 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "immersedBoundaryWallFunctionFvPatchFields.H"
#include "fvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePatchFields(immersedBoundaryWallFunction);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,55 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef immersedBoundaryWallFunctionFvPatchFields_H
#define immersedBoundaryWallFunctionFvPatchFields_H
#include "immersedBoundaryWallFunctionFvPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeFieldTypedefs(immersedBoundaryWallFunction)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //