Commit 55e5a777 authored by shunbo's avatar shunbo
Browse files

initial commit

parents
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
set -x
(wmake libso BCs && wmake )
# ----------------------------------------------------------------- end-of-file
U/maxwellSlipUFvPatchVectorgpuField.C
T/smoluchowskiJumpTFvPatchScalargpuField.C
rho/fixedRhoFvPatchScalargpuField.C
LIB = $(FOAM_LIBBIN)/librhoCentralFoam-GPU
EXE_INC = \
-I$(LIB_SRC)/gpufiniteVolume/lnInclude \
-I$(LIB_SRC)/gpuOpenFOAM/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/transportModels-GPU/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels-GPU/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels-GPU/specie/lnInclude
LIB_LIBS = \
-lgpufiniteVolume \
-lgpuOpenFOAM \
-lfiniteVolume \
-lcompressibleTransportModels-GPU \
-lfluidThermophysicalModels-GPU \
-lspecie-GPU
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2020 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 "smoluchowskiJumpTFvPatchScalargpuField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchgpuFieldMapper.H"
#include "volgpuFields.H"
#include "basicThermo.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::smoluchowskiJumpTFvPatchScalargpuField::smoluchowskiJumpTFvPatchScalargpuField
(
const gpufvPatch& p,
const DimensionedgpuField<scalar, gpuvolMesh>& iF
)
:
mixedFvPatchScalargpuField(p, iF),
UName_("U"),
rhoName_("rho"),
psiName_("thermo:psi"),
muName_("thermo:mu"),
accommodationCoeff_(1.0),
Twall_(p.size(), Zero),
gamma_(1.4)
{
refValue() = 0.0;
refGrad() = 0.0;
valueFraction() = 0.0;
}
Foam::smoluchowskiJumpTFvPatchScalargpuField::smoluchowskiJumpTFvPatchScalargpuField
(
const smoluchowskiJumpTFvPatchScalargpuField& ptf,
const gpufvPatch& p,
const DimensionedgpuField<scalar, gpuvolMesh>& iF,
const fvPatchgpuFieldMapper& mapper
)
:
mixedFvPatchScalargpuField(ptf, p, iF, mapper),
UName_(ptf.UName_),
rhoName_(ptf.rhoName_),
psiName_(ptf.psiName_),
muName_(ptf.muName_),
accommodationCoeff_(ptf.accommodationCoeff_),
Twall_(ptf.Twall_),
gamma_(ptf.gamma_)
{}
Foam::smoluchowskiJumpTFvPatchScalargpuField::smoluchowskiJumpTFvPatchScalargpuField
(
const gpufvPatch& p,
const DimensionedgpuField<scalar, gpuvolMesh>& iF,
const dictionary& dict
)
:
mixedFvPatchScalargpuField(p, iF),
UName_(dict.getOrDefault<word>("U", "U")),
rhoName_(dict.getOrDefault<word>("rho", "rho")),
psiName_(dict.getOrDefault<word>("psi", "thermo:psi")),
muName_(dict.getOrDefault<word>("mu", "thermo:mu")),
accommodationCoeff_(dict.get<scalar>("accommodationCoeff")),
Twall_("Twall", dict, p.size()),
gamma_(dict.getOrDefault<scalar>("gamma", 1.4))
{
if
(
mag(accommodationCoeff_) < SMALL
|| mag(accommodationCoeff_) > 2.0
)
{
FatalIOErrorInFunction(dict)
<< "unphysical accommodationCoeff specified"
<< "(0 < accommodationCoeff <= 1)" << endl
<< exit(FatalIOError);
}
if (dict.found("value"))
{
fvPatchgpuField<scalar>::operator=
(
scalargpuField("value", dict, p.size())
);
}
else
{
fvPatchgpuField<scalar>::operator=(patchInternalField());
}
refValue() = *this;
refGrad() = 0.0;
valueFraction() = 0.0;
}
Foam::smoluchowskiJumpTFvPatchScalargpuField::smoluchowskiJumpTFvPatchScalargpuField
(
const smoluchowskiJumpTFvPatchScalargpuField& ptpsf,
const DimensionedgpuField<scalar, gpuvolMesh>& iF
)
:
mixedFvPatchScalargpuField(ptpsf, iF),
accommodationCoeff_(ptpsf.accommodationCoeff_),
Twall_(ptpsf.Twall_),
gamma_(ptpsf.gamma_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Map from self
void Foam::smoluchowskiJumpTFvPatchScalargpuField::autoMap
(
const fvPatchgpuFieldMapper& m
)
{
mixedFvPatchScalargpuField::autoMap(m);
}
// Reverse-map the given fvPatchField onto this fvPatchField
void Foam::smoluchowskiJumpTFvPatchScalargpuField::rmap
(
const fvPatchgpuField<scalar>& ptf,
const labelgpuList& addr
)
{
mixedFvPatchgpuField<scalar>::rmap(ptf, addr);
}
// Update the coefficients associated with the patch field
void Foam::smoluchowskiJumpTFvPatchScalargpuField::updateCoeffs()
{
if (updated())
{
return;
}
const fvPatchScalargpuField& pmu =
patch().lookupPatchField<volScalargpuField, scalar>(muName_);
const fvPatchScalargpuField& prho =
patch().lookupPatchField<volScalargpuField, scalar>(rhoName_);
const fvPatchgpuField<scalar>& ppsi =
patch().lookupPatchField<volScalargpuField, scalar>(psiName_);
const fvPatchVectorgpuField& pU =
patch().lookupPatchField<volVectorgpuField, vector>(UName_);
// Prandtl number reading consistent with rhoCentralFoam
const dictionary& thermophysicalProperties =
db().lookupObject<IOdictionary>(basicThermo::dictName);
dimensionedScalar Pr
(
"Pr",
dimless,
thermophysicalProperties.subDict("mixture").subDict("transport")
);
gpuField<scalar> C2
(
pmu/prho
*sqrt(ppsi*constant::mathematical::piByTwo)
*2.0*gamma_/Pr.value()/(gamma_ + 1.0)
*(2.0 - accommodationCoeff_)/accommodationCoeff_
);
gpuField<scalar> aCoeff(prho.snGrad() - prho/C2);
gpuField<scalar> KEbyRho(0.5*magSqr(pU));
valueFraction() = (1.0/(1.0 + patch().deltaCoeffs()*C2));
refValue() = Twall_;
refGrad() = 0.0;
mixedFvPatchScalargpuField::updateCoeffs();
}
// Write
void Foam::smoluchowskiJumpTFvPatchScalargpuField::write(Ostream& os) const
{
fvPatchScalargpuField::write(os);
os.writeEntryIfDifferent<word>("U", "U", UName_);
os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
os.writeEntryIfDifferent<word>("mu", "thermo:mu", muName_);
os.writeEntry("accommodationCoeff", accommodationCoeff_);
Twall_.writeEntry("Twall", os);
os.writeEntry("gamma", gamma_);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalargpuField,
smoluchowskiJumpTFvPatchScalargpuField
);
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation
-------------------------------------------------------------------------------
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::smoluchowskiJumpTFvPatchScalarField
Description
Smoluchowski temperature jump boundary condition
SourceFiles
smoluchowskiJumpTFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef smoluchowskiJumpTFvPatchScalargpuField_H
#define smoluchowskiJumpTFvPatchScalargpuField_H
#include "mixedFvPatchgpuFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class smoluchowskiJumpTFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class smoluchowskiJumpTFvPatchScalargpuField
:
public mixedFvPatchScalargpuField
{
// Private data
//- Velocity field name, default = "U"
word UName_;
//- Density field name, default = "rho"
word rhoName_;
//- Compressibility field name, default = "thermo:psi"
word psiName_;
//- Dynamic viscosity field name, default = "thermo:mu"
word muName_;
//- Accommodation coefficient
scalar accommodationCoeff_;
//- Wall surface temperature
scalarField Twall_;
//- Heat capacity ratio (default 1.4)
scalar gamma_;
public:
//- Runtime type information
TypeName("smoluchowskiJumpT");
// Constructors
//- Construct from patch and internal field
smoluchowskiJumpTFvPatchScalargpuField
(
const gpufvPatch&,
const DimensionedgpuField<scalar, gpuvolMesh>&
);
//- Construct from patch, internal field and dictionary
smoluchowskiJumpTFvPatchScalargpuField
(
const gpufvPatch&,
const DimensionedgpuField<scalar, gpuvolMesh>&,
const dictionary&
);
//- Construct by mapping given smoluchowskiJumpTFvPatchScalarField
// onto a new patch
smoluchowskiJumpTFvPatchScalargpuField
(
const smoluchowskiJumpTFvPatchScalargpuField&,
const gpufvPatch&,
const DimensionedgpuField<scalar, gpuvolMesh>&,
const fvPatchgpuFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchScalargpuField> clone() const
{
return tmp<fvPatchScalargpuField>
(
new smoluchowskiJumpTFvPatchScalargpuField(*this)
);
}
//- Construct as copy setting internal field reference
smoluchowskiJumpTFvPatchScalargpuField
(
const smoluchowskiJumpTFvPatchScalargpuField&,
const DimensionedgpuField<scalar, gpuvolMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalargpuField> clone
(
const DimensionedgpuField<scalar, gpuvolMesh>& iF
) const
{
return tmp<fvPatchScalargpuField>
(
new smoluchowskiJumpTFvPatchScalargpuField(*this, iF)
);
}
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchgpuFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchgpuField<scalar>&,
const labelgpuList&
);
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2020 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 "maxwellSlipUFvPatchVectorgpuField.H"
#include "addToRunTimeSelectionTable.H"
#include "mathematicalConstants.H"
#include "fvPatchgpuFieldMapper.H"
#include "volgpuFields.H"
#include "gpufvcGrad.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::maxwellSlipUFvPatchVectorgpuField::maxwellSlipUFvPatchVectorgpuField
(
const gpufvPatch& p,
const DimensionedgpuField<vector, gpuvolMesh>& iF
)
:
partialSlipFvPatchVectorgpuField(p, iF),
TName_("T"),
rhoName_("rho"),
psiName_("thermo:psi"),
muName_("thermo:mu"),
tauMCName_("tauMC"),
accommodationCoeff_(1.0),
Uwall_(p.size(), Zero),
thermalCreep_(true),
curvature_(true)
{}
Foam::maxwellSlipUFvPatchVectorgpuField::maxwellSlipUFvPatchVectorgpuField
(
const maxwellSlipUFvPatchVectorgpuField& mspvf,
const gpufvPatch& p,
const DimensionedgpuField<vector, gpuvolMesh>& iF,
const fvPatchgpuFieldMapper& mapper
)
:
partialSlipFvPatchVectorgpuField(mspvf, p, iF, mapper),
TName_(mspvf.TName_),
rhoName_(mspvf.rhoName_),
psiName_(mspvf.psiName_),
muName_(mspvf.muName_),
tauMCName_(mspvf.tauMCName_),
accommodationCoeff_(mspvf.accommodationCoeff_),
Uwall_(mspvf.Uwall_),
thermalCreep_(mspvf.thermalCreep_),
curvature_(mspvf.curvature_)
{}
Foam::maxwellSlipUFvPatchVectorgpuField::maxwellSlipUFvPatchVectorgpuField
(
const gpufvPatch& p,
const DimensionedgpuField<vector, gpuvolMesh>& iF,
const dictionary& dict
)
:
partialSlipFvPatchVectorgpuField(p, iF),
TName_(dict.getOrDefault<word>("T", "T")),
rhoName_(dict.getOrDefault<word>("rho", "rho")),
psiName_(dict.getOrDefault<word>("psi", "thermo:psi")),
muName_(dict.getOrDefault<word>("mu", "thermo:mu")),
tauMCName_(dict.getOrDefault<word>("tauMC", "tauMC")),
accommodationCoeff_(dict.get<scalar>("accommodationCoeff")),
Uwall_("Uwall", dict, p.size()),
thermalCreep_(dict.getOrDefault("thermalCreep", true)),
curvature_(dict.getOrDefault("curvature", true))
{
if
(
mag(accommodationCoeff_) < SMALL
|| mag(accommodationCoeff_) > 2.0
)
{
FatalIOErrorInFunction(dict)
<< "unphysical accommodationCoeff_ specified"
<< "(0 < accommodationCoeff_ <= 1)" << endl
<< exit(FatalIOError);
}
if (dict.found("value"))
{
fvPatchgpuField<vector>::operator=
(
vectorgpuField("value", dict, p.size())
);
if (dict.found("refValue") && dict.found("valueFraction"))
{
this->refValue() = vectorgpuField("refValue", dict, p.size());
this->valueFraction() =
scalargpuField("valueFraction", dict, p.size());
}
else
{
this->refValue() = *this;
this->valueFraction() = scalar(1);
}
}
}
Foam::maxwellSlipUFvPatchVectorgpuField::maxwellSlipUFvPatchVectorgpuField
(
const maxwellSlipUFvPatchVectorgpuField& mspvf,
const DimensionedgpuField<vector, gpuvolMesh>& iF
)
:
partialSlipFvPatchVectorgpuField(mspvf, iF),
TName_(mspvf.TName_),
rhoName_(mspvf.rhoName_),
psiName_(mspvf.psiName_),
muName_(mspvf.muName_),
tauMCName_(mspvf.tauMCName_),
accommodationCoeff_(mspvf.accommodationCoeff_),
Uwall_(mspvf.Uwall_),
thermalCreep_(mspvf.thermalCreep_),
curvature_(mspvf.curvature_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::maxwellSlipUFvPatchVectorgpuField::updateCoeffs()
{
if (updated())
{
return;
}
const fvPatchScalargpuField& pmu =
patch().lookupPatchField<volScalargpuField, scalar>(muName_);
const fvPatchScalargpuField& prho =
patch().lookupPatchField<volScalargpuField, scalar>(rhoName_);
const fvPatchgpuField<scalar>& ppsi =
patch().lookupPatchField<volScalargpuField, scalar>(psiName_);
gpuField<scalar> C1
(
sqrt(ppsi*constant::mathematical::piByTwo)
* (2.0 - accommodationCoeff_)/accommodationCoeff_
);
gpuField<scalar> pnu(pmu/prho);
valueFraction() = (1.0/(1.0 + patch().deltaCoeffs()*C1*pnu));
refValue() = Uwall_;
if (thermalCreep_)
{
const volScalargpuField& vsfT =
this->db().objectRegistry::lookupObject<volScalargpuField>(TName_);
label patchi = this->patch().index();
const fvPatchScalargpuField& pT = vsfT.boundaryField()[patchi];
gpuField<vector> gradpT(fvc::grad(vsfT)().boundaryField()[patchi]);
vectorgpuField n(patch().nf());
refValue() -= 3.0*pnu/(4.0*pT)*transform(I - n*n, gradpT);
}
if (curvature_)
{
const fvPatchTensorgpuField& ptauMC =
patch().lookupPatchField<volTensorgpuField, tensor>(tauMCName_);
vectorgpuField n(patch().nf());
refValue() -= C1/prho*transform(I - n*n, (n & ptauMC));
}
partialSlipFvPatchVectorgpuField::updateCoeffs();
}
void Foam::maxwellSlipUFvPatchVectorgpuField::write(Ostream& os) const
{
fvPatchVectorgpuField::write(os);
os.writeEntryIfDifferent<word>("T", "T", TName_);
os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
os.writeEntryIfDifferent<word>("mu", "thermo:mu", muName_);
os.writeEntryIfDifferent<word>("tauMC", "tauMC", tauMCName_);
os.writeEntry("accommodationCoeff", accommodationCoeff_);
Uwall_.writeEntry("Uwall", os);
os.writeEntry("thermalCreep", thermalCreep_);
os.writeEntry("curvature", curvature_);
refValue().writeEntry("refValue", os);
valueFraction().writeEntry("valueFraction", os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchVectorgpuField,
maxwellSlipUFvPatchVectorgpuField
);
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation
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/>.
Class
Foam::maxwellSlipUFvPatchVectorField
Description
Maxwell slip boundary condition including thermal creep and surface
curvature terms that can be optionally switched off.
SourceFiles
fixedRhoFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef maxwellSlipUFvPatchVectorgpuField_H
#define maxwellSlipUFvPatchVectorgpuField_H
#include "partialSlipFvPatchgpuFields.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class maxwellSlipUFvPatch Declaration
\*---------------------------------------------------------------------------*/
class maxwellSlipUFvPatchVectorgpuField
:
public partialSlipFvPatchVectorgpuField
{
// Private data
//- Temperature field name, default = "T"
word TName_;
//- Density field name, default = "rho"
word rhoName_;
//- Compressibility field name, default = "thermo:psi"
word psiName_;
//- Dynamic viscosity field name, default = "thermo:mu"
word muName_;
//- tauMC field name, default = "tauMC"
word tauMCName_;
// Accommodation coefficient
scalar accommodationCoeff_;
// Wall velocity
vectorgpuField Uwall_;
// Include thermal creep term (default on)
Switch thermalCreep_;
// Include boundary curvature term (default on)
Switch curvature_;
public:
//- Runtime type information
TypeName("maxwellSlipU");
// Constructors
//- Construct from patch and internal field
maxwellSlipUFvPatchVectorgpuField
(
const gpufvPatch&,
const DimensionedgpuField<vector, gpuvolMesh>&
);
//- Construct from patch, internal field and dictionary
maxwellSlipUFvPatchVectorgpuField
(
const gpufvPatch&,
const DimensionedgpuField<vector, gpuvolMesh>&,
const dictionary&
);
//- Construct by mapping given
// maxwellSlipUFvPatchVectorField onto a new patch
maxwellSlipUFvPatchVectorgpuField
(
const maxwellSlipUFvPatchVectorgpuField&,
const gpufvPatch&,
const DimensionedgpuField<vector, gpuvolMesh>&,
const fvPatchgpuFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorgpuField> clone() const
{
return tmp<fvPatchVectorgpuField>
(
new maxwellSlipUFvPatchVectorgpuField(*this)
);
}
//- Construct as copy setting internal field reference
maxwellSlipUFvPatchVectorgpuField
(
const maxwellSlipUFvPatchVectorgpuField&,
const DimensionedgpuField<vector, gpuvolMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchVectorgpuField> clone
(
const DimensionedgpuField<vector, gpuvolMesh>& iF
) const
{
return tmp<fvPatchVectorgpuField>
(
new maxwellSlipUFvPatchVectorgpuField(*this, iF)
);
}
// Member functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2020 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 "fixedRhoFvPatchScalargpuField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchgpuFieldMapper.H"
#include "volgpuFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fixedRhoFvPatchScalargpuField::fixedRhoFvPatchScalargpuField
(
const gpufvPatch& p,
const DimensionedgpuField<scalar, gpuvolMesh>& iF
)
:
fixedValueFvPatchScalargpuField(p, iF),
pName_("p"),
psiName_("thermo:psi")
{}
Foam::fixedRhoFvPatchScalargpuField::fixedRhoFvPatchScalargpuField
(
const fixedRhoFvPatchScalargpuField& ptf,
const gpufvPatch& p,
const DimensionedgpuField<scalar, gpuvolMesh>& iF,
const fvPatchgpuFieldMapper& mapper
)
:
fixedValueFvPatchScalargpuField(ptf, p, iF, mapper),
pName_(ptf.pName_),
psiName_(ptf.psiName_)
{}
Foam::fixedRhoFvPatchScalargpuField::fixedRhoFvPatchScalargpuField
(
const gpufvPatch& p,
const DimensionedgpuField<scalar, gpuvolMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalargpuField(p, iF, dict),
pName_(dict.getOrDefault<word>("p", "p")),
psiName_(dict.getOrDefault<word>("psi", "thermo:psi"))
{}
Foam::fixedRhoFvPatchScalargpuField::fixedRhoFvPatchScalargpuField
(
const fixedRhoFvPatchScalargpuField& frpsf
)
:
fixedValueFvPatchScalargpuField(frpsf),
pName_(frpsf.pName_),
psiName_(frpsf.psiName_)
{}
Foam::fixedRhoFvPatchScalargpuField::fixedRhoFvPatchScalargpuField
(
const fixedRhoFvPatchScalargpuField& frpsf,
const DimensionedgpuField<scalar, gpuvolMesh>& iF
)
:
fixedValueFvPatchScalargpuField(frpsf, iF),
pName_(frpsf.pName_),
psiName_(frpsf.psiName_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fixedRhoFvPatchScalargpuField::updateCoeffs()
{
if (updated())
{
return;
}
const fvPatchgpuField<scalar>& psip =
patch().lookupPatchField<volScalargpuField, scalar>(psiName_);
const fvPatchgpuField<scalar>& pp =
patch().lookupPatchField<volScalargpuField, scalar>(pName_);
operator==(psip*pp);
fixedValueFvPatchScalargpuField::updateCoeffs();
}
void Foam::fixedRhoFvPatchScalargpuField::write(Ostream& os) const
{
fvPatchScalargpuField::write(os);
os.writeEntryIfDifferent<word>("p", "p", pName_);
os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalargpuField,
fixedRhoFvPatchScalargpuField
);
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
-------------------------------------------------------------------------------
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::fixedRhoFvPatchScalarField
Group
grpInletBoundaryConditions
Description
Foam::fixedRhoFvPatchScalarField
This boundary condition provides a fixed density inlet condition for
compressible solvers, where the density of calculated using:
\f[
\rho = \psi p
\f]
where
\vartable
p | pressure [Pa]
\rho | density [kg/m3]
\endvartable
Usage
\table
Property | Description | Required | Default value
p | Pressure field name | no | p
psi | Compressibility field name | no | thermo:psi
\endtable
Example of the boundary condition specification:
\verbatim
<patchName>
{
type fixedRho;
}
\endverbatim
SourceFiles
fixedRhoFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef fixedRhoFvPatchScalargpuField_H
#define fixedRhoFvPatchScalargpuField_H
#include "fixedValueFvPatchgpuFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class fixedRhoFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class fixedRhoFvPatchScalargpuField
:
public fixedValueFvPatchScalargpuField
{
private:
// Private data
//- Pressure field name, default = "p"
word pName_;
//- Compressibility field name, default = "thermo:psi"
word psiName_;
public:
//- Runtime type information
TypeName("fixedRho");
// Constructors
//- Construct from patch and internal field
fixedRhoFvPatchScalargpuField
(
const gpufvPatch&,
const DimensionedgpuField<scalar, gpuvolMesh>&
);
//- Construct from patch, internal field and dictionary
fixedRhoFvPatchScalargpuField
(
const gpufvPatch&,
const DimensionedgpuField<scalar, gpuvolMesh>&,
const dictionary&
);
//- Construct by mapping given fixedRhoFvPatchScalarField
// onto a new patch
fixedRhoFvPatchScalargpuField
(
const fixedRhoFvPatchScalargpuField&,
const gpufvPatch&,
const DimensionedgpuField<scalar, gpuvolMesh>&,
const fvPatchgpuFieldMapper&
);
//- Construct as copy
fixedRhoFvPatchScalargpuField
(
const fixedRhoFvPatchScalargpuField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalargpuField> clone() const
{
return tmp<fvPatchScalargpuField>
(
new fixedRhoFvPatchScalargpuField(*this)
);
}
//- Construct as copy setting internal field reference
fixedRhoFvPatchScalargpuField
(
const fixedRhoFvPatchScalargpuField&,
const DimensionedgpuField<scalar, gpuvolMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalargpuField> clone
(
const DimensionedgpuField<scalar, gpuvolMesh>& iF
) const
{
return tmp<fvPatchScalargpuField>
(
new fixedRhoFvPatchScalargpuField(*this, iF)
);
}
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
rhoReactingCentralFoam.C
EXE = $(FOAM_APPBIN)/rhoReactingCentralFoam
EXE_INC = \
-IBCs/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/gpufiniteVolume/lnInclude \
-I$(LIB_SRC)/gpuOpenFOAM/lnInclude \
-I${LIB_SRC}/meshTools/lnInclude \
-I${LIB_SRC}/sampling/lnInclude \
-I$(LIB_SRC)/TurbulenceModels-GPU/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels-GPU/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels-GPU/specie/lnInclude \
-I$(LIB_SRC)/transportModels-GPU/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels-GPU/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels-GPU/chemistryModel/lnInclude \
-I$(LIB_SRC)/thermophysicalModels-GPU/thermophysicalProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels-GPU/thermophysicalFunctions/lnInclude \
-I$(LIB_SRC)/thermophysicalModels-GPU/reactionThermo/lnInclude \
-I$(LIB_SRC)/combustionModels-GPU/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lgpufiniteVolume \
-lgpuOpenFOAM \
-lmeshTools \
-lsampling \
-lturbulenceModels-GPU \
-lcompressibleTurbulenceModels-GPU \
-lspecie-GPU \
-lcompressibleTransportModels-GPU \
-lfluidThermophysicalModels-GPU \
-lthermophysicalProperties-GPU \
-lreactionThermophysicalModels-GPU \
-lchemistryModel-GPU \
-lcombustionModels-GPU \
-lrhoCentralFoam-GPU \
-ldynamicFvMesh \
-ltopoChangerFvMesh
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
-------------------------------------------------------------------------------
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/>.
Global
centralCourantNo
Description
Calculates the mean and maximum wave speed based Courant Numbers.
\*---------------------------------------------------------------------------*/
if (devicemesh.hostmesh().nInternalFaces())
{
scalargpuField sumAmaxSf(fvc::surfaceSum(amaxSf)().primitiveField());
CoNum = 0.5*gMax(sumAmaxSf/devicemesh.V().field())*runTime.deltaTValue();
meanCoNum =
0.5*(gSum(sumAmaxSf)/gSum(devicemesh.V().field()))*runTime.deltaTValue();
}
Info<< "Mean and max Courant Numbers = "
<< meanCoNum << " " << CoNum << endl;
// ************************************************************************* //
volScalargpuField& p = thermo.p();
const volScalargpuField& T = thermo.T();
const volScalargpuField& psi = thermo.psi();
const volScalargpuField& mu = thermo.mu();
bool inviscid(true);
if (max(mu.primitiveField()) > 0.0)
{
inviscid = false;
}
PtrList<volScalargpuField> DiffsY(Y.size());
forAll(Y, i)
{
DiffsY.set
(
i,
new volScalargpuField
(
IOobject
(
"DiffsY",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
devicemesh,
dimensionedScalar("zero", mu.dimensions(), 0.0),
zeroGradientFvPatchScalargpuField::typeName
)
);
}
PtrList<volScalargpuField> HsY(Y.size());
forAll(Y, i)
{
HsY.set
(
i,
new volScalargpuField
(
IOobject
(
"HsY",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
devicemesh,
dimensionedScalar("zero", e.dimensions(), 0.0),
zeroGradientFvPatchScalargpuField::typeName
)
);
}
#include "gpucreateRDeltaT.H"
Info<< "Reading thermophysical properties\n" << endl;
autoPtr<psiReactionThermo> pThermo(psiReactionThermo::New(devicemesh));
psiReactionThermo& thermo = pThermo();
thermo.validate(args.executable(), "h", "e");
/*autoPtr<psiThermo> pThermo
(
psiThermo::New(mesh)
);
psiThermo& thermo = pThermo();*/
// switch for cold flow or reacting flow
bool SolveChemistry = readBool(runTime.controlDict().lookup("SolveChemistry"));
basicSpecieMixture& composition = thermo.composition();
PtrList<volScalargpuField>& Y = composition.Y();
const word inertSpecie(thermo.get<word>("inertSpecie"));
if (!composition.species().found(inertSpecie))
{
FatalIOErrorIn(args.executable().c_str(), thermo)
<< "Inert specie " << inertSpecie << " not found in available species "
<< composition.species() << exit(FatalIOError);
}
volScalargpuField& e = thermo.he();
Info<< "Reading field U\n" << endl;
volVectorgpuField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
devicemesh
);
volScalargpuField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
thermo.rho()
);
volVectorgpuField rhoU
(
IOobject
(
"rhoU",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
rho*U
);
volScalargpuField rhoE
(
IOobject
(
"rhoE",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
rho*(e + 0.5*magSqr(U))
);
surfaceScalargpuField pos
(
IOobject
(
"pos",
runTime.timeName(),
mesh
),
devicemesh,
dimensionedScalar("pos", dimless, 1.0)
);
surfaceScalargpuField neg
(
IOobject
(
"neg",
runTime.timeName(),
mesh
),
devicemesh,
dimensionedScalar("neg", dimless, -1.0)
);
surfaceScalargpuField phi("phi", fvc::flux(rhoU));
Info<< "Creating turbulence model\n" << endl;
autoPtr<compressible::turbulenceModel> turbulence
(
compressible::turbulenceModel::New
(
rho,
U,
phi,
thermo
)
);
Info<< "Creating combustion model\n" << endl;
autoPtr<CombustionModel<psiReactionThermo>> combustion
(
CombustionModel<psiReactionThermo>::New(thermo, turbulence())
);
gpumultivariateSurfaceInterpolationScheme<scalar>::fieldTable fields;
forAll(Y, i)
{
fields.add(Y[i]);
}
fields.add(thermo.he());
Info<< "Creating field kinetic energy K\n" << endl;
volScalargpuField K("K", 0.5*magSqr(U));
PtrList<volScalargpuField> rhoY(Y.size());
forAll(Y, i)
{
rhoY.set
(
i,
new volScalargpuField
(
IOobject
(
"rho"+Y[i].name(),
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
rho*Y[i]
)
);
}
volScalargpuField Qdot
(
IOobject
(
"Qdot",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
devicemesh,
dimensionedScalar(dimEnergy/dimVolume/dimTime, 0.0)
);
const label inertIndex(composition.species()[inertSpecie]);
volScalargpuField Yt
(
IOobject
(
"Yt",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
devicemesh,
dimensionedScalar( dimless, 0)//,
);
Info<< "Reading transport properties" <<endl;
IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
dictionary Schmidt(transportProperties.subDict("Sc"));
scalarField Sc(Y.size(),0.75);
forAll(Sc,i)
{
const word& name = Y[i].name();
if(Schmidt.found(name))
{
Sc[i]=readScalar(Schmidt.lookup(name));
}
}
const scalar Sct(Schmidt.lookupOrDefault<scalar>("Sct",0.7));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment