Commit 4a57b9be authored by Henry Weller's avatar Henry Weller
Browse files

GeometricField: Rationalized and simplified access to the dimensioned internal field

Given that the type of the dimensioned internal field is encapsulated in
the GeometricField class the name need not include "Field"; the type
name is "Internal" so

volScalarField::DimensionedInternalField -> volScalarField::Internal

In addition to the ".dimensionedInternalField()" access function the
simpler "()" de-reference operator is also provided to greatly simplify
FV equation source term expressions which need not evaluate boundary
conditions.  To demonstrate this kEpsilon.C has been updated to use
dimensioned internal field expressions in the k and epsilon equation
source terms.
parent c9a57e40
......@@ -75,7 +75,7 @@ License
// Reaction source time scale
if (alphaTemp < 1.0)
{
volScalarField::DimensionedInternalField rDeltaTT
volScalarField::Internal rDeltaTT
(
mag(reaction->Sh())/(alphaTemp*rho*thermo.Cp()*T)
);
......
......@@ -74,7 +74,7 @@ License
// Reaction source time scale
{
volScalarField::DimensionedInternalField rDeltaTT
volScalarField::Internal rDeltaTT
(
mag
(
......
......@@ -74,7 +74,7 @@ License
// Reaction source time scale
{
volScalarField::DimensionedInternalField rDeltaTT
volScalarField::Internal rDeltaTT
(
mag
(
......
......@@ -6,7 +6,7 @@
for (int gCorr=0; gCorr<nAlphaCorr; gCorr++)
{
volScalarField::DimensionedInternalField Sp
volScalarField::Internal Sp
(
IOobject
(
......@@ -18,7 +18,7 @@
dimensionedScalar("Sp", dgdt.dimensions(), 0.0)
);
volScalarField::DimensionedInternalField Su
volScalarField::Internal Su
(
IOobject
(
......
......@@ -1058,7 +1058,7 @@ void Foam::multiphaseMixtureThermo::solveAlphas
surfaceScalarField& alphaPhi = alphaPhiCorrs[phasei];
alphaPhi += upwind<scalar>(mesh_, phi_).flux(alpha);
volScalarField::DimensionedInternalField Sp
volScalarField::Internal Sp
(
IOobject
(
......@@ -1070,7 +1070,7 @@ void Foam::multiphaseMixtureThermo::solveAlphas
dimensionedScalar("Sp", alpha.dgdt().dimensions(), 0.0)
);
volScalarField::DimensionedInternalField Su
volScalarField::Internal Su
(
IOobject
(
......
......@@ -218,7 +218,7 @@ void Foam::multiphaseSystem::solveAlphas()
surfaceScalarField& alphaPhic = alphaPhiCorrs[phasei];
alphaPhic += upwind<scalar>(mesh_, phi_).flux(phase);
volScalarField::DimensionedInternalField Sp
volScalarField::Internal Sp
(
IOobject
(
......@@ -230,7 +230,7 @@ void Foam::multiphaseSystem::solveAlphas()
dimensionedScalar("Sp", divU.dimensions(), 0.0)
);
volScalarField::DimensionedInternalField Su
volScalarField::Internal Su
(
IOobject
(
......
......@@ -206,7 +206,7 @@ void Foam::twoPhaseSystem::solve()
const surfaceScalarField& phi2 = phase2_.phi();
// Construct the dilatation rate source term
tmp<volScalarField::DimensionedInternalField> tdgdt;
tmp<volScalarField::Internal> tdgdt;
if (phase1_.divU().valid() && phase2_.divU().valid())
{
......@@ -257,7 +257,7 @@ void Foam::twoPhaseSystem::solve()
for (int acorr=0; acorr<nAlphaCorr; acorr++)
{
volScalarField::DimensionedInternalField Sp
volScalarField::Internal Sp
(
IOobject
(
......@@ -269,7 +269,7 @@ void Foam::twoPhaseSystem::solve()
dimensionedScalar("Sp", dimless/dimTime, 0.0)
);
volScalarField::DimensionedInternalField Su
volScalarField::Internal Su
(
IOobject
(
......
......@@ -392,7 +392,7 @@ void Foam::twoPhaseSystem::solve()
for (int acorr=0; acorr<nAlphaCorr; acorr++)
{
volScalarField::DimensionedInternalField Sp
volScalarField::Internal Sp
(
IOobject
(
......@@ -404,7 +404,7 @@ void Foam::twoPhaseSystem::solve()
dimensionedScalar("Sp", dgdt_.dimensions(), 0.0)
);
volScalarField::DimensionedInternalField Su
volScalarField::Internal Su
(
IOobject
(
......
......@@ -148,8 +148,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
decompositionMethod& decomposer = decomposerPtr_();
volScalarField::InternalField& icellWeights = cellWeights.internalField();
volScalarField::Internal& icellWeights = cellWeights;
// For each cell in the mesh has it been determined if it is fully
// inside, outside, or overlaps the surface
......@@ -632,7 +631,7 @@ Foam::labelList Foam::backgroundMeshDecomposition::selectRefinementCells
volScalarField& cellWeights
) const
{
volScalarField::InternalField& icellWeights = cellWeights.internalField();
volScalarField::Internal& icellWeights = cellWeights;
labelHashSet cellsToRefine;
......@@ -873,7 +872,7 @@ Foam::backgroundMeshDecomposition::distribute
mesh_.write();
}
volScalarField::InternalField& icellWeights = cellWeights.internalField();
volScalarField::Internal& icellWeights = cellWeights;
while (true)
{
......
......@@ -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
......@@ -175,19 +175,19 @@ void calc
// Read vol-internal fields.
PtrList<volScalarField::DimensionedInternalField> vsiFlds;
PtrList<volScalarField::Internal> vsiFlds;
ReadFields(mesh, objects, vsiFlds);
PtrList<volVectorField::DimensionedInternalField> vviFlds;
PtrList<volVectorField::Internal> vviFlds;
ReadFields(mesh, objects, vviFlds);
PtrList<volSphericalTensorField::DimensionedInternalField> vstiFlds;
PtrList<volSphericalTensorField::Internal> vstiFlds;
ReadFields(mesh, objects, vstiFlds);
PtrList<volSymmTensorField::DimensionedInternalField> vsymtiFlds;
PtrList<volSymmTensorField::Internal> vsymtiFlds;
ReadFields(mesh, objects, vsymtiFlds);
PtrList<volTensorField::DimensionedInternalField> vtiFlds;
PtrList<volTensorField::Internal> vtiFlds;
ReadFields(mesh, objects, vtiFlds);
// Read surface fields.
......
......@@ -683,19 +683,19 @@ DebugSwitches
pointIndexHitList 0;
pointPatchField 0;
pointScalarField 0;
pointScalarField::DimensionedInternalField 0;
pointScalarField::Internal 0;
pointSet 0;
pointSphericalTensorField 0;
pointSphericalTensorField::DimensionedInternalField 0;
pointSphericalTensorField::Internal 0;
pointSymmTensorField 0;
pointSymmTensorField::DimensionedInternalField 0;
pointSymmTensorField::Internal 0;
pointTensorField 0;
pointTensorField::DimensionedInternalField 0;
pointTensorField::Internal 0;
pointToCell 0;
pointToFace 0;
pointToPoint 0;
pointVectorField 0;
pointVectorField::DimensionedInternalField 0;
pointVectorField::Internal 0;
pointZone 0;
polyBoundaryMesh 0;
polyMesh 0;
......@@ -798,18 +798,18 @@ DebugSwitches
surfacePatch 0;
surfacePatchIOList 0;
surfaceScalarField 0;
surfaceScalarField::DimensionedInternalField 0;
surfaceScalarField::Internal 0;
surfaceSlipDisplacement 0;
surfaceSphericalTensorField 0;
surfaceSphericalTensorField::DimensionedInternalField 0;
surfaceSphericalTensorField::Internal 0;
surfaceSymmTensorField 0;
surfaceSymmTensorField::DimensionedInternalField 0;
surfaceSymmTensorField::Internal 0;
surfaceTensorField 0;
surfaceTensorField::DimensionedInternalField 0;
surfaceTensorField::Internal 0;
surfaceToCell 0;
surfaceToPoint 0;
surfaceVectorField 0;
surfaceVectorField::DimensionedInternalField 0;
surfaceVectorField::Internal 0;
surfaceWriter 0;
surfaces 0;
swirlInjector 0;
......@@ -876,15 +876,15 @@ DebugSwitches
viscosityModel 0;
volPointInterpolation 0;
volScalarField 0;
volScalarField::DimensionedInternalField 0;
volScalarField::Internal 0;
volSphericalTensorField 0;
volSphericalTensorField::DimensionedInternalField 0;
volSphericalTensorField::Internal 0;
volSymmTensorField 0;
volSymmTensorField::DimensionedInternalField 0;
volSymmTensorField::Internal 0;
volTensorField 0;
volTensorField::DimensionedInternalField 0;
volTensorField::Internal 0;
volVectorField 0;
volVectorField::DimensionedInternalField 0;
volVectorField::Internal 0;
vtk 0;
walkPatch 0;
wall 0;
......
......@@ -79,7 +79,13 @@ public:
// Public typedefs
//- Type of mesh on which this DimensionedField is instantiated
typedef typename GeoMesh::Mesh Mesh;
//- Type of the field from which this DimensionedField is derived
typedef Field<Type> FieldType;
//- Component type of the elements of the field
typedef typename Field<Type>::cmptType cmptType;
......
......@@ -55,6 +55,11 @@ class oneField
public:
// Public typedefs
typedef oneField FieldType;
// Constructors
//- Construct null
......
......@@ -689,7 +689,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::~GeometricField()
template<class Type, template<class> class PatchField, class GeoMesh>
typename
Foam::GeometricField<Type, PatchField, GeoMesh>::DimensionedInternalField&
Foam::GeometricField<Type, PatchField, GeoMesh>::Internal&
Foam::GeometricField<Type, PatchField, GeoMesh>::dimensionedInternalFieldRef()
{
this->setUpToDate();
......@@ -700,7 +700,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::dimensionedInternalFieldRef()
template<class Type, template<class> class PatchField, class GeoMesh>
typename
Foam::GeometricField<Type, PatchField, GeoMesh>::InternalField&
Foam::GeometricField<Type, PatchField, GeoMesh>::Internal::FieldType&
Foam::GeometricField<Type, PatchField, GeoMesh>::internalField()
{
this->setUpToDate();
......
......@@ -95,12 +95,19 @@ public:
// Public typedefs
//- Type of mesh on which this GeometricField is instantiated
typedef typename GeoMesh::Mesh Mesh;
//- Type of boundary mesh on which this
// GeometricField::GeometricBoundaryField is instantiated
typedef typename GeoMesh::BoundaryMesh BoundaryMesh;
typedef DimensionedField<Type, GeoMesh> DimensionedInternalField;
typedef Field<Type> InternalField;
typedef PatchField<Type> PatchFieldType;
//- Type of the internal field from which this GeometricField is derived
typedef DimensionedField<Type, GeoMesh> Internal;
//- Type of the patch field of which the
// GeometricField::GeometricBoundaryField is composed
typedef PatchField<Type> Patch;
class GeometricBoundaryField
......@@ -126,7 +133,7 @@ public:
GeometricBoundaryField
(
const BoundaryMesh&,
const DimensionedInternalField&,
const Internal&,
const word&
);
......@@ -137,7 +144,7 @@ public:
GeometricBoundaryField
(
const BoundaryMesh&,
const DimensionedInternalField&,
const Internal&,
const wordList& wantedPatchTypes,
const wordList& actualPatchTypes = wordList()
);
......@@ -148,14 +155,14 @@ public:
GeometricBoundaryField
(
const BoundaryMesh&,
const DimensionedInternalField&,
const Internal&,
const PtrList<PatchField<Type>>&
);
//- Construct as copy setting the reference to the internal field
GeometricBoundaryField
(
const DimensionedInternalField&,
const Internal&,
const GeometricBoundaryField&
);
......@@ -173,7 +180,7 @@ public:
GeometricBoundaryField
(
const BoundaryMesh&,
const DimensionedInternalField&,
const Internal&,
const dictionary&
);
......@@ -432,23 +439,23 @@ public:
//- Return a reference to the dimensioned internal field
// Note: this increments the event counter and checks the
// old-time fields; avoid in loops.
DimensionedInternalField& dimensionedInternalFieldRef();
Internal& dimensionedInternalFieldRef();
//- Return a const-reference to the dimensioned internal field
inline const DimensionedInternalField& dimensionedInternalField() const;
inline const Internal& dimensionedInternalField() const;
//- Return a const-reference to the dimensioned internal field
// of a "vol" field. Useful in the formulation of source-terms
// for FV equations
inline const DimensionedInternalField& v() const;
inline const Internal& v() const;
//- Return a reference to the internal field
// Note: this increments the event counter and checks the
// old-time fields; avoid in loops.
InternalField& internalField();
typename Internal::FieldType& internalField();
//- Return a const-reference to the internal field
inline const InternalField& internalField() const;
inline const typename Internal::FieldType& internalField() const;
//- Return a reference to the boundary field
// Note: this increments the event counter and checks the
......@@ -570,9 +577,8 @@ public:
// Member operators
//- Return a const-reference to the dimensioned internal field
// of a "vol" field. Useful in the formulation of source-terms
// for FV equations
inline const DimensionedInternalField& operator~() const;
// Useful in the formulation of source-terms for FV equations
inline const Internal& operator()() const;
void operator=(const GeometricField<Type, PatchField, GeoMesh>&);
void operator=(const tmp<GeometricField<Type, PatchField, GeoMesh>>&);
......
......@@ -36,7 +36,18 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::null()
template<class Type, template<class> class PatchField, class GeoMesh>
inline
const typename
Foam::GeometricField<Type, PatchField, GeoMesh>::DimensionedInternalField&
Foam::GeometricField<Type, PatchField, GeoMesh>::Internal&
Foam::GeometricField<Type, PatchField, GeoMesh>::
operator()() const
{
return *this;
}
template<class Type, template<class> class PatchField, class GeoMesh>
inline
const typename
Foam::GeometricField<Type, PatchField, GeoMesh>::Internal&
Foam::GeometricField<Type, PatchField, GeoMesh>::
dimensionedInternalField() const
{
......@@ -47,7 +58,7 @@ dimensionedInternalField() const
template<class Type, template<class> class PatchField, class GeoMesh>
inline
const typename
Foam::GeometricField<Type, PatchField, GeoMesh>::InternalField&
Foam::GeometricField<Type, PatchField, GeoMesh>::Internal::FieldType&
Foam::GeometricField<Type, PatchField, GeoMesh>::internalField() const
{
return *this;
......
......@@ -176,7 +176,7 @@ template
class GeoMesh
>
Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
DimensionedInternalField::DimensionedInternalField
Internal::Internal
(
const IOobject& io,
const Mesh& mesh,
......@@ -364,7 +364,7 @@ template
class GeoMesh
>
Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
DimensionedInternalField::~DimensionedInternalField()
Internal::~Internal()
{
// Set the internalField storage pointer to NULL before its destruction
// to protect the field it a slice of.
......
......@@ -70,7 +70,7 @@ public:
typedef typename GeoMesh::Mesh Mesh;
typedef typename GeoMesh::BoundaryMesh BoundaryMesh;
class DimensionedInternalField;
class Internal;
private:
......@@ -172,7 +172,7 @@ public:
/*---------------------------------------------------------------------------*\
Class SlicedGeometricField::DimensionedInternalField Declaration
Class SlicedGeometricField::Internal Declaration
\*---------------------------------------------------------------------------*/
//- The internalField of a SlicedGeometricField
......@@ -184,9 +184,9 @@ template
class GeoMesh
>
class SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
DimensionedInternalField
Internal
:
public GeometricField<Type, PatchField, GeoMesh>::DimensionedInternalField
public GeometricField<Type, PatchField, GeoMesh>::Internal
{
public:
......@@ -194,7 +194,7 @@ public:
// Constructors
//- Construct from components and field to slice
DimensionedInternalField
Internal
(
const IOobject&,
const Mesh&,
......@@ -204,7 +204,7 @@ public:
//- Destructor
~DimensionedInternalField();
~Internal();
};
......
......@@ -59,9 +59,8 @@ public:
// Public typedefs
typedef oneField DimensionedInternalField;
typedef oneField InternalField;
typedef oneField PatchFieldType;
typedef oneField Internal;
typedef oneField Patch;
typedef oneFieldField GeometricBoundaryField;
typedef one cmptType;
......@@ -82,9 +81,11 @@ public:
inline oneField oldTime() const;
inline InternalField internalField() const;
inline Internal operator()() const;
inline DimensionedInternalField v() const;
inline Internal v() const;
inline typename Internal::FieldType internalField() const;
inline GeometricBoundaryField boundaryField() const;
};
......@@ -96,16 +97,16 @@ inline const geometricOneField& operator*
const geometricOneField&
);
inline const geometricOneField::DimensionedInternalField& operator*
inline const geometricOneField::Internal& operator*
(
const geometricOneField::DimensionedInternalField&,
const geometricOneField::Internal&,
const geometricOneField&
);
inline const geometricOneField::DimensionedInternalField& operator*
inline const geometricOneField::Internal& operator*
(
const geometricOneField&,
const geometricOneField::DimensionedInternalField&
const geometricOneField::Internal&
);
inline const geometricOneField& operator/
......@@ -114,16 +115,16 @@ inline const geometricOneField& operator/
const geometricOneField&
);
inline const geometricOneField::DimensionedInternalField& operator/
inline const geometricOneField::Internal& operator/
(
const geometricOneField::DimensionedInternalField&,
const geometricOneField::Internal&,
const geometricOneField&
);
inline const geometricOneField::DimensionedInternalField& operator/
inline const geometricOneField::Internal& operator/
(
const geometricOneField&,
const geometricOneField::DimensionedInternalField&
const geometricOneField::Internal&
);
......
......@@ -51,17 +51,24 @@ inline Foam::oneField Foam::geometricOneField::oldTime() const
}
inline Foam::geometricOneField::InternalField
Foam::geometricOneField::internalField() const
inline Foam::geometricOneField::Internal
Foam::geometricOneField::operator()() const
{
return InternalField();
return Internal();
}
inline Foam::geometricOneField::DimensionedInternalField
inline Foam::geometricOneField::Internal
Foam::geometricOneField::v() const
{
return DimensionedInternalField();