Skip to content
Snippets Groups Projects
Commit 29b8ed44 authored by Gregor Weiss's avatar Gregor Weiss Committed by Sergey Lesnik
Browse files

ROLLBACK: remove linearSize from UList

parent 5a9127eb
Branches
No related merge requests found
......@@ -117,23 +117,6 @@ Foam::label Foam::UList<T>::byteSize() const
}
template<class T>
Foam::label Foam::UList<T>::addToLinearSize( Foam::label size ) const
{
linearSize_ += size;
return linearSize_;
}
template<class T>
Foam::label Foam::UList<T>::linearSize() const
{
linearSize_ = 0;
Foam::calculateLinearSize(this, linearSize_);
return linearSize_;
}
template<class T>
void Foam::sort(UList<T>& a)
{
......
......@@ -49,49 +49,6 @@ SourceFiles
#include "className.H"
#include<type_traits>
/// checks the existence of size() method
template<typename C>
struct has_size_method
{
private:
template<typename T>
static constexpr auto check(T*)->typename std::is_same
<
decltype( std::declval<T>().size() ),
Foam::label
>::type; // attempt to call size()
template<typename>
static constexpr std::false_type check(...);
typedef decltype(check<C>(0)) type;
public:
static constexpr bool value = type::value;
};
/// checks the existence of size() method
template<typename C>
class has_linearSize_method
{
template<typename T>
static constexpr auto check(T*)->typename std::is_same
<
decltype( std::declval<T>().linearSize() ),
Foam::label
>::type; // attempt to call size()
template<typename>
static constexpr std::false_type check(...);
typedef decltype(check<C>(0)) type;
public:
static constexpr bool value = type::value;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
......@@ -127,9 +84,6 @@ class UList
//- Number of elements in UList.
label size_;
//- Number of elements of primitive type in multi-dimensional UList.
mutable label linearSize_;
protected:
......@@ -211,12 +165,6 @@ public:
// i.e. contiguous<T>() == true
label byteSize() const;
//- Return size of linearized data
label linearSize() const;
//- Adding sizes of multi-dimensional lists during traversing
label addToLinearSize( label ) const;
//- Return a const pointer to the first data element,
// similar to the STL front() method and the string::data() method
// This can be used (with caution) when interfacing with C code.
......@@ -432,30 +380,6 @@ inline void reverse(UList<T>&);
template<class T>
void swap( UList<T>& a, UList<T>& b );
template<typename ValueType>
typename std::enable_if
<
!has_linearSize_method<ValueType>::value,
label
>::type
calculateLinearSize
(
const UList<ValueType>* someList,
label& linearSize
);
template<typename ValueType>
typename std::enable_if
<
has_linearSize_method<ValueType>::value,
label
>::type
calculateLinearSize
(
const UList<ValueType>* someList,
label& linearSize
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
......
......@@ -356,47 +356,4 @@ void Foam::swap( UList<T>& a, UList<T>& b )
a.swap(b);
}
template<typename ValueType>
typename std::enable_if
<
!has_linearSize_method<ValueType>::value,
Foam::label
>::type
Foam::calculateLinearSize
(
const Foam::UList<ValueType>* someList,
Foam::label& linearSize
)
{
linearSize += someList->size();
return 0;
}
template<typename ValueType>
typename std::enable_if
<
has_linearSize_method<ValueType>::value,
Foam::label
>::type
Foam::calculateLinearSize
(
const Foam::UList<ValueType>* someList,
Foam::label& linearSize
)
{
for
(
auto elementIter = someList->begin();
elementIter != someList->end();
++elementIter
)
{
Foam::calculateLinearSize( elementIter, linearSize );
}
return 0;
}
// ************************************************************************* //
......@@ -1598,7 +1598,17 @@ bool Foam::polyMesh::write() const
faceList sliceFaces = sliceablePermutation.retrieveFaces();
// Linearize faces and points
label k = 0;
Foam::label linearSizeOfFaces = allFaces_.linearSize();
Foam::label linearSizeOfFaces =
std::accumulate
(
allFaces_.begin(),
allFaces_.end(),
0,
[] (label size, Foam::face input)
{
return std::move(size) + input.size();
}
);
Foam::List<Foam::label> linearizedFaces( linearSizeOfFaces, 0 );
forAll( sliceFaces, i )
{
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment