geometricOneField: Enhanced to provide better correspondence to GeometricField

This commit is contained in:
Henry Weller
2016-04-06 14:21:04 +01:00
parent fea0dc5203
commit 596bd8ba45
7 changed files with 98 additions and 32 deletions

View File

@ -64,7 +64,7 @@ public:
// Member Operators
inline scalar operator[](const label) const;
inline one operator[](const label) const;
inline oneField field() const;
};

View File

@ -27,9 +27,9 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline Foam::scalar Foam::oneField::operator[](const label) const
inline Foam::one Foam::oneField::operator[](const label) const
{
return scalar(1);
return one();
}

View File

@ -57,6 +57,13 @@ class geometricOneField
public:
// Public typedefs
typedef oneField InternalField;
typedef oneField PatchFieldType;
typedef oneFieldField GeometricBoundaryField;
typedef one cmptType;
// Constructors
//- Construct null
@ -68,13 +75,15 @@ public:
inline const dimensionSet& dimensions() const;
inline scalar operator[](const label) const;
inline one operator[](const label) const;
inline oneField field() const;
inline oneField oldTime() const;
inline oneFieldField boundaryField() const;
inline InternalField internalField() const;
inline GeometricBoundaryField boundaryField() const;
};

View File

@ -32,9 +32,9 @@ inline const Foam::dimensionSet& Foam::geometricOneField::dimensions() const
return dimless;
}
inline Foam::scalar Foam::geometricOneField::operator[](const label) const
inline Foam::one Foam::geometricOneField::operator[](const label) const
{
return scalar(1);
return one();
}
inline Foam::oneField Foam::geometricOneField::field() const
@ -47,9 +47,16 @@ inline Foam::oneField Foam::geometricOneField::oldTime() const
return oneField();
}
inline Foam::oneFieldField Foam::geometricOneField::boundaryField() const
inline Foam::geometricOneField::InternalField
Foam::geometricOneField::internalField() const
{
return oneFieldField();
return InternalField();
}
inline Foam::geometricOneField::GeometricBoundaryField
Foam::geometricOneField::boundaryField() const
{
return GeometricBoundaryField();
}

View File

@ -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
@ -29,11 +29,16 @@ Description
unnecessary manipulations for objects which are known to be one at
compile-time.
SourceFiles
oneI.H
\*---------------------------------------------------------------------------*/
#ifndef one_H
#define one_H
#include "label.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
@ -47,11 +52,34 @@ class one
{
public:
typedef one value_type;
// Constructors
//- Construct null
one()
{}
// Member operators
//- Return 1 for label
inline operator label() const
{
return 1;
}
//- Return 1 for float
inline operator float() const
{
return 1;
}
//- Return 1 for double
inline operator double() const
{
return 1;
}
};

View File

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "one.H"
#include "scalar.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -32,6 +33,14 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class arg2>
class innerProduct<one, arg2>
{
public:
typedef arg2 type;
};
inline const one& operator*(const one& o, const one&)
{
return o;
@ -49,6 +58,11 @@ inline const Type& operator*(const one&, const Type& t)
return t;
}
template<class Type>
inline const Type& operator&(const one&, const Type& t)
{
return t;
}
inline const one& operator/(const one& o, const one&)
{

View File

@ -51,32 +51,40 @@ class zero
{
public:
zero()
{}
typedef zero value_type;
//- Return 0 for bool
inline operator bool() const
{
return 0;
}
// Constructors
//- Return 0 for label
inline operator label() const
{
return 0;
}
//- Construct null
zero()
{}
//- Return 0 for float
inline operator float() const
{
return 0;
}
//- Return 0 for double
inline operator double() const
{
return 0;
}
// Member operators
//- Return 0 for bool
inline operator bool() const
{
return 0;
}
//- Return 0 for label
inline operator label() const
{
return 0;
}
//- Return 0 for float
inline operator float() const
{
return 0;
}
//- Return 0 for double
inline operator double() const
{
return 0;
}
};