mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: reduce some file clutter for zero/one/nullObject
- more consistent location for oneField, oneFieldField inline definitions - eliminate nullObjectI.H for more transparency
This commit is contained in:
committed by
Andrew Heather
parent
ba8f237b21
commit
bd9992d0d5
@ -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 |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -47,26 +47,27 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class oneField Declaration
|
Class oneFieldField Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class oneFieldField
|
class oneFieldField
|
||||||
:
|
:
|
||||||
public one
|
public one
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
oneFieldField()
|
oneFieldField() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
inline oneField operator[](const label) const;
|
inline oneField operator[](const label) const
|
||||||
|
{
|
||||||
|
return oneField();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -74,10 +75,6 @@ public:
|
|||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#include "oneFieldFieldI.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,38 +1 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
#warning File removed - left for old dependency check only
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd |
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
| Copyright (C) 2011 OpenFOAM Foundation
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
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/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "oneFieldField.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
inline Foam::oneField Foam::oneFieldField::operator[](const label) const
|
|
||||||
{
|
|
||||||
return oneField();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
|
|||||||
@ -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 |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -54,7 +54,6 @@ class oneField
|
|||||||
:
|
:
|
||||||
public one
|
public one
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Public typedefs
|
// Public typedefs
|
||||||
@ -65,23 +64,23 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
oneField()
|
oneField() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
inline one operator[](const label) const;
|
inline one operator[](const label) const
|
||||||
|
{
|
||||||
|
return one();
|
||||||
|
}
|
||||||
|
|
||||||
inline oneField field() const;
|
inline oneField field() const
|
||||||
|
{
|
||||||
|
return oneField();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline const oneField& operator*(const oneField&, const oneField&);
|
|
||||||
|
|
||||||
inline const oneField& operator/(const oneField&, const oneField&);
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -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 |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -25,40 +25,25 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "oneField.H"
|
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
inline const oneField& operator*(const oneField& of, const oneField&)
|
||||||
|
{
|
||||||
|
return of;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const oneField& operator/(const oneField& of, const oneField&)
|
||||||
|
{
|
||||||
|
return of;
|
||||||
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline Foam::one Foam::oneField::operator[](const label) const
|
} // End namespace Foam
|
||||||
{
|
|
||||||
return one();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline Foam::oneField Foam::oneField::field() const
|
|
||||||
{
|
|
||||||
return oneField();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::oneField& Foam::operator*
|
|
||||||
(
|
|
||||||
const oneField& of,
|
|
||||||
const oneField&
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return of;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::oneField& Foam::operator/
|
|
||||||
(
|
|
||||||
const oneField& of,
|
|
||||||
const oneField&
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return of;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -31,11 +31,9 @@ Description
|
|||||||
|
|
||||||
Its contents occupy enough space to also be reinterpreted
|
Its contents occupy enough space to also be reinterpreted
|
||||||
as another class with a null pointer or zero long for its first
|
as another class with a null pointer or zero long for its first
|
||||||
member. There is an additional zero second parameter for safe
|
member, with additional zero parameters for safe casting to List etc.
|
||||||
casting to List etc.
|
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
nullObjectI.H
|
|
||||||
nullObject.C
|
nullObject.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -137,50 +135,74 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// IOstream Operators
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
//- Read from Istream consumes no content.
|
|
||||||
inline Istream& operator>>(Istream& is, NullObject&)
|
|
||||||
{
|
|
||||||
return is;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Write to Ostream emits no content.
|
|
||||||
inline Ostream& operator<<(Ostream& os, const NullObject&)
|
|
||||||
{
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Globals
|
||||||
|
|
||||||
//- Pointer to the unique nullObject
|
//- Pointer to the unique nullObject
|
||||||
extern const NullObject* nullObjectPtr;
|
extern const NullObject* nullObjectPtr;
|
||||||
|
|
||||||
|
|
||||||
//- Reference to the nullObject of type T
|
// IOstream Operators
|
||||||
|
|
||||||
|
//- Read from Istream consumes no content.
|
||||||
|
inline Istream& operator>>(Istream& is, NullObject&) noexcept
|
||||||
|
{
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Write to Ostream emits no content.
|
||||||
|
inline Ostream& operator<<(Ostream& os, const NullObject&) noexcept
|
||||||
|
{
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Global Functions
|
||||||
|
|
||||||
|
//- Pointer (of type T) to the nullObject
|
||||||
template<class T>
|
template<class T>
|
||||||
inline const T& NullObjectRef();
|
inline const T* NullObjectPtr()
|
||||||
|
{
|
||||||
|
return reinterpret_cast<const T*>(nullObjectPtr);
|
||||||
|
}
|
||||||
|
|
||||||
//- Pointer to the nullObject of type T
|
//- Reference (of type T) to the nullObject
|
||||||
template<class T>
|
template<class T>
|
||||||
inline const T* NullObjectPtr();
|
inline const T& NullObjectRef()
|
||||||
|
{
|
||||||
|
return *reinterpret_cast<const T*>(nullObjectPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//- True if t is a reference to the nullObject of type T
|
//- True if ptr is a pointer (of type T) to the nullObject
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool isNull(const T& t);
|
inline bool isNull(const T* ptr)
|
||||||
|
{
|
||||||
|
return ptr == NullObjectPtr<T>();
|
||||||
|
}
|
||||||
|
|
||||||
//- True if t is not a reference to the nullObject of type T
|
//- True if obj is a reference (of type T) to the nullObject
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool notNull(const T& t);
|
inline bool isNull(const T& obj)
|
||||||
|
{
|
||||||
|
return &obj == NullObjectPtr<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//- True if t is a pointer to the nullObject of type T
|
//- True if ptr is not a pointer (of type T) to the nullObject
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool isNull(const T* t);
|
inline bool notNull(const T* ptr)
|
||||||
|
{
|
||||||
|
return ptr != NullObjectPtr<T>();
|
||||||
|
}
|
||||||
|
|
||||||
//- True if t is not a pointer to the nullObject of type T
|
//- True if obj is not a reference (of type T) to the nullObject
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool notNull(const T* t);
|
inline bool notNull(const T& obj)
|
||||||
|
{
|
||||||
|
return &obj != NullObjectPtr<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -189,10 +211,6 @@ inline bool notNull(const T* t);
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#include "nullObjectI.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -1,67 +1 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
#warning File removed - left for old dependency check only
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd |
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
| Copyright (C) 2014-2016 OpenFOAM Foundation
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
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/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T& Foam::NullObjectRef()
|
|
||||||
{
|
|
||||||
return *reinterpret_cast<const T*>(nullObjectPtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T* Foam::NullObjectPtr()
|
|
||||||
{
|
|
||||||
return reinterpret_cast<const T*>(nullObjectPtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline bool Foam::isNull(const T& t)
|
|
||||||
{
|
|
||||||
return &t == NullObjectPtr<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline bool Foam::notNull(const T& t)
|
|
||||||
{
|
|
||||||
return &t != NullObjectPtr<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline bool Foam::isNull(const T* t)
|
|
||||||
{
|
|
||||||
return t == NullObjectPtr<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline bool Foam::notNull(const T* t)
|
|
||||||
{
|
|
||||||
return t != NullObjectPtr<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
|
|||||||
@ -28,11 +28,14 @@ Class
|
|||||||
|
|
||||||
Description
|
Description
|
||||||
A class representing the concept of 1 (one), which can be used to avoid
|
A class representing the concept of 1 (one), which can be used to avoid
|
||||||
manipulating objects that are known to be 'one' at compile-time.
|
manipulating objects that are known to be \em one at compile-time.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
oneI.H
|
oneI.H
|
||||||
|
|
||||||
|
SeeAlso
|
||||||
|
Foam::zero
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef one_H
|
#ifndef one_H
|
||||||
|
|||||||
@ -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) 2017-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -28,12 +28,15 @@ Class
|
|||||||
|
|
||||||
Description
|
Description
|
||||||
A class representing the concept of 0 (zero), which can be used to avoid
|
A class representing the concept of 0 (zero), which can be used to avoid
|
||||||
manipulating objects that are known to be 'zero' at compile-time.
|
manipulating objects that are known to be \em zero at compile-time.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
zero.C
|
zero.C
|
||||||
zeroI.H
|
zeroI.H
|
||||||
|
|
||||||
|
SeeAlso
|
||||||
|
Foam::one
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef zero_H
|
#ifndef zero_H
|
||||||
@ -121,7 +124,7 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Global zero
|
//- Global zero
|
||||||
static constexpr const zero Zero;
|
static constexpr const zero Zero;
|
||||||
|
|
||||||
// IOstream Operators
|
// IOstream Operators
|
||||||
|
|||||||
Reference in New Issue
Block a user