Merge branch 'feature-pTraits-vectorspace' into 'develop'

Extend traits to include VectorSpace tests and wrapped access to pTraits static members

See merge request Development/openfoam!619
This commit is contained in:
Andrew Heather 2023-08-11 12:40:00 +00:00
commit 53b3fff7d5
53 changed files with 415 additions and 242 deletions

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,9 +30,12 @@ Description
#include "IOstreams.H"
#include "pTraits.H"
#include "contiguous.H"
#include "boolVector.H" // A FixedList pretending to be a vector
#include "vector.H"
#include "tensor.H"
#include "uLabel.H"
#include "Switch.H"
#include <type_traits>
@ -40,14 +44,72 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
//- Test if Type has typeName member
template<class T, class = void>
struct has_typeName : std::false_type {};
//- Test if Type has typeName member
template<class T>
struct has_typeName<T, stdFoam::void_t<decltype(pTraits<T>::typeName)>>
:
std::true_type
{};
template<class T>
typename std::enable_if<has_typeName<T>::value, void>::type
printTypeName()
{
Info<< pTraits<T>::typeName;
}
template<class T>
typename std::enable_if<!has_typeName<T>::value, void>::type
printTypeName()
{
Info<< typeid(T).name();
}
template<class T, class = void>
struct has_zero_one : std::false_type {};
template<class T>
struct has_zero_one
<
T,
stdFoam::void_t<decltype(pTraits<T>::zero), decltype(pTraits<T>::one)>
> : std::true_type {};
template<class T>
typename std::enable_if<has_zero_one<T>::value, void>::type
printMinMaxRange()
{
Info<< " zero=" << pTraits<T>::zero
<< " one=" << pTraits<T>::one;
}
template<class T>
typename std::enable_if<!has_zero_one<T>::value, void>::type
printMinMaxRange()
{}
template<class T>
void printTraits()
{
Info<< pTraits<T>::typeName
<< ": zero=" << pTraits<T>::zero
<< " one=" << pTraits<T>::one
<< " integral=" << std::is_integral<T>::value
printTypeName<T>();
printMinMaxRange<T>();
Info<< " integral=" << std::is_integral<T>::value
<< " floating=" << std::is_floating_point<T>::value
<< " rank=" << pTraits_rank<T>::value
<< " nComponents=" << pTraits_nComponents<T>::value
<< " vector-space=" << Switch::name(is_vectorspace<T>::value)
<< " is_label=" << Switch::name(is_contiguous_label<T>::value)
<< " is_scalar=" << Switch::name(is_contiguous_scalar<T>::value)
<< endl;
}
@ -69,6 +131,9 @@ int main()
printTraits<scalar>();
printTraits<vector>();
printTraits<tensor>();
printTraits<boolVector>();
printTraits<word>();
printTraits<std::string>();
{
pTraits<bool> b(true);

View File

@ -6,7 +6,7 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2020 OpenCFD Ltd.
# Copyright (C) 2020-2023 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -116,11 +116,10 @@ export WM_PROJECT_DIR="$projectDir"
#
# parse this type of content
# ----
# default_clang_version=llvm-3.7.1
# default_gcc_version=gcc-4.8.5
# default_clang_version=llvm-[digits].[digits].[digits]
# default_gcc_version=gcc-[digits].[digits].[digits]
#
# Gcc48*) gcc_version=gcc-4.8.5 ;;
# Gcc49*) gcc_version=gcc-4.9.4 ;;
# Gcc121*) gcc_version=gcc-[digits].[digits].[digits] ;;
# ----
queryCompiler()

View File

@ -1,10 +1,10 @@
## OpenFOAM&reg; System Requirements
OpenFOAM requires a functioning C++11 compiler and GNU `make` build toolchain.
OpenFOAM requires a functioning C++14 compiler and GNU `make` build toolchain.
### Minimum recommended versions
- gcc : 4.8.5 (absolute minimum, not really recommended)
- gcc : 7.5.0 (minimum, not necessarily recommended)
- cmake: 3.8 (required for ParaView and CGAL build)
- boost: 1.48 (required for CGAL build and some functionality)
- fftw: 3.3.7 (recommended - required for FFT-related functionality)
@ -217,4 +217,4 @@ at any later stage _without_ recompiling OpenFOAM itself.
[wiki-config]: https://develop.openfoam.com/Development/openfoam/-/wikis/configuring
---
Copyright 2019-2022 OpenCFD Ltd
Copyright 2019-2023 OpenCFD Ltd

View File

@ -6,7 +6,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2016 OpenFOAM Foundation
# Copyright (C) 2016-2022 OpenCFD Ltd.
# Copyright (C) 2016-2023 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -58,8 +58,8 @@ switch ("$WM_COMPILER_TYPE")
case ThirdParty:
# Default/minimum versions (compiler, GMP, MPFR, MPC) - override as needed
set default_clang_version=llvm-3.7.1
set default_gcc_version=gcc-4.8.5
set default_clang_version=llvm-5.0.2
set default_gcc_version=gcc-7.5.0
set default_gmp_version=gmp-system
set default_mpfr_version=mpfr-system
@ -127,6 +127,7 @@ case ThirdParty:
case Gcc75*:
set gcc_version=gcc-7.5.0
breaksw
# Older : no assurance that they still work for OpenFOAM
case Gcc74*:
set gcc_version=gcc-7.4.0
breaksw
@ -159,24 +160,24 @@ case ThirdParty:
case Gcc55*:
set gcc_version=gcc-5.5.0
breaksw
case Gcc54*:
set gcc_version=gcc-5.4.0
breaksw
case Gcc53*:
set gcc_version=gcc-5.3.0
breaksw
case Gcc52*:
set gcc_version=gcc-5.2.0
breaksw
case Gcc51*:
set gcc_version=gcc-5.1.0
breaksw
case Gcc49*:
set gcc_version=gcc-4.9.4
breaksw
case Gcc48*:
set gcc_version=gcc-4.8.5
breaksw
#ancient# case Gcc54*:
#ancient# set gcc_version=gcc-5.4.0
#ancient# breaksw
#ancient# case Gcc53*:
#ancient# set gcc_version=gcc-5.3.0
#ancient# breaksw
#ancient# case Gcc52*:
#ancient# set gcc_version=gcc-5.2.0
#ancient# breaksw
#ancient# case Gcc51*:
#ancient# set gcc_version=gcc-5.1.0
#ancient# breaksw
#ancient# case Gcc49*:
#ancient# set gcc_version=gcc-4.9.4
#ancient# breaksw
#ancient# case Gcc48*:
#ancient# set gcc_version=gcc-4.8.5
#ancient# breaksw
case Clang:
set clang_version="$default_clang_version"
@ -217,18 +218,18 @@ case ThirdParty:
case Clang50*:
set clang_version=llvm-5.0.2
breaksw
case Clang40*:
set clang_version=llvm-4.0.1
breaksw
case Clang39*:
set clang_version=llvm-3.9.1
breaksw
case Clang38*:
set clang_version=llvm-3.8.1
breaksw
case Clang37*:
set clang_version=llvm-3.7.1
breaksw
#ancient# case Clang40*:
#ancient# set clang_version=llvm-4.0.1
#ancient# breaksw
#ancient# case Clang39*:
#ancient# set clang_version=llvm-3.9.1
#ancient# breaksw
#ancient# case Clang38*:
#ancient# set clang_version=llvm-3.8.1
#ancient# breaksw
#ancient# case Clang37*:
#ancient# set clang_version=llvm-3.7.1
#ancient# breaksw
endsw

View File

@ -6,7 +6,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2016-2022 OpenCFD Ltd.
# Copyright (C) 2016-2023 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -58,8 +58,8 @@ case "$WM_COMPILER_TYPE" in
ThirdParty)
# Default/minimum versions (compiler, GMP, MPFR, MPC) - override as needed
default_clang_version=llvm-3.7.1
default_gcc_version=gcc-4.8.5
default_clang_version=llvm-5.0.2
default_gcc_version=gcc-7.5.0
default_gmp_version=gmp-system
default_mpfr_version=mpfr-system
@ -92,6 +92,7 @@ ThirdParty)
Gcc82*) gcc_version=gcc-8.2.0 ;;
Gcc81*) gcc_version=gcc-8.1.0 ;;
Gcc75*) gcc_version=gcc-7.5.0 ;;
# Older : no assurance that they still work for OpenFOAM
Gcc74*) gcc_version=gcc-7.4.0 ;;
Gcc73*) gcc_version=gcc-7.3.0 ;;
Gcc72*) gcc_version=gcc-7.2.0 ;;
@ -103,12 +104,12 @@ ThirdParty)
Gcc62*) gcc_version=gcc-6.2.0 ;;
Gcc61*) gcc_version=gcc-6.1.0 ;;
Gcc55*) gcc_version=gcc-5.5.0 ;;
Gcc54*) gcc_version=gcc-5.4.0 ;;
Gcc53*) gcc_version=gcc-5.3.0 ;;
Gcc52*) gcc_version=gcc-5.2.0 ;;
Gcc51*) gcc_version=gcc-5.1.0 ;;
Gcc49*) gcc_version=gcc-4.9.4 ;;
Gcc48*) gcc_version=gcc-4.8.5 ;;
#ancient# Gcc54*) gcc_version=gcc-5.4.0 ;;
#ancient# Gcc53*) gcc_version=gcc-5.3.0 ;;
#ancient# Gcc52*) gcc_version=gcc-5.2.0 ;;
#ancient# Gcc51*) gcc_version=gcc-5.1.0 ;;
#ancient# Gcc49*) gcc_version=gcc-4.9.4 ;;
#ancient# Gcc48*) gcc_version=gcc-4.8.5 ;;
Clang) clang_version="$default_clang_version" ;;
Clang140*) clang_version=llvm-14.0.5 ;;
@ -123,10 +124,10 @@ ThirdParty)
Clang70*) clang_version=llvm-7.0.1 ;;
Clang60*) clang_version=llvm-6.0.1 ;;
Clang50*) clang_version=llvm-5.0.2 ;;
Clang40*) clang_version=llvm-4.0.1 ;;
Clang39*) clang_version=llvm-3.9.1 ;;
Clang38*) clang_version=llvm-3.8.1 ;;
Clang37*) clang_version=llvm-3.7.1 ;;
#ancient# Clang40*) clang_version=llvm-4.0.1 ;;
#ancient# Clang39*) clang_version=llvm-3.9.1 ;;
#ancient# Clang38*) clang_version=llvm-3.8.1 ;;
#ancient# Clang37*) clang_version=llvm-3.7.1 ;;
esac

View File

@ -530,8 +530,8 @@ inline void Foam::CircularBuffer<T>::operator=(const T& val)
template<class T>
inline void Foam::CircularBuffer<T>::operator=(const Foam::zero)
{
this->array_one() = Zero;
this->array_two() = Zero;
this->array_one() = Foam::zero{};
this->array_two() = Foam::zero{};
}

View File

@ -507,7 +507,7 @@ inline void Foam::CompactListList<T>::operator=(const T& val)
template<class T>
inline void Foam::CompactListList<T>::operator=(const Foam::zero)
{
values_ = Zero;
values_ = Foam::zero{};
}

View File

@ -171,7 +171,7 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList
const Foam::zero
)
:
List<T>(len, Zero),
List<T>(len, Foam::zero{}),
capacity_(List<T>::size())
{}
@ -815,7 +815,7 @@ inline void Foam::DynamicList<T, SizeMin>::operator=
const Foam::zero
)
{
UList<T>::operator=(Zero);
UList<T>::operator=(Foam::zero{});
}

View File

@ -51,7 +51,7 @@ inline Foam::FixedList<T, N>::FixedList(const T& val)
template<class T, unsigned N>
inline Foam::FixedList<T, N>::FixedList(const Foam::zero)
{
this->fill(Zero);
this->fill(Foam::zero{});
}
@ -500,7 +500,7 @@ inline void Foam::FixedList<T, N>::operator=(const T& val)
template<class T, unsigned N>
inline void Foam::FixedList<T, N>::operator=(const Foam::zero)
{
this->fill(Zero);
this->fill(Foam::zero{});
}

View File

@ -300,7 +300,7 @@ inline void Foam::List<T>::operator=(const T& val)
template<class T>
inline void Foam::List<T>::operator=(const Foam::zero)
{
UList<T>::operator=(Zero);
UList<T>::operator=(Foam::zero{});
}

View File

@ -160,7 +160,7 @@ inline void Foam::SubList<T>::operator=(const T& val)
template<class T>
inline void Foam::SubList<T>::operator=(const Foam::zero)
{
UList<T>::operator=(Zero);
UList<T>::operator=(Foam::zero{});
}

View File

@ -30,14 +30,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>
inline constexpr Foam::SortableList<T>::SortableList() noexcept
:
List<T>(),
indices_()
{}
template<class T>
inline Foam::SortableList<T>::SortableList(const label size)
:
@ -48,7 +40,7 @@ inline Foam::SortableList<T>::SortableList(const label size)
template<class T>
inline Foam::SortableList<T>::SortableList(const label size, const Foam::zero)
:
List<T>(size, Zero)
List<T>(size, Foam::zero{})
{}

View File

@ -73,7 +73,7 @@ public:
// Constructors
//- Default construct
inline constexpr SortableList() noexcept;
SortableList() noexcept = default;
//- Construct given size, sort later.
// The indices remain empty until the list is sorted

View File

@ -51,19 +51,27 @@ const Foam::token& Foam::Istream::peekBack() const noexcept
return (putBackAvail_ ? putBackToken_ : token::undefinedToken);
}
// Return the putback token if available or fetch a new token
// from the stream.
//
// Foam::token& Foam::Istream::peekToken()
// {
// if (!putBackAvail_)
// {
// putBackToken_.reset();
// token tok;
// this->read(tok);
// putBackToken_ = std::move(tok);
// }
//
// return putBackToken_;
// }
bool Foam::Istream::peekBack(token& tok)
void Foam::Istream::putBackClear()
{
if (putBackAvail_)
{
tok = putBackToken_;
}
else
{
tok.reset();
}
return putBackAvail_;
putBackAvail_ = false;
putBackToken_.reset();
}
@ -89,6 +97,28 @@ void Foam::Istream::putBack(const token& tok)
}
void Foam::Istream::putBack(token&& tok)
{
if (bad())
{
FatalIOErrorInFunction(*this)
<< "Attempt to put back onto bad stream"
<< exit(FatalIOError);
}
else if (putBackAvail_)
{
FatalIOErrorInFunction(*this)
<< "Attempt to put back another token"
<< exit(FatalIOError);
}
else
{
putBackAvail_ = true;
putBackToken_ = std::move(tok);
}
}
bool Foam::Istream::getBack(token& tok)
{
if (bad())
@ -100,7 +130,7 @@ bool Foam::Istream::getBack(token& tok)
else if (putBackAvail_)
{
putBackAvail_ = false;
tok = putBackToken_;
tok = std::move(putBackToken_);
return true;
}

View File

@ -77,10 +77,7 @@ protected:
// Protected Member Functions
//- True if putback token is in use
bool hasPutback() const noexcept
{
return putBackAvail_;
}
bool hasPutback() const noexcept { return putBackAvail_; }
public:
@ -124,15 +121,16 @@ public:
// if a putback is unavailable.
const token& peekBack() const noexcept;
//- Fetch putback token without removing it.
// \return false sets the token to undefined if no put-back
// was available
bool peekBack(token& tok);
//- Drop the putback token
void putBackClear();
//- Put back a token. Only a single put back is permitted
//- Put back a token (copy). Only a single put back is permitted
void putBack(const token& tok);
//- Get the put-back token if there is one.
//- Put back a token (move). Only a single put back is permitted
void putBack(token&& tok);
//- Retrieve the put-back token if there is one.
// \return false and sets token to undefined if no put-back
// was available
bool getBack(token& tok);

View File

@ -273,6 +273,12 @@ Foam::Istream& Foam::UIPstreamBase::read(token& t)
}
}
// Reset token, adjust its line number according to the stream
t.reset();
t.lineNumber(this->lineNumber());
// Read character, return on error
// - with additional handling for special stream flags
@ -303,9 +309,6 @@ Foam::Istream& Foam::UIPstreamBase::read(token& t)
while (c == token::FLAG);
// Set the line number of this token to the current stream line number
t.lineNumber(this->lineNumber());
// Analyse input starting with this character.
switch (c)
{

View File

@ -538,6 +538,10 @@ Foam::Istream& Foam::ISstream::read(token& t)
return *this;
}
// Reset token, adjust its line number according to the stream
t.reset();
t.lineNumber(this->lineNumber());
// Assume that the streams supplied are in working order.
// Lines are counted by '\n'
@ -546,9 +550,6 @@ Foam::Istream& Foam::ISstream::read(token& t)
char c = nextValid();
// Set the line number of this token to the current stream line number
t.lineNumber(this->lineNumber());
// Return on error
if (!c)
{

View File

@ -510,6 +510,9 @@ public:
//- Token is COMPOUND
inline bool isCompound() const noexcept;
//- True if token is not UNDEFINED or ERROR. Same as good().
explicit operator bool() const noexcept { return good(); }
// Access
@ -690,6 +693,7 @@ public:
void operator=(string*) = delete;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// IOstream Operators

View File

@ -412,10 +412,10 @@ void Foam::Time::readDict()
if (writeStreamOption_.compression() == IOstreamOption::COMPRESSED)
{
if (writeStreamOption_.format() == IOstreamOption::BINARY)
if (writeStreamOption_.format() != IOstreamOption::ASCII)
{
IOWarningInFunction(controlDict_)
<< "Disabled binary format compression"
<< "Disabled output compression for non-ascii format"
<< " (inefficient/ineffective)"
<< endl;

View File

@ -165,7 +165,7 @@ inline Foam::DynamicField<T, SizeMin>::DynamicField
const Foam::zero
)
:
Field<T>(len, Zero),
Field<T>(len, Foam::zero{}),
capacity_(Field<T>::size())
{}
@ -696,7 +696,7 @@ inline void Foam::DynamicField<T, SizeMin>::operator=
const Foam::zero
)
{
UList<T>::operator=(Zero);
UList<T>::operator=(Foam::zero{});
}

View File

@ -60,7 +60,7 @@ inline Foam::Field<Type>::Field(const label len, const Type& val)
template<class Type>
inline Foam::Field<Type>::Field(const label len, const Foam::zero)
:
List<Type>(len, Zero)
List<Type>(len, Foam::zero{})
{}
@ -81,7 +81,7 @@ inline Foam::Field<Type>::Field(const Foam::one, Type&& val)
template<class Type>
inline Foam::Field<Type>::Field(const Foam::one, const Foam::zero)
:
List<Type>(Foam::one{}, Zero)
List<Type>(Foam::one{}, Foam::zero{})
{}
@ -224,7 +224,7 @@ inline void Foam::Field<Type>::operator=(const Type& val)
template<class Type>
inline void Foam::Field<Type>::operator=(const Foam::zero)
{
List<Type>::operator=(Zero);
List<Type>::operator=(Foam::zero{});
}

View File

@ -33,7 +33,7 @@ Description
#define Foam_FieldM_H
#include "error.H"
#include "ListLoopM.H"
#include "ListLoopM.H" // For list access macros
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -165,7 +165,7 @@ inline void Foam::SubField<Type>::operator=(const Type& val)
template<class Type>
inline void Foam::SubField<Type>::operator=(const Foam::zero)
{
SubList<Type>::operator=(Zero);
SubList<Type>::operator=(Foam::zero{});
}

View File

@ -40,7 +40,7 @@ Foam::DiagonalMatrix<Type>::DiagonalMatrix(const label n)
template<class Type>
Foam::DiagonalMatrix<Type>::DiagonalMatrix(const label n, const Foam::zero)
:
List<Type>(n, Zero)
List<Type>(n, Foam::zero{})
{}

View File

@ -64,7 +64,7 @@ inline Foam::Matrix<Form, Type>::Matrix(const labelPair& dims)
template<class Form, class Type>
inline Foam::Matrix<Form, Type>::Matrix(const labelPair& dims, const Foam::zero)
:
Matrix<Form, Type>(dims.first(), dims.second(), Zero)
Matrix<Form, Type>(dims.first(), dims.second(), Foam::zero{})
{}

View File

@ -57,7 +57,7 @@ inline Foam::RectangularMatrix<Type>::RectangularMatrix
const Foam::zero
)
:
Matrix<RectangularMatrix<Type>, Type>(m, n, Zero)
Matrix<RectangularMatrix<Type>, Type>(m, n, Foam::zero{})
{}
@ -81,7 +81,7 @@ inline Foam::RectangularMatrix<Type>::RectangularMatrix
const Identity<AnyType>
)
:
Matrix<RectangularMatrix<Type>, Type>(dims.first(), dims.second(), Zero)
RectangularMatrix<Type>(dims.first(), dims.second(), Foam::zero{})
{
for (label i = 0; i < min(dims.first(), dims.second()); ++i)
{
@ -107,7 +107,7 @@ inline Foam::RectangularMatrix<Type>::RectangularMatrix
const Foam::zero
)
:
RectangularMatrix<Type>(dims.first(), dims.second(), Zero)
RectangularMatrix<Type>(dims.first(), dims.second(), Foam::zero{})
{}
@ -184,7 +184,7 @@ inline void Foam::RectangularMatrix<Type>::operator=
template<class Type>
inline void Foam::RectangularMatrix<Type>::operator=(const Foam::zero)
{
Matrix<RectangularMatrix<Type>, Type>::operator=(Zero);
Matrix<RectangularMatrix<Type>, Type>::operator=(Foam::zero{});
}

View File

@ -85,7 +85,7 @@ template<class Type>
template<class AnyType>
void Foam::SquareMatrix<Type>::operator=(const Identity<AnyType>)
{
Matrix<SquareMatrix<Type>, Type>::operator=(Zero);
Matrix<SquareMatrix<Type>, Type>::operator=(Foam::zero{});
for (label i = 0; i < this->n(); ++i)
{

View File

@ -51,7 +51,7 @@ inline Foam::SquareMatrix<Type>::SquareMatrix
const Foam::zero
)
:
Matrix<SquareMatrix<Type>, Type>(n, n, Zero)
Matrix<SquareMatrix<Type>, Type>(n, n, Foam::zero{})
{}
@ -74,7 +74,7 @@ inline Foam::SquareMatrix<Type>::SquareMatrix
const Identity<AnyType>
)
:
Matrix<SquareMatrix<Type>, Type>(n, n, Zero)
SquareMatrix<Type>(n, Foam::zero{})
{
for (label i = 0; i < n; ++i)
{
@ -91,7 +91,7 @@ inline Foam::SquareMatrix<Type>::SquareMatrix
const Identity<AnyType>
)
:
Matrix<SquareMatrix<Type>, Type>(dims, Zero)
Matrix<SquareMatrix<Type>, Type>(dims, Foam::zero{})
{
CHECK_MATRIX_IS_SQUARE(dims.first(), dims.second());
@ -121,7 +121,7 @@ inline Foam::SquareMatrix<Type>::SquareMatrix
const Foam::zero
)
:
Matrix<SquareMatrix<Type>, Type>(dims, Zero)
Matrix<SquareMatrix<Type>, Type>(dims, Foam::zero{})
{
CHECK_MATRIX_IS_SQUARE(dims.first(), dims.second());
}
@ -148,7 +148,7 @@ inline Foam::SquareMatrix<Type>::SquareMatrix
const Foam::zero
)
:
Matrix<SquareMatrix<Type>, Type>(m, n, Zero)
Matrix<SquareMatrix<Type>, Type>(m, n, Foam::zero{})
{
CHECK_MATRIX_IS_SQUARE(m, n);
}
@ -300,7 +300,7 @@ inline void Foam::SquareMatrix<Type>::operator=(SquareMatrix<Type>&& mat)
template<class Type>
inline void Foam::SquareMatrix<Type>::operator=(const Foam::zero)
{
Matrix<SquareMatrix<Type>, Type>::operator=(Zero);
Matrix<SquareMatrix<Type>, Type>::operator=(Foam::zero{});
}

View File

@ -117,7 +117,7 @@ template<class Type>
template<class AnyType>
void Foam::SymmetricSquareMatrix<Type>::operator=(const Identity<AnyType>)
{
Matrix<SymmetricSquareMatrix<Type>, Type>::operator=(Zero);
Matrix<SymmetricSquareMatrix<Type>, Type>::operator=(Foam::zero{});
for (label i=0; i < this->n(); ++i)
{

View File

@ -51,7 +51,7 @@ inline Foam::SymmetricSquareMatrix<Type>::SymmetricSquareMatrix
const Foam::zero
)
:
Matrix<SymmetricSquareMatrix<Type>, Type>(n, n, Zero)
Matrix<SymmetricSquareMatrix<Type>, Type>(n, n, Foam::zero{})
{}
@ -74,7 +74,7 @@ inline Foam::SymmetricSquareMatrix<Type>::SymmetricSquareMatrix
const Identity<AnyType>
)
:
Matrix<SymmetricSquareMatrix<Type>, Type>(n, n, Zero)
SymmetricSquareMatrix<Type>(n, Foam::zero{})
{
for (label i=0; i < n; ++i)
{
@ -105,7 +105,7 @@ Foam::SymmetricSquareMatrix<Type>::clone() const
template<class Type>
inline void Foam::SymmetricSquareMatrix<Type>::operator=(const Foam::zero)
{
Matrix<SymmetricSquareMatrix<Type>, Type>::operator=(Zero);
Matrix<SymmetricSquareMatrix<Type>, Type>::operator=(Foam::zero{});
}

View File

@ -78,7 +78,7 @@ inline Foam::IjkField<Type>::IjkField
const Foam::zero
)
:
Field<Type>(cmptProduct(ijk), Zero),
Field<Type>(cmptProduct(ijk), Foam::zero{}),
ijk_(ijk)
{}
@ -247,7 +247,7 @@ inline void Foam::IjkField<Type>::operator=(const Type& val)
template<class Type>
inline void Foam::IjkField<Type>::operator=(const Foam::zero)
{
Field<Type>::operator=(Zero);
Field<Type>::operator=(Foam::zero{});
}

View File

@ -117,7 +117,13 @@ public:
return boundary_;
}
//- Return parallel info
//- Is demand-driven parallel info available?
bool hasGlobalData() const noexcept
{
return GeoMesh<polyMesh>::mesh_.hasGlobalData();
}
//- Return parallel info (demand-driven)
const globalMeshData& globalData() const
{
return GeoMesh<polyMesh>::mesh_.globalData();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017, 2020 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -707,7 +707,12 @@ Foam::polyMesh::polyMesh
}
Foam::polyMesh::polyMesh(const IOobject& io, const zero, const bool syncPar)
Foam::polyMesh::polyMesh
(
const IOobject& io,
const Foam::zero,
const bool syncPar
)
:
polyMesh(io, pointField(), faceList(), labelList(), labelList(), syncPar)
{}
@ -992,7 +997,7 @@ void Foam::polyMesh::addPatches
// recalculation. Problem: should really be done in removeBoundary but
// there is some info in parallelData which might be interesting inbetween
// removeBoundary and addPatches.
globalMeshDataPtr_.clear();
globalMeshDataPtr_.reset(nullptr);
if (validBoundary)
{
@ -1304,6 +1309,12 @@ void Foam::polyMesh::resetMotion() const
}
bool Foam::polyMesh::hasGlobalData() const noexcept
{
return bool(globalMeshDataPtr_);
}
const Foam::globalMeshData& Foam::polyMesh::globalData() const
{
if (!globalMeshDataPtr_)
@ -1322,18 +1333,6 @@ const Foam::globalMeshData& Foam::polyMesh::globalData() const
}
Foam::label Foam::polyMesh::comm() const noexcept
{
return comm_;
}
Foam::label& Foam::polyMesh::comm() noexcept
{
return comm_;
}
void Foam::polyMesh::removeFiles(const fileName& instanceDir) const
{
fileName meshFilesPath = thisDb().time().path()/instanceDir/meshDir();

View File

@ -332,7 +332,7 @@ public:
//- Construct from IOobject or as zero-sized mesh
// Boundary is added using addPatches() member function
polyMesh(const IOobject& io, const zero, const bool syncPar=true);
polyMesh(const IOobject& io, const Foam::zero, const bool syncPar=true);
//- Construct from IOobject and components.
// Boundary is added using addPatches() member function
@ -507,14 +507,8 @@ public:
return cellZones_;
}
//- Return parallel info
const globalMeshData& globalData() const;
//- Return communicator used for parallel communication
label comm() const noexcept;
//- Return communicator used for parallel communication
label& comm() noexcept;
// Database
//- Return the object registry
const objectRegistry& thisDb() const noexcept
@ -523,6 +517,21 @@ public:
}
// Parallel
//- The communicator used for parallel communication
label comm() const noexcept { return comm_; }
//- The communicator used for parallel communication
label& comm() noexcept { return comm_; }
//- Is demand-driven parallel info available?
bool hasGlobalData() const noexcept;
//- Return parallel info (demand-driven)
const globalMeshData& globalData() const;
// Mesh motion
//- Is mesh dynamic

View File

@ -185,7 +185,7 @@ void Foam::polyMesh::clearAddressing(const bool isMeshUpdate)
// parallelData depends on the processorPatch ordering so force
// recalculation
globalMeshDataPtr_.clear();
globalMeshDataPtr_.reset(nullptr);
// Reset valid directions
geometricD_ = Zero;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2022 OpenCFD Ltd.
Copyright (C) 2020-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -65,6 +65,9 @@ public:
//- Rank of a vector is 1
static constexpr direction rank = 1;
//- Number of components in this vector space
static constexpr direction nComponents = 3;
//- Component labeling enumeration
enum components { X, Y, Z };

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -42,17 +42,20 @@ Note
#include <cstdint>
#include <iostream>
#include "pTraits.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Forward Declarations
class Istream;
class Ostream;
// Typedefs
typedef uint8_t direction;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Read direction (uint8_t) from stream.
direction readDirection(Istream& is);
@ -68,6 +71,10 @@ std::ostream& operator<<(std::ostream& os, const direction val);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "pTraits.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,10 +28,10 @@ Class
Foam::pTraits
Description
A traits class, which is primarily used for primitives.
A traits class, which is primarily used for primitives and vector-space.
All primitives need a specialised version of this class. The
specialised version will normally also require a conversion
specialised versions will normally also require a conversion
method.
\*---------------------------------------------------------------------------*/
@ -39,14 +39,33 @@ Description
#ifndef Foam_pTraits_H
#define Foam_pTraits_H
#include "direction.H"
#include <type_traits> // For std::integral_constant, std::void_t (C++17)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace stdFoam
{
//- Map a sequence of any types to \c void as per C++17 \c std::void_t
template<class... >
using void_t = void;
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward Declarations
class Istream;
class Ostream;
/*---------------------------------------------------------------------------*\
Class zero_one Declaration
\*---------------------------------------------------------------------------*/
//- Represents 0/1 range or concept. Used for tagged dispatch or clamping
class zero_one {};
/*---------------------------------------------------------------------------*\
Class pTraits Declaration
@ -78,11 +97,70 @@ public:
/*---------------------------------------------------------------------------*\
Class zero_one Declaration
VectorSpace Traits
\*---------------------------------------------------------------------------*/
//- Represents 0/1 range or concept. Used for tagged dispatch or clamping
class zero_one {};
//- Test for VectorSpace : default is false
template<class T, class = void>
struct is_vectorspace : std::false_type {};
//- Test for VectorSpace : test for T::rank != 0 static member directly
// Do not need pTraits layer since rank is defined via VectorSpace etc
template<class T>
struct is_vectorspace<T, stdFoam::void_t<decltype(T::rank)>>
:
std::integral_constant<bool, (T::rank != 0)>
{};
//- The vector-space rank: default is 0.
template<class T, class = void>
struct pTraits_rank : std::integral_constant<Foam::direction, 0> {};
//- Rank of VectorSpace,
//- using the pTraits \c rank static member.
template<class T>
struct pTraits_rank
<
T,
stdFoam::void_t<decltype(pTraits<T>::rank)>
>
:
std::integral_constant<Foam::direction, pTraits<T>::rank>
{};
//- The vector-space number of components: default is 1.
template<class T, class = void>
struct pTraits_nComponents : std::integral_constant<Foam::direction, 1> {};
//- Number of VectorSpace components,
//- using the pTraits \c nComponents static member.
template<class T>
struct pTraits_nComponents
<
T,
stdFoam::void_t<decltype(pTraits<T>::nComponents)>
>
:
std::integral_constant<Foam::direction, pTraits<T>::nComponents>
{};
//- Test for pTraits zero : default is false
template<class T, class = void>
struct pTraits_has_zero : std::false_type {};
//- Test for pTraits zero
template<class T>
struct pTraits_has_zero
<
T,
stdFoam::void_t<decltype(pTraits<T>::zero)>
>
:
std::true_type
{};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -952,16 +952,6 @@ void Foam::faMatrix<Type>::operator-=
}
template<class Type>
void Foam::faMatrix<Type>::operator+=(const Foam::zero)
{}
template<class Type>
void Foam::faMatrix<Type>::operator-=(const Foam::zero)
{}
template<class Type>
void Foam::faMatrix<Type>::operator*=
(

View File

@ -499,8 +499,8 @@ public:
void operator+=(const dimensioned<Type>&);
void operator-=(const dimensioned<Type>&);
void operator+=(const Foam::zero);
void operator-=(const Foam::zero);
void operator+=(const Foam::zero) {}
void operator-=(const Foam::zero) {}
void operator*=(const areaScalarField::Internal&);
void operator*=(const tmp<areaScalarField::Internal>&);

View File

@ -970,6 +970,12 @@ Foam::faMesh::edgeTransformTensors() const
}
bool Foam::faMesh::hasGlobalData() const noexcept
{
return bool(globalMeshDataPtr_);
}
const Foam::faGlobalMeshData& Foam::faMesh::globalData() const
{
if (!globalMeshDataPtr_)

View File

@ -648,13 +648,19 @@ public:
const fileName& facesInstance() const;
// Communication support
// Parallel
//- Return communicator used for parallel communication
inline label comm() const noexcept;
label comm() const noexcept { return comm_; }
//- Return communicator used for parallel communication
inline label& comm() noexcept;
label& comm() noexcept { return comm_; }
//- Is demand-driven parallel info available?
bool hasGlobalData() const noexcept;
//- Return parallel info (demand-driven)
const faGlobalMeshData& globalData() const;
// Access: Mesh size parameters
@ -736,9 +742,6 @@ public:
//- The polyPatch/local-face for each faceLabels()
inline const List<labelPair>& whichPatchFaces() const;
//- Return parallel info
const faGlobalMeshData& globalData() const;
//- Return ldu addressing
virtual const lduAddressing& lduAddr() const;

View File

@ -41,18 +41,6 @@ inline const Foam::faBoundaryMesh& Foam::faMesh::boundary() const noexcept
}
inline Foam::label Foam::faMesh::comm() const noexcept
{
return comm_;
}
inline Foam::label& Foam::faMesh::comm() noexcept
{
return comm_;
}
inline Foam::label Foam::faMesh::nPoints() const noexcept
{
return nPoints_;

View File

@ -146,7 +146,7 @@ template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>>
ddt
(
const one&,
const Foam::one,
const GeometricField<Type, fvPatchField, volMesh>& vf
)
{
@ -159,7 +159,7 @@ tmp<GeometricField<Type, fvPatchField, volMesh>>
ddt
(
const GeometricField<Type, fvPatchField, volMesh>& vf,
const one&
const Foam::one
)
{
return ddt(vf);

View File

@ -99,7 +99,7 @@ namespace fvc
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> ddt
(
const one&,
const Foam::one,
const GeometricField<Type, fvPatchField, volMesh>&
);
@ -107,13 +107,13 @@ namespace fvc
tmp<GeometricField<Type, fvPatchField, volMesh>> ddt
(
const GeometricField<Type, fvPatchField, volMesh>&,
const one&
const Foam::one
);
inline geometricZeroField ddt
(
const one&,
const one&
const Foam::one,
const Foam::one
)
{
return geometricZeroField();

View File

@ -61,7 +61,7 @@ template<class Type>
tmp<fvMatrix<Type>>
ddt
(
const one&,
const Foam::one,
const GeometricField<Type, fvPatchField, volMesh>& vf
)
{
@ -128,8 +128,8 @@ template<class Type>
tmp<fvMatrix<Type>>
ddt
(
const one&,
const one&,
const Foam::one,
const Foam::one,
const GeometricField<Type, fvPatchField, volMesh>& vf
)
{
@ -141,7 +141,7 @@ template<class Type>
tmp<fvMatrix<Type>>
ddt
(
const one&,
const Foam::one,
const volScalarField& rho,
const GeometricField<Type, fvPatchField, volMesh>& vf
)
@ -155,7 +155,7 @@ tmp<fvMatrix<Type>>
ddt
(
const volScalarField& alpha,
const one&,
const Foam::one,
const GeometricField<Type, fvPatchField, volMesh>& vf
)
{

View File

@ -61,7 +61,7 @@ namespace fvm
template<class Type>
tmp<fvMatrix<Type>> ddt
(
const one&,
const Foam::one,
const GeometricField<Type, fvPatchField, volMesh>&
);
@ -90,15 +90,15 @@ namespace fvm
template<class Type>
tmp<fvMatrix<Type>> ddt
(
const one&,
const one&,
const Foam::one,
const Foam::one,
const GeometricField<Type, fvPatchField, volMesh>&
);
template<class Type>
tmp<fvMatrix<Type>> ddt
(
const one&,
const Foam::one,
const volScalarField&,
const GeometricField<Type, fvPatchField, volMesh>&
);
@ -107,7 +107,7 @@ namespace fvm
tmp<fvMatrix<Type>> ddt
(
const volScalarField&,
const one&,
const Foam::one,
const GeometricField<Type, fvPatchField, volMesh>&
);
}

View File

@ -100,7 +100,7 @@ template<class Type>
tmp<fvMatrix<Type>>
laplacian
(
const zero&,
const Foam::zero,
const GeometricField<Type, fvPatchField, volMesh>& vf,
const word& name
)
@ -116,7 +116,7 @@ template<class Type>
tmp<fvMatrix<Type>>
laplacian
(
const zero&,
const Foam::zero,
const GeometricField<Type, fvPatchField, volMesh>& vf
)
{
@ -131,7 +131,7 @@ template<class Type>
tmp<fvMatrix<Type>>
laplacian
(
const one&,
const Foam::one,
const GeometricField<Type, fvPatchField, volMesh>& vf,
const word& name
)
@ -144,7 +144,7 @@ template<class Type>
tmp<fvMatrix<Type>>
laplacian
(
const one&,
const Foam::one,
const GeometricField<Type, fvPatchField, volMesh>& vf
)
{

View File

@ -70,7 +70,7 @@ namespace fvm
template<class Type>
tmp<fvMatrix<Type>> laplacian
(
const zero&,
const Foam::zero,
const GeometricField<Type, fvPatchField, volMesh>&,
const word&
);
@ -78,7 +78,7 @@ namespace fvm
template<class Type>
tmp<fvMatrix<Type>> laplacian
(
const zero&,
const Foam::zero,
const GeometricField<Type, fvPatchField, volMesh>&
);
@ -86,7 +86,7 @@ namespace fvm
template<class Type>
tmp<fvMatrix<Type>> laplacian
(
const one&,
const Foam::one,
const GeometricField<Type, fvPatchField, volMesh>&,
const word&
);
@ -94,7 +94,7 @@ namespace fvm
template<class Type>
tmp<fvMatrix<Type>> laplacian
(
const one&,
const Foam::one,
const GeometricField<Type, fvPatchField, volMesh>&
);

View File

@ -1763,16 +1763,6 @@ void Foam::fvMatrix<Type>::operator-=
}
template<class Type>
void Foam::fvMatrix<Type>::operator+=(const Foam::zero)
{}
template<class Type>
void Foam::fvMatrix<Type>::operator-=(const Foam::zero)
{}
template<class Type>
void Foam::fvMatrix<Type>::operator*=
(

View File

@ -676,8 +676,8 @@ public:
void operator+=(const dimensioned<Type>&);
void operator-=(const dimensioned<Type>&);
void operator+=(const Foam::zero);
void operator-=(const Foam::zero);
void operator+=(const Foam::zero) {}
void operator-=(const Foam::zero) {}
void operator*=(const volScalarField::Internal&);
void operator*=(const tmp<volScalarField::Internal>&);

View File

@ -1,12 +1,12 @@
#------------------------------------------------------------------------------
# C++14 support with gcc-5 and later, but several systems (as of 2021)
# are still using gcc-4.8.4 (centos7, suse SLES12, ...)
# gcc compiler
#
# NOTE if your system gcc is new enough can simply use c++14 too.
# On older systems: may need to upgrade the compiler, use a ThirdParty compiler
# or clang to have sufficient C++ language.
#------------------------------------------------------------------------------
SUFFIXES += .C .cc .cpp .cxx
CC := g++$(COMPILER_VERSION) -std=c++11
CC := g++$(COMPILER_VERSION) -std=c++14
c++ARCH :=
c++DBUG :=