diff --git a/applications/test/volField/Test-volField.C b/applications/test/volField/Test-volField.C index 37e4d303bf..688650b2c0 100644 --- a/applications/test/volField/Test-volField.C +++ b/applications/test/volField/Test-volField.C @@ -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,6 +52,10 @@ int main(int argc, char *argv[]) mesh ); + Info<< nl + << "p.v().size(): " + << p.v().size() << endl; + Info<< "Reading field U\n" << endl; volVectorField U ( diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H index fe30dc9181..d5be62367a 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H @@ -437,6 +437,11 @@ public: //- Return a const-reference to the dimensioned internal field inline const DimensionedInternalField& 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; + //- Return a reference to the internal field // Note: this increments the event counter and checks the // old-time fields; avoid in loops. @@ -564,6 +569,11 @@ 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; + void operator=(const GeometricField&); void operator=(const tmp>&); void operator=(const dimensioned&); diff --git a/src/finiteVolume/fields/volFields/volFields.H b/src/finiteVolume/fields/volFields/volFields.H index 145fc5dccb..2372a59069 100644 --- a/src/finiteVolume/fields/volFields/volFields.H +++ b/src/finiteVolume/fields/volFields/volFields.H @@ -62,13 +62,16 @@ void GeometricField::replace const GeometricField& sf ); - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "volFieldsI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/finiteVolume/fields/volFields/volFieldsI.H b/src/finiteVolume/fields/volFields/volFieldsI.H new file mode 100644 index 0000000000..27599b47eb --- /dev/null +++ b/src/finiteVolume/fields/volFields/volFieldsI.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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 . + +\*---------------------------------------------------------------------------*/ + +template class PatchField, class GeoMesh> +inline +const typename +Foam::GeometricField::DimensionedInternalField& +Foam::GeometricField:: +v() const +{ + static_assert(isVolMesh::value, "Only valid for volFields"); + return *this; +} + + +template class PatchField, class GeoMesh> +inline +const typename +Foam::GeometricField::DimensionedInternalField& +Foam::GeometricField:: +operator~() const +{ + static_assert(isVolMesh::value, "Only valid for volFields"); + return *this; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/volMesh/volMesh.H b/src/finiteVolume/volMesh/volMesh.H index 243bf16907..d132df1070 100644 --- a/src/finiteVolume/volMesh/volMesh.H +++ b/src/finiteVolume/volMesh/volMesh.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-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,6 +27,12 @@ Class Description Mesh data needed to do the Finite Volume discretisation. +Class + Foam::isVolMesh + +Description + Supports static assertion that a template argument is of type volMesh. + \*---------------------------------------------------------------------------*/ #ifndef volMesh_H @@ -35,6 +41,7 @@ Description #include "GeoMesh.H" #include "fvMesh.H" #include "primitiveMesh.H" +#include // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -83,6 +90,24 @@ public: }; +/*---------------------------------------------------------------------------*\ + Class isVolMesh Declaration +\*---------------------------------------------------------------------------*/ + +template +class isVolMesh +: + public std::false_type +{}; + + +template<> +class isVolMesh +: + public std::true_type +{}; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam