ENH: add '_bytes()' versions of List data(), cdata()

- simply adds in the reinterpret_cast, which simplifies coding for
  binary data movement.
  Name complements the size_bytes() method for contiguous data

STYLE: container IO.C files into main headers for better visibility

STYLE: include CompactListList.H in polyTopoChange

- avoids future mismatches if the CompactListList template signature
  changes

GIT: relocate CompactListList into CompactLists/ directory
This commit is contained in:
Mark Olesen
2021-10-13 15:14:47 +02:00
parent 3d3d287452
commit 3781f17eee
52 changed files with 465 additions and 348 deletions

View File

@ -401,6 +401,12 @@ public:
//- A pointer to the raw storage
inline unsigned int* data() noexcept;
//- A const pointer to the raw storage, reinterpreted as byte data
inline const char* cdata_bytes() const noexcept;
//- A pointer to the raw storage, reinterpreted as byte data
inline char* data_bytes() noexcept;
//- The number of bytes used in the raw storage
//- including any unused padding.
inline std::streamsize size_bytes() const noexcept;

View File

@ -561,6 +561,20 @@ inline unsigned int* Foam::PackedList<Width>::data() noexcept
}
template<unsigned Width>
inline const char* Foam::PackedList<Width>::cdata_bytes() const noexcept
{
return blocks_.cdata_bytes();
}
template<unsigned Width>
inline char* Foam::PackedList<Width>::data_bytes() noexcept
{
return blocks_.data_bytes();
}
template<unsigned Width>
inline std::streamsize Foam::PackedList<Width>::size_bytes() const noexcept
{

View File

@ -88,11 +88,7 @@ Foam::Istream& Foam::PackedList<Width>::readList(Istream& is)
if (len)
{
// NOTE: independent of WM_LABEL_SIZE
is.read
(
reinterpret_cast<char*>(list.data()),
list.size_bytes()
);
is.read(list.data_bytes(), list.size_bytes());
is.fatalCheck
(
@ -197,11 +193,7 @@ Foam::Ostream& Foam::PackedList<Width>::writeList
if (len)
{
// write(...) includes surrounding start/end delimiters
os.write
(
reinterpret_cast<const char*>(list.cdata()),
list.size_bytes()
);
os.write(list.cdata_bytes(), list.size_bytes());
}
}
else if (len > 1 && list.uniform())

View File

@ -248,8 +248,4 @@ const
}
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
#include "CompactListListIO.C"
// ************************************************************************* //

View File

@ -275,6 +275,7 @@ public:
#ifdef NoRepository
#include "CompactListList.C"
#include "CompactListListIO.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -56,7 +56,8 @@ class BiIndirectList
UList<T>& posList_;
UList<T>& negList_;
List<label> addressing_;
labelList addressing_;
public:
@ -76,7 +77,7 @@ public:
(
const UList<T>& posList,
const UList<T>& negList,
List<label>&& addr
labelList&& addr
);
@ -90,23 +91,24 @@ public:
//- True if the list is empty (ie, size() is zero).
inline bool empty() const noexcept;
inline const UList<T>& posList() const;
inline const UList<T>& negList() const;
inline const UList<T>& posList() const noexcept;
inline const UList<T>& negList() const noexcept;
//- Return the list addressing
inline const List<label>& addressing() const;
inline const labelList& addressing() const noexcept;
//- Calculate index given whether index is into posList or negList
inline static label posIndex(const label i);
inline static label negIndex(const label i);
// Edit
//- Copy reset addressing
inline void resetAddressing(const labelUList& addr);
//- Move reset addressing
inline void resetAddressing(List<label>&& addr);
inline void resetAddressing(labelList&& addr);
// Member Operators

View File

@ -63,7 +63,7 @@ inline Foam::BiIndirectList<T>::BiIndirectList
(
const UList<T>& posList,
const UList<T>& negList,
List<label>&& addr
labelList&& addr
)
:
posList_(const_cast<UList<T>&>(posList)),
@ -89,22 +89,22 @@ inline bool Foam::BiIndirectList<T>::empty() const noexcept
template<class T>
inline const Foam::UList<T>& Foam::BiIndirectList<T>::posList() const
inline const Foam::UList<T>& Foam::BiIndirectList<T>::posList() const noexcept
{
return posList_;
}
template<class T>
inline const Foam::UList<T>& Foam::BiIndirectList<T>::negList() const
inline const Foam::UList<T>& Foam::BiIndirectList<T>::negList() const noexcept
{
return negList_;
}
template<class T>
inline const Foam::List<Foam::label>& Foam::BiIndirectList<T>::addressing()
const
inline const Foam::labelList&
Foam::BiIndirectList<T>::addressing() const noexcept
{
return addressing_;
}
@ -123,7 +123,7 @@ inline void Foam::BiIndirectList<T>::resetAddressing
template<class T>
inline void Foam::BiIndirectList<T>::resetAddressing
(
List<label>&& addr
labelList&& addr
)
{
addressing_.transfer(addr);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,8 +31,6 @@ Description
normally to used by IndirectList.
Private inheritance is often used by any inheriting classes.
SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef IndirectListAddressing_H
@ -76,13 +74,13 @@ public:
// Member Functions
//- Const access to the addressing
const Addr& addressing() const
const Addr& addressing() const noexcept
{
return storedAddr_;
}
//- Non-const access to the addressing
Addr& addressing()
Addr& addressing() noexcept
{
return storedAddr_;
}

View File

@ -147,7 +147,7 @@ public:
}
//- The addressing used for the list
inline const Addr& addressing() const
inline const Addr& addressing() const noexcept
{
return addr_;
}

View File

@ -36,8 +36,9 @@ Description
SizeMin template parameter dictating a lower bound.
SourceFiles
DynamicListI.H
DynamicList.C
DynamicListI.H
DynamicListIO.C
\*---------------------------------------------------------------------------*/
@ -56,10 +57,10 @@ namespace Foam
template<class T, int SizeMin> class DynamicList;
template<class T, int SizeMin>
inline Istream& operator>>(Istream&, DynamicList<T, SizeMin>&);
Istream& operator>>(Istream& is, DynamicList<T, SizeMin>& list);
template<class T, int SizeMin>
inline Ostream& operator<<(Ostream&, const DynamicList<T, SizeMin>&);
Ostream& operator<<(Ostream& os, const DynamicList<T, SizeMin>& list);
/*---------------------------------------------------------------------------*\
@ -156,6 +157,10 @@ public:
//- Size of the underlying storage.
inline label capacity() const noexcept;
//- Number of contiguous bytes of the underlying storage.
// \note Only meaningful for contiguous data
inline std::streamsize capacity_bytes() const noexcept;
// Sizing
@ -336,12 +341,12 @@ public:
// Reading/writing
//- Read from Istream, discarding existing contents
inline Istream& readList(Istream& is);
Istream& readList(Istream& is);
// IOstream Operators
//- Read from Istream, discarding existing contents
//- Use the readList() method to read contents from Istream.
friend Istream& operator>> <T, SizeMin>
(
Istream& is,
@ -357,6 +362,24 @@ public:
};
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
//- Read List contents from Istream
template<class T, int SizeMin>
Istream& operator>>(Istream& is, DynamicList<T, SizeMin>& list)
{
return list.readList(is);
}
//- Write List to Ostream, as per UList::writeList() with default length.
template<class T, int SizeMin>
Ostream& operator<<(Ostream& os, const DynamicList<T, SizeMin>& list)
{
return (os << static_cast<const UList<T>&>(list));
}
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
// Exchange contents of lists - see DynamicList::swap().
@ -367,6 +390,8 @@ inline void Swap(DynamicList<T, SizeMinA>& a, DynamicList<T, SizeMinB>& b)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Hashing for List data
template<class T, int SizeMin>
struct Hash<DynamicList<T, SizeMin>> : List<T>::hasher {};
@ -384,6 +409,7 @@ struct Hash<DynamicList<T, SizeMin>> : List<T>::hasher {};
#ifdef NoRepository
#include "DynamicList.C"
#include "DynamicListIO.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -207,16 +207,6 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList
}
template<class T, int SizeMin>
inline Foam::DynamicList<T, SizeMin>::DynamicList(Istream& is)
:
List<T>(),
capacity_(0)
{
this->readList(is);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, int SizeMin>
@ -226,6 +216,14 @@ inline Foam::label Foam::DynamicList<T, SizeMin>::capacity() const noexcept
}
template<class T, int SizeMin>
inline std::streamsize
Foam::DynamicList<T, SizeMin>::capacity_bytes() const noexcept
{
return std::streamsize(capacity_)*sizeof(T);
}
template<class T, int SizeMin>
inline void Foam::DynamicList<T, SizeMin>::setCapacity
(
@ -867,47 +865,4 @@ inline void Foam::DynamicList<T, SizeMin>::operator=
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class T, int SizeMin>
inline Foam::Istream& Foam::DynamicList<T, SizeMin>::readList
(
Istream& is
)
{
DynamicList<T, SizeMin>& list = *this;
// Use entire storage - ie, resize(capacity())
(void) list.expandStorage();
static_cast<List<T>&>(list).readList(is);
list.capacity_ = list.size();
return is;
}
template<class T, int SizeMin>
inline Foam::Istream& Foam::operator>>
(
Istream& is,
DynamicList<T, SizeMin>& list
)
{
return list.readList(is);
}
template<class T, int SizeMin>
inline Foam::Ostream& Foam::operator<<
(
Ostream& os,
const DynamicList<T, SizeMin>& list
)
{
os << static_cast<const List<T>&>(list);
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,67 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "List.H"
#include "Istream.H"
#include "token.H"
#include "SLList.H"
#include "contiguous.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T, int SizeMin>
Foam::DynamicList<T, SizeMin>::DynamicList(Istream& is)
:
List<T>(),
capacity_(0)
{
this->readList(is);
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class T, int SizeMin>
Foam::Istream& Foam::DynamicList<T, SizeMin>::readList
(
Istream& is
)
{
DynamicList<T, SizeMin>& list = *this;
// Needs rewrite (2021-10)
// Use entire storage - ie, resize(capacity())
(void) list.expandStorage();
static_cast<List<T>&>(list).readList(is);
list.capacity_ = list.size();
return is;
}
// ************************************************************************* //

View File

@ -29,10 +29,10 @@ License
#include "FixedList.H"
#include "ListLoopM.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class T, unsigned N>
std::streamsize Foam::FixedList<T, N>::byteSize() const
std::streamsize Foam::FixedList<T, N>::byteSize()
{
if (!is_contiguous<T>::value)
{
@ -40,10 +40,12 @@ std::streamsize Foam::FixedList<T, N>::byteSize() const
<< "Invalid for non-contiguous data types"
<< abort(FatalError);
}
return this->size_bytes();
return FixedList<T, N>::size_bytes();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, unsigned N>
Foam::label Foam::FixedList<T, N>::find(const T& val, label pos) const
{
@ -215,8 +217,4 @@ bool Foam::FixedList<T, N>::operator>=(const FixedList<T, N>& list) const
}
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
#include "FixedListIO.C"
// ************************************************************************* //

View File

@ -69,6 +69,9 @@ template<class T> class UList;
template<class T, unsigned N>
Istream& operator>>(Istream& is, FixedList<T, N>& list);
template<class T, unsigned N>
Ostream& operator<<(Ostream& os, const FixedList<T, N>& list);
/*---------------------------------------------------------------------------*\
Class FixedList Declaration
@ -197,16 +200,23 @@ public:
// Access
//- 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
//- Return pointer to the underlying array serving as data storage.
inline const T* cdata() const noexcept;
//- Return a 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
//- Return pointer to the underlying array serving as data storage.
inline T* data() noexcept;
//- Return pointer to the underlying array serving as data storage,
// reinterpreted as byte data
// \note Only meaningful for contiguous data
inline const char* cdata_bytes() const noexcept;
//- Return pointer to the underlying array serving as data storage,
// reinterpreted as byte data
// \note Only meaningful for contiguous data
inline char* data_bytes() noexcept;
//- The first element of the list, position [0]
inline T& first() noexcept;
@ -220,12 +230,12 @@ public:
inline const T& last() const noexcept;
//- Number of contiguous bytes for the list data,
//- no runtime check that the type is actually contiguous
// \note Only meaningful for contiguous data
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;
//- runtime FatalError if type is not contiguous
static std::streamsize byteSize();
//- Return the forward circular index, i.e. next index
//- which returns to the first at the end of the list
@ -448,7 +458,7 @@ public:
// IOstream Operators
//- Read from Istream, discarding contents of existing List
//- Use the readList() method to read contents from Istream.
friend Istream& operator>> <T, N>
(
Istream& is,
@ -523,6 +533,14 @@ inline void Swap(FixedList<T, N>& a, FixedList<T, N>& b)
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
//- Read List contents from Istream, list must have the proper size!
template<class T, unsigned N>
Istream& operator>>(Istream& is, FixedList<T, N>& list)
{
return list.readList(is);
}
//- Write List to Ostream, as per FixedList::writeList() with default length.
// The default short-length is given by Detail::ListPolicy::short_length
template<class T, unsigned N>
@ -545,6 +563,7 @@ Ostream& operator<<(Ostream& os, const FixedList<T, N>& list)
#ifdef NoRepository
#include "FixedList.C"
#include "FixedListIO.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -180,6 +180,22 @@ Foam::FixedList<T, N>::data() noexcept
}
template<class T, unsigned N>
inline const char*
Foam::FixedList<T, N>::cdata_bytes() const noexcept
{
return reinterpret_cast<const char*>(v_);
}
template<class T, unsigned N>
inline char*
Foam::FixedList<T, N>::data_bytes() noexcept
{
return reinterpret_cast<char*>(v_);
}
template<class T, unsigned N>
inline std::streamsize Foam::FixedList<T, N>::size_bytes() noexcept
{

View File

@ -45,6 +45,15 @@ void Foam::FixedList<T, N>::writeEntry(Ostream& os) const
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T, unsigned N>
Foam::FixedList<T, N>::FixedList(Istream& is)
{
this->readList(is);
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class T, unsigned N>
@ -81,11 +90,7 @@ Foam::Ostream& Foam::FixedList<T, N>::writeList
// Binary and contiguous. Size is always non-zero
// write(...) includes surrounding start/end delimiters
os.write
(
reinterpret_cast<const char*>(list.cdata()),
list.size_bytes()
);
os.write(list.cdata_bytes(), list.size_bytes());
}
else if
(
@ -155,7 +160,7 @@ Foam::Istream& Foam::FixedList<T, N>::readList
Detail::readContiguous<T>
(
is,
reinterpret_cast<char*>(list.data()),
list.data_bytes(),
list.size_bytes()
);
@ -247,20 +252,4 @@ Foam::Istream& Foam::FixedList<T, N>::readList
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class T, unsigned N>
Foam::FixedList<T, N>::FixedList(Istream& is)
{
this->readList(is);
}
template<class T, unsigned N>
Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, N>& list)
{
return list.readList(is);
}
// ************************************************************************* //

View File

@ -660,8 +660,4 @@ void Foam::List<T>::operator=(SLList<T>&& list)
}
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
#include "ListIO.C"
// ************************************************************************* //

View File

@ -305,7 +305,7 @@ public:
// IOstream Operators
//- Read List from Istream, discarding contents of existing List
//- Use the readList() method to read contents from Istream.
friend Istream& operator>> <T>
(
Istream& is,
@ -360,6 +360,16 @@ template<class T>
struct Hash<List<T>> : List<T>::hasher {};
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
//- Read List contents from Istream
template<class T>
Istream& operator>>(Istream& is, List<T>& list)
{
return list.readList(is);
}
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
//- Create identity map of the given length with (map[i] == i)
@ -379,6 +389,7 @@ labelList identity(const label len, label start=0);
#ifdef NoRepository
#include "List.C"
#include "ListIO.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -32,7 +32,7 @@ License
#include "SLList.H"
#include "contiguous.H"
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>
Foam::List<T>::List(Istream& is)
@ -43,6 +43,8 @@ Foam::List<T>::List(Istream& is)
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class T>
Foam::Istream& Foam::List<T>::readList(Istream& is)
{
@ -87,7 +89,7 @@ Foam::Istream& Foam::List<T>::readList(Istream& is)
Detail::readContiguous<T>
(
is,
reinterpret_cast<char*>(list.data()),
list.data_bytes(),
list.size_bytes()
);
@ -164,11 +166,4 @@ Foam::Istream& Foam::List<T>::readList(Istream& is)
}
template<class T>
Foam::Istream& Foam::operator>>(Istream& is, List<T>& list)
{
return list.readList(is);
}
// ************************************************************************* //

View File

@ -388,8 +388,4 @@ bool Foam::UList<T>::operator>=(const UList<T>& list) const
}
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
#include "UListIO.C"
// ************************************************************************* //

View File

@ -257,16 +257,22 @@ public:
//- Return reverse circular value (ie, previous value in the list)
inline T& rcValue(const label i);
//- 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
//- Return pointer to the underlying array serving as data storage.
inline const T* cdata() const noexcept;
//- Return a 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
//- Return pointer to the underlying array serving as data storage.
inline T* data() noexcept;
//- Return pointer to the underlying array serving as data storage,
// reinterpreted as byte data
// \note Only meaningful for contiguous data
inline const char* cdata_bytes() const noexcept;
//- Return pointer to the underlying array serving as data storage,
// reinterpreted as byte data
// \note Only meaningful for contiguous data
inline char* data_bytes() noexcept;
//- Return the first element of the list
inline T& first();
@ -279,12 +285,12 @@ public:
//- Return the last element of the list
inline const T& last() const;
//- Number of contiguous bytes for the List data,
//- no runtime check that the type is actually contiguous
//- Number of contiguous bytes for the List data.
// \note Only meaningful for contiguous data
inline std::streamsize size_bytes() const noexcept;
//- Number of contiguous bytes for the List data,
//- with runtime check that the type is actually contiguous
//- runtime FatalError if type is not contiguous
std::streamsize byteSize() const;
@ -484,8 +490,7 @@ public:
// IOstream Operators
//- Read List contents from Istream.
// The List must have the proper size before calling
//- Use the readList() method to read contents from Istream.
friend Istream& operator>> <T>
(
Istream& os,
@ -586,6 +591,14 @@ Ostream& UList<char>::writeList(Ostream& os, const label /*unused*/) const;
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
//- Read List contents from Istream, list must have the proper size!
template<class T>
Istream& operator>>(Istream& is, UList<T>& list)
{
return list.readList(is);
}
//- Write List to Ostream, as per UList::writeList() with default length.
// The default short-length is given by Detail::ListPolicy::short_length
template<class T>
@ -594,7 +607,7 @@ Ostream& operator<<(Ostream& os, const UList<T>& list)
return list.writeList(os, Detail::ListPolicy::short_length<T>::value);
}
//- Write std::vector to Ostream
//- Write std::vector to Ostream. ASCII only, no line-breaks
template<class T>
Ostream& operator<<(Ostream& os, const std::vector<T>& list);
@ -685,6 +698,7 @@ struct sizeOp
#ifdef NoRepository
#include "UList.C"
#include "UListIO.C"
#include "stdVectorIO.C"
#endif

View File

@ -207,6 +207,20 @@ inline T* Foam::UList<T>::data() noexcept
}
template<class T>
inline const char* Foam::UList<T>::cdata_bytes() const noexcept
{
return reinterpret_cast<const char*>(v_);
}
template<class T>
inline char* Foam::UList<T>::data_bytes() noexcept
{
return reinterpret_cast<char*>(v_);
}
template<class T>
inline std::streamsize Foam::UList<T>::size_bytes() const noexcept
{

View File

@ -94,11 +94,7 @@ Foam::Ostream& Foam::UList<T>::writeList
if (len)
{
// write(...) includes surrounding start/end delimiters
os.write
(
reinterpret_cast<const char*>(list.cdata()),
list.size_bytes()
);
os.write(list.cdata_bytes(), list.size_bytes());
}
}
else if (len > 1 && is_contiguous<T>::value && list.uniform())
@ -224,7 +220,7 @@ Foam::Istream& Foam::UList<T>::readList(Istream& is)
Detail::readContiguous<T>
(
is,
reinterpret_cast<char*>(list.data()),
list.data_bytes(),
list.size_bytes()
);
@ -313,11 +309,4 @@ Foam::Istream& Foam::UList<T>::readList(Istream& is)
}
template<class T>
Foam::Istream& Foam::operator>>(Istream& is, UList<T>& list)
{
return list.readList(is);
}
// ************************************************************************* //

View File

@ -38,7 +38,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const std::vector<T>& list)
auto iter = list.cbegin();
const auto last = list.cend();
// Write ascii list contents, no breaks
// Write ascii list contents, no line breaks
os << label(list.size()) << token::BEGIN_LIST;

View File

@ -583,9 +583,9 @@ void Foam::decomposedBlockData::gather
)
{
const label nProcs = UPstream::nProcs(comm);
datas.setSize(nProcs);
datas.resize(nProcs);
char* data0Ptr = reinterpret_cast<char*>(datas.data());
char* data0Ptr = datas.data_bytes();
List<int> recvOffsets;
List<int> recvSizes;

View File

@ -313,7 +313,7 @@ void Foam::Pstream::listCombineGather
(
UPstream::commsTypes::scheduled,
belowID,
reinterpret_cast<char*>(receivedValues.data()),
receivedValues.data_bytes(),
receivedValues.size_bytes(),
tag,
comm
@ -370,7 +370,7 @@ void Foam::Pstream::listCombineGather
(
UPstream::commsTypes::scheduled,
myComm.above(),
reinterpret_cast<const char*>(Values.cdata()),
Values.cdata_bytes(),
Values.size_bytes(),
tag,
comm
@ -450,7 +450,7 @@ void Foam::Pstream::listCombineScatter
(
UPstream::commsTypes::scheduled,
myComm.above(),
reinterpret_cast<char*>(Values.data()),
Values.data_bytes(),
Values.size_bytes(),
tag,
comm
@ -492,7 +492,7 @@ void Foam::Pstream::listCombineScatter
(
UPstream::commsTypes::scheduled,
belowID,
reinterpret_cast<const char*>(Values.cdata()),
Values.cdata_bytes(),
Values.size_bytes(),
tag,
comm

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,7 +59,7 @@ void Foam::Pstream::exchangeContainer
(
UPstream::commsTypes::nonBlocking,
proci,
reinterpret_cast<char*>(recvBufs[proci].begin()),
recvBufs[proci].data_bytes(),
recvSizes[proci]*sizeof(T),
tag,
comm
@ -81,8 +81,8 @@ void Foam::Pstream::exchangeContainer
(
UPstream::commsTypes::nonBlocking,
proci,
reinterpret_cast<const char*>(sendBufs[proci].begin()),
sendBufs[proci].size()*sizeof(T),
sendBufs[proci].cdata_bytes(),
sendBufs[proci].size_bytes(),
tag,
comm
)

View File

@ -84,7 +84,7 @@ void Pstream::gatherList
(
UPstream::commsTypes::scheduled,
belowID,
reinterpret_cast<char*>(receivedValues.data()),
receivedValues.data_bytes(),
receivedValues.size_bytes(),
tag,
comm
@ -160,7 +160,7 @@ void Pstream::gatherList
(
UPstream::commsTypes::scheduled,
myComm.above(),
reinterpret_cast<const char*>(sendingValues.cdata()),
sendingValues.cdata_bytes(),
sendingValues.size_bytes(),
tag,
comm
@ -246,7 +246,7 @@ void Pstream::scatterList
(
UPstream::commsTypes::scheduled,
myComm.above(),
reinterpret_cast<char*>(receivedValues.data()),
receivedValues.data_bytes(),
receivedValues.size_bytes(),
tag,
comm
@ -302,7 +302,7 @@ void Pstream::scatterList
(
UPstream::commsTypes::scheduled,
belowID,
reinterpret_cast<const char*>(sendingValues.cdata()),
sendingValues.cdata_bytes(),
sendingValues.size_bytes(),
tag,
comm

View File

@ -167,6 +167,10 @@ public:
//- Size of the underlying storage.
inline label capacity() const noexcept;
//- Number of contiguous bytes of the underlying storage.
// \note Only meaningful for contiguous data
inline std::streamsize capacity_bytes() const noexcept;
// Sizing
@ -240,6 +244,13 @@ public:
inline T remove();
// Reading/writing
//- Read from Istream, discarding existing contents
// Uses a DynamicList::readList internally
inline Istream& readList(Istream& is);
// Member Operators
//- Return non-const access to an element, resizing list if needed
@ -270,7 +281,7 @@ public:
// IOstream Operators
//- Read from Istream, discarding existing contents
//- Use the readList() method to read contents from Istream.
friend Istream& operator>> <T, SizeMin>
(
Istream& is,

View File

@ -244,6 +244,14 @@ inline Foam::label Foam::DynamicField<T, SizeMin>::capacity() const noexcept
}
template<class T, int SizeMin>
inline std::streamsize
Foam::DynamicField<T, SizeMin>::capacity_bytes() const noexcept
{
return std::streamsize(capacity_)*sizeof(T);
}
template<class T, int SizeMin>
inline void Foam::DynamicField<T, SizeMin>::setCapacity
(
@ -611,12 +619,13 @@ inline void Foam::DynamicField<T, SizeMin>::operator=
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class T, int SizeMin>
inline Foam::Istream& Foam::operator>>
inline Foam::Istream& Foam::DynamicField<T, SizeMin>::readList
(
Istream& is,
DynamicField<T, SizeMin>& rhs
Istream& is
)
{
DynamicField<T, SizeMin>& rhs = *this;
// Use entire storage - ie, resize(capacity())
(void) rhs.expandStorage();
@ -627,6 +636,17 @@ inline Foam::Istream& Foam::operator>>
}
template<class T, int SizeMin>
inline Foam::Istream& Foam::operator>>
(
Istream& is,
DynamicField<T, SizeMin>& rhs
)
{
return rhs.readList(is);
}
template<class T, int SizeMin>
inline Foam::Ostream& Foam::operator<<
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -123,8 +123,8 @@ void Foam::processorCyclicPointPatchField<Type>::initSwapAddSeparated
(
commsType,
procPatch_.neighbProcNo(),
reinterpret_cast<char*>(receiveBuf_.data()),
receiveBuf_.byteSize(),
receiveBuf_.data_bytes(),
receiveBuf_.size_bytes(),
procPatch_.tag(),
procPatch_.comm()
);
@ -133,8 +133,8 @@ void Foam::processorCyclicPointPatchField<Type>::initSwapAddSeparated
(
commsType,
procPatch_.neighbProcNo(),
reinterpret_cast<const char*>(pf.cdata()),
pf.byteSize(),
pf.cdata_bytes(),
pf.size_bytes(),
procPatch_.tag(),
procPatch_.comm()
);
@ -159,8 +159,8 @@ void Foam::processorCyclicPointPatchField<Type>::swapAddSeparated
(
commsType,
procPatch_.neighbProcNo(),
reinterpret_cast<char*>(receiveBuf_.data()),
receiveBuf_.byteSize(),
receiveBuf_.data_bytes(),
receiveBuf_.size_bytes(),
procPatch_.tag(),
procPatch_.comm()
);

View File

@ -76,7 +76,7 @@ void Foam::LUscalarMatrix::solve
(
Pstream::commsTypes::scheduled,
Pstream::masterNo(),
reinterpret_cast<const char*>(x.cdata()),
x.cdata_bytes(),
x.byteSize(),
Pstream::msgType(),
comm_
@ -111,7 +111,7 @@ void Foam::LUscalarMatrix::solve
(
Pstream::commsTypes::scheduled,
Pstream::masterNo(),
reinterpret_cast<char*>(x.data()),
x.data_bytes(),
x.byteSize(),
Pstream::msgType(),
comm_

View File

@ -1035,8 +1035,4 @@ operator^
} // End namespace Foam
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include "MatrixIO.C"
// ************************************************************************* //

View File

@ -66,6 +66,12 @@ template<class Form, class Type> class Matrix;
template<class MatrixType> class ConstMatrixBlock;
template<class MatrixType> class MatrixBlock;
template<class Form, class Type>
Istream& operator>>(Istream& is, Matrix<Form, Type>& mat);
template<class Form, class Type>
Ostream& operator<<(Ostream& os, const Matrix<Form, Type>& mat);
/*---------------------------------------------------------------------------*\
Class Matrix Declaration
@ -204,12 +210,23 @@ public:
//- be used to address into Matrix contents
inline Type* data() noexcept;
//- Return pointer to the underlying array serving as data storage,
//- reinterpreted as byte data.
// \note Only meaningful for contiguous data
inline const char* cdata_bytes() const noexcept;
//- Return pointer to the underlying array serving as data storage,
//- reinterpreted as byte data.
// \note Only meaningful for contiguous data
inline char* data_bytes() noexcept;
//- Number of contiguous bytes for the Matrix data,
//- no runtime check that the type is actually contiguous
// \note Only meaningful for contiguous data
inline std::streamsize size_bytes() const noexcept;
//- Number of contiguous bytes for the Matrix data,
//- with runtime check that the type is actually contiguous
//- runtime FatalError if type is not contiguous
std::streamsize byteSize() const;
//- Return const pointer to data in the specified row
@ -590,12 +607,20 @@ public:
//- Read Matrix from Istream, discarding contents of existing Matrix.
template<class Form, class Type>
Istream& operator>>(Istream& is, Matrix<Form, Type>& mat);
Istream& operator>>(Istream& is, Matrix<Form, Type>& mat)
{
mat.readMatrix(is);
return is;
}
//- Write Matrix to Ostream, as per Matrix::writeMatrix() with
//- default length, which is given by Detail::ListPolicy::short_length
template<class Form, class Type>
Ostream& operator<<(Ostream& os, const Matrix<Form, Type>& mat);
Ostream& operator<<(Ostream& os, const Matrix<Form, Type>& mat)
{
return mat.writeMatrix(os, Detail::ListPolicy::short_length<Type>::value);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -610,6 +635,7 @@ Ostream& operator<<(Ostream& os, const Matrix<Form, Type>& mat);
#ifdef NoRepository
#include "Matrix.C"
#include "MatrixIO.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -212,6 +212,20 @@ inline Type* Foam::Matrix<Form, Type>::data() noexcept
}
template<class Form, class Type>
inline const char* Foam::Matrix<Form, Type>::cdata_bytes() const noexcept
{
return reinterpret_cast<const char*>(v_);
}
template<class Form, class Type>
inline char* Foam::Matrix<Form, Type>::data_bytes() noexcept
{
return reinterpret_cast<char*>(v_);
}
template<class Form, class Type>
inline std::streamsize Foam::Matrix<Form, Type>::size_bytes() const noexcept
{

View File

@ -34,7 +34,7 @@ License
#include "ListPolicy.H"
#include <algorithm>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Form, class Type>
Foam::Matrix<Form, Type>::Matrix(Istream& is)
@ -43,10 +43,12 @@ Foam::Matrix<Form, Type>::Matrix(Istream& is)
nCols_(0),
v_(nullptr)
{
operator>>(is, *this);
this->readMatrix(is);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Form, class Type>
bool Foam::Matrix<Form, Type>::readMatrix(Istream& is)
{
@ -77,7 +79,7 @@ bool Foam::Matrix<Form, Type>::readMatrix(Istream& is)
Detail::readContiguous<Type>
(
is,
reinterpret_cast<char*>(v_),
this->data_bytes(),
this->size_bytes()
);
@ -159,11 +161,7 @@ Foam::Ostream& Foam::Matrix<Form, Type>::writeMatrix
if (len)
{
// write(...) includes surrounding start/end delimiters
os.write
(
reinterpret_cast<const char*>(mat.cdata()),
mat.size_bytes()
);
os.write(mat.cdata_bytes(), mat.size_bytes());
}
}
else
@ -240,19 +238,4 @@ Foam::Ostream& Foam::Matrix<Form, Type>::writeMatrix
}
template<class Form, class Type>
Foam::Istream& Foam::operator>>(Istream& is, Matrix<Form, Type>& mat)
{
mat.readMatrix(is);
return is;
}
template<class Form, class Type>
Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<Form, Type>& mat)
{
return mat.writeMatrix(os, Detail::ListPolicy::short_length<Type>::value);
}
// ************************************************************************* //

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.
@ -51,7 +51,7 @@ void Foam::processorLduInterface::send
(
commsType,
neighbProcNo(),
reinterpret_cast<const char*>(f.cdata()),
f.cdata_bytes(),
nBytes,
tag(),
comm()
@ -113,7 +113,7 @@ void Foam::processorLduInterface::receive
(
commsType,
neighbProcNo(),
reinterpret_cast<char*>(f.data()),
f.data_bytes(),
f.byteSize(),
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.
@ -114,8 +114,8 @@ void Foam::processorGAMGInterfaceField::initInterfaceMatrixUpdate
(
Pstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(),
reinterpret_cast<char*>(scalarReceiveBuf_.data()),
scalarReceiveBuf_.byteSize(),
scalarReceiveBuf_.data_bytes(),
scalarReceiveBuf_.size_bytes(),
procInterface_.tag(),
comm()
);
@ -125,8 +125,8 @@ void Foam::processorGAMGInterfaceField::initInterfaceMatrixUpdate
(
Pstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(),
reinterpret_cast<const char*>(scalarSendBuf_.cdata()),
scalarSendBuf_.byteSize(),
scalarSendBuf_.cdata_bytes(),
scalarSendBuf_.size_bytes(),
procInterface_.tag(),
comm()
);

View File

@ -77,7 +77,7 @@ void Foam::globalIndex::gather
(
commsType,
procIDs[i],
reinterpret_cast<char*>(procSlot.data()),
procSlot.data_bytes(),
procSlot.size_bytes(),
tag,
comm
@ -112,7 +112,7 @@ void Foam::globalIndex::gather
(
commsType,
procIDs[i],
reinterpret_cast<char*>(procSlot.data()),
procSlot.data_bytes(),
procSlot.size_bytes(),
tag,
comm
@ -137,7 +137,7 @@ void Foam::globalIndex::gather
(
commsType,
procIDs[0],
reinterpret_cast<const char*>(fld.cdata()),
fld.cdata_bytes(),
fld.size_bytes(),
tag,
comm
@ -167,7 +167,7 @@ void Foam::globalIndex::gather
(
commsType,
procIDs[0],
reinterpret_cast<const char*>(fld.cdata()),
fld.cdata_bytes(),
fld.size_bytes(),
tag,
comm
@ -403,7 +403,7 @@ void Foam::globalIndex::scatter
(
commsType,
procIDs[i],
reinterpret_cast<const char*>(procSlot.cdata()),
procSlot.cdata_bytes(),
procSlot.size_bytes(),
tag,
comm
@ -438,7 +438,7 @@ void Foam::globalIndex::scatter
(
commsType,
procIDs[i],
reinterpret_cast<const char*>(procSlot.cdata()),
procSlot.cdata_bytes(),
procSlot.size_bytes(),
tag,
comm
@ -463,7 +463,7 @@ void Foam::globalIndex::scatter
(
commsType,
procIDs[0],
reinterpret_cast<char*>(fld.data()),
fld.data_bytes(),
fld.size_bytes(),
tag,
comm
@ -493,7 +493,7 @@ void Foam::globalIndex::scatter
(
commsType,
procIDs[0],
reinterpret_cast<char*>(fld.data()),
fld.data_bytes(),
fld.size_bytes(),
tag,
comm

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.
@ -960,8 +960,8 @@ void Foam::mapDistributeBase::compact
(
Pstream::commsTypes::nonBlocking,
domain,
reinterpret_cast<char*>(recvFields[domain].data()),
recvFields[domain].size()*sizeof(bool),
recvFields[domain].data_bytes(),
recvFields[domain].size_bytes(),
tag,
comm_
);
@ -994,8 +994,8 @@ void Foam::mapDistributeBase::compact
(
Pstream::commsTypes::nonBlocking,
domain,
reinterpret_cast<const char*>(subField.cdata()),
subField.size()*sizeof(bool),
subField.cdata_bytes(),
subField.size_bytes(),
tag,
comm_
);
@ -1132,8 +1132,8 @@ void Foam::mapDistributeBase::compact
(
Pstream::commsTypes::nonBlocking,
domain,
reinterpret_cast<char*>(recvFields[domain].data()),
recvFields[domain].size()*sizeof(bool),
recvFields[domain].data_bytes(),
recvFields[domain].size_bytes(),
tag,
comm_
);
@ -1165,8 +1165,8 @@ void Foam::mapDistributeBase::compact
(
Pstream::commsTypes::nonBlocking,
domain,
reinterpret_cast<const char*>(subField.cdata()),
subField.size()*sizeof(bool),
subField.cdata_bytes(),
subField.size_bytes(),
tag,
comm_
);

View File

@ -535,7 +535,7 @@ void Foam::mapDistributeBase::distribute
(
Pstream::commsTypes::nonBlocking,
domain,
reinterpret_cast<const char*>(subField.cdata()),
subField.cdata_bytes(),
subField.size_bytes(),
tag,
comm
@ -558,7 +558,7 @@ void Foam::mapDistributeBase::distribute
(
Pstream::commsTypes::nonBlocking,
domain,
reinterpret_cast<char*>(recvFields[domain].data()),
recvFields[domain].data_bytes(),
recvFields[domain].size_bytes(),
tag,
comm
@ -1060,7 +1060,7 @@ void Foam::mapDistributeBase::distribute
(
Pstream::commsTypes::nonBlocking,
domain,
reinterpret_cast<const char*>(subField.cdata()),
subField.cdata_bytes(),
subField.size_bytes(),
tag,
comm
@ -1083,7 +1083,7 @@ void Foam::mapDistributeBase::distribute
(
Pstream::commsTypes::nonBlocking,
domain,
reinterpret_cast<char*>(recvFields[domain].data()),
recvFields[domain].data_bytes(),
recvFields[domain].size_bytes(),
tag,
comm

View File

@ -1052,7 +1052,7 @@ void Foam::syncTools::syncBoundaryFaceList
(
Pstream::commsTypes::nonBlocking,
procPatch.neighbProcNo(),
reinterpret_cast<char*>(fld.data()),
fld.data_bytes(),
fld.size_bytes()
);
}
@ -1078,7 +1078,7 @@ void Foam::syncTools::syncBoundaryFaceList
(
Pstream::commsTypes::nonBlocking,
procPatch.neighbProcNo(),
reinterpret_cast<const char*>(fld.cdata()),
fld.cdata_bytes(),
fld.size_bytes()
);
}
@ -1279,7 +1279,7 @@ void Foam::syncTools::syncFaceList
(
Pstream::commsTypes::nonBlocking,
procPatch.neighbProcNo(),
reinterpret_cast<char*>(recvInfo.data()),
recvInfo.data_bytes(),
recvInfo.size_bytes()
);
}
@ -1314,7 +1314,7 @@ void Foam::syncTools::syncFaceList
(
Pstream::commsTypes::nonBlocking,
procPatch.neighbProcNo(),
reinterpret_cast<const char*>(sendInfo.cdata()),
sendInfo.cdata_bytes(),
sendInfo.size_bytes()
);
}

View File

@ -138,11 +138,7 @@ void Foam::vtk::writeListParallel
if (!Pstream::master())
{
UOPstream os(Pstream::masterNo(), pBufs);
os.write
(
reinterpret_cast<const char*>(values.cdata()),
values.size_bytes()
);
os.write(values.cdata_bytes(), values.size_bytes());
}
pBufs.finishedSends();
@ -164,11 +160,7 @@ void Foam::vtk::writeListParallel
List<label> recv(sizes.localSize(proci));
UIPstream is(proci, pBufs);
is.read
(
reinterpret_cast<char*>(recv.data()),
recv.size_bytes()
);
is.read(recv.data_bytes(), recv.size_bytes());
// Write with offset
const label offsetId = procOffset.offset(proci);

View File

@ -179,11 +179,7 @@ void Foam::vtk::writeListParallel
UOPstream os(Pstream::masterNo(), pBufs);
if (is_contiguous<Type>::value)
{
os.write
(
reinterpret_cast<const char*>(values.cdata()),
values.size_bytes()
);
os.write(values.cdata_bytes(), values.size_bytes());
}
else
{
@ -208,11 +204,7 @@ void Foam::vtk::writeListParallel
if (is_contiguous<Type>::value)
{
is.read
(
reinterpret_cast<char*>(recv.data()),
recv.size_bytes()
);
is.read(recv.data_bytes(), recv.size_bytes());
}
else
{
@ -295,11 +287,7 @@ void Foam::vtk::writeListParallel
UOPstream os(Pstream::masterNo(), pBufs);
if (is_contiguous<Type>::value)
{
os.write
(
reinterpret_cast<const char*>(send.cdata()),
send.size_bytes()
);
os.write(send.cdata_bytes(), send.size_bytes());
}
else
{
@ -324,11 +312,7 @@ void Foam::vtk::writeListParallel
if (is_contiguous<Type>::value)
{
is.read
(
reinterpret_cast<char*>(recv.data()),
recv.size_bytes()
);
is.read(recv.data_bytes(), recv.size_bytes());
}
else
{
@ -361,16 +345,8 @@ void Foam::vtk::writeListsParallel
UOPstream os(Pstream::masterNo(), pBufs);
if (is_contiguous<Type>::value)
{
os.write
(
reinterpret_cast<const char*>(values1.cdata()),
values1.size_bytes()
);
os.write
(
reinterpret_cast<const char*>(values2.cdata()),
values2.size_bytes()
);
os.write(values1.cdata_bytes(), values1.size_bytes());
os.write(values2.cdata_bytes(), values2.size_bytes());
}
else
{
@ -402,11 +378,7 @@ void Foam::vtk::writeListsParallel
List<Type> recv(sizes1.localSize(proci));
if (is_contiguous<Type>::value)
{
is.read
(
reinterpret_cast<char*>(recv.data()),
recv.size_bytes()
);
is.read(recv.data_bytes(), recv.size_bytes());
}
else
{
@ -420,11 +392,7 @@ void Foam::vtk::writeListsParallel
List<Type> recv(sizes2.localSize(proci));
if (is_contiguous<Type>::value)
{
is.read
(
reinterpret_cast<char*>(recv.data()),
recv.size_bytes()
);
is.read(recv.data_bytes(), recv.size_bytes());
}
else
{

View File

@ -1058,7 +1058,7 @@ void Foam::faMesh::calcPointAreaNormals() const
(
Pstream::commsTypes::blocking,
procPatch.neighbProcNo(),
reinterpret_cast<const char*>(patchPointNormals.cdata()),
patchPointNormals.cdata_bytes(),
patchPointNormals.byteSize()
);
}
@ -1074,7 +1074,7 @@ void Foam::faMesh::calcPointAreaNormals() const
(
Pstream::commsTypes::blocking,
procPatch.neighbProcNo(),
reinterpret_cast<char*>(ngbPatchPointNormals.data()),
ngbPatchPointNormals.data_bytes(),
ngbPatchPointNormals.byteSize()
);
}

View File

@ -144,6 +144,13 @@ void Foam::calculatedProcessorFvPatchField<Type>::initEvaluate
{
if (Pstream::parRun())
{
if (!is_contiguous<Type>::value)
{
FatalErrorInFunction
<< "Invalid for non-contiguous data types"
<< abort(FatalError);
}
//this->patchInternalField(sendBuf_);
// Bypass patchInternalField since uses fvPatch addressing
{
@ -163,8 +170,8 @@ void Foam::calculatedProcessorFvPatchField<Type>::initEvaluate
(
Pstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(),
reinterpret_cast<char*>(this->data()),
this->byteSize(),
this->data_bytes(),
this->size_bytes(),
procInterface_.tag(),
procInterface_.comm()
);
@ -174,8 +181,8 @@ void Foam::calculatedProcessorFvPatchField<Type>::initEvaluate
(
Pstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(),
reinterpret_cast<const char*>(sendBuf_.cdata()),
this->byteSize(),
sendBuf_.cdata_bytes(),
sendBuf_.size_bytes(),
procInterface_.tag(),
procInterface_.comm()
);
@ -245,8 +252,8 @@ void Foam::calculatedProcessorFvPatchField<Type>::initInterfaceMatrixUpdate
(
Pstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(),
reinterpret_cast<char*>(scalarReceiveBuf_.data()),
scalarReceiveBuf_.byteSize(),
scalarReceiveBuf_.data_bytes(),
scalarReceiveBuf_.size_bytes(),
procInterface_.tag(),
procInterface_.comm()
);
@ -257,8 +264,8 @@ void Foam::calculatedProcessorFvPatchField<Type>::initInterfaceMatrixUpdate
(
Pstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(),
reinterpret_cast<const char*>(scalarSendBuf_.cdata()),
scalarSendBuf_.byteSize(),
scalarSendBuf_.cdata_bytes(),
scalarSendBuf_.size_bytes(),
procInterface_.tag(),
procInterface_.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.
@ -225,15 +225,22 @@ void Foam::processorFvPatchField<Type>::initEvaluate
&& !Pstream::floatTransfer
)
{
// Fast path. Receive into *this
if (!is_contiguous<Type>::value)
{
FatalErrorInFunction
<< "Invalid for non-contiguous data types"
<< abort(FatalError);
}
// Receive straight into *this
this->setSize(sendBuf_.size());
outstandingRecvRequest_ = UPstream::nRequests();
UIPstream::read
(
Pstream::commsTypes::nonBlocking,
procPatch_.neighbProcNo(),
reinterpret_cast<char*>(this->data()),
this->byteSize(),
this->data_bytes(),
this->size_bytes(),
procPatch_.tag(),
procPatch_.comm()
);
@ -243,8 +250,8 @@ void Foam::processorFvPatchField<Type>::initEvaluate
(
Pstream::commsTypes::nonBlocking,
procPatch_.neighbProcNo(),
reinterpret_cast<const char*>(sendBuf_.cdata()),
sendBuf_.byteSize(),
sendBuf_.cdata_bytes(),
sendBuf_.size_bytes(),
procPatch_.tag(),
procPatch_.comm()
);
@ -353,8 +360,8 @@ void Foam::processorFvPatchField<Type>::initInterfaceMatrixUpdate
(
Pstream::commsTypes::nonBlocking,
procPatch_.neighbProcNo(),
reinterpret_cast<char*>(scalarReceiveBuf_.data()),
scalarReceiveBuf_.byteSize(),
scalarReceiveBuf_.data_bytes(),
scalarReceiveBuf_.size_bytes(),
procPatch_.tag(),
procPatch_.comm()
);
@ -364,8 +371,8 @@ void Foam::processorFvPatchField<Type>::initInterfaceMatrixUpdate
(
Pstream::commsTypes::nonBlocking,
procPatch_.neighbProcNo(),
reinterpret_cast<const char*>(scalarSendBuf_.cdata()),
scalarSendBuf_.byteSize(),
scalarSendBuf_.cdata_bytes(),
scalarSendBuf_.size_bytes(),
procPatch_.tag(),
procPatch_.comm()
);
@ -503,8 +510,8 @@ void Foam::processorFvPatchField<Type>::initInterfaceMatrixUpdate
(
Pstream::commsTypes::nonBlocking,
procPatch_.neighbProcNo(),
reinterpret_cast<char*>(receiveBuf_.data()),
receiveBuf_.byteSize(),
receiveBuf_.data_bytes(),
receiveBuf_.size_bytes(),
procPatch_.tag(),
procPatch_.comm()
);
@ -514,8 +521,8 @@ void Foam::processorFvPatchField<Type>::initInterfaceMatrixUpdate
(
Pstream::commsTypes::nonBlocking,
procPatch_.neighbProcNo(),
reinterpret_cast<const char*>(sendBuf_.cdata()),
sendBuf_.byteSize(),
sendBuf_.cdata_bytes(),
sendBuf_.size_bytes(),
procPatch_.tag(),
procPatch_.comm()
);

View File

@ -39,7 +39,6 @@ License
#include "polyRemoveCell.H"
#include "objectMap.H"
#include "processorPolyPatch.H"
#include "CompactListList.H"
#include "ListOps.H"
#include "mapPolyMesh.H"
@ -584,7 +583,7 @@ void Foam::polyTopoChange::makeCellCells
// Handles removed cells. Returns number of remaining cells.
Foam::label Foam::polyTopoChange::getCellOrder
(
const CompactListList<label, labelList>& cellCellAddressing,
const CompactListList<label>& cellCellAddressing,
labelList& oldToNew
) const
{

View File

@ -68,6 +68,7 @@ SourceFiles
#include "DynamicList.H"
#include "labelList.H"
#include "CompactListList.H"
#include "pointField.H"
#include "Map.H"
#include "HashSet.H"
@ -78,7 +79,7 @@ SourceFiles
namespace Foam
{
// Forward declarations
// Forward Declarations
class face;
class primitiveMesh;
class polyMesh;
@ -91,7 +92,6 @@ class topoAction;
class objectMap;
class IOobject;
class mapPolyMesh;
template<class T, class Container> class CompactListList;
/*---------------------------------------------------------------------------*\
Class polyTopoChange Declaration
@ -294,13 +294,13 @@ class polyTopoChange
void makeCellCells
(
const label nActiveFaces,
CompactListList<label, labelList>& cellCells
CompactListList<label>& cellCells
) const;
//- Cell ordering (bandCompression). Returns number of remaining cells.
label getCellOrder
(
const CompactListList<label, labelList>& cellCellAddressing,
const CompactListList<label>& cellCellAddressing,
labelList& oldToNew
) const;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -115,8 +115,8 @@ void Foam::calculatedProcessorGAMGInterfaceField::initInterfaceMatrixUpdate
(
Pstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(),
reinterpret_cast<char*>(scalarReceiveBuf_.data()),
scalarReceiveBuf_.byteSize(),
scalarReceiveBuf_.data_bytes(),
scalarReceiveBuf_.size_bytes(),
procInterface_.tag(),
comm()
);
@ -126,8 +126,8 @@ void Foam::calculatedProcessorGAMGInterfaceField::initInterfaceMatrixUpdate
(
Pstream::commsTypes::nonBlocking,
procInterface_.neighbProcNo(),
reinterpret_cast<const char*>(scalarSendBuf_.cdata()),
scalarSendBuf_.byteSize(),
scalarSendBuf_.cdata_bytes(),
scalarSendBuf_.size_bytes(),
procInterface_.tag(),
comm()
);