Commit a5525778 authored by Andrew Heather's avatar Andrew Heather
Browse files
parents c8bff967 6fb475b4
......@@ -22,8 +22,7 @@
==
fvc::reconstruct
(
fvc::interpolate(rho)*(g & mesh.Sf())
- fvc::snGrad(p)*mesh.magSf()
(- ghf*fvc::snGrad(rho) - fvc::snGrad(pmh))*mesh.magSf()
)
);
}
Info<< "Reading field p\n" << endl;
volScalarField p
Info<< "Reading field pmh\n" << endl;
volScalarField pmh
(
IOobject
(
"p",
"pmh",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
......@@ -119,11 +119,6 @@
#include "compressibleCreatePhi.H"
label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue);
Info<< "Calculating field mul\n" << endl;
volScalarField mul
(
......@@ -346,3 +341,48 @@
),
mut + mul
);
Info<< "Calculating field (g.h)f\n" << endl;
volScalarField gh("gh", g & mesh.C());
surfaceScalarField ghf = surfaceScalarField("gh", g & mesh.Cf());
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
pmh + rho*gh
);
label pmhRefCell = 0;
scalar pmhRefValue = 0.0;
setRefCell
(
pmh,
mesh.solutionDict().subDict("PISO"),
pmhRefCell,
pmhRefValue
);
scalar pRefValue = 0.0;
if (pmh.needReference())
{
pRefValue = readScalar
(
mesh.solutionDict().subDict("PISO").lookup("pRefValue")
);
p += dimensionedScalar
(
"p",
p.dimensions(),
pRefValue - getRefCellValue(p, pmhRefCell)
);
}
volScalarField rUA = 1.0/UEqn.A();
surfaceScalarField rUAf
(
"(rho*(1|A(U)))",
fvc::interpolate(rho)*fvc::interpolate(rUA)
);
U = rUA*UEqn.H();
phi =
fvc::interpolate(rho)
*(
(fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, rho, U, phi)
);
surfaceScalarField phiU("phiU", phi);
phi -= ghf*fvc::snGrad(rho)*rUAf*mesh.magSf();
for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pmhEqn
(
fvm::laplacian(rUAf, pmh) == fvc::ddt(rho) + fvc::div(phi)
);
pmhEqn.setReference(pmhRefCell, pmhRefValue);
pmhEqn.solve();
if (nonOrth == nNonOrthCorr)
{
phi -= pmhEqn.flux();
}
}
p == pmh + rho*gh;
if (pmh.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pRefValue - getRefCellValue(p, pmhRefCell)
);
}
#include "rhoEqn.H"
#include "compressibleContinuityErrs.H"
U += rUA*fvc::reconstruct((phi - phiU)/rUAf);
U.correctBoundaryConditions();
......@@ -64,23 +64,25 @@ int main(int argc, char *argv[])
#include "rhoEqn.H"
#include "calcVdj.H"
for (int oCorr=0; oCorr<nOuterCorr; oCorr++)
{
#include "calcVdj.H"
#include "UEqn.H"
#include "UEqn.H"
#include "alphaEqn.H"
#include "alphaEqn.H"
#include "correctViscosity.H"
#include "correctViscosity.H"
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
#include "pmhEqn.H"
}
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
#include "pEqn.H"
#include "kEpsilon.H"
}
#include "kEpsilon.H"
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
......
......@@ -345,12 +345,12 @@ public:
);
//- Construct as copy of tmp<GeometricField> deleting argument
# ifdef ConstructFromTmp
#ifdef ConstructFromTmp
GeometricField
(
const tmp<GeometricField<Type, PatchField, GeoMesh> >&
);
# endif
#endif
//- Construct as copy resetting IO parameters
GeometricField
......@@ -367,13 +367,13 @@ public:
);
//- Construct as copy resetting name
# ifdef ConstructFromTmp
#ifdef ConstructFromTmp
GeometricField
(
const word& newName,
const tmp<GeometricField<Type, PatchField, GeoMesh> >&
);
# endif
#endif
//- Construct as copy resetting IO parameters and patch type
GeometricField
......@@ -392,9 +392,8 @@ public:
);
// Destructor
virtual ~GeometricField();
//- Destructor
virtual ~GeometricField();
// Member Functions
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -72,11 +72,17 @@ public:
// Member Functions
//- Conversion to a Scalar
//- Access to the Scalar value
operator Scalar() const
{
return p_;
}
//- Access to the Scalar value
operator Scalar&()
{
return p_;
}
};
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -81,6 +81,7 @@ public:
nComponents = 1 //!< Number of components in bool is 1
};
// Static data members
static const char* const typeName;
......@@ -88,18 +89,26 @@ public:
static const bool zero;
static const bool one;
// Constructors
//- Construct from Istream
pTraits(Istream&);
// Member Functions
//- Conversion to a bool
//- Access to the bool value
operator bool() const
{
return p_;
}
//- Access to the bool value
operator bool&()
{
return p_;
}
};
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -153,6 +153,7 @@ public:
nComponents = 1 //!< Number of components in label is 1
};
// Static data members
static const char* const typeName;
......@@ -162,18 +163,26 @@ public:
static const label min;
static const label max;
// Constructors
//- Construct from Istream
pTraits(Istream&);
// Member Functions
//- Conversion to a label
//- Access to the label value
operator label() const
{
return p_;
}
//- Access to the label value
operator label&()
{
return p_;
}
};
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -137,6 +137,7 @@ public:
nComponents = 1 //!< Number of components in uLabel is 1
};
// Static data members
static const char* const typeName;
......@@ -146,6 +147,7 @@ public:
static const uLabel max;
static const uLabel min;
// Constructors
//- Construct from Istream
......@@ -154,11 +156,17 @@ public:
// Member Functions
//- Conversion to a uLabel
//- Access to the uLabel value
operator uLabel() const
{
return p_;
}
//- Access to the uLabel value
operator uLabel&()
{
return p_;
}
};
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -54,15 +54,30 @@ class pTraits
public:
pTraits(const PrimitiveType& p)
:
PrimitiveType(p)
{}
// Constructors
pTraits(Istream& is)
:
PrimitiveType(is)
{}
pTraits(const PrimitiveType& p)
:
PrimitiveType(p)
{}
pTraits(Istream& is)
:
PrimitiveType(is)
{}
// Member operators
operator PrimitiveType() const
{
return *this;
}
operator PrimitiveType&()
{
return *this;
}
};
......
......@@ -117,10 +117,14 @@ void buoyantPressureFvPatchScalarField::updateCoeffs()
const fvPatchField<scalar>& rho =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
// If the variable name is "pd" assume it is p - rho*g.h
// If the variable name is "pmh" or "pd" assume it is p - rho*g.h
// and set the gradient appropriately.
// Otherwise assume the variable is the static pressure.
if (dimensionedInternalField().name() == "pd")
if
(
dimensionedInternalField().name() == "pmh"
|| dimensionedInternalField().name() == "pd"
)
{
gradient() = -rho.snGrad()*(g.value() & patch().Cf());
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -26,42 +26,37 @@ License
#include "AverageIOField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
AverageIOField<Type>::AverageIOField
Foam::AverageIOField<Type>::AverageIOField
(
const IOobject& io
)
:
regIOobject(io),
pTraits<Type>(readStream(typeName)),
Field<Type>(readStream(typeName))
regIOobject(io)
{
readStream(typeName) >> average_;
readStream(typeName) >> static_cast<Field<Type>&>(*this);
close();
}
template<class Type>
AverageIOField<Type>::AverageIOField
Foam::AverageIOField<Type>::AverageIOField
(
const IOobject& io,
const label size
)
:
regIOobject(io),
pTraits<Type>(pTraits<Type>::zero),
Field<Type>(size)
Field<Type>(size),
average_(0)
{}
template<class Type>
AverageIOField<Type>::AverageIOField
Foam::AverageIOField<Type>::AverageIOField
(
const IOobject& io,
const Type& average,
......@@ -69,21 +64,28 @@ AverageIOField<Type>::AverageIOField
)
:
regIOobject(io),
pTraits<Type>(average),
Field<Type>(f)
Field<Type>(f),
average_(average)
{
if (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
{
readStream(typeName)
>> static_cast<Type&>(*this)
>> average_
>> static_cast<Field<Type>&>(*this);
close();
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
bool Foam::AverageIOField<Type>::writeData(Ostream& os) const
{
os << average_
<< token::NL
<< static_cast<const Field<Type>&>(*this);
return os.good();
}
} // End namespace Foam
// ************************************************************************* //
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -45,16 +45,20 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class AverageIOField Declaration
Class AverageIOField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class AverageIOField
:
public regIOobject,
public pTraits<Type>,
public Field<Type>
{
// Private data
//- The average of the field
Type average_;
public:
......@@ -87,19 +91,17 @@ public:
// Member functions
const pTraits<Type>& average() const
const Type& average() const
{
return static_cast<const pTraits<Type>&>(*this);
return average_;
}
bool writeData(Ostream& os) const
Type& average()
{
os << static_cast<const Type&>(*this)
<< token::NL
<< static_cast<const Field<Type>&>(*this);
return os.good();
return average_;
}
bool writeData(Ostream& os) const;
};
......
......@@ -22,6 +22,8 @@ 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 "AverageIOField.H"
......