Merge branch 'develop' into MPI

This commit is contained in:
Hamidreza Norouzi 2024-04-20 06:16:28 -07:00
commit 1321e6340e
6 changed files with 100 additions and 7 deletions

View File

@ -28,7 +28,7 @@ Licence:
#include "span.hpp" #include "span.hpp"
#include "iOstream.hpp" #include "iOstream.hpp"
#include "iIstream.hpp" #include "iIstream.hpp"
#include "createDataIO.hpp" #include "dataIO.hpp"
#include "pFlowProcessors.hpp" #include "pFlowProcessors.hpp"
namespace pFlow namespace pFlow
@ -82,7 +82,7 @@ bool writeSpan(
const IOPattern& iop) const IOPattern& iop)
{ {
auto ioPtr = createDataIO<T>(pFlowProcessors().localRunTypeName(), iop); auto ioPtr = dataIO<T>::create(iop);
if(!ioPtr) if(!ioPtr)
{ {
@ -141,7 +141,7 @@ bool readStdVector
const IOPattern& iop const IOPattern& iop
) )
{ {
auto ioPtr = createDataIO<T>(pFlowProcessors().localRunTypeName(), iop); auto ioPtr = dataIO<T>::create(iop);
if(!ioPtr) if(!ioPtr)
{ {

View File

@ -258,3 +258,32 @@ bool pFlow::dataIO<T>::readData
} }
} }
template<typename T>
pFlow::uniquePtr<pFlow::dataIO<T>>
pFlow::dataIO<T>::create(const IOPattern& iop)
{
word dataIOType = angleBracketsNames2(
"dataIO",
getTypeName<T>(),
pFlowProcessors().localRunTypeName());
if(IOPatternvCtorSelector_.search(dataIOType))
{
return IOPatternvCtorSelector_[dataIOType](iop);
}
else
{
printKeys
(
fatalError << "Ctor Selector "<< dataIOType << " does not exist. \n"
<<"Avaiable ones are: \n\n"
,
IOPatternvCtorSelector_
);
fatalExit;
}
return nullptr;
}

View File

@ -28,6 +28,8 @@ Licence:
#include "IOPattern.hpp" #include "IOPattern.hpp"
#include "iOstream.hpp" #include "iOstream.hpp"
#include "iIstream.hpp" #include "iIstream.hpp"
#include "virtualConstructor.hpp"
#include "pFlowProcessors.hpp"
@ -98,6 +100,14 @@ public:
virtual ~dataIO() = default; virtual ~dataIO() = default;
create_vCtor
(
dataIO,
IOPattern,
(const IOPattern& iop),
(iop)
);
/// Write data to the end of file from all processors. /// Write data to the end of file from all processors.
/// This method should be called from all processors. /// This method should be called from all processors.
bool writeData(iOstream& os, span<T> data); bool writeData(iOstream& os, span<T> data);
@ -106,6 +116,9 @@ public:
iIstream& is, iIstream& is,
std::vector<T>& data); std::vector<T>& data);
static
uniquePtr<dataIO> create(const IOPattern& iop);
}; };
template<typename T> template<typename T>
@ -123,6 +136,6 @@ iOstream& operator<<(iOstream& os, const span<T>& s)
} }
#include "dataIOTemplate.cpp" #include "dataIO.cpp"
#endif #endif

View File

@ -30,6 +30,12 @@ class dataIORegular
: :
public dataIO<T> public dataIO<T>
{ {
public:
using DataIORegularType = dataIORegular<T>;
using DataIOType = dataIO<T>;
protected: protected:
bool gatherData(span<T> data ) override bool gatherData(span<T> data ) override
@ -41,7 +47,7 @@ protected:
public: public:
TypeInfo("dataIO<regular>"); TypeInfoTemplate111("dataIO",T,"regular");
dataIORegular(const IOPattern& iop) dataIORegular(const IOPattern& iop)
: :
@ -58,6 +64,13 @@ public:
~dataIORegular() = default; ~dataIORegular() = default;
add_vCtor
(
DataIOType,
DataIORegularType,
IOPattern
);
}; };

View File

@ -0,0 +1,38 @@
#include "types.hpp"
#include "dataIO.hpp"
#include "dataIORegular.hpp"
template class pFlow::dataIO<pFlow::uint8>;
template class pFlow::dataIORegular<pFlow::uint8>;
template class pFlow::dataIO<pFlow::int8>;
template class pFlow::dataIORegular<pFlow::int8>;
template class pFlow::dataIO<pFlow::int32>;
template class pFlow::dataIORegular<pFlow::int32>;
template class pFlow::dataIO<pFlow::int64>;
template class pFlow::dataIORegular<pFlow::int64>;
template class pFlow::dataIO<pFlow::uint32>;
template class pFlow::dataIORegular<pFlow::uint32>;
template class pFlow::dataIO<pFlow::uint64>;
template class pFlow::dataIORegular<pFlow::uint64>;
template class pFlow::dataIO<pFlow::real>;
template class pFlow::dataIORegular<pFlow::real>;
template class pFlow::dataIO<pFlow::realx3>;
template class pFlow::dataIORegular<pFlow::realx3>;
template class pFlow::dataIO<pFlow::realx4>;
template class pFlow::dataIORegular<pFlow::realx4>;
template class pFlow::dataIO<pFlow::word>;
template class pFlow::dataIORegular<pFlow::word>;
/*template class pFlow::dataIO<char>;
template class pFlow::dataIORegular<char>;*/