Skip to content

Commit

Permalink
Added an incompressible alphatWallFunction. (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
friedenhe authored Oct 9, 2024
1 parent 1234524 commit 39692e8
Show file tree
Hide file tree
Showing 3 changed files with 320 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/adjoint/Make/files_Incompressible
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ boundaryConditions/multiFreqVector/multiFreqVectorFvPatchField.C
boundaryConditions/nutUSpaldingWallFunctionDF/nutUSpaldingWallFunctionFvPatchScalarFieldDF.C
boundaryConditions/varyingVelocity/varyingVelocityFvPatchVectorField.C
boundaryConditions/varyingVelocityInletOutlet/varyingVelocityInletOutletFvPatchVectorField.C
boundaryConditions/alphatWallFunctionIncomp/alphatWallFunctionIncompFvPatchScalarField.C
models/dummyTurbulenceModel/makeDummyTurbulenceModelIncompressible.C
models/SpalartAllmarasFv3/makeSpalartAllmarasFv3Incompressible.C
models/SpalartAllmarasFv3FieldInversion/makeSpalartAllmarasFv3FieldInversionIncompressible.C
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd
-------------------------------------------------------------------------------
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 "alphatWallFunctionIncompFvPatchScalarField.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
namespace incompressible
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

alphatWallFunctionIncompressibleFvPatchScalarField::
alphatWallFunctionIncompressibleFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
Prt_(0.85)
{
}


alphatWallFunctionIncompressibleFvPatchScalarField::
alphatWallFunctionIncompressibleFvPatchScalarField
(
const alphatWallFunctionIncompressibleFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
Prt_(ptf.Prt_)
{
}


alphatWallFunctionIncompressibleFvPatchScalarField::
alphatWallFunctionIncompressibleFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict),
Prt_(dict.get<scalar>("Prt")) // force read to avoid ambiguity
{
}


alphatWallFunctionIncompressibleFvPatchScalarField::
alphatWallFunctionIncompressibleFvPatchScalarField
(
const alphatWallFunctionIncompressibleFvPatchScalarField& wfpsf
)
:
fixedValueFvPatchScalarField(wfpsf),
Prt_(wfpsf.Prt_)
{
}


alphatWallFunctionIncompressibleFvPatchScalarField::
alphatWallFunctionIncompressibleFvPatchScalarField
(
const alphatWallFunctionIncompressibleFvPatchScalarField& wfpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(wfpsf, iF),
Prt_(wfpsf.Prt_)
{
}


// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

void alphatWallFunctionIncompressibleFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}

const label patchi = patch().index();

// Retrieve turbulence properties from model

const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>
(
IOobject::groupName
(
turbulenceModel::propertiesName,
internalField().group()
)
);

const tmp<scalarField> tnutw = turbModel.nut(patchi);

operator==(tnutw/Prt_);

fixedValueFvPatchField<scalar>::updateCoeffs();
}


void alphatWallFunctionIncompressibleFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);
os.writeEntry("Prt", Prt_);
writeEntry("value", os);
}


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

makePatchTypeField
(
fvPatchScalarField,
alphatWallFunctionIncompressibleFvPatchScalarField
);

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace incompressible
} // End namespace Foam

// ************************************************************************* //
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/*---------------------------------------------------------------------------*\
DAFoam : Discrete Adjoint with OpenFOAM
Version : v3
This file is modified from OpenFOAM's source code
src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/
wallFunctions/alphatWallFunctionIncompressibles/alphatWallFunctionIncompressible
The turbulent thermal diffusivity calculated using:
\f[
\alpha_t = \frac{\nu_t}{Pr_t}
\f]
OpenFOAM: The Open Source CFD Toolbox
Copyright (C): 2011-2016 OpenFOAM Foundation
OpenFOAM License:
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/>.
Description:
Fixed traction boundary condition for the standard linear elastic,
fixed coefficient displacement equation.
\*---------------------------------------------------------------------------*/

#ifndef alphatWallFunctionIncompressibleFvPatchScalarField_H
#define alphatWallFunctionIncompressibleFvPatchScalarField_H

#include "fixedValueFvPatchFields.H"
#include "turbulenceModel.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
namespace incompressible
{

/*---------------------------------------------------------------------------*\
Class alphatWallFunctionIncompressibleFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/

class alphatWallFunctionIncompressibleFvPatchScalarField
:
public fixedValueFvPatchScalarField
{
protected:

// Protected data

//- Turbulent Prandtl number
scalar Prt_;

public:

//- Runtime type information
TypeName("incompressible::alphatWallFunction");


// Constructors

//- Construct from patch and internal field
alphatWallFunctionIncompressibleFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);

//- Construct from patch, internal field and dictionary
alphatWallFunctionIncompressibleFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);

//- Construct by mapping given
// alphatWallFunctionIncompressibleFvPatchScalarField
// onto a new patch
alphatWallFunctionIncompressibleFvPatchScalarField
(
const alphatWallFunctionIncompressibleFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);

//- Construct as copy
alphatWallFunctionIncompressibleFvPatchScalarField
(
const alphatWallFunctionIncompressibleFvPatchScalarField&
);

//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new alphatWallFunctionIncompressibleFvPatchScalarField(*this)
);
}

//- Construct as copy setting internal field reference
alphatWallFunctionIncompressibleFvPatchScalarField
(
const alphatWallFunctionIncompressibleFvPatchScalarField&,
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 alphatWallFunctionIncompressibleFvPatchScalarField(*this, iF)
);
}


// Member functions

// Evaluation functions

//- Update the coefficients associated with the patch field
virtual void updateCoeffs();


// I-O

//- Write
virtual void write(Ostream&) const;
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace incompressible
} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //

0 comments on commit 39692e8

Please sign in to comment.