From 20733b7dd2f76212303764d16401cec067a44869 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Wed, 17 Jun 2015 14:38:20 +0100 Subject: [PATCH] rhoCentralFoam: Ensure fixed value boundary conditions are preserved Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1748 --- .../compressible/rhoCentralFoam/Allwclean | 2 +- .../compressible/rhoCentralFoam/Allwmake | 2 +- .../rhoCentralFoam/BCs/Make/options | 2 + .../mixedFixedValueSlipFvPatchField.H | 6 +-- .../rhoCentralFoam/compressibleCourantNo.H | 52 ------------------- .../rhoCentralFoam/createFields.H | 22 ++++++-- .../rhoCentralFoam/directionInterpolate.H | 27 +++++++++- .../rhoCentralFoam/rhoBoundaryTypes.H | 14 ----- .../rhoCentralDyMFoam/rhoCentralDyMFoam.C | 6 +-- .../rhoCentralFoam/rhoCentralFoam.C | 6 +-- 10 files changed, 56 insertions(+), 83 deletions(-) delete mode 100644 applications/solvers/compressible/rhoCentralFoam/compressibleCourantNo.H delete mode 100644 applications/solvers/compressible/rhoCentralFoam/rhoBoundaryTypes.H diff --git a/applications/solvers/compressible/rhoCentralFoam/Allwclean b/applications/solvers/compressible/rhoCentralFoam/Allwclean index cc5398c0..1a0374d9 100755 --- a/applications/solvers/compressible/rhoCentralFoam/Allwclean +++ b/applications/solvers/compressible/rhoCentralFoam/Allwclean @@ -1,5 +1,5 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory set -x wclean libso BCs diff --git a/applications/solvers/compressible/rhoCentralFoam/Allwmake b/applications/solvers/compressible/rhoCentralFoam/Allwmake index 33e08e10..5c4ed20c 100755 --- a/applications/solvers/compressible/rhoCentralFoam/Allwmake +++ b/applications/solvers/compressible/rhoCentralFoam/Allwmake @@ -1,5 +1,5 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory set -x (wmake libso BCs && wmake && wmake rhoCentralDyMFoam) diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/Make/options b/applications/solvers/compressible/rhoCentralFoam/BCs/Make/options index 6870682c..98566f52 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/Make/options +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/Make/options @@ -1,10 +1,12 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/transportModels/compressible/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude LIB_LIBS = \ -lfiniteVolume \ + -lcompressibleTransportModels \ -lfluidThermophysicalModels \ -lspecie diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchField.H b/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchField.H index a2880681..d27b722a 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchField.H +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip/mixedFixedValueSlipFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -85,7 +85,7 @@ public: ); //- Construct by mapping given mixedFixedValueSlipFvPatchField - //- onto a new patch + //- Onto a new patch mixedFixedValueSlipFvPatchField ( const mixedFixedValueSlipFvPatchField&, @@ -217,7 +217,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository -# include "mixedFixedValueSlipFvPatchField.C" + #include "mixedFixedValueSlipFvPatchField.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/compressible/rhoCentralFoam/compressibleCourantNo.H b/applications/solvers/compressible/rhoCentralFoam/compressibleCourantNo.H deleted file mode 100644 index 3ccce14d..00000000 --- a/applications/solvers/compressible/rhoCentralFoam/compressibleCourantNo.H +++ /dev/null @@ -1,52 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 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 . - -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.deltaTValue(); - - meanCoNum = - (sum(amaxSfbyDelta)/sum(mesh.magSf())).value() - *runTime.deltaTValue(); -} - -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 index c1618d63..425ba78b 100644 --- a/applications/solvers/compressible/rhoCentralFoam/createFields.H +++ b/applications/solvers/compressible/rhoCentralFoam/createFields.H @@ -32,7 +32,6 @@ volVectorField U mesh ); -#include "rhoBoundaryTypes.H" volScalarField rho ( IOobject @@ -44,7 +43,7 @@ volScalarField rho IOobject::AUTO_WRITE ), thermo.rho(), - rhoBoundaryTypes + derivedPatchFieldTypes(p) ); volVectorField rhoU @@ -57,7 +56,8 @@ volVectorField rhoU IOobject::NO_READ, IOobject::NO_WRITE ), - rho*U + rho*U, + derivedPatchFieldTypes(U) ); volScalarField rhoE @@ -70,7 +70,8 @@ volScalarField rhoE IOobject::NO_READ, IOobject::NO_WRITE ), - rho*(e + 0.5*magSqr(U)) + rho*(e + 0.5*magSqr(U)), + derivedPatchFieldTypes(T) ); surfaceScalarField pos @@ -98,7 +99,18 @@ surfaceScalarField neg ); -surfaceScalarField phi("phi", mesh.Sf() & fvc::interpolate(rhoU)); +surfaceScalarField phi +( + IOobject + ( + "phi", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh.Sf() & fvc::interpolate(rhoU) +); Info<< "Creating turbulence model\n" << endl; autoPtr turbulence diff --git a/applications/solvers/compressible/rhoCentralFoam/directionInterpolate.H b/applications/solvers/compressible/rhoCentralFoam/directionInterpolate.H index d818f2f0..a223ecb5 100644 --- a/applications/solvers/compressible/rhoCentralFoam/directionInterpolate.H +++ b/applications/solvers/compressible/rhoCentralFoam/directionInterpolate.H @@ -31,8 +31,9 @@ tmp > interpolate { if ( - !sf.boundaryField()[patchi].coupled() + !sf.boundaryField()[patchi].coupled() && sf.boundaryField()[patchi].size() + && !vf.boundaryField()[patchi].fixesValue() && dir.boundaryField()[patchi][0] > 0 ) { @@ -44,4 +45,28 @@ tmp > interpolate return tsf; } + +template +wordList derivedPatchFieldTypes +( + const GeometricField& vf +) +{ + wordList phiTypes + ( + vf.boundaryField().size(), + calculatedFvPatchField::typeName + ); + + forAll(vf.boundaryField(), patchi) + { + if (vf.boundaryField()[patchi].fixesValue()) + { + phiTypes[patchi] = fixedValueFvPatchField::typeName; + } + } + + return phiTypes; +} + } diff --git a/applications/solvers/compressible/rhoCentralFoam/rhoBoundaryTypes.H b/applications/solvers/compressible/rhoCentralFoam/rhoBoundaryTypes.H deleted file mode 100644 index 7118d24f..00000000 --- a/applications/solvers/compressible/rhoCentralFoam/rhoBoundaryTypes.H +++ /dev/null @@ -1,14 +0,0 @@ -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/rhoCentralDyMFoam/rhoCentralDyMFoam.C b/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C index 1020a543..92f74e69 100644 --- a/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C +++ b/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C @@ -187,7 +187,7 @@ int main(int argc, char *argv[]) rhoU.dimensionedInternalField() /rho.dimensionedInternalField(); U.correctBoundaryConditions(); - rhoU.boundaryField() = rho.boundaryField()*U.boundaryField(); + rhoU.boundaryField() == rho.boundaryField()*U.boundaryField(); if (!inviscid) { @@ -221,7 +221,7 @@ int main(int argc, char *argv[]) e = rhoE/rho - 0.5*magSqr(U); e.correctBoundaryConditions(); thermo.correct(); - rhoE.boundaryField() = + rhoE.boundaryField() == rho.boundaryField()* ( e.boundaryField() + 0.5*magSqr(U.boundaryField()) @@ -242,7 +242,7 @@ int main(int argc, char *argv[]) rho.dimensionedInternalField() /psi.dimensionedInternalField(); p.correctBoundaryConditions(); - rho.boundaryField() = psi.boundaryField()*p.boundaryField(); + rho.boundaryField() == psi.boundaryField()*p.boundaryField(); turbulence->correct(); diff --git a/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C index 570123d5..200db91c 100644 --- a/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C +++ b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C @@ -169,7 +169,7 @@ int main(int argc, char *argv[]) rhoU.dimensionedInternalField() /rho.dimensionedInternalField(); U.correctBoundaryConditions(); - rhoU.boundaryField() = rho.boundaryField()*U.boundaryField(); + rhoU.boundaryField() == rho.boundaryField()*U.boundaryField(); if (!inviscid) { @@ -203,7 +203,7 @@ int main(int argc, char *argv[]) e = rhoE/rho - 0.5*magSqr(U); e.correctBoundaryConditions(); thermo.correct(); - rhoE.boundaryField() = + rhoE.boundaryField() == rho.boundaryField()* ( e.boundaryField() + 0.5*magSqr(U.boundaryField()) @@ -224,7 +224,7 @@ int main(int argc, char *argv[]) rho.dimensionedInternalField() /psi.dimensionedInternalField(); p.correctBoundaryConditions(); - rho.boundaryField() = psi.boundaryField()*p.boundaryField(); + rho.boundaryField() == psi.boundaryField()*p.boundaryField(); turbulence->correct();