ENH: noexcept size_bytes() method for lists

- for use when the is_contiguous check has already been done outside
  the loop. Naming as per std::span.

STYLE: use data/cdata instead of begin

ENH: replace random_shuffle with shuffle, fix OSX int64 ambiguity
This commit is contained in:
Mark Olesen 2021-02-26 18:10:42 +01:00
parent 51cd7ceecb
commit fa645c2dac
40 changed files with 188 additions and 132 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2013 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -124,7 +124,7 @@ int main(int argc, char *argv[])
std::for_each(test6.begin(), test6.end(), [](label& x){ x *= 3; });
// Randomize the list
std::random_shuffle(test6.begin(), test6.end());
Foam::shuffle(test6);
Info<< "randomized input list: " << flatOutput(test6) << nl;
@ -160,7 +160,7 @@ int main(int argc, char *argv[])
// List reorder
labelList oldToNew(identity(40));
std::random_shuffle(oldToNew.begin(), oldToNew.end());
Foam::shuffle(oldToNew);
// Force a few -1:
oldToNew[4] = oldToNew[8] = -1;
@ -192,9 +192,9 @@ int main(int argc, char *argv[])
)
);
Info<<"packed input: " << flatOutput(packed) << nl;
Info<< "packed input: " << packed << nl;
inplaceReorder(oldToNew, packed);
Info<<" reorder: " << flatOutput(packed) << nl << nl;
Info<<" reorder: " << packed << nl << nl;
Info<< "\nEnd\n" << endl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,6 +34,7 @@ Description
#include "vector.H"
#include "IOstreams.H"
#include <algorithm>
#include <random>
using namespace Foam;
@ -115,9 +116,8 @@ void testData(const VecSpace& vs)
int main(int argc, char *argv[])
{
Info<<"normalised: " << vector(1,2,3).normalise() << nl;
Info<<"normalised: " << vector(VSMALL,VSMALL,VSMALL).normalise() << nl;
Info<<"normalised: " <<
vector(ROOTVSMALL,ROOTVSMALL,ROOTVSMALL).normalise() << nl;
Info<<"normalised: " << vector::uniform(VSMALL).normalise() << nl;
Info<<"normalised: " << vector::uniform(ROOTVSMALL).normalise() << nl;
{
vector vec1(0.5, 0.5, 0.5);
@ -134,7 +134,7 @@ int main(int argc, char *argv[])
std::sort(vec2.begin(), vec2.end());
Info<< "sorted: " << vec2 << nl;
std::random_shuffle(vec2.begin(), vec2.end());
std::shuffle(vec2.begin(), vec2.end(), std::default_random_engine());
Info<< "shuffled: " << vec2 << nl;
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,6 +34,8 @@ License
#include "scalarIOField.H"
#include "labelIOField.H"
#include "pointConversion.H"
#include <algorithm>
#include <random>
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -304,7 +307,7 @@ Foam::Map<Foam::label> Foam::DelaunayMesh<Triangulation>::rangeInsertWithInfo
);
}
std::random_shuffle(points.begin(), points.end());
std::shuffle(points.begin(), points.end(), std::default_random_engine());
spatial_sort
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,6 +33,8 @@ License
#include "pointConversion.H"
#include "indexedVertexEnum.H"
#include "IOmanip.H"
#include <algorithm>
#include <random>
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
@ -880,7 +882,12 @@ Foam::DistributedDelaunayMesh<Triangulation>::rangeInsertReferredWithInfo
);
}
std::random_shuffle(pointsBbDistSqr.begin(), pointsBbDistSqr.end());
std::shuffle
(
pointsBbDistSqr.begin(),
pointsBbDistSqr.end(),
std::default_random_engine()
);
// Sort in ascending order by the distance of the point from the centre
// of the processor bounding box

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -401,6 +401,10 @@ public:
//- A pointer to the raw storage
inline unsigned int* data() noexcept;
//- The number of bytes used in the raw storage
//- including any unused padding.
inline std::streamsize size_bytes() const noexcept;
//- The number of bytes used in the raw storage
//- including any unused padding.
inline std::streamsize byteSize() const noexcept;

View File

@ -562,12 +562,19 @@ inline unsigned int* Foam::PackedList<Width>::data() noexcept
template<unsigned Width>
inline std::streamsize Foam::PackedList<Width>::byteSize() const noexcept
inline std::streamsize Foam::PackedList<Width>::size_bytes() const noexcept
{
return num_blocks(size()) * sizeof(block_type);
}
template<unsigned Width>
inline std::streamsize Foam::PackedList<Width>::byteSize() const noexcept
{
return this->size_bytes();
}
template<unsigned Width>
inline void Foam::PackedList<Width>::swap(PackedList<Width>& rhs)
{

View File

@ -128,7 +128,7 @@ Foam::Istream& Foam::PackedList<Width>::read(Istream& is)
is.read
(
reinterpret_cast<char*>(list.data()),
list.byteSize()
list.size_bytes()
);
is.fatalCheck
@ -230,7 +230,7 @@ Foam::Ostream& Foam::PackedList<Width>::writeList
os.write
(
reinterpret_cast<const char*>(list.cdata()),
list.byteSize()
list.size_bytes()
);
}
}

View File

@ -88,7 +88,7 @@ Foam::Ostream& Foam::bitSet::writeList
os.write
(
reinterpret_cast<const char*>(list.cdata()),
list.byteSize()
list.size_bytes()
);
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,8 +40,7 @@ std::streamsize Foam::FixedList<T, N>::byteSize() const
<< "Invalid for non-contiguous data types"
<< abort(FatalError);
}
return N*sizeof(T);
return this->size_bytes();
}

View File

@ -216,7 +216,12 @@ public:
//- The last element of the list, position [N-1]
inline const T& last() const noexcept;
//- The number of bytes stored by the list data for contiguous types
//- Number of contiguous bytes for the list data,
//- no runtime check that the type is actually contiguous
inline static std::streamsize size_bytes() noexcept;
//- Number of contiguous bytes for the list data,
//- with runtime check that the type is actually contiguous
std::streamsize byteSize() const;
//- Return the forward circular index, i.e. next index

View File

@ -184,6 +184,13 @@ Foam::FixedList<T, N>::data() noexcept
}
template<class T, unsigned N>
inline std::streamsize Foam::FixedList<T, N>::size_bytes() noexcept
{
return N*sizeof(T);
}
template<class T, unsigned N>
inline T& Foam::FixedList<T, N>::first() noexcept
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -199,7 +199,7 @@ Foam::List<T>::List(const UList<T>& a)
{
std::memcpy
(
static_cast<void*>(this->v_), a.v_, this->byteSize()
static_cast<void*>(this->v_), a.v_, this->size_bytes()
);
}
else
@ -232,7 +232,7 @@ Foam::List<T>::List(const List<T>& a)
{
std::memcpy
(
static_cast<void*>(this->v_), a.v_, this->byteSize()
static_cast<void*>(this->v_), a.v_, this->size_bytes()
);
}
else
@ -274,7 +274,7 @@ Foam::List<T>::List(List<T>& a, bool reuse)
{
std::memcpy
(
static_cast<void*>(this->v_), a.v_, this->byteSize()
static_cast<void*>(this->v_), a.v_, this->size_bytes()
);
}
else
@ -516,7 +516,7 @@ void Foam::List<T>::operator=(const UList<T>& a)
{
std::memcpy
(
static_cast<void*>(this->v_), a.v_, this->byteSize()
static_cast<void*>(this->v_), a.v_, this->size_bytes()
);
}
else

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,6 +32,7 @@ License
#include "labelRange.H"
#include <algorithm>
#include <random>
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -120,7 +121,7 @@ void Foam::UList<T>::deepCopy(const UList<T>& list)
{
std::memcpy
(
static_cast<void*>(this->v_), list.v_, this->byteSize()
static_cast<void*>(this->v_), list.v_, this->size_bytes()
);
}
else
@ -196,8 +197,7 @@ std::streamsize Foam::UList<T>::byteSize() const
<< "Invalid for non-contiguous data types"
<< abort(FatalError);
}
return this->size_*sizeof(T);
return this->size_bytes();
}
@ -281,7 +281,7 @@ void Foam::stableSort(UList<T>& a, const Compare& comp)
template<class T>
void Foam::shuffle(UList<T>& a)
{
std::random_shuffle(a.begin(), a.end());
std::shuffle(a.begin(), a.end(), std::default_random_engine());
}

View File

@ -274,8 +274,12 @@ public:
//- Return the last element of the list
inline const T& last() const;
//- The number of bytes stored by the list data for contiguous types
// \note is a std::streamsize since it is used in stream ops
//- Number of contiguous bytes for the List data,
//- no runtime check that the type is actually contiguous
inline std::streamsize size_bytes() const noexcept;
//- Number of contiguous bytes for the List data,
//- with runtime check that the type is actually contiguous
std::streamsize byteSize() const;
@ -530,7 +534,7 @@ public:
{
if (is_contiguous<T>::value)
{
return Hasher(obj.cdata(), obj.size()*sizeof(T), seed);
return Hasher(obj.cdata(), obj.size_bytes(), seed);
}
for (const T& val : obj)
@ -600,7 +604,7 @@ struct Hash<UList<T>>
{
if (is_contiguous<T>::value)
{
return Hasher(obj.cdata(), obj.size()*sizeof(T), seed);
return Hasher(obj.cdata(), obj.size_bytes(), seed);
}
for (const T& val : obj)
{

View File

@ -207,6 +207,13 @@ inline T* Foam::UList<T>::data() noexcept
}
template<class T>
inline std::streamsize Foam::UList<T>::size_bytes() const noexcept
{
return std::streamsize(size_)*sizeof(T);
}
template<class T>
inline bool Foam::UList<T>::found(const T& val, label pos) const
{

View File

@ -146,7 +146,7 @@ Foam::Ostream& Foam::UList<T>::writeList
os.write
(
reinterpret_cast<const char*>(list.cdata()),
list.byteSize()
list.size_bytes()
);
}
}

View File

@ -609,7 +609,7 @@ void Foam::decomposedBlockData::gather
const label nProcs = UPstream::nProcs(comm);
datas.setSize(nProcs);
char* data0Ptr = reinterpret_cast<char*>(datas.begin());
char* data0Ptr = reinterpret_cast<char*>(datas.data());
List<int> recvOffsets;
List<int> recvSizes;
@ -682,15 +682,15 @@ void Foam::decomposedBlockData::gatherSlaveData
)
{
// Note: UPstream::gather limited to int
nSend = int(data.byteSize());
nSend = int(data.size_bytes());
}
UPstream::gather
(
data.begin(),
data.cdata(),
nSend,
recvData.begin(),
recvData.data(),
sliceSizes,
sliceOffsets,
comm
@ -822,8 +822,8 @@ bool Foam::decomposedBlockData::writeBlocks
(
UPstream::commsTypes::scheduled,
proci,
elems.begin(),
elems.size(),
elems.data(),
elems.size_bytes(),
Pstream::msgType(),
comm
);
@ -841,8 +841,8 @@ bool Foam::decomposedBlockData::writeBlocks
(
UPstream::commsTypes::scheduled,
UPstream::masterNo(),
data.begin(),
data.byteSize(),
data.cdata(),
data.size_bytes(),
Pstream::msgType(),
comm
);
@ -1015,12 +1015,12 @@ bool Foam::decomposedBlockData::writeData(Ostream& os) const
if (isA<OFstream>(os))
{
// Serial file output - can use writeRaw()
os.writeRaw(data.cdata(), data.byteSize());
os.writeRaw(data.cdata(), data.size_bytes());
}
else
{
// Other cases are less fortunate, and no std::string_view
std::string str(data.cdata(), data.byteSize());
std::string str(data.cdata(), data.size_bytes());
os.writeQuoted(str, false);
}
@ -1052,7 +1052,7 @@ bool Foam::decomposedBlockData::writeObject
}
labelList recvSizes;
gather(comm_, label(this->byteSize()), recvSizes);
gather(comm_, label(this->size_bytes()), recvSizes);
List<std::streamoff> start;
PtrList<SubList<char>> slaveData; // dummy slave data

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -170,7 +170,7 @@ Foam::UOPstream::~UOPstream()
(
commsType_,
toProcNo_,
sendBuf_.begin(),
sendBuf_.cdata(),
sendBuf_.size(),
tag_,
comm_

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -314,7 +314,7 @@ void Foam::Pstream::listCombineGather
UPstream::commsTypes::scheduled,
belowID,
reinterpret_cast<char*>(receivedValues.data()),
receivedValues.byteSize(),
receivedValues.size_bytes(),
tag,
comm
);
@ -371,7 +371,7 @@ void Foam::Pstream::listCombineGather
UPstream::commsTypes::scheduled,
myComm.above(),
reinterpret_cast<const char*>(Values.cdata()),
Values.byteSize(),
Values.size_bytes(),
tag,
comm
);
@ -451,7 +451,7 @@ void Foam::Pstream::listCombineScatter
UPstream::commsTypes::scheduled,
myComm.above(),
reinterpret_cast<char*>(Values.data()),
Values.byteSize(),
Values.size_bytes(),
tag,
comm
);
@ -493,7 +493,7 @@ void Foam::Pstream::listCombineScatter
UPstream::commsTypes::scheduled,
belowID,
reinterpret_cast<const char*>(Values.cdata()),
Values.byteSize(),
Values.size_bytes(),
tag,
comm
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,7 +85,7 @@ void Pstream::gatherList
UPstream::commsTypes::scheduled,
belowID,
reinterpret_cast<char*>(receivedValues.data()),
receivedValues.byteSize(),
receivedValues.size_bytes(),
tag,
comm
);
@ -161,7 +161,7 @@ void Pstream::gatherList
UPstream::commsTypes::scheduled,
myComm.above(),
reinterpret_cast<const char*>(sendingValues.cdata()),
sendingValues.byteSize(),
sendingValues.size_bytes(),
tag,
comm
);
@ -247,7 +247,7 @@ void Pstream::scatterList
UPstream::commsTypes::scheduled,
myComm.above(),
reinterpret_cast<char*>(receivedValues.data()),
receivedValues.byteSize(),
receivedValues.size_bytes(),
tag,
comm
);
@ -303,7 +303,7 @@ void Pstream::scatterList
UPstream::commsTypes::scheduled,
belowID,
reinterpret_cast<const char*>(sendingValues.cdata()),
sendingValues.byteSize(),
sendingValues.size_bytes(),
tag,
comm
);

View File

@ -465,7 +465,7 @@ bool Foam::OFstreamCollator::write
UPstream::commsTypes::nonBlocking,
proci,
reinterpret_cast<char*>(slaveData[proci].data()),
slaveData[proci].byteSize(),
slaveData[proci].size_bytes(),
Pstream::msgType(),
localComm_
);
@ -480,7 +480,7 @@ bool Foam::OFstreamCollator::write
UPstream::commsTypes::nonBlocking,
0,
reinterpret_cast<const char*>(slice.cdata()),
slice.byteSize(),
slice.size_bytes(),
Pstream::msgType(),
localComm_
)
@ -489,7 +489,7 @@ bool Foam::OFstreamCollator::write
FatalErrorInFunction
<< "Cannot send outgoing message. "
<< "to:" << 0 << " nBytes:"
<< label(slice.byteSize())
<< label(slice.size_bytes())
<< Foam::abort(FatalError);
}
}

View File

@ -469,8 +469,7 @@ std::streamsize Foam::Matrix<Form, Type>::byteSize() const
<< "Invalid for non-contiguous data types"
<< abort(FatalError);
}
return mRows_*nCols_*sizeof(Type);
return this->size_bytes();
}

View File

@ -204,7 +204,12 @@ public:
//- be used to address into Matrix contents
inline Type* data() noexcept;
//- The number of bytes stored by the Matrix data for contiguous types
//- Number of contiguous bytes for the Matrix data,
//- no runtime check that the type is actually contiguous
inline std::streamsize size_bytes() const noexcept;
//- Number of contiguous bytes for the Matrix data,
//- with runtime check that the type is actually contiguous
std::streamsize byteSize() const;
//- Return const pointer to data in the specified row

View File

@ -211,6 +211,13 @@ inline Type* Foam::Matrix<Form, Type>::data() noexcept
}
template<class Form, class Type>
inline std::streamsize Foam::Matrix<Form, Type>::size_bytes() const noexcept
{
return mRows_*nCols_*sizeof(Type);
}
template<class Form, class Type>
inline const Type* Foam::Matrix<Form, Type>::rowData(const label irow) const
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 Mattijs Janssens
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -67,7 +67,7 @@ void Foam::PPCG::gSumMagProd
{
Foam::reduce
(
globalSum.begin(),
globalSum.data(),
globalSum.size(),
sumOp<solveScalar>(),
Pstream::msgType(),

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -66,7 +66,7 @@ void Foam::globalIndex::gather
commsType,
procIDs[i],
reinterpret_cast<char*>(procSlot.data()),
procSlot.byteSize(),
procSlot.size_bytes(),
tag,
comm
);
@ -133,7 +133,7 @@ void Foam::globalIndex::gather
commsType,
procIDs[0],
reinterpret_cast<const char*>(fld.cdata()),
fld.byteSize(),
fld.size_bytes(),
tag,
comm
);
@ -170,7 +170,7 @@ void Foam::globalIndex::gather
commsType,
procIDs[0],
reinterpret_cast<const char*>(fld.cdata()),
fld.byteSize(),
fld.size_bytes(),
tag,
comm
);
@ -319,7 +319,7 @@ void Foam::globalIndex::scatter
commsType,
procIDs[i],
reinterpret_cast<const char*>(procSlot.cdata()),
procSlot.byteSize(),
procSlot.size_bytes(),
tag,
comm
);
@ -366,7 +366,7 @@ void Foam::globalIndex::scatter
commsType,
procIDs[i],
reinterpret_cast<const char*>(procSlot.cdata()),
procSlot.byteSize(),
procSlot.size_bytes(),
tag,
comm
);
@ -391,7 +391,7 @@ void Foam::globalIndex::scatter
commsType,
procIDs[0],
reinterpret_cast<char*>(fld.data()),
fld.byteSize(),
fld.size_bytes(),
tag,
comm
);
@ -428,7 +428,7 @@ void Foam::globalIndex::scatter
commsType,
procIDs[0],
reinterpret_cast<char*>(fld.data()),
fld.byteSize(),
fld.size_bytes(),
tag,
comm
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1920,7 +1920,7 @@ Foam::pointField Foam::globalMeshData::sharedPoints() const
(
Pstream::commsTypes::blocking,
slave,
sharedPoints.size()*sizeof(Foam::vector) // byteSize()
sharedPoints.size_bytes()
);
toSlave << sharedPoints;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -536,7 +536,7 @@ void Foam::mapDistributeBase::distribute
Pstream::commsTypes::nonBlocking,
domain,
reinterpret_cast<const char*>(subField.cdata()),
subField.byteSize(),
subField.size_bytes(),
tag,
comm
);
@ -559,7 +559,7 @@ void Foam::mapDistributeBase::distribute
Pstream::commsTypes::nonBlocking,
domain,
reinterpret_cast<char*>(recvFields[domain].data()),
recvFields[domain].byteSize(),
recvFields[domain].size_bytes(),
tag,
comm
);
@ -1061,7 +1061,7 @@ void Foam::mapDistributeBase::distribute
Pstream::commsTypes::nonBlocking,
domain,
reinterpret_cast<const char*>(subField.cdata()),
subField.size()*sizeof(T),
subField.size_bytes(),
tag,
comm
);
@ -1084,7 +1084,7 @@ void Foam::mapDistributeBase::distribute
Pstream::commsTypes::nonBlocking,
domain,
reinterpret_cast<char*>(recvFields[domain].data()),
recvFields[domain].size()*sizeof(T),
recvFields[domain].size_bytes(),
tag,
comm
);

View File

@ -1053,7 +1053,7 @@ void Foam::syncTools::syncBoundaryFaceList
Pstream::commsTypes::nonBlocking,
procPatch.neighbProcNo(),
reinterpret_cast<char*>(fld.data()),
fld.byteSize()
fld.size_bytes()
);
}
}
@ -1079,7 +1079,7 @@ void Foam::syncTools::syncBoundaryFaceList
Pstream::commsTypes::nonBlocking,
procPatch.neighbProcNo(),
reinterpret_cast<const char*>(fld.cdata()),
fld.byteSize()
fld.size_bytes()
);
}
}
@ -1280,7 +1280,7 @@ void Foam::syncTools::syncFaceList
Pstream::commsTypes::nonBlocking,
procPatch.neighbProcNo(),
reinterpret_cast<char*>(recvInfo.data()),
recvInfo.byteSize()
recvInfo.size_bytes()
);
}
}
@ -1315,7 +1315,7 @@ void Foam::syncTools::syncFaceList
Pstream::commsTypes::nonBlocking,
procPatch.neighbProcNo(),
reinterpret_cast<const char*>(sendInfo.cdata()),
sendInfo.byteSize()
sendInfo.size_bytes()
);
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -200,7 +200,7 @@ struct Hash<Pair<T>>
{
if (is_contiguous<T>::value)
{
return Hasher(obj.cdata(), sizeof(obj), seed);
return Hasher(obj.cdata(), obj.size_bytes(), seed);
}
seed = Hash<T>()(obj.first(), seed);

View File

@ -73,6 +73,8 @@ MAXMINPOW(float, int, float)
MAXMINPOW(float, float, long)
MAXMINPOW(float, long, float)
#if defined(__APPLE__) && WM_LABEL_SIZE == 64
MAXMINPOW(double, double, int64_t)
MAXMINPOW(double, int64_t, double)
MAXMINPOW(float, float, int64_t)
MAXMINPOW(float, int64_t, float)
#endif

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -115,7 +115,7 @@ Foam::UIPstream::UIPstream
(
commsType,
fromProcNo_,
externalBuf_.begin(),
externalBuf_.data(),
wantedSize,
tag_,
comm_
@ -221,7 +221,7 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
(
commsType(),
fromProcNo_,
externalBuf_.begin(),
externalBuf_.data(),
wantedSize,
tag_,
comm_

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -770,10 +770,10 @@ void Foam::UPstream::allToAll
(
// NOTE: const_cast is a temporary hack for
// backward-compatibility with versions of OpenMPI < 1.7.4
const_cast<label*>(sendData.begin()),
const_cast<label*>(sendData.cdata()),
sizeof(label),
MPI_BYTE,
recvData.begin(),
recvData.data(),
sizeof(label),
MPI_BYTE,
PstreamGlobals::MPICommunicators_[communicator]
@ -1090,7 +1090,7 @@ void Foam::UPstream::allocatePstreamCommunicator
(
PstreamGlobals::MPIGroups_[parentIndex],
procIDs_[index].size(),
procIDs_[index].begin(),
procIDs_[index].cdata(),
&PstreamGlobals::MPIGroups_[index]
);
@ -1188,7 +1188,7 @@ void Foam::UPstream::waitRequests(const label start)
MPI_Waitall
(
waitRequests.size(),
waitRequests.begin(),
waitRequests.data(),
MPI_STATUSES_IGNORE
)
)

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -184,7 +184,7 @@ void Foam::ccm::reader::readMap
(
&(globalState_->error),
mapId,
data.begin(),
data.data(),
kCCMIOStart,
kCCMIOEnd
);

View File

@ -42,7 +42,6 @@ License
#include "ccmInternal.H" // include last to avoid any strange interactions
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::labelList Foam::ccm::reader::patchStartList(label initial) const
@ -311,7 +310,7 @@ Foam::labelList Foam::ccm::reader::readVertices
nullptr,
nullptr,
nullptr,
vrts.begin(),
vrts.data(),
kCCMIOStart,
kCCMIOEnd
);
@ -388,7 +387,7 @@ void Foam::ccm::reader::readCells
&(globalState_->error),
cellsNode,
&mapId,
cellTableId_.begin(),
cellTableId_.data(),
kCCMIOStart,
kCCMIOEnd
);
@ -597,7 +596,7 @@ void Foam::ccm::reader::readCells
kCCMIOInternalFaces,
nullptr,
nullptr,
ccmFaces.begin(),
ccmFaces.data(),
kCCMIOStart,
kCCMIOEnd
);
@ -607,7 +606,7 @@ void Foam::ccm::reader::readCells
&(globalState_->error),
nodeId,
kCCMIOInternalFaces,
faceCells.begin(),
faceCells.data(),
kCCMIOStart,
kCCMIOEnd
);
@ -686,7 +685,7 @@ void Foam::ccm::reader::readCells
kCCMIOBoundaryFaces,
nullptr,
nullptr,
ccmFaces.begin(),
ccmFaces.data(),
kCCMIOStart,
kCCMIOEnd
);
@ -695,7 +694,7 @@ void Foam::ccm::reader::readCells
&(globalState_->error),
nodeId,
kCCMIOBoundaryFaces,
faceCells.begin(),
faceCells.data(),
kCCMIOStart,
kCCMIOEnd
);
@ -837,7 +836,7 @@ void Foam::ccm::reader::readInterfaces
&(globalState_->error),
interfaceNode,
"ProstarBaffles",
mapData.begin(),
mapData.data(),
kCCMIOStart,
kCCMIOEnd
);
@ -880,7 +879,7 @@ void Foam::ccm::reader::readInterfaces
&(globalState_->error),
interfaceNode,
"FaceIds",
mapData.begin(),
mapData.data(),
kCCMIOStart,
kCCMIOEnd
);
@ -1058,7 +1057,7 @@ void Foam::ccm::reader::readMonitoring
// CCMIOGetNode(nullptr, childNode, "Cells", &subNode);
// CCMIORead1i
// (
// nullptr, subNode, faceCells.begin(),
// nullptr, subNode, faceCells.data(),
// kCCMIOStart, kCCMIOEnd
// );
//

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -542,7 +542,6 @@ Foam::ccm::reader::readField
&& dataLocation == requestedLocation
)
{
#ifdef SOLID_STRESS_HACK
bool okayCombination = true;
@ -611,7 +610,7 @@ Foam::ccm::reader::readField
dataNode,
nullptr,
nullptr,
rawData.begin(),
rawData.data(),
kCCMIOStart,
kCCMIOEnd
);
@ -627,7 +626,6 @@ Foam::ccm::reader::readField
const label cellId = mapData[i];
scalarData[cellId] = rawData[i];
}
}
}
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -74,7 +74,7 @@ void Foam::ccm::writer::addLinearMap
mapId,
size,
(start + size),
data.begin(),
data.cdata(),
kCCMIOStart,
kCCMIOEnd
);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -175,7 +175,7 @@ void Foam::ccm::writer::writeFaces
nodeType,
mapId,
streamSize,
ccmStream.begin(),
ccmStream.cdata(),
kCCMIOStart,
kCCMIOEnd
);
@ -235,7 +235,7 @@ void Foam::ccm::writer::writeFaces
nodeId,
nodeType,
mapId,
ccmStream.begin(),
ccmStream.cdata(),
kCCMIOStart,
kCCMIOEnd
);
@ -262,7 +262,7 @@ void Foam::ccm::writer::writeFaces
nodeId,
"ProstarFaceId",
size,
ccmStream.begin(),
ccmStream.cdata(),
kCCMIOStart,
kCCMIOEnd
);
@ -290,7 +290,7 @@ void Foam::ccm::writer::writeFaces
"ProstarFaceId",
size,
2,
ccmStream.begin(),
ccmStream.cdata(),
kCCMIOStart,
kCCMIOEnd
);
@ -337,7 +337,7 @@ void Foam::ccm::writer::writeVertices
verticesNode,
3, scaling,
vertexMap,
vrts.begin(),
vrts.cdata(),
kCCMIOStart,
kCCMIOEnd
);
@ -612,7 +612,7 @@ void Foam::ccm::writer::writeCells
&(globalState_->error),
cellsNode,
maps_->cells,
mapData.begin(),
mapData.data(),
kCCMIOStart, kCCMIOEnd
);
assertNoError("writing 'Cells' node");
@ -640,7 +640,7 @@ void Foam::ccm::writer::writeCells
cellsNode,
"CellTopologyType",
mesh_.nCells(),
mapData.begin(),
mapData.cdata(),
kCCMIOStart, kCCMIOEnd
);
@ -701,7 +701,7 @@ void Foam::ccm::writer::writeInterfaces
"FaceIds",
interfaces.size(),
2,
mapData.begin(), kCCMIOStart, kCCMIOEnd
mapData.cdata(), kCCMIOStart, kCCMIOEnd
)
!= kCCMIONoErr
)

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -737,7 +737,7 @@ void Foam::ccm::writer::writeSolution
kCCMIOFace,
const_cast<scalar*>
(
field.primitiveField().begin()
field.primitiveField().cdata()
),
kCCMIOStart,
kCCMIOEnd
@ -762,7 +762,10 @@ void Foam::ccm::writer::writeSolution
nodeId,
maps_->boundary[patchI],
kCCMIOFace,
field.boundaryField()[patchI].begin(),
const_cast<scalar*>
(
field.boundaryField()[patchI].cdata()
),
kCCMIOStart,
kCCMIOEnd
);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -170,7 +170,7 @@ void Foam::calculatedProcessorFvPatchField<Type>::initEvaluate
(
Pstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(),
reinterpret_cast<char*>(this->begin()),
reinterpret_cast<char*>(this->data()),
this->byteSize(),
procInterface_.tag(),
procInterface_.comm()
@ -181,7 +181,7 @@ void Foam::calculatedProcessorFvPatchField<Type>::initEvaluate
(
Pstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(),
reinterpret_cast<const char*>(sendBuf_.begin()),
reinterpret_cast<const char*>(sendBuf_.cdata()),
this->byteSize(),
procInterface_.tag(),
procInterface_.comm()
@ -246,7 +246,7 @@ void Foam::calculatedProcessorFvPatchField<Type>::initInterfaceMatrixUpdate
(
Pstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(),
reinterpret_cast<char*>(scalarReceiveBuf_.begin()),
reinterpret_cast<char*>(scalarReceiveBuf_.data()),
scalarReceiveBuf_.byteSize(),
procInterface_.tag(),
procInterface_.comm()
@ -257,7 +257,7 @@ void Foam::calculatedProcessorFvPatchField<Type>::initInterfaceMatrixUpdate
(
Pstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(),
reinterpret_cast<const char*>(scalarSendBuf_.begin()),
reinterpret_cast<const char*>(scalarSendBuf_.cdata()),
scalarSendBuf_.byteSize(),
procInterface_.tag(),
procInterface_.comm()