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

View File

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

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -33,6 +34,8 @@ License
#include "scalarIOField.H" #include "scalarIOField.H"
#include "labelIOField.H" #include "labelIOField.H"
#include "pointConversion.H" #include "pointConversion.H"
#include <algorithm>
#include <random>
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * 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 spatial_sort
( (

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -33,6 +33,8 @@ License
#include "pointConversion.H" #include "pointConversion.H"
#include "indexedVertexEnum.H" #include "indexedVertexEnum.H"
#include "IOmanip.H" #include "IOmanip.H"
#include <algorithm>
#include <random>
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * 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 // Sort in ascending order by the distance of the point from the centre
// of the processor bounding box // of the processor bounding box

View File

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

View File

@ -562,12 +562,19 @@ inline unsigned int* Foam::PackedList<Width>::data() noexcept
template<unsigned Width> 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); 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> template<unsigned Width>
inline void Foam::PackedList<Width>::swap(PackedList<Width>& rhs) 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 is.read
( (
reinterpret_cast<char*>(list.data()), reinterpret_cast<char*>(list.data()),
list.byteSize() list.size_bytes()
); );
is.fatalCheck is.fatalCheck
@ -230,7 +230,7 @@ Foam::Ostream& Foam::PackedList<Width>::writeList
os.write os.write
( (
reinterpret_cast<const char*>(list.cdata()), reinterpret_cast<const char*>(list.cdata()),
list.byteSize() list.size_bytes()
); );
} }
} }

View File

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

View File

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

View File

@ -216,7 +216,12 @@ public:
//- The last element of the list, position [N-1] //- The last element of the list, position [N-1]
inline const T& last() const noexcept; 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; std::streamsize byteSize() const;
//- Return the forward circular index, i.e. next index //- 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> template<class T, unsigned N>
inline T& Foam::FixedList<T, N>::first() noexcept inline T& Foam::FixedList<T, N>::first() noexcept
{ {

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -32,6 +32,7 @@ License
#include "labelRange.H" #include "labelRange.H"
#include <algorithm> #include <algorithm>
#include <random>
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -120,7 +121,7 @@ void Foam::UList<T>::deepCopy(const UList<T>& list)
{ {
std::memcpy std::memcpy
( (
static_cast<void*>(this->v_), list.v_, this->byteSize() static_cast<void*>(this->v_), list.v_, this->size_bytes()
); );
} }
else else
@ -196,8 +197,7 @@ std::streamsize Foam::UList<T>::byteSize() const
<< "Invalid for non-contiguous data types" << "Invalid for non-contiguous data types"
<< abort(FatalError); << abort(FatalError);
} }
return this->size_bytes();
return this->size_*sizeof(T);
} }
@ -281,7 +281,7 @@ void Foam::stableSort(UList<T>& a, const Compare& comp)
template<class T> template<class T>
void Foam::shuffle(UList<T>& a) 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 //- Return the last element of the list
inline const T& last() const; inline const T& last() const;
//- The number of bytes stored by the list data for contiguous types //- Number of contiguous bytes for the List data,
// \note is a std::streamsize since it is used in stream ops //- 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; std::streamsize byteSize() const;
@ -530,7 +534,7 @@ public:
{ {
if (is_contiguous<T>::value) 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) for (const T& val : obj)
@ -600,7 +604,7 @@ struct Hash<UList<T>>
{ {
if (is_contiguous<T>::value) 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) 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> template<class T>
inline bool Foam::UList<T>::found(const T& val, label pos) const 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 os.write
( (
reinterpret_cast<const char*>(list.cdata()), 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); const label nProcs = UPstream::nProcs(comm);
datas.setSize(nProcs); datas.setSize(nProcs);
char* data0Ptr = reinterpret_cast<char*>(datas.begin()); char* data0Ptr = reinterpret_cast<char*>(datas.data());
List<int> recvOffsets; List<int> recvOffsets;
List<int> recvSizes; List<int> recvSizes;
@ -682,15 +682,15 @@ void Foam::decomposedBlockData::gatherSlaveData
) )
{ {
// Note: UPstream::gather limited to int // Note: UPstream::gather limited to int
nSend = int(data.byteSize()); nSend = int(data.size_bytes());
} }
UPstream::gather UPstream::gather
( (
data.begin(), data.cdata(),
nSend, nSend,
recvData.begin(), recvData.data(),
sliceSizes, sliceSizes,
sliceOffsets, sliceOffsets,
comm comm
@ -822,8 +822,8 @@ bool Foam::decomposedBlockData::writeBlocks
( (
UPstream::commsTypes::scheduled, UPstream::commsTypes::scheduled,
proci, proci,
elems.begin(), elems.data(),
elems.size(), elems.size_bytes(),
Pstream::msgType(), Pstream::msgType(),
comm comm
); );
@ -841,8 +841,8 @@ bool Foam::decomposedBlockData::writeBlocks
( (
UPstream::commsTypes::scheduled, UPstream::commsTypes::scheduled,
UPstream::masterNo(), UPstream::masterNo(),
data.begin(), data.cdata(),
data.byteSize(), data.size_bytes(),
Pstream::msgType(), Pstream::msgType(),
comm comm
); );
@ -1015,12 +1015,12 @@ bool Foam::decomposedBlockData::writeData(Ostream& os) const
if (isA<OFstream>(os)) if (isA<OFstream>(os))
{ {
// Serial file output - can use writeRaw() // Serial file output - can use writeRaw()
os.writeRaw(data.cdata(), data.byteSize()); os.writeRaw(data.cdata(), data.size_bytes());
} }
else else
{ {
// Other cases are less fortunate, and no std::string_view // 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); os.writeQuoted(str, false);
} }
@ -1052,7 +1052,7 @@ bool Foam::decomposedBlockData::writeObject
} }
labelList recvSizes; labelList recvSizes;
gather(comm_, label(this->byteSize()), recvSizes); gather(comm_, label(this->size_bytes()), recvSizes);
List<std::streamoff> start; List<std::streamoff> start;
PtrList<SubList<char>> slaveData; // dummy slave data PtrList<SubList<char>> slaveData; // dummy slave data

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -204,7 +204,12 @@ public:
//- be used to address into Matrix contents //- be used to address into Matrix contents
inline Type* data() noexcept; 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; std::streamsize byteSize() const;
//- Return const pointer to data in the specified row //- 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> template<class Form, class Type>
inline const Type* Foam::Matrix<Form, Type>::rowData(const label irow) const inline const Type* Foam::Matrix<Form, Type>::rowData(const label irow) const
{ {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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