src/postProcessing/functionObjects/field/Make/files: Corrected

This commit is contained in:
Henry Weller
2016-04-26 20:31:58 +01:00
parent dc2951ca2f
commit 3cfc54ba09
12 changed files with 65 additions and 143 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -30,7 +30,6 @@ InClass
#define vtkOpenFOAMTupleRemap_H #define vtkOpenFOAMTupleRemap_H
// OpenFOAM includes // OpenFOAM includes
#include "StaticAssert.H"
#include "Swap.H" #include "Swap.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,17 +38,6 @@ template<class Type>
inline void vtkOpenFOAMTupleRemap(float vec[]); inline void vtkOpenFOAMTupleRemap(float vec[]);
// a symmTensor specialization to remap OpenFOAM -> ParaView naming order
// Qt/Core/pqScalarBarRepresentation.cxx defines this order
// { "XX", "YY", "ZZ", "XY", "YZ", "XZ" }
// in pqScalarBarRepresentation::getDefaultComponentLabel()
// whereas OpenFOAM uses this order
// { XX, XY, XZ, YY, YZ, ZZ }
//
// for extra safety, assert that symmTensor indeed has 6 components
StaticAssert(Foam::symmTensor::nComponents == 6);
// Template specialization for symmTensor // Template specialization for symmTensor
template<> template<>
inline void vtkOpenFOAMTupleRemap<Foam::symmTensor>(float vec[]) inline void vtkOpenFOAMTupleRemap<Foam::symmTensor>(float vec[])

View File

@ -30,7 +30,6 @@ InClass
#define vtkOpenFOAMTupleRemap_H #define vtkOpenFOAMTupleRemap_H
// OpenFOAM includes // OpenFOAM includes
#include "StaticAssert.H"
#include "Swap.H" #include "Swap.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,17 +38,6 @@ template<class Type>
inline void vtkOpenFOAMTupleRemap(float vec[]); inline void vtkOpenFOAMTupleRemap(float vec[]);
// a symmTensor specialization to remap OpenFOAM -> ParaView naming order
// Qt/Core/pqScalarBarRepresentation.cxx defines this order
// { "XX", "YY", "ZZ", "XY", "YZ", "XZ" }
// in pqScalarBarRepresentation::getDefaultComponentLabel()
// whereas OpenFOAM uses this order
// { XX, XY, XZ, YY, YZ, ZZ }
//
// for extra safety, assert that symmTensor indeed has 6 components
StaticAssert(Foam::symmTensor::nComponents == 6);
// Template specialization for symmTensor // Template specialization for symmTensor
template<> template<>
inline void vtkOpenFOAMTupleRemap<Foam::symmTensor>(float vec[]) inline void vtkOpenFOAMTupleRemap<Foam::symmTensor>(float vec[])

View File

@ -44,7 +44,7 @@ SourceFiles
#define DynamicList_H #define DynamicList_H
#include "List.H" #include "List.H"
#include "StaticAssert.H" #include <type_traits>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -79,8 +79,11 @@ class DynamicList
: :
public List<T> public List<T>
{ {
//- Avoid invalid sizing parameters static_assert
StaticAssert((SizeInc || SizeMult) && SizeDiv); (
(SizeInc || SizeMult) && SizeDiv,
"Invalid sizing parameters"
);
// Private data // Private data

View File

@ -42,7 +42,7 @@ SourceFiles
#include "uLabel.H" #include "uLabel.H"
#include "Hash.H" #include "Hash.H"
#include "autoPtr.H" #include "autoPtr.H"
#include "StaticAssert.H" #include <type_traits>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -70,8 +70,11 @@ template<class T> class SLList;
template<class T, unsigned Size> template<class T, unsigned Size>
class FixedList class FixedList
{ {
//- Size must be positive (non-zero) and also fit as a signed value static_assert
StaticAssert(Size && Size <= INT_MAX); (
Size && Size <= INT_MAX,
"Size must be positive (non-zero) and also fit as a signed value"
);
// Private data // Private data

View File

@ -103,7 +103,7 @@ SourceFiles
#include "labelList.H" #include "labelList.H"
#include "UIndirectList.H" #include "UIndirectList.H"
#include "StaticAssert.H" #include <type_traits>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -174,7 +174,11 @@ private:
// it is more efficient to use a normal list. // it is more efficient to use a normal list.
// Thus max nBits is 1/2 of the base storage size. // Thus max nBits is 1/2 of the base storage size.
// For simplicity, assume 8-bit bytes in the assert. // For simplicity, assume 8-bit bytes in the assert.
StaticAssert(nBits && nBits <= (sizeof(StorageType) << 2)); static_assert
(
nBits && nBits <= (sizeof(StorageType) << 2),
"nBits must be positive (non-zero) and fit within the storage"
);
// Private data // Private data

View File

@ -36,9 +36,9 @@ SourceFiles
#define NamedEnum_H #define NamedEnum_H
#include "HashTable.H" #include "HashTable.H"
#include "StaticAssert.H"
#include "stringList.H" #include "stringList.H"
#include "wordList.H" #include "wordList.H"
#include <type_traits>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,7 +55,7 @@ class NamedEnum
public HashTable<int> public HashTable<int>
{ {
//- nEnum must be positive (non-zero) //- nEnum must be positive (non-zero)
StaticAssert(nEnum > 0); static_assert(nEnum > 0, "nEnum must be positive (non-zero)");
// Private Member Functions // Private Member Functions

View File

@ -1,87 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
Class
Foam::StaticAssertionFailed
Description
Macros and classes to provide static (compile-time) assertions.
Ideas from various sources
(http://www.ddj.com/cpp/184401547, http://www.boost.org)
\*---------------------------------------------------------------------------*/
#ifndef StaticAssert_H
#define StaticAssert_H
namespace Foam
{
//- Forward declaration of StaticAssertionFailed.
// Leave as an incomplete class so that sizeof(..) fails
template<bool Truth> class StaticAssertionFailed;
/*---------------------------------------------------------------------------*\
Class StaticAssertionFailed Declaration
\*---------------------------------------------------------------------------*/
//- Specialization for successful assertions
template<>
class StaticAssertionFailed<true>
{};
//- Helper class for handling static assertions
template<unsigned Test>
class StaticAssertionTest {};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Paste together strings, even if an argument is itself a macro
#define StaticAssertMacro(X,Y) StaticAssertMacro1(X,Y)
#define StaticAssertMacro1(X,Y) StaticAssertMacro2(X,Y)
#define StaticAssertMacro2(X,Y) X##Y
#ifdef __GNUC__
#define StaticAssertUnusedTypedef __attribute__((unused))
#else
#define StaticAssertUnusedTypedef
#endif
//- Assert that some test is true at compile-time
#define StaticAssert(Test) \
typedef ::Foam::StaticAssertionTest \
< \
sizeof( ::Foam::StaticAssertionFailed<((Test) ? true : false)>) \
> StaticAssertMacro(StaticAssertionTest, __LINE__) StaticAssertUnusedTypedef
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -37,7 +37,7 @@ SourceFiles
#define DynamicField_H #define DynamicField_H
#include "Field.H" #include "Field.H"
#include "StaticAssert.H" #include <type_traits>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -73,8 +73,11 @@ class DynamicField
: :
public Field<T> public Field<T>
{ {
//- Avoid invalid sizing parameters static_assert
StaticAssert((SizeInc || SizeMult) && SizeDiv); (
(SizeInc || SizeMult) && SizeDiv,
"Avoid invalid sizing parameters"
);
// Private data // Private data

View File

@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "StaticAssert.H" #include <type_traits>
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -90,8 +90,16 @@ ConstBlock(const msType& matrix)
: :
matrix_(matrix) matrix_(matrix)
{ {
StaticAssert(msType::mRows >= BRowStart + mRows); static_assert
StaticAssert(msType::nCols >= BColStart + nCols); (
msType::mRows >= BRowStart + mRows,
"Rows in block > rows in matrix"
);
static_assert
(
msType::nCols >= BColStart + nCols,
"Columns in block > columns in matrix"
);
} }
@ -103,8 +111,16 @@ Block(msType& matrix)
: :
matrix_(matrix) matrix_(matrix)
{ {
StaticAssert(msType::mRows >= BRowStart + mRows); static_assert
StaticAssert(msType::nCols >= BColStart + nCols); (
msType::mRows >= BRowStart + mRows,
"Rows in block > rows in matrix"
);
static_assert
(
msType::nCols >= BColStart + nCols,
"Columns in block > columns in matrix"
);
} }
@ -114,7 +130,7 @@ template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
template<Foam::direction Row, Foam::direction Col> template<Foam::direction Row, Foam::direction Col>
inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::elmt() const inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::elmt() const
{ {
StaticAssert(Row < Mrows && Col < Ncols); static_assert(Row < Mrows && Col < Ncols, "Address outside matrix");
return this->v_[Row*Ncols + Col]; return this->v_[Row*Ncols + Col];
} }
@ -123,7 +139,7 @@ template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
template<Foam::direction Row, Foam::direction Col> template<Foam::direction Row, Foam::direction Col>
inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::elmt() inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::elmt()
{ {
StaticAssert(Row < Mrows && Col < Ncols); static_assert(Row < Mrows && Col < Ncols, "Address outside matrix");
return this->v_[Row*Ncols + Col]; return this->v_[Row*Ncols + Col];
} }
@ -256,7 +272,7 @@ template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols> inline Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>
Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::identity() Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::identity()
{ {
StaticAssert(Mrows == Ncols); static_assert(Mrows == Ncols, "Matrix is not square");
msType result(Zero); msType result(Zero);
for (direction i=0; i<Ncols; ++i) for (direction i=0; i<Ncols; ++i)
@ -499,7 +515,7 @@ operator=
const VectorSpace<VSForm, Cmpt, SubTensor::mRows>& v const VectorSpace<VSForm, Cmpt, SubTensor::mRows>& v
) )
{ {
StaticAssert(nCols == 1); static_assert(nCols == 1, "Matrix must have a single column");
for (direction i=0; i<SubTensor::mRows; ++i) for (direction i=0; i<SubTensor::mRows; ++i)
{ {
@ -560,7 +576,11 @@ inline typename typeOfInnerProduct<Cmpt, Form1, Form2>::type operator&
const MatrixSpace<Form2, Cmpt, Mrows2, Ncols2>& matrix2 const MatrixSpace<Form2, Cmpt, Mrows2, Ncols2>& matrix2
) )
{ {
StaticAssert(Ncols1 == Mrows2); static_assert
(
Ncols1 == Mrows2,
"Number of columns in matrix 1 != number of rows in matrix 2"
);
typename typeOfInnerProduct<Cmpt, Form1, Form2>::type result(Zero); typename typeOfInnerProduct<Cmpt, Form1, Form2>::type result(Zero);

View File

@ -27,7 +27,7 @@ License
#include "products.H" #include "products.H"
#include "VectorSpaceOps.H" #include "VectorSpaceOps.H"
#include "ops.H" #include "ops.H"
#include "StaticAssert.H" #include <type_traits>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -79,7 +79,11 @@ VectorSpace<Form, Cmpt, Ncmpts>::ConstBlock<SubVector, BStart>::ConstBlock
: :
vs_(vs) vs_(vs)
{ {
StaticAssert(vsType::nComponents >= BStart + nComponents); static_assert
(
vsType::nComponents >= BStart + nComponents,
"Requested block size > VectorSpace size"
);
} }

View File

@ -52,7 +52,7 @@ SourceFiles
#include "scalar.H" #include "scalar.H"
#include "Ostream.H" #include "Ostream.H"
#include "VectorSpace.H" #include "VectorSpace.H"
#include "StaticAssert.H" #include <type_traits>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -81,8 +81,7 @@ class Polynomial
: :
public VectorSpace<Polynomial<PolySize>, scalar, PolySize> public VectorSpace<Polynomial<PolySize>, scalar, PolySize>
{ {
//- Size must be positive (non-zero) static_assert(PolySize > 0, "Size must be positive (non-zero)");
StaticAssert(PolySize > 0);
// Private data // Private data

View File

@ -46,7 +46,4 @@ surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C
regionSizeDistribution/regionSizeDistribution.C regionSizeDistribution/regionSizeDistribution.C
regionSizeDistribution/regionSizeDistributionFunctionObject.C regionSizeDistribution/regionSizeDistributionFunctionObject.C
histogram/histogram.C
histogram/histogramFunctionObject.C
LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects