Commit 99a10ece authored by Henry Weller's avatar Henry Weller
Browse files

Boundary conditions: Added extrapolatedCalculatedFvPatchField

To be used instead of zeroGradientFvPatchField for temporary fields for
which zero-gradient extrapolation is use to evaluate the boundary field
but avoiding fields derived from temporary field using field algebra
inheriting the zeroGradient boundary condition by the reuse of the
temporary field storage.

zeroGradientFvPatchField should not be used as the default patch field
for any temporary fields and should be avoided for non-temporary fields
except where it is clearly appropriate;
extrapolatedCalculatedFvPatchField and calculatedFvPatchField are
generally more suitable defaults depending on the manner in which the
boundary values are specified or evaluated.

The entire OpenFOAM-dev code-base has been updated following the above
recommendations.

Henry G. Weller
CFD Direct
parent 979e1ee1
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -24,7 +24,6 @@ License
\*---------------------------------------------------------------------------*/
#include "basicXiSubXiEq.H"
#include "zeroGradientFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -93,59 +92,43 @@ Foam::tmp<Foam::volScalarField> Foam::XiEqModels::basicSubGrid::XiEq() const
const scalarField Cw = pow(mesh.V(), 2.0/3.0);
tmp<volScalarField> tN
volScalarField N
(
new volScalarField
IOobject
(
IOobject
(
"tN",
mesh.time().constant(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
"N",
mesh.time().constant(),
mesh,
dimensionedScalar("zero", Nv.dimensions(), 0.0),
zeroGradientFvPatchVectorField::typeName
)
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("zero", Nv.dimensions(), 0.0)
);
volScalarField& N = tN();
N.internalField() = Nv.internalField()*Cw;
tmp<volSymmTensorField> tns
volSymmTensorField ns
(
new volSymmTensorField
IOobject
(
IOobject
(
"tns",
U.mesh().time().timeName(),
U.mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
"ns",
U.mesh().time().timeName(),
U.mesh(),
dimensionedSymmTensor
(
"zero",
nsv.dimensions(),
pTraits<symmTensor>::zero
),
zeroGradientFvPatchSymmTensorField::typeName
IOobject::NO_READ,
IOobject::NO_WRITE
),
U.mesh(),
dimensionedSymmTensor
(
"zero",
nsv.dimensions(),
pTraits<symmTensor>::zero
)
);
volSymmTensorField& ns = tns();
ns.internalField() = nsv.internalField()*Cw;
volScalarField n(max(N - (Uhat & ns & Uhat), scalar(1e-4)));
volScalarField b((Uhat & B_ & Uhat)/sqrt(n));
volScalarField up(sqrt((2.0/3.0)*turbulence_.k()));
volScalarField XiSubEq
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -24,7 +24,6 @@ License
\*---------------------------------------------------------------------------*/
#include "basicXiSubG.H"
#include "zeroGradientFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -74,29 +73,7 @@ Foam::tmp<Foam::volScalarField> Foam::XiGModels::basicSubGrid::G() const
volScalarField& Gtot = tGtot();
const scalarField Cw = pow(Su_.mesh().V(), 2.0/3.0);
tmp<volScalarField> tN
(
new volScalarField
(
IOobject
(
"tN",
Su_.mesh().time().timeName(),
Su_.mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
Su_.mesh(),
dimensionedScalar("zero", Nv.dimensions(), 0.0),
zeroGradientFvPatchVectorField::typeName
)
);
volScalarField& N = tN();
N.internalField() = Nv.internalField()*Cw;
scalarField N(Nv.internalField()*Cw);
forAll(N, celli)
{
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -24,7 +24,6 @@ License
\*---------------------------------------------------------------------------*/
#include "basic.H"
#include "zeroGradientFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -110,8 +109,7 @@ Foam::tmp<Foam::volSymmTensorField> Foam::PDRDragModels::basic::Dcu() const
"zero",
dimMass/dimTime/pow(dimLength, 3),
pTraits<symmTensor>::zero
),
zeroGradientFvPatchSymmTensorField::typeName
)
)
);
......@@ -145,8 +143,7 @@ Foam::tmp<Foam::volScalarField> Foam::PDRDragModels::basic::Gk() const
IOobject::NO_WRITE
),
U_.mesh(),
dimensionedScalar("zero", dimMass/dimLength/pow(dimTime, 3), 0.0),
zeroGradientFvPatchVectorField::typeName
dimensionedScalar("zero", dimMass/dimLength/pow(dimTime, 3), 0.0)
)
);
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -24,7 +24,6 @@ License
\*---------------------------------------------------------------------------*/
#include "XiEqModel.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -111,39 +110,30 @@ Foam::XiEqModel::calculateSchelkinEffect(const scalar uPrimeCoef) const
false
),
mesh,
dimensionedScalar("zero", Nv.dimensions(), 0.0),
zeroGradientFvPatchVectorField::typeName
dimensionedScalar("zero", Nv.dimensions(), 0.0)
)
);
volScalarField& N = tN();
N.internalField() = Nv.internalField()*pow(mesh.V(), 2.0/3.0);
tmp<volSymmTensorField> tns
volSymmTensorField ns
(
new volSymmTensorField
IOobject
(
IOobject
(
"tns",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
"tns",
mesh.time().timeName(),
mesh,
dimensionedSymmTensor
(
"zero",
nsv.dimensions(),
pTraits<symmTensor>::zero
)
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedSymmTensor
(
"zero",
nsv.dimensions(),
pTraits<symmTensor>::zero
)
);
volSymmTensorField& ns = tns();
ns.internalField() = nsv.internalField()*pow(mesh.V(), 2.0/3.0);
const volVectorField Uhat
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -34,7 +34,6 @@ Description
#include "dynamicFvMesh.H"
#include "psiThermo.H"
#include "turbulentFluidThermoModel.H"
#include "zeroGradientFvPatchFields.H"
#include "fixedRhoFvPatchScalarField.H"
#include "directionInterpolate.H"
#include "motionSolver.H"
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -33,7 +33,6 @@ Description
#include "fvCFD.H"
#include "psiThermo.H"
#include "turbulentFluidThermoModel.H"
#include "zeroGradientFvPatchFields.H"
#include "fixedRhoFvPatchScalarField.H"
#include "directionInterpolate.H"
#include "localEulerDdtScheme.H"
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -59,8 +59,6 @@ void Foam::multiphaseMixtureThermo::calcAlphas()
alphas_ += level*phase();
level += 1.0;
}
alphas_.correctBoundaryConditions();
}
......@@ -104,8 +102,7 @@ Foam::multiphaseMixtureThermo::multiphaseMixtureThermo
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("alphas", dimless, 0.0),
zeroGradientFvPatchScalarField::typeName
dimensionedScalar("alphas", dimless, 0.0)
),
sigmas_(lookup("sigmas")),
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -54,8 +54,6 @@ void Foam::multiphaseSystem::calcAlphas()
alphas_ += level*iter();
level += 1.0;
}
alphas_.correctBoundaryConditions();
}
......@@ -417,8 +415,7 @@ Foam::multiphaseSystem::multiphaseSystem
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("alphas", dimless, 0.0),
zeroGradientFvPatchScalarField::typeName
dimensionedScalar("alphas", dimless, 0.0)
),
sigmas_(lookup("sigmas")),
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -52,8 +52,6 @@ void Foam::multiphaseMixture::calcAlphas()
alphas_ += level*iter();
level += 1.0;
}
alphas_.correctBoundaryConditions();
}
......@@ -108,8 +106,7 @@ Foam::multiphaseMixture::multiphaseMixture
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("alphas", dimless, 0.0),
zeroGradientFvPatchScalarField::typeName
dimensionedScalar("alphas", dimless, 0.0)
),
nu_
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -27,6 +27,7 @@ License
#include "phasePair.H"
#include "fvcGrad.H"
#include "surfaceInterpolate.H"
#include "zeroGradientFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -34,6 +34,7 @@ License
#include "fvcDiv.H"
#include "fvmSup.H"
#include "fvMatrix.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -78,8 +78,7 @@ Foam::InertPhaseModel<BasePhaseModel>::Sh() const
this->mesh()
),
this->mesh(),
dimensionedScalar("zero", dimEnergy/dimTime/dimVolume, 0),
zeroGradientFvPatchScalarField::typeName
dimensionedScalar("zero", dimEnergy/dimTime/dimVolume, 0)
)
);
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -64,8 +64,6 @@ void Foam::multiphaseSystem::calcAlphas()
alphas_ += level*phases()[i];
level += 1.0;
}
alphas_.correctBoundaryConditions();
}
......@@ -506,8 +504,7 @@ Foam::multiphaseSystem::multiphaseSystem
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("alphas", dimless, 0.0),
zeroGradientFvPatchScalarField::typeName
dimensionedScalar("alphas", dimless, 0.0)
),
cAlphas_(lookup("interfaceCompression")),
......
EXE_INC = \
EXE_INC = -ggdb3 \
-ItwoPhaseSystem/lnInclude \
-I../phaseSystems/lnInclude \
-I../interfacialModels/lnInclude \
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -27,6 +27,7 @@ License
#include "phasePair.H"
#include "fvcGrad.H"
#include "surfaceInterpolate.H"
#include "zeroGradientFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......
......@@ -41,8 +41,7 @@
"rho",
dimMass/dimVolume,
rhoValue
),
zeroGradientFvPatchField<scalar>::typeName
)
)
);
}
......@@ -97,8 +96,7 @@
"Erho",
dimMass/dimLength/sqr(dimTime),
rhoEValue
),
zeroGradientFvPatchField<scalar>::typeName
)
)
);
}
......@@ -152,8 +150,7 @@
"nu",
dimless,
nuValue
),
zeroGradientFvPatchField<scalar>::typeName
)
)
);
}
......
......@@ -75,8 +75,7 @@ if (thermalStress)
"C",
dimensionSet(0, 2, -2 , -1, 0),
CValue
),
zeroGradientFvPatchField<scalar>::typeName
)
)
);
......@@ -131,8 +130,7 @@ if (thermalStress)
"rhoK",
dimensionSet(1, 1, -3 , -1, 0),
rhoKValue
),
zeroGradientFvPatchField<scalar>::typeName
)
)
);
......@@ -188,8 +186,7 @@ if (thermalStress)
"alpha",
inv(dimTemperature),
alphaValue
),
zeroGradientFvPatchField<scalar>::typeName
)
)
);
}
......
......@@ -398,8 +398,7 @@ int main(int argc, char *argv[])
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("cellDist", dimless, 0),
zeroGradientFvPatchScalarField::typeName
dimensionedScalar("cellDist", dimless, 0)
);
forAll(procIds, celli)
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -236,20 +236,18 @@ void writeDecomposition
false // do not register
),
mesh,
dimensionedScalar(name, dimless, -1),
zeroGradientFvPatchScalarField::typeName