Skip to content

Commit

Permalink
Merged main into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
friedenhe committed Jan 30, 2025
2 parents 2ceaa86 + 08422e9 commit 042f515
Show file tree
Hide file tree
Showing 5 changed files with 324 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/adjoint/DAFunction/DAFunctionWallHeatFlux.H
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ protected:
/// the area of all heat flux patches
scalar areaSum_ = -9999.0;

/// if calculating flux per unit area or total, which mode to use
word calcMode_;

public:
TypeName("wallHeatFlux");
// Constructors
Expand Down
1 change: 1 addition & 0 deletions src/adjoint/DAMisc/Make/files
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ MRFDF/IOMRFZoneListDF.C
meshWaveFrozen/meshWaveFrozenPatchDistMethod.C
pimpleControlDF/pimpleControlDF.C
tractionDisplacement/tractionDisplacementFvPatchVectorField.C
alphatWallFunctionIncomp/alphatWallFunctionIncompFvPatchScalarField.C

LIB = $(DAFOAM_ROOT_PATH)/OpenFOAM/sharedLibs/libDAMisc$(WM_CODI_AD_LIB_POSTFIX)
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

// ************************************************************************* //
2 changes: 1 addition & 1 deletion src/newTurbModels/incompressible/Make/options
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ EXE_INC = \
-I$(PETSC_DIR)/$(PETSC_ARCH)/include \
$(shell mpicc -show | grep -o '\-I[^ ]*') \
$(shell python3-config --includes)


LIB_LIBS = \
-lturbulenceModels$(WM_CODI_AD_LIB_POSTFIX) \
Expand Down

0 comments on commit 042f515

Please sign in to comment.