Skip to content
Snippets Groups Projects
Commit 50965fe6 authored by andy's avatar andy
Browse files

ENH: Enabled both compressible and incompressible usage for the fixedShearStress BC

parent 62889245
No related branches found
No related tags found
No related merge requests found
porousBafflePressure/porousBafflePressureFvPatchFields.C
fixedShearStress/fixedShearStressFvPatchVectorField.C
LIB = $(FOAM_LIBBIN)/libturbulenceDerivedFvPatchFields
......@@ -28,28 +28,25 @@ License
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "RASModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
#include "incompressible/RAS/RASModel/RASModel.H"
#include "compressible/RAS/RASModel/RASModel.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
Foam::fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchVectorField(p, iF),
phiName_("phi"),
rhoName_("rho"),
tau0_(vector::zero)
{}
fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
Foam::fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
......@@ -57,13 +54,15 @@ fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
)
:
fixedValueFvPatchVectorField(p, iF),
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
tau0_(dict.lookupOrDefault<vector>("tau", vector::zero))
{
fvPatchField<vector>::operator=(patchInternalField());
}
fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
Foam::fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
(
const fixedShearStressFvPatchVectorField& ptf,
const fvPatch& p,
......@@ -72,76 +71,102 @@ fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
)
:
fixedValueFvPatchVectorField(ptf, p, iF, mapper),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_),
tau0_(ptf.tau0_)
{}
fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
Foam::fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
(
const fixedShearStressFvPatchVectorField& ptf
)
:
fixedValueFvPatchVectorField(ptf),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_),
tau0_(ptf.tau0_)
{}
fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
Foam::fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
(
const fixedShearStressFvPatchVectorField& ptf,
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchVectorField(ptf, iF),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_),
tau0_(ptf.tau0_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void fixedShearStressFvPatchVectorField::updateCoeffs()
void Foam::fixedShearStressFvPatchVectorField::updateCoeffs()
{
if (updated())
{
return;
}
const label patchi = patch().index();
const label patchI = patch().index();
const turbulenceModel& turbModel =
db().lookupObject<turbulenceModel>("turbulenceModel");
const surfaceScalarField& phi =
db().lookupObject<surfaceScalarField>(phiName_);
const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi];
scalarField nuEff;
if (phi.dimensions() == dimVelocity*dimArea)
{
const incompressible::turbulenceModel& turbModel =
db().lookupObject<incompressible::turbulenceModel>
(
"turbulenceModel"
);
const vectorField Ui(Uw.patchInternalField());
nuEff = turbModel.nuEff()()[patchI];
}
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
{
const compressible::turbulenceModel& turbModel =
db().lookupObject<compressible::turbulenceModel>
(
"turbulenceModel"
);
vector tauHat = tau0_/(mag(tau0_) + ROOTVSMALL);
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
const scalarField& ry = patch().deltaCoeffs();
nuEff = turbModel.muEff()()[patchI]/rhop;
}
else
{
FatalErrorIn("fixedShearStressFvPatchVectorField::updateCoeffs()")
<< "dimensions of phi are not correct"
<< "\n on patch " << this->patch().name()
<< " of field " << this->dimensionedInternalField().name()
<< " in file " << this->dimensionedInternalField().objectPath()
<< exit(FatalError);
}
tmp<volScalarField> tnuEff = turbModel.nuEff();
const volScalarField& nuEff = tnuEff();
const scalarField& nuEffw = nuEff.boundaryField()[patchi];
const vectorField Uc(patchInternalField());
tmp<vectorField> UwUpdated =
tauHat*(tauHat & (tau0_*(1.0/(ry*nuEffw)) + Ui));
vector tauHat = tau0_/(mag(tau0_) + ROOTVSMALL);
operator==(UwUpdated);
const scalarField& ry = patch().deltaCoeffs();
if (debug)
{
tmp<vectorField> nHat = this->patch().nf();
volSymmTensorField Reff(turbModel.devReff());
Info << "tau : " << (nHat & Reff.boundaryField()[patchi])() << endl;
}
operator==(tauHat*(tauHat & (tau0_*(1.0/(ry*nuEff)) + Uc)));
fixedValueFvPatchVectorField::updateCoeffs();
}
void fixedShearStressFvPatchVectorField::write(Ostream& os) const
void Foam::fixedShearStressFvPatchVectorField::write(Ostream& os) const
{
fixedValueFvPatchVectorField::write(os);
writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
os.writeKeyword("tau") << tau0_ << token::END_STATEMENT << nl;
writeEntry("value", os);
}
......@@ -149,15 +174,13 @@ void fixedShearStressFvPatchVectorField::write(Ostream& os) const
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField
(
fvPatchVectorField,
fixedShearStressFvPatchVectorField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace incompressible
} // End namespace Foam
namespace Foam
{
makePatchTypeField
(
fvPatchVectorField,
fixedShearStressFvPatchVectorField
);
}
// ************************************************************************* //
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -43,8 +43,7 @@ SourceFiles
namespace Foam
{
namespace incompressible
{
/*---------------------------------------------------------------------------*\
Class fixedShearStressFvPatchVectorField Declaration
\*---------------------------------------------------------------------------*/
......@@ -55,6 +54,12 @@ class fixedShearStressFvPatchVectorField
{
// Private data
//- Name of flux field (default = phi)
const word phiName_;
//- Name of density field (default = rho)
const word rhoName_;
//- Constant shear stress
const vector tau0_;
......@@ -138,7 +143,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace incompressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -51,7 +51,6 @@ $(kappatWallFunctions)/kappatJayatillekeWallFunction/kappatJayatillekeWallFuncti
derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C
derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C
derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C
derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C
derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.C
derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment