From a1daf57045f7ee75f2865e2ec5ddc5573f2cf01d Mon Sep 17 00:00:00 2001 From: Chris Greenshields Date: Wed, 25 Jun 2008 16:26:37 +0100 Subject: [PATCH] Adding new rhoCentralFoam solver --- .../compressible/rhoCentralFoam/Allwclean | 5 + .../compressible/rhoCentralFoam/Allwmake | 5 + .../rhoCentralFoam/BCs/Make/files | 6 + .../rhoCentralFoam/BCs/Make/options | 10 + .../T/smoluchowskiJumpTFvPatchScalarField.C | 230 ++++++++++++++++++ .../T/smoluchowskiJumpTFvPatchScalarField.H | 162 ++++++++++++ .../BCs/U/maxwellSlipUFvPatchVectorField.C | 212 ++++++++++++++++ .../BCs/U/maxwellSlipUFvPatchVectorField.H | 150 ++++++++++++ .../mixedFixedValueSlipFvPatchField.C | 204 ++++++++++++++++ .../mixedFixedValueSlipFvPatchField.H | 228 +++++++++++++++++ .../mixedFixedValueSlipFvPatchFields.C | 46 ++++ .../mixedFixedValueSlipFvPatchFields.H | 50 ++++ .../mixedFixedValueSlipFvPatchFieldsFwd.H | 51 ++++ .../BCs/rho/fixedRhoFvPatchScalarField.C | 122 ++++++++++ .../BCs/rho/fixedRhoFvPatchScalarField.H | 140 +++++++++++ .../compressible/rhoCentralFoam/Make/files | 3 + .../compressible/rhoCentralFoam/Make/options | 12 + .../rhoCentralFoam/compressibleCourantNo.H | 51 ++++ .../rhoCentralFoam/createFields.H | 97 ++++++++ .../rhoCentralFoam/readFluxScheme.H | 19 ++ .../readThermophysicalProperties.H | 22 ++ .../rhoCentralFoam/rhoBoundaryTypes.H | 17 ++ .../rhoCentralFoam/rhoCentralFoam.C | 226 +++++++++++++++++ 23 files changed, 2068 insertions(+) create mode 100755 applications/solvers/compressible/rhoCentralFoam/Allwclean create mode 100755 applications/solvers/compressible/rhoCentralFoam/Allwmake create mode 100644 applications/solvers/compressible/rhoCentralFoam/BCs/Make/files create mode 100644 applications/solvers/compressible/rhoCentralFoam/BCs/Make/options create mode 100644 applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C create mode 100644 applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H create mode 100644 applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C create mode 100644 applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.H create mode 100644 applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchField.C create mode 100644 applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchField.H create mode 100644 applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchFields.C create mode 100644 applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchFields.H create mode 100644 applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchFieldsFwd.H create mode 100644 applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C create mode 100644 applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.H create mode 100644 applications/solvers/compressible/rhoCentralFoam/Make/files create mode 100644 applications/solvers/compressible/rhoCentralFoam/Make/options create mode 100644 applications/solvers/compressible/rhoCentralFoam/compressibleCourantNo.H create mode 100644 applications/solvers/compressible/rhoCentralFoam/createFields.H create mode 100644 applications/solvers/compressible/rhoCentralFoam/readFluxScheme.H create mode 100644 applications/solvers/compressible/rhoCentralFoam/readThermophysicalProperties.H create mode 100644 applications/solvers/compressible/rhoCentralFoam/rhoBoundaryTypes.H create mode 100644 applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C diff --git a/applications/solvers/compressible/rhoCentralFoam/Allwclean b/applications/solvers/compressible/rhoCentralFoam/Allwclean new file mode 100755 index 0000000000..e90223203b --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/Allwclean @@ -0,0 +1,5 @@ +#!/bin/sh + +wclean libso BCs +wclean + diff --git a/applications/solvers/compressible/rhoCentralFoam/Allwmake b/applications/solvers/compressible/rhoCentralFoam/Allwmake new file mode 100755 index 0000000000..69a108d537 --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/Allwmake @@ -0,0 +1,5 @@ +#!/bin/sh + +wmake libso BCs +wmake + diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/Make/files b/applications/solvers/compressible/rhoCentralFoam/BCs/Make/files new file mode 100644 index 0000000000..ed40a642ae --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/Make/files @@ -0,0 +1,6 @@ +mixedFixedValueSlip/mixedFixedValueSlipFvPatchFields.C +U/maxwellSlipUFvPatchVectorField.C +T/smoluchowskiJumpTFvPatchScalarField.C +rho/fixedRhoFvPatchScalarField.C + +LIB = $(FOAM_USER_LIBBIN)/librhoCentralFoam diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/Make/options b/applications/solvers/compressible/rhoCentralFoam/BCs/Make/options new file mode 100644 index 0000000000..d4fb23181c --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/Make/options @@ -0,0 +1,10 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -lbasicThermophysicalModels \ + -lspecie + diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C new file mode 100644 index 0000000000..c163a08c33 --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C @@ -0,0 +1,230 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2004 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "smoluchowskiJumpTFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "mathematicalConstants.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(p, iF), + accommodationCoeff_(1.0), + Twall_(p.size(), 0.0), + gamma_(1.4) +{ + refValue() = 0.0; + refGrad() = 0.0; + valueFraction() = 0.0; +} + +smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField +( + const smoluchowskiJumpTFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + accommodationCoeff_(ptf.accommodationCoeff_), + Twall_(ptf.Twall_), + gamma_(ptf.gamma_) +{} + + +smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + accommodationCoeff_(readScalar(dict.lookup("accommodationCoeff"))), + Twall_("Twall", dict, p.size()) +{ + if + ( + mag(accommodationCoeff_) < SMALL + || + mag(accommodationCoeff_) > 2.0 + ) + { + FatalIOErrorIn + ( + "smoluchowskiJumpTFvPatchScalarField::" + "smoluchowskiJumpTFvPatchScalarField" + "(" + " const fvPatch&," + " const DimensionedField&," + " const dictionary&" + ")", + dict + ) << "unphysical accommodationCoeff_ specified" + << "(0 < accommodationCoeff_ <= 1)" << endl + << exit(FatalError); + } + + if (dict.found("value")) + { + fvPatchField::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + fvPatchField::operator=(patchInternalField()); + } + + if (dict.found("gamma")) + { + gamma_ = readScalar(dict.lookup("gamma")); + } + else + { + gamma_ = 1.4; + } + + refValue() = *this; + refGrad() = 0.0; + valueFraction() = 0.0; +} + + +smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField +( + const smoluchowskiJumpTFvPatchScalarField& ptpsf, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(ptpsf, iF), + accommodationCoeff_(ptpsf.accommodationCoeff_), + Twall_(ptpsf.Twall_), + gamma_(ptpsf.gamma_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +// Map from self +void smoluchowskiJumpTFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + mixedFvPatchScalarField::autoMap(m); +} + + +// Reverse-map the given fvPatchField onto this fvPatchField +void smoluchowskiJumpTFvPatchScalarField::rmap +( + const fvPatchField& ptf, + const labelList& addr +) +{ + mixedFvPatchField::rmap(ptf, addr); +} + + +// Update the coefficients associated with the patch field +void smoluchowskiJumpTFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const fvPatchScalarField& pmu = + patch().lookupPatchField("mu"); + const fvPatchScalarField& prho = + patch().lookupPatchField("rho"); + const fvPatchField& ppsi = + patch().lookupPatchField("psi"); + const fvPatchVectorField& pU = + patch().lookupPatchField("U"); + + // Prandtl number reading consistent with rhoCentralFoam + const dictionary& thermophysicalProperties = + db().lookupObject("thermophysicalProperties"); + dimensionedScalar Pr = dimensionedScalar("Pr", dimless, 1.0); + if (thermophysicalProperties.found("Pr")) + { + Pr = thermophysicalProperties.lookup("Pr"); + } + + Field C2 = pmu/prho + *sqrt(ppsi*mathematicalConstant::pi/2.0) + *2.0*gamma_/Pr.value()/(gamma_ + 1.0) + *(2.0 - accommodationCoeff_)/accommodationCoeff_; + + Field aCoeff = prho.snGrad() - prho/C2; + Field KEbyRho = 0.5*magSqr(pU); + + valueFraction() = (1.0/(1.0 + patch().deltaCoeffs()*C2)); + refValue() = Twall_; + refGrad() = 0.0; + + mixedFvPatchScalarField::updateCoeffs(); +} + + +// Write +void smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("accommodationCoeff") + << accommodationCoeff_ << token::END_STATEMENT << nl; + Twall_.writeEntry("Twall", os); + os.writeKeyword("gamma") + << gamma_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchScalarField, smoluchowskiJumpTFvPatchScalarField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H new file mode 100644 index 0000000000..9534a66293 --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2004 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::smoluchowskiJumpTFvPatchScalarField + +Description + Smoluchowski temperature jump boundary condition + +SourceFiles + smoluchowskiJumpTFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef smoluchowskiJumpTFvPatchScalarFields_H +#define smoluchowskiJumpTFvPatchScalarFields_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class smoluchowskiJumpTFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class smoluchowskiJumpTFvPatchScalarField +: + public mixedFvPatchScalarField +{ + + // Private data + + // 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 + smoluchowskiJumpTFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + smoluchowskiJumpTFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given smoluchowskiJumpTFvPatchScalarField + // onto a new patch + smoluchowskiJumpTFvPatchScalarField + ( + const smoluchowskiJumpTFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new smoluchowskiJumpTFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + smoluchowskiJumpTFvPatchScalarField + ( + const smoluchowskiJumpTFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new smoluchowskiJumpTFvPatchScalarField(*this, iF) + ); + } + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchField&, + const labelList& + ); + + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C new file mode 100644 index 0000000000..53329b0326 --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C @@ -0,0 +1,212 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2004 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + +\*---------------------------------------------------------------------------*/ + +#include "maxwellSlipUFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" +#include "mathematicalConstants.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "fvCFD.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFixedValueSlipFvPatchVectorField(p, iF), + accommodationCoeff_(1.0), + Uwall_(p.size(), vector(0.0, 0.0, 0.0)), + thermalCreep_(true), + curvature_(true) +{} + + +maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField +( + const maxwellSlipUFvPatchVectorField& tdpvf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFixedValueSlipFvPatchVectorField(tdpvf, p, iF, mapper), + accommodationCoeff_(tdpvf.accommodationCoeff_), + Uwall_(tdpvf.Uwall_), + thermalCreep_(tdpvf.thermalCreep_), + curvature_(tdpvf.curvature_) +{} + + +maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFixedValueSlipFvPatchVectorField(p, iF), + accommodationCoeff_(readScalar(dict.lookup("accommodationCoeff"))), + Uwall_("Uwall", dict, p.size()), + thermalCreep_(dict.lookupOrDefault("thermalCreep", true)), + curvature_(dict.lookupOrDefault("curvature", true)) +{ + if + ( + mag(accommodationCoeff_) < SMALL + || + mag(accommodationCoeff_) > 2.0 + ) + { + FatalIOErrorIn + ( + "maxwellSlipUFvPatchScalarField::" + "maxwellSlipUFvPatchScalarField" + "(const fvPatch&, const scalarField&, const dictionary&)", + dict + ) << "unphysical accommodationCoeff_ specified" + << "(0 < accommodationCoeff_ <= 1)" << endl + << exit(FatalError); + } + + if (dict.found("value")) + { + fvPatchField::operator= + ( + vectorField("value", dict, p.size()) + ); + } + else + { + mixedFixedValueSlipFvPatchVectorField::evaluate(); + } +} + + +maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField +( + const maxwellSlipUFvPatchVectorField& tdpvf, + const DimensionedField& iF +) +: + mixedFixedValueSlipFvPatchVectorField(tdpvf, iF), + accommodationCoeff_(tdpvf.accommodationCoeff_), + Uwall_(tdpvf.Uwall_), + thermalCreep_(tdpvf.thermalCreep_), + curvature_(tdpvf.curvature_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +// Update the coefficients associated with the patch field +void maxwellSlipUFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const fvPatchScalarField& pmu = + patch().lookupPatchField("mu"); + const fvPatchScalarField& prho = + patch().lookupPatchField("rho"); + const fvPatchField& ppsi = + patch().lookupPatchField("psi"); + + Field C1 = sqrt(ppsi*mathematicalConstant::pi/2.0) + *(2.0 - accommodationCoeff_)/accommodationCoeff_; + + Field pnu = pmu/prho; + valueFraction() = (1.0/(1.0 + patch().deltaCoeffs()*C1*pnu)); + + refValue() = Uwall_; + + if(thermalCreep_) + { + const GeometricField& vsfT = + this->db().objectRegistry:: + lookupObject >("T"); + label patchi = this->patch().index(); + const fvPatchScalarField& pT = vsfT.boundaryField()[patchi]; + Field gradpT = fvc::grad(vsfT)().boundaryField()[patchi]; + vectorField n = patch().nf(); + + refValue() -= 3.0*pnu/(4.0*pT)*transform(I - n*n, gradpT); + } + + if(curvature_) + { + const fvPatchTensorField& ptauMC = + patch().lookupPatchField("tauMC"); + vectorField n = patch().nf(); + + refValue() -= C1/prho*transform(I - n*n, (n & ptauMC)); + } + + mixedFixedValueSlipFvPatchVectorField::updateCoeffs(); +} + + +// Write +void maxwellSlipUFvPatchVectorField::write(Ostream& os) const +{ + fvPatchVectorField::write(os); + os.writeKeyword("accommodationCoeff") + << accommodationCoeff_ << token::END_STATEMENT << nl; + Uwall_.writeEntry("Uwall", os); + os.writeKeyword("thermalCreep") + << thermalCreep_ << token::END_STATEMENT << nl; + os.writeKeyword("curvature") << curvature_ << token::END_STATEMENT << nl; + + os.writeKeyword("refValue") + << refValue() << token::END_STATEMENT << nl; + os.writeKeyword("valueFraction") + << valueFraction() << token::END_STATEMENT << nl; + + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchVectorField, maxwellSlipUFvPatchVectorField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.H b/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.H new file mode 100644 index 0000000000..45004c408b --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.H @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +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 maxwellSlipUFvPatchVectorField_H +#define maxwellSlipUFvPatchVectorField_H + +#include "mixedFixedValueSlipFvPatchFields.H" +#include "Switch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class maxwellSlipUFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class maxwellSlipUFvPatchVectorField +: + public mixedFixedValueSlipFvPatchVectorField +{ + + // Private data + + // Accommodation coefficient + scalar accommodationCoeff_; + + // Wall velocity + vectorField 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 + maxwellSlipUFvPatchVectorField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + maxwellSlipUFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // maxwellSlipUFvPatchVectorField onto a new patch + maxwellSlipUFvPatchVectorField + ( + const maxwellSlipUFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new maxwellSlipUFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + maxwellSlipUFvPatchVectorField + ( + const maxwellSlipUFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new maxwellSlipUFvPatchVectorField(*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 + +// ************************************************************************* // diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchField.C new file mode 100644 index 0000000000..c75ba11c88 --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchField.C @@ -0,0 +1,204 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "mixedFixedValueSlipFvPatchField.H" +#include "symmTransformField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +mixedFixedValueSlipFvPatchField::mixedFixedValueSlipFvPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + transformFvPatchField(p, iF), + refValue_(p.size()), + valueFraction_(p.size(), 1.0) +{} + + +template +mixedFixedValueSlipFvPatchField::mixedFixedValueSlipFvPatchField +( + const mixedFixedValueSlipFvPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + transformFvPatchField(ptf, p, iF, mapper), + refValue_(ptf.refValue_, mapper), + valueFraction_(ptf.valueFraction_, mapper) +{} + + +template +mixedFixedValueSlipFvPatchField::mixedFixedValueSlipFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + transformFvPatchField(p, iF), + refValue_("refValue", dict, p.size()), + valueFraction_("valueFraction", dict, p.size()) +{} + + +template +mixedFixedValueSlipFvPatchField::mixedFixedValueSlipFvPatchField +( + const mixedFixedValueSlipFvPatchField& ptf +) +: + transformFvPatchField(ptf), + refValue_(ptf.refValue_), + valueFraction_(ptf.valueFraction_) +{} + +template +mixedFixedValueSlipFvPatchField::mixedFixedValueSlipFvPatchField +( + const mixedFixedValueSlipFvPatchField& ptf, + const DimensionedField& iF +) +: + transformFvPatchField(ptf, iF), + refValue_(ptf.refValue_), + valueFraction_(ptf.valueFraction_) +{} + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +// Map from self +template +void mixedFixedValueSlipFvPatchField::autoMap +( + const fvPatchFieldMapper& m +) +{ + Field::autoMap(m); + refValue_.autoMap(m); + valueFraction_.autoMap(m); +} + + +// Reverse-map the given fvPatchField onto this fvPatchField +template +void mixedFixedValueSlipFvPatchField::rmap +( + const fvPatchField& ptf, + const labelList& addr +) +{ + transformFvPatchField::rmap(ptf, addr); + + const mixedFixedValueSlipFvPatchField& dmptf = + refCast >(ptf); + + refValue_.rmap(dmptf.refValue_, addr); + valueFraction_.rmap(dmptf.valueFraction_, addr); +} + + +// Return gradient at boundary +template +tmp > mixedFixedValueSlipFvPatchField::snGrad() const +{ + vectorField nHat = this->patch().nf(); + Field pif = this->patchInternalField(); + + return + ( + valueFraction_*refValue_ + + (1.0 - valueFraction_)*transform(I - sqr(nHat), pif) - pif + )*this->patch().deltaCoeffs(); +} + + +// Evaluate the field on the patch +template +void mixedFixedValueSlipFvPatchField::evaluate(const Pstream::commsTypes) +{ + if (!this->updated()) + { + this->updateCoeffs(); + } + + vectorField nHat = this->patch().nf(); + + Field::operator= + ( + valueFraction_*refValue_ + + + (1.0 - valueFraction_) + *transform(I - nHat*nHat, this->patchInternalField()) + ); + + transformFvPatchField::evaluate(); +} + + +// Return defining fields +template +tmp > mixedFixedValueSlipFvPatchField::snGradTransformDiag() const +{ + vectorField nHat = this->patch().nf(); + vectorField diag(nHat.size()); + + diag.replace(vector::X, mag(nHat.component(vector::X))); + diag.replace(vector::Y, mag(nHat.component(vector::Y))); + diag.replace(vector::Z, mag(nHat.component(vector::Z))); + + return + valueFraction_*Type(pTraits::one) + + (1.0 - valueFraction_)*transformFieldMask(pow::rank>(diag)); +} + + +// Write +template +void mixedFixedValueSlipFvPatchField::write(Ostream& os) const +{ + transformFvPatchField::write(os); + refValue_.writeEntry("refValue", os); + valueFraction_.writeEntry("valueFraction", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchField.H b/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchField.H new file mode 100644 index 0000000000..812b0e8094 --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchField.H @@ -0,0 +1,228 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::mixedFixedValueSlipFvPatchField + +Description + A mixed boundary type that blends between fixedValue and slip, as opposed + to the standard mixed condition that blends between fixedValue and + fixedGradient; required to implement maxwellSlipU condition. + +SourceFiles + mixedFixedValueSlipFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef mixedFixedValueSlipFvPatchField_H +#define mixedFixedValueSlipFvPatchField_H + +#include "transformFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class mixedFixedValueSlipFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +template +class mixedFixedValueSlipFvPatchField +: + public transformFvPatchField +{ + // Private data + + //- Value field used for boundary condition + Field refValue_; + + //- Fraction (0-1) of value used for boundary condition + scalarField valueFraction_; + +public: + + //- Runtime type information + TypeName("mixedFixedValueSlip"); + + + // Constructors + + //- Construct from patch and internal field + mixedFixedValueSlipFvPatchField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + mixedFixedValueSlipFvPatchField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given mixedFixedValueSlipFvPatchField + //- onto a new patch + mixedFixedValueSlipFvPatchField + ( + const mixedFixedValueSlipFvPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + mixedFixedValueSlipFvPatchField + ( + const mixedFixedValueSlipFvPatchField& + ); + + //- Construct and return a clone + virtual tmp > clone() const + { + return tmp > + ( + new mixedFixedValueSlipFvPatchField(*this) + ); + } + + //- Construct as copy setting internal field reference + mixedFixedValueSlipFvPatchField + ( + const mixedFixedValueSlipFvPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp > clone + ( + const DimensionedField& iF + ) const + { + return tmp > + ( + new mixedFixedValueSlipFvPatchField(*this, iF) + ); + } + + // Member functions + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchField&, + const labelList& + ); + + // Return defining fields + + virtual Field& refValue() + { + return refValue_; + } + + virtual const Field& refValue() const + { + return refValue_; + } + + virtual scalarField& valueFraction() + { + return valueFraction_; + } + + virtual const scalarField& valueFraction() const + { + return valueFraction_; + } + + // Evaluation functions + + //- Return gradient at boundary + virtual tmp > snGrad() const; + + //- Evaluate the patch field + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::blocking + ); + + //- Return face-gradient transform diagonal + virtual tmp > snGradTransformDiag() const; + + + //- Write + virtual void write(Ostream&) const; + + + // Member operators + + virtual void operator=(const UList&) {} + + virtual void operator=(const fvPatchField&) {} + virtual void operator+=(const fvPatchField&) {} + virtual void operator-=(const fvPatchField&) {} + virtual void operator*=(const fvPatchField&) {} + virtual void operator/=(const fvPatchField&) {} + + virtual void operator+=(const Field&) {} + virtual void operator-=(const Field&) {} + + virtual void operator*=(const Field&) {} + virtual void operator/=(const Field&) {} + + virtual void operator=(const Type&) {} + virtual void operator+=(const Type&) {} + virtual void operator-=(const Type&) {} + virtual void operator*=(const scalar) {} + virtual void operator/=(const scalar) {} +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "mixedFixedValueSlipFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchFields.C b/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchFields.C new file mode 100644 index 0000000000..bd0311acf3 --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchFields.C @@ -0,0 +1,46 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Description + +\*---------------------------------------------------------------------------*/ + +#include "mixedFixedValueSlipFvPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePatchFields(mixedFixedValueSlip); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchFields.H b/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchFields.H new file mode 100644 index 0000000000..3cd664de65 --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchFields.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +\*---------------------------------------------------------------------------*/ + +#ifndef mixedFixedValueSlipFvPatchFields_H +#define mixedFixedValueSlipFvPatchFields_H + +#include "mixedFixedValueSlipFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(mixedFixedValueSlip) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchFieldsFwd.H b/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchFieldsFwd.H new file mode 100644 index 0000000000..8a28d70ce7 --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchFieldsFwd.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#ifndef mixedFixedValueSlipFvPatchFieldsFwd_H +#define mixedFixedValueSlipFvPatchFieldsFwd_H + +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template class mixedFixedValueSlipFvPatchField; + +makePatchTypeFieldTypedefs(mixedFixedValueSlip) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C new file mode 100644 index 0000000000..b005aef7be --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C @@ -0,0 +1,122 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "fixedRhoFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "fvCFD.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +fixedRhoFvPatchScalarField::fixedRhoFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{} + + +fixedRhoFvPatchScalarField::fixedRhoFvPatchScalarField +( + const fixedRhoFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +fixedRhoFvPatchScalarField::fixedRhoFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{} + + +fixedRhoFvPatchScalarField::fixedRhoFvPatchScalarField +( + const fixedRhoFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf) +{} + + +fixedRhoFvPatchScalarField::fixedRhoFvPatchScalarField +( + const fixedRhoFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void fixedRhoFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const fvPatchField& psip = + patch().lookupPatchField("psi"); + + const fvPatchField& pp = + patch().lookupPatchField("p"); + + operator==(psip*pp); + + fixedValueFvPatchScalarField::updateCoeffs(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchScalarField, fixedRhoFvPatchScalarField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.H b/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.H new file mode 100644 index 0000000000..175c36db95 --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.H @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::fixedRhoFvPatchScalarField + +Description + Foam::fixedRhoFvPatchScalarField + +SourceFiles + fixedRhoFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fixedRhoFvPatchScalarField_H +#define fixedRhoFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class fixedRhoFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class fixedRhoFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + +public: + + //- Runtime type information + TypeName("fixedRho"); + + + // Constructors + + //- Construct from patch and internal field + fixedRhoFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + fixedRhoFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given fixedRhoFvPatchScalarField + // onto a new patch + fixedRhoFvPatchScalarField + ( + const fixedRhoFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + fixedRhoFvPatchScalarField + ( + const fixedRhoFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new fixedRhoFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + fixedRhoFvPatchScalarField + ( + const fixedRhoFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new fixedRhoFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/compressible/rhoCentralFoam/Make/files b/applications/solvers/compressible/rhoCentralFoam/Make/files new file mode 100644 index 0000000000..7c0c3704ee --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/Make/files @@ -0,0 +1,3 @@ +rhoCentralFoam.C + +EXE = $(FOAM_APPBIN)/rhoCentralFoam diff --git a/applications/solvers/compressible/rhoCentralFoam/Make/options b/applications/solvers/compressible/rhoCentralFoam/Make/options new file mode 100644 index 0000000000..b6ede7054d --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/Make/options @@ -0,0 +1,12 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -IBCs/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude +EXE_LIBS = \ + -lfiniteVolume \ + -lbasicThermophysicalModels \ + -lspecie \ + -L$(FOAM_USER_LIBBIN) \ + -lrhoCentralFoam diff --git a/applications/solvers/compressible/rhoCentralFoam/compressibleCourantNo.H b/applications/solvers/compressible/rhoCentralFoam/compressibleCourantNo.H new file mode 100644 index 0000000000..423f6ad4ec --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/compressibleCourantNo.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Global + compressibleCourantNo + +Description + Calculates the mean and maximum wave speed based Courant Numbers. + +\*---------------------------------------------------------------------------*/ + +scalar CoNum = 0.0; +scalar meanCoNum = 0.0; + +if (mesh.nInternalFaces()) +{ + surfaceScalarField amaxSfbyDelta = + mesh.surfaceInterpolation::deltaCoeffs()*amaxSf; + + CoNum = max(amaxSfbyDelta/mesh.magSf()) + .value()*runTime.deltaT().value(); + + meanCoNum = (sum(amaxSfbyDelta)/sum(mesh.magSf())) + .value()*runTime.deltaT().value(); +} + +Info<< "Mean and max Courant Numbers = " + << meanCoNum << " " << CoNum << endl; + +// ************************************************************************* // diff --git a/applications/solvers/compressible/rhoCentralFoam/createFields.H b/applications/solvers/compressible/rhoCentralFoam/createFields.H new file mode 100644 index 0000000000..3b273bb3dd --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/createFields.H @@ -0,0 +1,97 @@ +Info<< "Reading thermophysical properties\n" << endl; + +autoPtr thermo +( + basicThermo::New(mesh) +); + +volScalarField& p = thermo->p(); +volScalarField& h = thermo->h(); +const volScalarField& T = thermo->T(); +const volScalarField& psi = thermo->psi(); +const volScalarField& mu = thermo->mu(); + +bool inviscid(true); +if (max(mu.internalField()) > 0.0) +{ + inviscid = false; +} + +Info<< "Reading field U\n" << endl; +volVectorField U +( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh +); + +#include "rhoBoundaryTypes.H" +volScalarField rho +( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + thermo->rho(), + rhoBoundaryTypes +); + +volVectorField rhoU +( + IOobject + ( + "rhoU", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + rho*U +); + +volScalarField rhoE +( + IOobject + ( + "rhoE", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + rho*(h + 0.5*magSqr(U)) - p +); + +surfaceScalarField pos +( + IOobject + ( + "pos", + runTime.timeName(), + mesh + ), + mesh, + dimensionedScalar("pos", dimless, 1.0) +); + +surfaceScalarField neg +( + IOobject + ( + "neg", + runTime.timeName(), + mesh + ), + mesh, + dimensionedScalar("neg", dimless, -1.0) +); diff --git a/applications/solvers/compressible/rhoCentralFoam/readFluxScheme.H b/applications/solvers/compressible/rhoCentralFoam/readFluxScheme.H new file mode 100644 index 0000000000..9f54c43ef3 --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/readFluxScheme.H @@ -0,0 +1,19 @@ +word fluxScheme("Kurganov"); +if (mesh.schemesDict().found("fluxScheme")) +{ + fluxScheme = word(mesh.schemesDict().lookup("fluxScheme")); + if ((fluxScheme == "Tadmor") || (fluxScheme == "Kurganov")) + { + Info<< "fluxScheme: " << fluxScheme << endl; + } + else + { + FatalErrorIn + ( + "rhoCentralFoam::readFluxScheme" + ) << "fluxScheme: " << fluxScheme + << " is not a valid choice. " + << "Options are: Tadmor, Kurganov" + << abort(FatalError); + } +} diff --git a/applications/solvers/compressible/rhoCentralFoam/readThermophysicalProperties.H b/applications/solvers/compressible/rhoCentralFoam/readThermophysicalProperties.H new file mode 100644 index 0000000000..435bcb7745 --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/readThermophysicalProperties.H @@ -0,0 +1,22 @@ +Info<< "Reading thermophysicalProperties\n" << endl; + +// Pr defined as a separate constant to enable calculation of k, currently +// inaccessible through thermo +IOdictionary thermophysicalProperties +( + IOobject + ( + "thermophysicalProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) +); + +dimensionedScalar Pr = dimensionedScalar("Pr", dimless, 1.0); + +if (thermophysicalProperties.found("Pr")) +{ + Pr = thermophysicalProperties.lookup("Pr"); +} diff --git a/applications/solvers/compressible/rhoCentralFoam/rhoBoundaryTypes.H b/applications/solvers/compressible/rhoCentralFoam/rhoBoundaryTypes.H new file mode 100644 index 0000000000..c85f491985 --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/rhoBoundaryTypes.H @@ -0,0 +1,17 @@ +const volScalarField::GeometricBoundaryField& pbf = p.boundaryField(); +wordList rhoBoundaryTypes = pbf.types(); + +forAll(rhoBoundaryTypes, patchi) +{ + if + ( + rhoBoundaryTypes[patchi] == "waveTransmissive" + ) + { + rhoBoundaryTypes[patchi] = zeroGradientFvPatchScalarField::typeName; + } + else if (pbf[patchi].fixesValue()) + { + rhoBoundaryTypes[patchi] = fixedRhoFvPatchScalarField::typeName; + } +} diff --git a/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C new file mode 100644 index 0000000000..a914647931 --- /dev/null +++ b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C @@ -0,0 +1,226 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + rhoCentralFoam + +Description + Density-based compressible flow solver based on central-upwind schemes of + Kurganov and Tadmor + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "basicThermo.H" +#include "zeroGradientFvPatchFields.H" +#include "fixedRhoFvPatchScalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + +# include "setRootCase.H" + +# include "createTime.H" +# include "createMesh.H" +# include "createFields.H" +# include "readThermophysicalProperties.H" +# include "readTimeControls.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +# include "readFluxScheme.H" + + dimensionedScalar v_zero("v_zero",dimVolume/dimTime, 0.0); + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + // --- upwind interpolation of primitive fields on faces + + surfaceScalarField rho_pos = + fvc::interpolate(rho, pos, "reconstruct(rho)"); + surfaceScalarField rho_neg = + fvc::interpolate(rho, neg, "reconstruct(rho)"); + + surfaceVectorField rhoU_pos = + fvc::interpolate(rhoU, pos, "reconstruct(U)"); + surfaceVectorField rhoU_neg = + fvc::interpolate(rhoU, neg, "reconstruct(U)"); + + volScalarField rPsi = 1.0/psi; + surfaceScalarField rPsi_pos = + fvc::interpolate(rPsi, pos, "reconstruct(T)"); + surfaceScalarField rPsi_neg = + fvc::interpolate(rPsi, neg, "reconstruct(T)"); + + surfaceScalarField h_pos = + fvc::interpolate(h, pos, "reconstruct(T)"); + surfaceScalarField h_neg = + fvc::interpolate(h, neg, "reconstruct(T)"); + + surfaceVectorField U_pos = rhoU_pos/rho_pos; + surfaceVectorField U_neg = rhoU_neg/rho_neg; + + surfaceScalarField p_pos = rho_pos*rPsi_pos; + surfaceScalarField p_neg = rho_neg*rPsi_neg; + + surfaceScalarField phiv_pos = U_pos & mesh.Sf(); + surfaceScalarField phiv_neg = U_neg & mesh.Sf(); + + volScalarField c = sqrt(thermo->Cp()/thermo->Cv()*rPsi); + surfaceScalarField cSf_pos = fvc::interpolate(c, pos, "reconstruct(T)")*mesh.magSf(); + surfaceScalarField cSf_neg = fvc::interpolate(c, neg, "reconstruct(T)")*mesh.magSf(); + + surfaceScalarField ap = max(max(phiv_pos + cSf_pos, phiv_neg + cSf_neg), v_zero); + surfaceScalarField am = min(min(phiv_pos - cSf_pos, phiv_neg - cSf_neg), v_zero); + + surfaceScalarField a_pos = ap/(ap - am); + + surfaceScalarField amaxSf("amaxSf", max(mag(am), mag(ap))); + +# include "compressibleCourantNo.H" +# include "readTimeControls.H" +# include "setDeltaT.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + surfaceScalarField aSf = am*a_pos; + + if (fluxScheme == "Tadmor") + { + aSf = -0.5*amaxSf; + a_pos = 0.5; + } + + surfaceScalarField a_neg = (1.0 - a_pos); + + phiv_pos *= a_pos; + phiv_neg *= a_neg; + + surfaceScalarField aphiv_pos = phiv_pos - aSf; + surfaceScalarField aphiv_neg = phiv_neg + aSf; + + surfaceScalarField phi("phi", aphiv_pos*rho_pos + aphiv_neg*rho_neg); + + surfaceVectorField phiUp = + (aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg) + + (a_pos*p_pos + a_neg*p_neg)*mesh.Sf(); + + surfaceScalarField phiEp = + aphiv_pos*rho_pos*(h_pos + 0.5*magSqr(U_pos)) + + aphiv_neg*rho_neg*(h_neg + 0.5*magSqr(U_neg)) + + aSf*p_pos - aSf*p_neg; + + volTensorField tauMC("tauMC", mu*dev2(fvc::grad(U)().T())); + + // --- Solve density + solve(fvm::ddt(rho) + fvc::div(phi)); + + // --- Solve momentum + solve(fvm::ddt(rhoU) + fvc::div(phiUp)); + + U.dimensionedInternalField() = + rhoU.dimensionedInternalField() + /rho.dimensionedInternalField(); + U.correctBoundaryConditions(); + rhoU.boundaryField() = rho.boundaryField()*U.boundaryField(); + + volScalarField rhoBydt(rho/runTime.deltaT()); + + if (!inviscid) + { + solve + ( + fvm::ddt(rho, U) - fvc::ddt(rho,U) + - fvm::laplacian(mu, U) + - fvc::div(tauMC) + ); + rhoU = rho*U; + } + + // --- Solve energy + surfaceScalarField sigmaDotU = + ( + ( + fvc::interpolate(mu)*mesh.magSf()*fvc::snGrad(U) + + (mesh.Sf() & fvc::interpolate(tauMC)) + ) + & (a_pos*U_pos + a_neg*U_neg) + ); + + solve + ( + fvm::ddt(rhoE) + + fvc::div(phiEp) + - fvc::div(sigmaDotU) + ); + + h = (rhoE + p)/rho - 0.5*magSqr(U); + h.correctBoundaryConditions(); + thermo->correct(); + rhoE.boundaryField() = + rho.boundaryField()* + ( + h.boundaryField() + 0.5*magSqr(U.boundaryField()) + ) + - p.boundaryField(); + + if (!inviscid) + { + volScalarField k("k", thermo->Cp()*mu/Pr); + solve + ( + fvm::ddt(rho, h) - fvc::ddt(rho, h) + - fvm::laplacian(thermo->alpha(), h) + + fvc::laplacian(thermo->alpha(), h) + - fvc::laplacian(k, T) + ); + thermo->correct(); + rhoE = rho*(h + 0.5*magSqr(U)) - p; + } + + p.dimensionedInternalField() = + rho.dimensionedInternalField() + /psi.dimensionedInternalField(); + p.correctBoundaryConditions(); + rho.boundaryField() = psi.boundaryField()*p.boundaryField(); + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return(0); +} + +// ************************************************************************* //