diff --git a/CMakeLists.txt b/CMakeLists.txt index e411fe79..3ce683a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,7 +74,7 @@ add_subdirectory(src) #add_subdirectory(solvers) -add_subdirectory(utilities) +#add_subdirectory(utilities) #add_subdirectory(DEMSystems) add_subdirectory(testIO) diff --git a/cmake/bashrc b/cmake/bashrc index 823f276d..32c92d87 100644 --- a/cmake/bashrc +++ b/cmake/bashrc @@ -29,7 +29,7 @@ export PATH="$pFlow_BIN_DIR:$PATH" export LD_LIBRARY_PATH="$pFlow_LIB_DIR:$LD_LIBRARY_PATH" -export LD_LIBRARY_PATH="$Zoltan_DIR/build/lib:$LD_LIBRARY_PATH" +export LD_LIBRARY_PATH="$Zoltan_DIR/lib:$LD_LIBRARY_PATH" #------------------------------------------------------------------------------ diff --git a/src/phasicFlow/CMakeLists.txt b/src/phasicFlow/CMakeLists.txt index 021ad360..65c91b59 100644 --- a/src/phasicFlow/CMakeLists.txt +++ b/src/phasicFlow/CMakeLists.txt @@ -6,6 +6,10 @@ types/types.cpp globals/error.cpp +processors/processors.cpp +processors/localProcessors.cpp +processors/pFlowProcessors.cpp + streams/token/tokenIO.cpp streams/token/token.cpp streams/iStream/IOstream.cpp @@ -20,14 +24,10 @@ streams/TStream/oTstream.cpp streams/Fstream/iFstream.cpp streams/Fstream/oFstream.cpp streams/Fstream/fileStream.cpp -streams/dataIO/dataIO.cpp -streams/dataIO/dataIONoMPI.cpp streams/streams.cpp fileSystem/fileSystem.cpp -processors/processors.cpp - dictionary/dictionary.cpp dictionary/fileDictionary.cpp dictionary/entry/iEntry.cpp @@ -39,6 +39,9 @@ containers/Field/Fields.cpp containers/List/anyList/anyList.cpp containers/pointField/pointFields.cpp +#setFieldList/setFieldList.cpp +#setFieldList/setFieldEntry.cpp + Timer/Timer.cpp Timer/Timers.cpp @@ -64,21 +67,58 @@ structuredData/plane/plane.cpp structuredData/domain/domain.cpp structuredData/domain/simulationDomain.cpp structuredData/domain/regularSimulationDomain.cpp -structuredData/pointStructure/boundaryList.cpp structuredData/pointStructure/internalPoints.cpp structuredData/pointStructure/pointStructure.cpp structuredData/boundaries/boundaryBase/boundaryBase.cpp structuredData/boundaries/boundaryExit/boundaryExit.cpp +structuredData/pointStructure/boundaryList.cpp + +commandLine/commandLine.cpp ) set(link_libs) -if(MPI_FOUND) - set(link_libs Kokkos::kokkos tbb PRIVATE MPI::MPI_CXX) +set(link_libs Kokkos::kokkos tbb) + + + +if(pFlow_Build_MPI) + + set(Zoltan_Install_DIR) + if(DEFINED ENV{Zoltan_DIR}) + set(Zoltan_Install_DIR $ENV{Zoltan_DIR}) + else() + set(Zoltan_Install_DIR $ENV{HOME}/PhasicFlow/Zoltan) + endif() + message(STATUS "Zoltan install directory is ${Zoltan_Install_DIR}") + + set(ZOLTAN_PREFIX "${Zoltan_Install_DIR}" CACHE STRING "Zoltan install directory") + + find_path(ZOLTAN_INCLUDE_DIR zoltan.h PATHS "${ZOLTAN_PREFIX}/include") + + message(STATUS "Zoltan include path: ${ZOLTAN_INCLUDE_DIR}") + + find_library(ZOLTAN_LIBRARY zoltan PATHS "${ZOLTAN_PREFIX}/lib") + message(STATUS "Zoltan lib path: ${ZOLTAN_LIBRARY}") + + list(APPEND SourceFiles + MPIParallelization/partitioning.cpp + MPIParallelization/rcb1DPartitioning.cpp + MPIParallelization/domain/MPISimulationDomain.cpp + #MPIParallelization/dataIOMPI.cpp + MPIParallelization/procCommunication.cpp + MPIParallelization/boundaryProcessor.cpp + MPIParallelization/scatteredMasterDistributeChar.cpp + ) + + list(APPEND link_libs MPI::MPI_CXX ${ZOLTAN_LIBRARY} -lm ) + pFlow_add_library_install(phasicFlow SourceFiles link_libs) + target_include_directories(phasicFlow PUBLIC ./globals ${ZOLTAN_INCLUDE_DIR}) + else() - set(link_libs Kokkos::kokkos tbb) + pFlow_add_library_install(phasicFlow SourceFiles link_libs) + target_include_directories(phasicFlow PUBLIC ./globals) endif() -pFlow_add_library_install(phasicFlow SourceFiles link_libs) -target_include_directories(phasicFlow PUBLIC ./globals) + diff --git a/src/phasicFlow/commandLine/commandLine.cpp b/src/phasicFlow/commandLine/commandLine.cpp index d2002570..f9d82161 100644 --- a/src/phasicFlow/commandLine/commandLine.cpp +++ b/src/phasicFlow/commandLine/commandLine.cpp @@ -38,10 +38,10 @@ pFlow::commandLine::commandLine(word appName, word disptn) CLI::App::add_flag_callback( "--description", [disptn, appName]() { - output<<"\n"<configurable(false); diff --git a/src/phasicFlow/containers/Field/Field.cpp b/src/phasicFlow/containers/Field/Field.cpp index 4f895a98..93b72c20 100644 --- a/src/phasicFlow/containers/Field/Field.cpp +++ b/src/phasicFlow/containers/Field/Field.cpp @@ -185,12 +185,14 @@ template class VectorField, class T, class PropType> bool pFlow::Field::read ( iIstream& is, - IOPattern::IOType iotype + const IOPattern& iop ) { - bool tokenFound; - tokenFound = is.findToken(fieldKey_); + bool tokenFound = true; + + if(iop.thisProcReadData()) + tokenFound = is.findToken(fieldKey_); if( !tokenFound ) { @@ -199,12 +201,13 @@ bool pFlow::Field::read return false; } - if( !VectorType::read(is, iotype) ) + if( !VectorType::read(is, iop) ) { ioErrorInFile(is.name(), is.lineNumber())<< "error in reading field data from field "<< this->name()<::read template class VectorField, class T, class PropType> bool pFlow::Field::write( iOstream& os, - IOPattern::IOType iotype)const + const IOPattern& iop)const { os.writeWordKeyword(fieldKey_)< bool write( iOstream& os, - IOPattern::IOType iotype, + const IOPattern& iop, const HostMask& mask)const { @@ -209,7 +209,7 @@ public: if(!os.check(FUNCTION_NAME))return false; - if(!VectorType::write(os, iotype)) return false; + if(!VectorType::write(os, iop)) return false; os.endEntry(); if(!os.check(FUNCTION_NAME))return false; diff --git a/src/phasicFlow/containers/Vector/Vector.cpp b/src/phasicFlow/containers/Vector/Vector.cpp index 9904d4a3..e17ce7a8 100644 --- a/src/phasicFlow/containers/Vector/Vector.cpp +++ b/src/phasicFlow/containers/Vector/Vector.cpp @@ -23,10 +23,10 @@ template bool pFlow::Vector::readVector ( iIstream& is, - IOPattern::IOType iotype + const IOPattern& iop ) { - return readStdVector(is, vectorField(), iotype); + return readStdVector(is, vectorField(), iop); } @@ -34,10 +34,10 @@ template bool pFlow::Vector::writeVector ( iOstream& os, - IOPattern::IOType iotype + const IOPattern& iop ) const { - return writeStdVector(os, vectorField(), iotype); + return writeStdVector(os, vectorField(), iop); } /*template diff --git a/src/phasicFlow/containers/Vector/Vector.hpp b/src/phasicFlow/containers/Vector/Vector.hpp index 05275ce5..acdbee16 100644 --- a/src/phasicFlow/containers/Vector/Vector.hpp +++ b/src/phasicFlow/containers/Vector/Vector.hpp @@ -334,7 +334,7 @@ public: inline auto getSpan()const { - return span(this->data(), this->size()); + return span(const_cast(this->data()), this->size()); } static constexpr bool isHostAccessible() @@ -357,19 +357,19 @@ public: inline VectorType operator -()const; /// Read vector (assume ASCII in input) - bool readVector(iIstream& is, IOPattern::IOType iotype); + bool readVector(iIstream& is, const IOPattern& iop); /// write vector - bool writeVector(iOstream& os, IOPattern::IOType iotype) const; + bool writeVector(iOstream& os, const IOPattern& iop) const; - bool read(iIstream& is, IOPattern::IOType iotype) + bool read(iIstream& is, const IOPattern& iop) { - return readVector(is, iotype); + return readVector(is, iop); } - bool write(iOstream& os, IOPattern::IOType iotype)const + bool write(iOstream& os, const IOPattern& iop)const { - return writeVector(os, iotype); + return writeVector(os, iop); } }; diff --git a/src/phasicFlow/containers/Vector/stdVectorHelper.hpp b/src/phasicFlow/containers/Vector/stdVectorHelper.hpp index 9c67a4ce..584d07c6 100644 --- a/src/phasicFlow/containers/Vector/stdVectorHelper.hpp +++ b/src/phasicFlow/containers/Vector/stdVectorHelper.hpp @@ -28,8 +28,8 @@ Licence: #include "span.hpp" #include "iOstream.hpp" #include "iIstream.hpp" -#include "dataIO.hpp" - +#include "createDataIO.hpp" +#include "pFlowProcessors.hpp" namespace pFlow { @@ -54,11 +54,11 @@ inline bool writeSpan( iOstream& os, const span& sp, - IOPattern::IOType iotype) + const IOPattern& iop) { - auto ioPtr = dataIO::create(iotype, IOPattern::exeMode()); - + auto ioPtr = createDataIO(pFlowProcessors().localRunTypeName(), iop); + if(!ioPtr) { fatalErrorInFunction; @@ -73,32 +73,27 @@ bool writeSpan( return true; } - template bool writeStdVector ( iOstream& os, const std::vector& vec, - IOPattern::IOType iotype + const IOPattern& iop ) { - span sp( const_cast(vec.data()), vec.size()); - - return writeSpan(os, sp, iotype); + auto sp = makeSpan(vec); + return writeSpan(os, sp, iop); } - - - template bool readStdVector ( iIstream& is, std::vector& vec, - IOPattern::IOType iotype + const IOPattern& iop ) { - auto ioPtr = dataIO::create(iotype, IOPattern::exeMode()); + auto ioPtr = createDataIO(pFlowProcessors().localRunTypeName(), iop); if(!ioPtr) { diff --git a/src/phasicFlow/containers/VectorHD/VectorSingle.cpp b/src/phasicFlow/containers/VectorHD/VectorSingle.cpp index c2b85e79..18b053e6 100644 --- a/src/phasicFlow/containers/VectorHD/VectorSingle.cpp +++ b/src/phasicFlow/containers/VectorHD/VectorSingle.cpp @@ -415,7 +415,7 @@ template INLINE_FUNCTION_H auto pFlow::VectorSingle::getSpan()const { - return span(view_.data(), this->size()); + return span(const_cast(view_.data()), this->size()); } template diff --git a/src/phasicFlow/containers/VectorHD/VectorSingle.hpp b/src/phasicFlow/containers/VectorHD/VectorSingle.hpp index 7a2ea557..52f3e103 100644 --- a/src/phasicFlow/containers/VectorHD/VectorSingle.hpp +++ b/src/phasicFlow/containers/VectorHD/VectorSingle.hpp @@ -370,10 +370,10 @@ public: /// Read vector from stream (ASCII) FUNCTION_H - bool read(iIstream& is, IOPattern::IOType iotype) + bool read(iIstream& is, const IOPattern& iop) { std::vector vecFromFile; - if(! readStdVector(is, vecFromFile, iotype)) return false; + if(! readStdVector(is, vecFromFile, iop)) return false; this->assign(vecFromFile); @@ -382,18 +382,18 @@ public: /// Write the vector to os FUNCTION_H - bool write(iOstream& os, IOPattern::IOType iotype)const + bool write(iOstream& os, const IOPattern& iop)const { auto hVec = hostVector(); auto sp = span( const_cast(hVec.data()), hVec.size()); - return writeSpan(os, sp, iotype); + return writeSpan(os, sp, iop); } template FUNCTION_H - bool write(iOstream& os, IOPattern::IOType iotype, const HostMask& mask)const + bool write(iOstream& os, const IOPattern& iop, const HostMask& mask)const { auto hVec = hostVector(); @@ -413,7 +413,7 @@ public: auto sp = span( finalField.data(), finalField.size()); - return writeSpan(os, sp, iotype); + return writeSpan(os, sp, iop); } diff --git a/src/phasicFlow/containers/span/span.hpp b/src/phasicFlow/containers/span/span.hpp index 8947c039..fc625d86 100644 --- a/src/phasicFlow/containers/span/span.hpp +++ b/src/phasicFlow/containers/span/span.hpp @@ -192,6 +192,42 @@ iOstream& operator<<(iOstream& os, const span& s) return os; } +template class Container> +span makeSpan(Container& container) +{ + return span(container.data(), container.size()); +} + +template class Container> +span makeSpan(const Container& container) +{ + return span( + const_cast(container.data()), + container.size()); +} + + +template +inline +span charSpan(span s) +{ + auto el = sizeof(T); + return span( + reinterpret_cast(s.data()), + s.size()*el); +} + +template +inline +span charSpan(span s) +{ + auto el = sizeof(T); + return span( + reinterpret_cast(s.data()), + s.size()*el); +} + + } // pFlow diff --git a/src/phasicFlow/demComponent/demComponent.cpp b/src/phasicFlow/demComponent/demComponent.cpp index 4b76b245..0307b333 100644 --- a/src/phasicFlow/demComponent/demComponent.cpp +++ b/src/phasicFlow/demComponent/demComponent.cpp @@ -19,8 +19,8 @@ Licence: -----------------------------------------------------------------------------*/ #include "demComponent.hpp" - - +#include "systemControl.hpp" +#include "Time.hpp" pFlow::demComponent::demComponent(const word& name, systemControl& control) : @@ -28,4 +28,14 @@ pFlow::demComponent::demComponent(const word& name, systemControl& control) control_(control), time_(control.time()), timers_(name, &control.timers()) -{} \ No newline at end of file +{} + +pFlow::real pFlow::demComponent::dt()const +{ + return time_.dt(); +} + +pFlow::real pFlow::demComponent::currentTime()const +{ + return time_.currentTime(); +} diff --git a/src/phasicFlow/demComponent/demComponent.hpp b/src/phasicFlow/demComponent/demComponent.hpp index d6ca633c..fb229ae9 100644 --- a/src/phasicFlow/demComponent/demComponent.hpp +++ b/src/phasicFlow/demComponent/demComponent.hpp @@ -21,13 +21,15 @@ Licence: #ifndef __demComponent_hpp__ #define __demComponent_hpp__ -#include "systemControl.hpp" -#include "Time.hpp" - +#include "types.hpp" +#include "typeInfo.hpp" +#include "Timers.hpp" namespace pFlow { +class systemControl; +class Time; /** * A base class for every main component of DEM system. * @@ -96,19 +98,11 @@ public: } /// Time step of integration - inline - real dt()const - { - return time_.dt(); - } - + real dt()const; + /// Current simulation time - inline - real currentTime()const - { - return time_.currentTime(); - } - + real currentTime()const; + inline const auto& time()const { diff --git a/src/phasicFlow/dictionary/dictionary.hpp b/src/phasicFlow/dictionary/dictionary.hpp index f6b75a55..db77733c 100644 --- a/src/phasicFlow/dictionary/dictionary.hpp +++ b/src/phasicFlow/dictionary/dictionary.hpp @@ -218,6 +218,9 @@ public: template bool addOrKeep(const word& keyword, const T& v); + template + bool addOrReplace(const word& keyword, const T& v); + void clear(); /// pointer to a subdictionary @@ -384,8 +387,20 @@ T dictionary::getValOrSet } } +template +inline bool dictionary::addOrReplace +( + const word &keyword, + const T &v +) +{ + uniquePtr ptr = makeUnique(keyword, *this ,v); + return addPtr(keyword, ptr, false); +} + + + } // pFlow - #endif // __dictionary_hpp__ diff --git a/src/phasicFlow/dictionary/fileDictionary.cpp b/src/phasicFlow/dictionary/fileDictionary.cpp index e550311f..a8abd443 100644 --- a/src/phasicFlow/dictionary/fileDictionary.cpp +++ b/src/phasicFlow/dictionary/fileDictionary.cpp @@ -1,22 +1,50 @@ #include "fileDictionary.hpp" -#include "IOPattern.hpp" -pFlow::fileDictionary::fileDictionary(const word &keyword) +pFlow::fileDictionary::fileDictionary +( + const objectFile & of, + repository* owner +) : - dictionary(keyword, true) + IOobject + ( + of, + IOPattern::IOPattern::AllProcessorsSimilar, + owner + ), + dictionary + ( + of.name(), + true + ) { + dictionary::name_ = IOobject::path().wordPath(); + if(!IOobject::read()) + { + fatalErrorInFunction<< + "Error in reading from dictionary "<< globalName()<>> Fatal error in phasicFlow\n"; - errorStream<<" Function "<< Red_Text(fnName) << " has not implmented yet!\n" << - " Function definition is in source file "<< Red_Text(fileName) << - " at line "<< Red_Text(lineNumber) <<'\n'; + errorStream<<" Function "<< Red_Text(fnName) << " has not been implemented yet!\n" << + " File "<< Yellow_Text(fileName) << + " at line "<< Yellow_Text(lineNumber) <<'\n'; return errorStream; } diff --git a/src/phasicFlow/processors/localProcessors.cpp b/src/phasicFlow/processors/localProcessors.cpp new file mode 100644 index 00000000..0dc7e658 --- /dev/null +++ b/src/phasicFlow/processors/localProcessors.cpp @@ -0,0 +1,117 @@ +#include "localProcessors.hpp" + +pFlow::localProcessors::localProcessors(const word &name) +: + processors(), + localSize_(processors::globalSize()), + localRank_(processors::globalRank()), + name_(name) +{ +#ifdef pFlow_Build_MPI + parrentCommunicator_ = pFlow::MPI::CommWorld; + localCommunicator_ = pFlow::MPI::CommWorld; +#endif + +} + +pFlow::localProcessors::localProcessors +( + const word &name, + const std::vector &ranks +) +: + processors(), + name_(name) +{ +#ifdef pFlow_Build_MPI + parrentCommunicator_ = pFlow::MPI::CommWorld; + + if(ranks.size()> this->globalSize() ) + { + fatalErrorInFunction<< + "the size of ranks is larger than parrent communicator size "< 1 ) + { + fatalErrorInFunction<< + "rank size for processors should not be greater than 1."; + fatalExit; + } + localSize_ = processors::globalSize(); + localRank_ = processors::globalRank(); + +#endif +} + +#ifdef pFlow_Build_MPI + +pFlow::localProcessors::localProcessors +( + pFlow::MPI::Comm parrentComm, + const word &name, + const std::vector &ranks +) +: + processors(), + name_(name) +{ + parrentCommunicator_ = parrentComm; + + int parSize; + + MPI_Comm_size(parrentCommunicator_, &parSize); + + if(ranks.size()> parSize ) + { + fatalErrorInFunction<< + "the size of ranks is larger than parrent communicator size "<& ranks); + + #ifdef pFlow_Build_MPI + localProcessors( + pFlow::MPI::Comm parrentComm, + const word& name, + const std::vector& ranks); + #endif + + // - Access + + /// @brief return name of the local communicator + inline + const auto& name()const + { + return name_; + } + + inline + auto localRank()const + { + return localRank_; + } + + inline + auto localSize()const + { + return localSize_; + } + + // - Methods + + inline + bool localMaster()const + { + return localRank_ == localMasterNo(); + } + + inline + int localMasterNo()const + { + return 0; + } + + inline + bool localParallel()const + { + return localSize_>1; + } + + inline + const char* localRunTypeName() + { + if(localParallel()) + return "MPI"; + else + return "regular"; + } + + inline + bool isThisActive()const + { + return isPartOfLocal_; + } + + #ifdef pFlow_Build_MPI + inline + auto parrentCommunicator()const + { + return parrentCommunicator_; + } + + inline + auto localCommunicator()const + { + return localCommunicator_; + } + #endif + +}; + +} + +#endif \ No newline at end of file diff --git a/src/phasicFlow/processors/pFlowProcessors.cpp b/src/phasicFlow/processors/pFlowProcessors.cpp new file mode 100644 index 00000000..73201b50 --- /dev/null +++ b/src/phasicFlow/processors/pFlowProcessors.cpp @@ -0,0 +1,18 @@ +#include "pFlowProcessors.hpp" + +static pFlow::localProcessors pFlowProcessors__{"pFlowProcessors"}; + +pFlow::localProcessors& pFlow::pFlowProcessors() +{ + return pFlowProcessors__; +} + +void pFlow::initialize_pFlowProcessors() +{ + pFlowProcessors__ = localProcessors("pFlowProcessors"); +} + +void pFlow::initialize_pFlowProcessors(const std::vector& ranks) +{ + pFlowProcessors__ = localProcessors("pFlowProcessors", ranks); +} \ No newline at end of file diff --git a/src/phasicFlow/processors/pFlowProcessors.hpp b/src/phasicFlow/processors/pFlowProcessors.hpp new file mode 100644 index 00000000..12ae1942 --- /dev/null +++ b/src/phasicFlow/processors/pFlowProcessors.hpp @@ -0,0 +1,14 @@ + +#include "localProcessors.hpp" + + +namespace pFlow +{ + +localProcessors& pFlowProcessors(); + +void initialize_pFlowProcessors(); + +void initialize_pFlowProcessors(const std::vector& ranks); + +} \ No newline at end of file diff --git a/src/phasicFlow/processors/processors.cpp b/src/phasicFlow/processors/processors.cpp index c9d0d380..75780bc6 100644 --- a/src/phasicFlow/processors/processors.cpp +++ b/src/phasicFlow/processors/processors.cpp @@ -21,7 +21,7 @@ Licence: #include "phasicFlowConfig.H" #ifdef pFlow_Build_MPI - #include + #include "mpiCommunication.hpp" #endif // from PhasicFlow @@ -29,7 +29,15 @@ Licence: #include "processors.hpp" #include "streams.hpp" +static int numVarsInitialized__ = 0; +#ifdef pFlow_Build_MPI + + pFlow::MPI::DataType pFlow::MPI::realx3Type__; + pFlow::MPI::DataType pFlow::MPI::realx4Type__; + pFlow::MPI::DataType pFlow::MPI::int32x3Type__; + +#endif void pFlow::processors::initProcessors(int argc, char *argv[]) { @@ -40,17 +48,31 @@ void pFlow::processors::initProcessors(int argc, char *argv[]) CheckMPI(MPI_Init(&argc, &argv), true); isSelfInitialized_ = true; - processors::globalSize_ = MPI::COMM_WORLD.Get_size(); - processors::globalRank_ = MPI::COMM_WORLD.Get_rank(); + argc_ = argc; + argv_ = argv; + + MPI_Comm_rank(MPI_COMM_WORLD, &processors::globalRank_); + MPI_Comm_size(MPI_COMM_WORLD, &processors::globalSize_); + - if(processors::isParallel()) + if(processors::globalParallel()) { pFlow::pOutput.activatePrefix(); pFlow::pOutput.setPrefixNum(processors::globalRank_); } - pFlow::mOutput.setMasterSlave(processors::isMaster()); - pFlow::errReport.setMasterSlave(processors::isMaster()); + pFlow::mOutput.setMasterSlave(processors::globalMaster()); + pFlow::errReport.setMasterSlave(processors::globalMaster()); + + MPI_Type_contiguous(3, pFlow::MPI::Type(), &pFlow::MPI::realx3Type__); + MPI_Type_commit(&pFlow::MPI::realx3Type__); + + MPI_Type_contiguous(4, pFlow::MPI::Type(), &pFlow::MPI::realx4Type__); + MPI_Type_commit(&pFlow::MPI::realx3Type__); + + MPI_Type_contiguous(3, pFlow::MPI::Type(), &pFlow::MPI::int32x3Type__); + MPI_Type_commit(&pFlow::MPI::int32x3Type__); + } #else @@ -64,6 +86,9 @@ void pFlow::processors::finalizeProcessors() #ifdef pFlow_Build_MPI if(isSelfInitialized_ && !isFinalized()) { + MPI::TypeFree(&pFlow::MPI::realx3Type__); + MPI::TypeFree(&pFlow::MPI::realx4Type__); + MPI::TypeFree(&pFlow::MPI::int32x3Type__); CheckMPI(MPI_Finalize(), true); } #else @@ -75,7 +100,7 @@ pFlow::processors::processors() { #ifdef pFlow_Build_MPI - if(isParallel() && !isInitialized()) + if(globalParallel() && !isInitialized()) { fatalErrorInFunction<< "MPI communication is not initialized yet!"<1; } static inline - const char* runTypeName() + const char* globalRunTypeName() { - if(isParallel()) + if(globalParallel()) { return "MPI"; } @@ -117,9 +122,9 @@ public: /// Is this processor the master processor? static inline - bool isMaster() + bool globalMaster() { - return processors::globalRank() == processors::masterNo(); + return processors::globalRank() == processors::globalMasterNo(); } /// Global size of processors @@ -136,10 +141,30 @@ public: return globalRank_; } + static inline + int argc() + { + return argc_; + } + + static inline + char** argv() + { + return argv_; + } + /// Abort MPI run or regular run static void abort(int error); +/*#ifdef pFlow_Build_MPI + static inline + auto worldCommunicator() + { + return pFlow::MPI::CommWorld; + } +#endif*/ + }; //processors diff --git a/src/phasicFlow/repository/IOobject/IOPattern.cpp b/src/phasicFlow/repository/IOobject/IOPattern.cpp index e5264175..bc240534 100644 --- a/src/phasicFlow/repository/IOobject/IOPattern.cpp +++ b/src/phasicFlow/repository/IOobject/IOPattern.cpp @@ -25,14 +25,11 @@ pFlow::IOPattern::IOPattern( IOType iotype) ioType_(iotype), globalSize_(processors::globalSize()), globalRank_(processors::globalRank()), - isMaster_(processors::isMaster()), - isParallel_(processors::isParallel()) + isMaster_(processors::globalMaster()), + isParallel_(processors::globalParallel()) {} pFlow::word pFlow::IOPattern::exeMode() { - if(processors::isParallel()) - return word("MPI"); - else - return word("NoMPI"); + return processors::globalRunTypeName(); } \ No newline at end of file diff --git a/src/phasicFlow/repository/IOobject/IOPattern.hpp b/src/phasicFlow/repository/IOobject/IOPattern.hpp index 092aae0f..9f8f3124 100644 --- a/src/phasicFlow/repository/IOobject/IOPattern.hpp +++ b/src/phasicFlow/repository/IOobject/IOPattern.hpp @@ -54,13 +54,13 @@ public: MasterProcessorOnly = 0, AllProcessorsSimilar = 1, MasterProcessorDistribute = 4, - AllProcessorsDifferent = 8 // this is used for << and >> operators for + AllProcessorsDifferent = 8 // this is used for << and >> operators for // standard input and output streams }; protected: - IOType ioType_; + IOType ioType_; int globalSize_ = 1; @@ -116,11 +116,18 @@ public: return isParallel_; } + inline + bool thisCallRead()const + { + if(isMasterProcessorOnly() && !isMaster())return false; + return true; + } + inline bool thisProcReadData()const { if(isMasterProcessorOnly() && !isMaster())return false; - if(isMasterProcessorDistribute() && !isMaster()) return false; + if(isMasterProcessorDistribute()&& !isMaster())return false; return true; } @@ -128,6 +135,7 @@ public: bool thisProcWriteData()const { if(isAllProcessorsDifferent()) return true; + if(isMasterProcessorDistribute())return true; return isMaster(); } diff --git a/src/phasicFlow/repository/IOobject/IOfileHeader.cpp b/src/phasicFlow/repository/IOobject/IOfileHeader.cpp index 3015dc2a..15fda4fb 100644 --- a/src/phasicFlow/repository/IOobject/IOfileHeader.cpp +++ b/src/phasicFlow/repository/IOobject/IOfileHeader.cpp @@ -17,7 +17,7 @@ Licence: implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -----------------------------------------------------------------------------*/ -#include "processors.hpp" + #include "IOfileHeader.hpp" #include "repository.hpp" @@ -31,13 +31,11 @@ pFlow::uniquePtr pFlow::IOfileHeader::inStream()const pFlow::uniquePtr pFlow::IOfileHeader::outStream()const { - - auto osPtr = makeUnique(path(), outFileBinary()); - if(osPtr && owner_) + if(osPtr && owner()) { - auto outPrecision = owner_->outFilePrecision(); + auto outPrecision = owner()->outFilePrecision(); osPtr->precision(outPrecision); } @@ -46,21 +44,19 @@ pFlow::uniquePtr pFlow::IOfileHeader::outStream()const pFlow::IOfileHeader::IOfileHeader ( - const objectFile& objf, - const repository* owner + const objectFile& objf ) : - objectFile(objf), - owner_(owner) + objectFile(objf) {} pFlow::fileSystem pFlow::IOfileHeader::path() const { fileSystem f; - if( owner_ ) + if( owner() ) { - f = owner_->path()/localPath(); + f = owner()->path()/localPath(); }else { @@ -72,8 +68,8 @@ pFlow::fileSystem pFlow::IOfileHeader::path() const bool pFlow::IOfileHeader::outFileBinary()const { - if(owner_) - return owner_->outFileBinary(); + if(owner()) + return owner()->outFileBinary(); else return false; } @@ -137,7 +133,6 @@ bool pFlow::IOfileHeader::writeHeader()const { if( !this->readWriteHeader() ) return false; - if( !processors::isMaster() ) return false; if( !implyWrite() ) return false; return true; @@ -185,15 +180,15 @@ bool pFlow::IOfileHeader::writeHeader(iOstream& os, bool forceWrite) const bool pFlow::IOfileHeader::readHeader()const { if( !implyRead())return false; - if( !this->readWriteHeader() ) return false; - return ioPattern().thisProcReadHeader(); + if( !this->readWriteHeader() ) return false; + return true; } bool pFlow::IOfileHeader::readHeader(iIstream& is, bool silent) { - - if(!readHeader()) return true; + if(!readHeader()) return true; + if( !is.findTokenAndNextSilent("objectName", objectName_) ) { if(!silent) @@ -231,18 +226,6 @@ bool pFlow::IOfileHeader::readHeader(iIstream& is, bool silent) return true; } -bool pFlow::IOfileHeader::writeData()const -{ - if(!implyWrite())return false; - return ioPattern().thisProcWriteData(); -} - -bool pFlow::IOfileHeader::readData()const -{ - if(!implyRead())return false; - return ioPattern().thisProcReadData(); -} - bool pFlow::IOfileHeader::writeBanner(iOstream& os)const { os<< diff --git a/src/phasicFlow/repository/IOobject/IOfileHeader.hpp b/src/phasicFlow/repository/IOobject/IOfileHeader.hpp index 569e6ab6..4d9964f7 100644 --- a/src/phasicFlow/repository/IOobject/IOfileHeader.hpp +++ b/src/phasicFlow/repository/IOobject/IOfileHeader.hpp @@ -40,9 +40,7 @@ protected: //// - data members - // owner repository - const repository* owner_ = nullptr; - + // object name read from file word objectName_; @@ -63,7 +61,7 @@ protected: public: // with owner - IOfileHeader(const objectFile& objf, const repository* owner = nullptr); + IOfileHeader(const objectFile& objf); // - object name const word& objectName()const @@ -78,11 +76,12 @@ public: } // - pointer to owner repository - const repository* owner()const - { - return owner_; - } - + virtual + const repository* owner()const + { + return nullptr; + } + // - path to file name fileSystem path() const; @@ -118,18 +117,13 @@ public: /// Write the header to the file, typeName comes from the one read from file bool writeHeader(iOstream& os, bool forceWrite = false) const; - /// Check if the data should be written to file - bool writeData()const; - /// Check if header should be read from file bool readHeader()const; /// Read the header in the file bool readHeader(iIstream& is, bool silent=false); - /// Check if data should be read from file - /// Always return true - bool readData()const; + /// write the banner bool writeBanner(iOstream& os)const; diff --git a/src/phasicFlow/repository/IOobject/IOobject.cpp b/src/phasicFlow/repository/IOobject/IOobject.cpp index 02cd841d..435f9033 100644 --- a/src/phasicFlow/repository/IOobject/IOobject.cpp +++ b/src/phasicFlow/repository/IOobject/IOobject.cpp @@ -24,53 +24,54 @@ Licence: pFlow::IOobject::IOobject ( - const objectFile& objf, - const repository* owner, - uniquePtr&& obj + const objectFile& objf, + const IOPattern& iop, + repository* owner ) : - IOfileHeader(objf, owner), - object_(obj.release()) + IOfileHeader(objf), + ioPattern_(iop), + owner_(owner) { - - if(!read(this->readWriteHeader())) - { - fatalErrorInFunction<< - "error in reading " << name() << " from path " << path()<addToRepository(this)) + { + fatalExit; + } } +pFlow::IOobject::~IOobject() +{ + if(owner_) + { + owner_->removeFromRepository(this); + } +} -pFlow::IOobject::IOobject +pFlow::repository* pFlow::IOobject::releaseOwner ( - const objectFile& objf, - const repository* owner, - uniquePtr&& obj + bool fromOwner ) -: - IOfileHeader(objf, owner), - object_( obj->object_.release()) -{ -} - - -bool pFlow::IOobject::isObjectValid()const -{ - return object_.get() != nullptr; +{ + auto* old = owner_; + if(old && !fromOwner) + { + old->removeFromRepository(this); + } + owner_ = nullptr; + return old; } bool pFlow::IOobject::read(bool rdHdr) { - + if( implyRead() ) { - if( rdHdr ) + if( rdHdr & ioPattern().thisCallRead()) { if( auto ptrIS = inStream(); ptrIS ) { if(!readHeader(ptrIS()))return false; - ptrIS.reset(nullptr); } else { @@ -80,17 +81,20 @@ bool pFlow::IOobject::read(bool rdHdr) } } - if( auto ptrIS = inStream(); ptrIS ) - { - if(!read(ptrIS(), rdHdr))return false; - - } - else - { - warningInFunction<< - "could not open file " << path() <read_object_t(is, ioPattern_); + + if(ioPattern().thisCallRead()) + { + return read(is, ioPattern()); + } + else + { + return true; + } + } bool pFlow::IOobject::write(iOstream& os) const { - if(this->readWriteHeader()) + if(this->writeHeader() && ioPattern().thisProcWriteHeader()) writeHeader(os, typeName()); - - return (object_->write_object_t(os, ioPattern_) && writeSeparator(os)); + + if(ioPattern().thisProcWriteData()) + { //return (object_->write_object_t(os, ioPattern_) && writeSeparator(os)); + notImplementedFunction; + //return object_->read_object_t(is, ioPattern_); + return false; + } + else + return true; } \ No newline at end of file diff --git a/src/phasicFlow/repository/IOobject/IOobject.hpp b/src/phasicFlow/repository/IOobject/IOobject.hpp index d2ef1c18..7e947192 100644 --- a/src/phasicFlow/repository/IOobject/IOobject.hpp +++ b/src/phasicFlow/repository/IOobject/IOobject.hpp @@ -25,7 +25,7 @@ Licence: #include "IOfileHeader.hpp" - +#include "IOPattern.hpp" namespace pFlow { @@ -36,177 +36,49 @@ class IOobject : public IOfileHeader { - -private: - - class iObject - { - public: - - virtual ~iObject()=default; - - // - clone - virtual uniquePtr clone() const = 0; - - virtual word typeName()const = 0; - - virtual bool read_object_t(iIstream& is, IOPattern iop) = 0; - - virtual bool write_object_t(iOstream& os, IOPattern iop)const = 0; - - }; - - template - class object_t - : - public iObject - { - protected: - dataType data_; - - public: - - template::value>> - object_t(Args&&... args) - : - data_(std::forward(args)...) - { - /*constexpr word msg(dataType::TYPENAME()+"input is not a member function.") - static_assert(std::is_member_function_pointer::value, - msg.c_str());*/ - } - - // cunstruct by copying data - object_t(const dataType& data): data_(data) - {} - - - virtual uniquePtr clone() const - { - return makeUnique(*this); - } - - virtual word typeName()const - { - return data_.typeName(); - } - - bool read_object_t(iIstream& is, IOPattern iop) override - { - return data_.read(is, iop); - } - - bool write_object_t(iOstream& os, IOPattern iop)const override - { - return data_.write(os, iop); - } - - auto& data() - { - return data_; - } - - const auto& data()const - { - return data_; - } - - }; - protected: - //// - data members + IOPattern ioPattern_; - // underlaying data object - uniquePtr object_ = nullptr; - - + mutable repository* owner_; public: // - typeinfo - word typeName()const - { - return object_->typeName(); - } + virtual + word typeName() const = 0; //// - Constructors // - construct from components, transfer the ownership of iObject (object_t) to the // onwner and read the object from file - IOobject(const objectFile& objf, const repository* owner, uniquePtr&& obj ); - - // - construct from components, transfer the ownership of IOobject to the owner (no read happens) - IOobject(const objectFile& objf, const repository* owner, uniquePtr&& obj); - - - template>::value && - !std::is_same>::value>> - IOobject(const objectFile& objf, const repository* owner, const T& data) - : - IOfileHeader(objf, owner), - object_(makeUnique>(data)) - { - if(!read(this->readWriteHeader())) - { - fatalErrorInFunction<< - "error in reading " << name() << " from path " << path()<>::value && - !std::is_same>::value>> - IOobject(const objectFile& objf, const repository* owner, T&& data) - : - IOfileHeader(objf, owner), - object_(makeUnique>(data)) - { - if(!read(this->readWriteHeader())) - { - fatalErrorInFunction<< - "error in reading " << name() << " from path " << path()< - static auto make(const objectFile& objf, Args&&... args); - - // - construct object_t with the Args as the arguments of object constructor - template - static uniquePtr make_object_t(Args&&... args); + IOobject(IOobject&& src) = delete; - //// - Access to data object + inline + const IOPattern& ioPattern()const + { + return ioPattern_; + } - // - is object valid - bool isObjectValid()const; + // - pointer to owner repository + const repository* owner()const override + { + return owner_; + } - // - ref to data object - template - auto& getObject(); - - // - const ref to data object - template - const auto& getObject()const; - + repository* releaseOwner(bool fromOwner = false); //// - IO operations @@ -221,7 +93,12 @@ public: // - write to istream bool write(iOstream& os) const; - + + virtual + bool write(iOstream& is, const IOPattern& iop)const = 0; + + virtual + bool read(iIstream& is, const IOPattern& iop) = 0; }; diff --git a/src/phasicFlow/repository/IOobject/IOobjectTemplates.cpp b/src/phasicFlow/repository/IOobject/IOobjectTemplates.cpp index 706f5ced..cdaa3fc6 100644 --- a/src/phasicFlow/repository/IOobject/IOobjectTemplates.cpp +++ b/src/phasicFlow/repository/IOobject/IOobjectTemplates.cpp @@ -19,7 +19,7 @@ Licence: -----------------------------------------------------------------------------*/ -template +/*template auto pFlow::IOobject::make ( const objectFile& objf, @@ -62,4 +62,4 @@ const auto& pFlow::IOobject::getObject()const fatalExit; } return static_cast&>(*object_).data(); -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/src/phasicFlow/repository/IOobject/objectFile.cpp b/src/phasicFlow/repository/IOobject/objectFile.cpp index a0b41f0c..d761c1ea 100644 --- a/src/phasicFlow/repository/IOobject/objectFile.cpp +++ b/src/phasicFlow/repository/IOobject/objectFile.cpp @@ -34,15 +34,13 @@ pFlow::objectFile::objectFile const fileSystem& localPath, const readFlag& rf, const writeFlag& wf, - IOPattern::IOType ioType, - bool rwHdr + bool rwHeader ) : name_(name), rFlag_(rf), wFlag_(wf), localPath_(localPath), - ioPattern_(ioType), - readWriteHeader_(rwHdr) + readWriteHeader_(rwHeader) { } \ No newline at end of file diff --git a/src/phasicFlow/repository/IOobject/objectFile.hpp b/src/phasicFlow/repository/IOobject/objectFile.hpp index d6a50eac..8bb5cb5f 100644 --- a/src/phasicFlow/repository/IOobject/objectFile.hpp +++ b/src/phasicFlow/repository/IOobject/objectFile.hpp @@ -23,14 +23,10 @@ Licence: #include "types.hpp" #include "fileSystem.hpp" -#include "IOPattern.hpp" - namespace pFlow { - - class objectFile { public: @@ -66,10 +62,8 @@ protected: /// Number of bytes used for writing/reading real variable (used for binray) int numBytesForReal_ = numBytesForReal__; - IOPattern ioPattern_ = {IOPattern::MasterProcessorOnly}; - - /// Does the objectFile write the header or not - bool readWriteHeader_ = true; + /// Does the objectFile read & write the header? + bool readWriteHeader_ = true; public: @@ -88,8 +82,7 @@ public: const fileSystem& localPath, const readFlag& rf = READ_NEVER, const writeFlag& wf = WRITE_NEVER, - IOPattern::IOType ioType = IOPattern::MasterProcessorOnly, - bool rwHdr = true + bool rwHeader = true ); // copy construct @@ -156,11 +149,6 @@ public: return wFlag_ == WRITE_NEVER; } - const IOPattern& ioPattern()const - { - return ioPattern_; - } - inline bool readWriteHeader()const { diff --git a/src/phasicFlow/repository/Time/Time.cpp b/src/phasicFlow/repository/Time/Time.cpp index e4367cee..693dcd85 100644 --- a/src/phasicFlow/repository/Time/Time.cpp +++ b/src/phasicFlow/repository/Time/Time.cpp @@ -104,6 +104,11 @@ pFlow::Time::Time( } } +pFlow::fileSystem pFlow::Time::localPath()const +{ + return fileSystem(timeName()); +} + bool pFlow::Time::write ( bool verbose diff --git a/src/phasicFlow/repository/Time/Time.hpp b/src/phasicFlow/repository/Time/Time.hpp index f1887b38..7bdf7091 100644 --- a/src/phasicFlow/repository/Time/Time.hpp +++ b/src/phasicFlow/repository/Time/Time.hpp @@ -70,10 +70,8 @@ public: //// - Methods - virtual fileSystem localPath()const - { - return fileSystem(timeName()); - } + fileSystem localPath()const override; + // - geometry repository const repository& geometry()const diff --git a/src/phasicFlow/repository/repository/repository.cpp b/src/phasicFlow/repository/repository/repository.cpp index edbf45ba..0702a9ce 100644 --- a/src/phasicFlow/repository/repository/repository.cpp +++ b/src/phasicFlow/repository/repository/repository.cpp @@ -18,7 +18,6 @@ Licence: -----------------------------------------------------------------------------*/ - #include "repository.hpp" @@ -33,7 +32,7 @@ pFlow::repository::repository localPath_(localPath), owner_(owner) { - + if(owner) { owner->addToRepository(this); @@ -42,10 +41,20 @@ pFlow::repository::repository pFlow::repository::~repository() { - if(owner_) + for(auto& objcs: objects_) + { + objcs.second->releaseOwner(true); + } + for(auto& reps: repositories_) + { + reps.second->releaseOwner(true); + } + + if(owner_) { - owner_->removeRepository(this); + owner_->removeFromRepository(this); } + } pFlow::word pFlow::repository::name()const @@ -106,26 +115,57 @@ bool pFlow::repository::addToRepository(repository* rep) return true; } -bool pFlow::repository::removeRepository(repository* rep) +bool pFlow::repository::removeFromRepository(repository* rep) { auto name = rep->name(); return repositories_.erase(name) == 1; } +bool pFlow::repository::removeFromRepository(IOobject *io) +{ + auto name = io->name(); + return objects_.erase(name) == 1; + +} +pFlow::repository *pFlow::repository::releaseOwner(bool fromOwner) +{ + auto* old = owner_; + if(old && !fromOwner) + { + old->removeFromRepository(this); + } + owner_ = nullptr; + return old; +} + +bool pFlow::repository::addToRepository(IOobject* io) +{ + if( !objects_.insertIf(io->name(), io ) ) + { + warningInFunction<< + "Failed to add repository " << io->name() << + " to repository " << this->name() << + ". It is already in this repository. \n"; + return false; + } + + return true; +} bool pFlow::repository::lookupObjectName(const word& nm)const { return objects_.search(nm); } -pFlow::word pFlow::repository::lookupObjectTypeName( +pFlow::word pFlow::repository::lookupObjectTypeName +( const word& nm - )const +)const { if(auto [iter, found] = objects_.findIf(nm); found) { - return iter->second.typeName(); + return iter->second->typeName(); } else { @@ -143,13 +183,11 @@ bool pFlow::repository::globalLookupObjectName )const { - - if(!downward) { // the object to start search and its owner - auto object = this; - auto owner = object->owner(); + auto* object = this; + auto* owner = object->owner(); // get to the top-most repository while(!owner) @@ -245,10 +283,10 @@ bool pFlow::repository::write { if(verbose) { - REPORT(1)<< "Writing to " << obj.second.path()<path()<write()) { return false; } diff --git a/src/phasicFlow/repository/repository/repository.hpp b/src/phasicFlow/repository/repository/repository.hpp index b257e692..cc5ec1c2 100644 --- a/src/phasicFlow/repository/repository/repository.hpp +++ b/src/phasicFlow/repository/repository/repository.hpp @@ -45,7 +45,7 @@ protected: repository* owner_; // - sorted names of objects with object index in vector of objects - wordMap objects_; + wordMap objects_; // - list of repositories that this repository owns // - it is not a managed list of pointers! @@ -100,61 +100,20 @@ public: // - ref to this repository repository& thisRepository(); - // - add rep to this repository - // return false if the name already exists + /// @brief add repository to this repository + /// return false if the name already exists bool addToRepository(repository* rep); - // - remove rep from the list of repositories - bool removeRepository(repository* rep); - + /// @brief remove rep from the list of repositories + bool removeFromRepository(repository* rep); - //// - Add/remove objects - - // - insert the object into repository if it does not exist - // return a refernce to underlying data object, this reference never invalidated - // until it is deleted from repository. - // issue a fatal error if it is already exists - // ** one time construction and no move/copy of object ** - template - T& emplaceObject(const objectFile& objf, Args&&... args); - - // - insert the object into repository if it does not exist - // return a refernce to underlying data object, this reference never invalidated - // until it is deleted from repository. - // - if the object already exist, after type check(if consistent), return the - // reference of the existing object and create no new object. - // ** one time construction and no move/copy of object ** - template - T& emplaceObjectOrGet(const objectFile& objf, Args&&... args); - - // - insert the object into repository and replace if it already exists (old object is destroyed) - // return a refernce to underlying data object, this reference never invalidated - // until it is deleted from repository. - // ** one time construction and no move/copy of object ** - template - T& emplaceReplaceObject(const objectFile& objf, Args&&... args); - - - // - Insert_or_replace the IOobejct into repository and change its ownership - // to this repository, take effect only if the object does not belong to - // any other repository - template - T& insertReplaceObject(uniquePtr&& ptr ); - - - // - Insert_or_replace the IOobejct into repository with new objectFile and - // change the ownership to this repository, take effect only if the object - // does not belong to any other repository - template - T& insertReplaceObject(const objectFile& objf, uniquePtr&& ptr ); - - // - rease an object from this repository - bool eraseObject(const word& name) - { - return objects_.erase(name) == 1; - } + /// @brief add IOobject to this repository + bool addToRepository(IOobject* io); + /// @brief remove rep from the list of repositories + bool removeFromRepository(IOobject* io); + repository* releaseOwner(bool fromOwner = false); //// - lookups and queries // - check if name of object exists diff --git a/src/phasicFlow/repository/repository/repositoryTemplates.cpp b/src/phasicFlow/repository/repository/repositoryTemplates.cpp index b7e514d7..52ec9b02 100644 --- a/src/phasicFlow/repository/repository/repositoryTemplates.cpp +++ b/src/phasicFlow/repository/repository/repositoryTemplates.cpp @@ -17,22 +17,7 @@ Licence: implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -----------------------------------------------------------------------------*/ - -template -pFlow::word pFlow::repository::reportTypeError (IOobject& object) -{ - word err; - err = "The requested object " + object.name() + " with type " + Type1::TYPENAME() + ", while the type " + - object.typeName() + "is found in repository " + this->name(); - - return err; -} - -template -bool pFlow::repository::checkForObjectType(IOobject& object) -{ - return Type::TYPENAME() == object.typeName(); -} +/* template T& pFlow::repository::emplaceObject(const objectFile& objf, Args&&... args) @@ -142,6 +127,25 @@ T& pFlow::repository::insertReplaceObject(const objectFile& objf, uniquePtr +pFlow::word pFlow::repository::reportTypeError(IOobject& object) +{ + word err; + err = "Object " + object.name() + " with type " + Type1::TYPENAME() + + "is requested, while the type " + + object.typeName() + "is found in repository " + this->name()+"."; + + return err; +} + +template +bool pFlow::repository::checkForObjectType(IOobject& object) +{ + return Type::TYPENAME() == object.typeName(); +} + template T& pFlow::repository::lookupObject(const word& name) { @@ -150,14 +154,15 @@ T& pFlow::repository::lookupObject(const word& name) if( checkType(iter->second) ) { - return iter->second.template getObject(); + return static_cast(iter->second); + }else { fatalErrorInFunction << reportTypeError(iter->second)<second.template getObject(); + return static_cast(iter->second); } } diff --git a/src/phasicFlow/repository/systemControl/Control.hpp b/src/phasicFlow/repository/systemControl/Control.hpp deleted file mode 100644 index 58df40a4..00000000 --- a/src/phasicFlow/repository/systemControl/Control.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/*------------------------------- phasicFlow --------------------------------- - O C enter of - O O E ngineering and - O O M ultiscale modeling of - OOOOOOO F luid flow ------------------------------------------------------------------------------- - Copyright (C): www.cemf.ir - email: hamid.r.norouzi AT gmail.com ------------------------------------------------------------------------------- -Licence: - This file is part of phasicFlow code. It is a free software for simulating - granular and multiphase flows. You can redistribute it and/or modify it under - the terms of GNU General Public License v3 or any other later versions. - - phasicFlow is distributed to help others in their research in the field of - granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - ------------------------------------------------------------------------------*/ - - -#ifndef __Control_hpp__ -#define __Control_hpp__ - - -// top-level entity repository for the whole application -// Each application that is executed in pFlow, should have -// settings/systemControl file in it. -// This repository holds two main repositories: Time and settings - -#include "systemControl.hpp" -#include "timeFolder.hpp" - -namespace pFlow -{ - - -inline systemControl& Control() -{ - static systemControl control_; - return control_; -} - -} // pFlow - - -#endif // __Control_hpp__ diff --git a/src/phasicFlow/repository/systemControl/systemControl.cpp b/src/phasicFlow/repository/systemControl/systemControl.cpp index a9616a58..f57fd453 100644 --- a/src/phasicFlow/repository/systemControl/systemControl.cpp +++ b/src/phasicFlow/repository/systemControl/systemControl.cpp @@ -25,6 +25,24 @@ Licence: #include "systemControl.hpp" #include "vocabs.hpp" +bool pFlow::systemControl::readDomainDict() +{ + if(!domainDict_) + { + domainDict_ = makeUnique + ( + objectFile + ( + domainFile__, + "", + objectFile::READ_ALWAYS, + objectFile::WRITE_NEVER + ), + &settings() + ); + } + return true; +} pFlow::word pFlow::systemControl::getRunName ( @@ -108,55 +126,58 @@ pFlow::systemControl::systemControl ( getTopFolder(path) ), - settings_ + settingsDict_ ( - settingsRepository__, - settingsFolder__, - this - ), - caseSetup_ - ( - caseSetupRepository__, - caseSetupFolder__, - this - ), - settingsDict_ - ( - settings().emplaceObject - ( - objectFile - ( - settingsFile__, - "", - objectFile::READ_ALWAYS, - objectFile::WRITE_NEVER, - IOPattern::AllProcessorsSimilar - ), - settingsFile__ - ) - ), - libs_(settingsDict_), - outFilePrecision_( - settingsDict_.getValOrSet("outFilePrecision", static_cast(6)) - ), - Time_ + makeUnique + ( + objectFile + ( + settingsFile__, + settingsFolder__, + objectFile::READ_ALWAYS, + objectFile::WRITE_NEVER + ), + this + ) + ), + Time_ ( this, - settingsDict_ + settingsDict_() ), - g_( - settingsDict_.getVal("g") + settings_ + ( + makeUnique + ( + settingsRepository__, + settingsFolder__, + this + ) + ), + caseSetup_ + ( + makeUnique + ( + caseSetupRepository__, + caseSetupFolder__, + this + ) ), - domain_( - settingsDict_.subDict("domain") + + libs_(settingsDict_()), + outFilePrecision_ + ( + settingsDict_().getValOrSet("outFilePrecision", static_cast(6)) ), timers_(runName_), timersReport_ ( - settingsDict_.getValOrSet("timersReport", Logical("Yes")) + settingsDict_().getValOrSet("timersReport", Logical("Yes")) ), writeToFileTimer_("Write to file", &timers_) -{} +{ + readDomainDict(); +} pFlow::systemControl::systemControl( const real startTime, @@ -179,71 +200,62 @@ pFlow::systemControl::systemControl( ( getTopFolder(path) ), - settings_ + settingsDict_ ( - settingsRepository__, - settingsFolder__, - this - ), - caseSetup_ - ( - caseSetupRepository__, - caseSetupFolder__, - this - ), - settingsDict_ - ( - settings().emplaceObject - ( - objectFile - ( - settingsFile__, - "", - objectFile::READ_ALWAYS, - objectFile::WRITE_NEVER - ), - settingsFile__ - ) - ), - libs_(settingsDict_), - Time_ + makeUnique + ( + objectFile + ( + settingsFile__, + settingsFolder__, + objectFile::READ_ALWAYS, + objectFile::WRITE_NEVER + ), + this + ) + ), + Time_ ( this, - settingsDict_, + settingsDict_(), startTime, endTime, saveInterval, startTimeName ), + settings_ + ( + makeUnique + ( + settingsRepository__, + settingsFolder__, + this + ) + ), + caseSetup_ + ( + makeUnique + ( + caseSetupRepository__, + caseSetupFolder__, + this + ) + ), + libs_(settingsDict_()), externalTimeControl_(true), - g_( - settingsDict_.getVal("g") - ), - domain_( - settingsDict_.subDict("domain") - ), timers_(runName_), timersReport_ ( - settingsDict_.getValOrSet("timersReport", Logical("Yes")) + settingsDict_->getValOrSet("timersReport", Logical("Yes")) ), writeToFileTimer_("Write to file", &timers_) -{} +{ + readDomainDict(); +} pFlow::fileDictionary& pFlow::systemControl::domainDict() { - return - settings().emplaceObjectOrGet - ( - objectFile - ( - domainFile__, - "", - objectFile::READ_ALWAYS, - objectFile::WRITE_NEVER - ), - domainFile__ - ); + return domainDict_(); } bool pFlow::systemControl::operator ++(int) diff --git a/src/phasicFlow/repository/systemControl/systemControl.hpp b/src/phasicFlow/repository/systemControl/systemControl.hpp index d79f157c..f48c9db7 100644 --- a/src/phasicFlow/repository/systemControl/systemControl.hpp +++ b/src/phasicFlow/repository/systemControl/systemControl.hpp @@ -50,35 +50,29 @@ protected: // - path to top-level folder const fileSystem topLevelFolder_; + /// settingsDict fileDictionary + uniquePtr settingsDict_; + /// time repository + Time Time_; /// settings folder repository - repository settings_; + uniquePtr settings_; /// caseSetup folder repository - repository caseSetup_; + uniquePtr caseSetup_; - /// settingsDict fileDictionary - fileDictionary& settingsDict_; + uniquePtr domainDict_ = nullptr; /// extra libs to be loaded - dynamicLinkLibs libs_; + dynamicLinkLibs libs_; /// precision for writing to file size_t outFilePrecision_ = 6; - /// time repository - Time Time_; /// if time control is managed externaly - - bool externalTimeControl_ = false; - - // - acceleration - realx3 g_; - - // - domain for dem world - box domain_; + bool externalTimeControl_ = false; // all timers Timers timers_; @@ -87,6 +81,8 @@ protected: Timer writeToFileTimer_; + bool readDomainDict(); + static word getRunName( const fileSystem& path); static word getTopFolder(const fileSystem& path); @@ -104,25 +100,25 @@ public: const fileSystem path = CWD() ); const repository& settings() const{ - return settings_; + return settings_(); } repository& settings(){ - return settings_; + return settings_(); } const repository& caseSetup()const{ - return caseSetup_; + return caseSetup_(); } repository& caseSetup(){ - return caseSetup_; + return caseSetup_(); } const Time& time() const { - return const_cast(Time_); + return Time_; } Time& time() @@ -156,11 +152,11 @@ public: } const fileDictionary& settingsDict()const{ - return settingsDict_; + return settingsDict_(); } fileDictionary& settingsDict(){ - return settingsDict_; + return settingsDict_(); } fileDictionary& domainDict(); @@ -171,14 +167,14 @@ public: return runName_; } - inline const realx3& g()const + inline const realx3 g()const { - return g_; + return settingsDict_().getVal("g"); } - inline const box& domain()const + inline box domain() { - return domain_; + return box(domainDict().subDict("globalBox")); } bool operator ++(int); diff --git a/src/phasicFlow/streams/dataIO/createDataIO.hpp b/src/phasicFlow/streams/dataIO/createDataIO.hpp new file mode 100644 index 00000000..c15c43b7 --- /dev/null +++ b/src/phasicFlow/streams/dataIO/createDataIO.hpp @@ -0,0 +1,35 @@ +#ifndef __createDataIO_hpp__ +#define __createDataIO_hpp__ + +#include "uniquePtr.hpp" +#include "dataIO.hpp" +#include "dataIORegular.hpp" +#include "dataIOMPI.hpp" + +namespace pFlow +{ + +template +uniquePtr> createDataIO( + const word& runType, const IOPattern& iop) +{ + if(runType == "regular") + { + return makeUnique>(iop); + } + else if(runType == "MPI") + { + return makeUnique>(iop); + } + else + { + fatalErrorInFunction<< "not dataIO pattern is specified for this "<< + runType< pFlow::dataIO::create -( - IOPattern::IOType iotype, - word exeMode -) -{ - auto ioMode = angleBracketsNames("dataIO", exeMode); - - if( wordvCtorSelector_.search(ioMode) ) - { - auto objPtr = wordvCtorSelector_[ioMode] - ( - iotype, - exeMode - ); - return objPtr; - } - else - { - printKeys - ( - fatalError << "Ctor Selector "<< Yellow_Text(ioMode) << " dose not exist. \n" - <<"Avaiable ones are: \n\n" - , - wordvCtorSelector_ - ); - fatalExit; - } - return nullptr; -} diff --git a/src/phasicFlow/streams/dataIO/dataIO.hpp b/src/phasicFlow/streams/dataIO/dataIO.hpp index 1a11ac2c..21da63ab 100644 --- a/src/phasicFlow/streams/dataIO/dataIO.hpp +++ b/src/phasicFlow/streams/dataIO/dataIO.hpp @@ -9,49 +9,37 @@ #include "IOPattern.hpp" #include "iOstream.hpp" #include "iIstream.hpp" -#include "virtualConstructor.hpp" + namespace pFlow { -class fileSystem; - - +template class dataIO { - -public: - - - static inline const uint64 ErrorReturn = static_cast(-1); - protected: - IOPattern ioPattern_; + IOPattern ioPattern_; - word executionMode_; + std::vector buffer_; - span buffer_; + span bufferSpan_; - template - span createSpan( span sp ) - { - return span( reinterpret_cast(sp.data()), sp.size()*sizeof(T) ); - } + + /// gather data from all processors and put the results in buffer_ + virtual bool gatherData(span data) = 0; public: /// Type info TypeInfo("dataIO"); - dataIO(IOPattern::IOType iotype, word exeMode) + dataIO(const IOPattern& iop) : - ioPattern_(iotype), - executionMode_(exeMode) + ioPattern_(iop) {} - dataIO(const dataIO&) = default; dataIO(dataIO &&) = default; @@ -62,199 +50,24 @@ public: virtual ~dataIO() = default; - create_vCtor - ( - dataIO, - word, - ( - IOPattern::IOType iotype, - word exeMode - ), - (iotype, exeMode) - ); - - /// Gather data from all processors and put the results in - /// buffer_ - virtual bool gatherData(span sp ) = 0; - /// Write data to the end of file from all processors. /// This method should be called from all processors. - template bool writeData(iOstream& os, span data); - template - bool readData(iIstream& is, std::vector& data); + bool readData( + iIstream& is, + std::vector& data); - template bool readAscii( iIstream& is, std::vector& vec ); - static - uniquePtr create(IOPattern::IOType iotype, word exeMode); - - }; -template<> -inline -bool dataIO::writeData(iOstream& os, span data) -{ - /*std::ostringstream ist(); - - for(auto i=0; i sp(ist.str().data(), ist.str().size()); - - if(!gatherData( sp) ) - { - fatalErrorInFunction<< - "Error in gathering data for out stream "<< os.name()<& data); - - bool writeDataToFileEndMPI( - const word& wordPath, - const span& data); - - bool readDataSTD( - const word& wordPath, - const std::vector chunkSizes, - span& data, - uint64 binaryBlockStart); - - bool readDataMPI( - const word& wordPath, - const std::vector chunkSizes, - span& data, - uint64 binaryBlockStart); - - bool readMetaMPI( - const word& wordPath, - std::vector& chunkSizes, - uint64 startPosSearch, - uint64 &startPosBinaryBlock); - - bool readMetaSTD( - const word& wordPath, - std::vector& chunkSizes, - uint64 startPosSearch, - uint64 &startPosBinaryBlock); - - bool waitForAllMPI(); - - bool maxReduction( uint64& src, uint64& dst); - - bool BcastPos(uint64 & pos); - -public: - - dataIO(IOPattern::IOType iotype) - : - ioPattern_(iotype) - {} - - ~dataIO()=default; - - template - bool writeDataEnd( - const word& wordPath, - const span& data); - - template - bool writeAsciiEnd( - iOstream& os, - const span& data); - - template - bool readDataBinary( - const word& wordPath, - std::vector& data, - uint64 startPos = 0); - - template - bool readAscii( - iIstream& is, - std::vector& vec ); - - template - bool readData( - iIstream& is, - std::vector& vec, - bool resume = false); // resume only works for binary - // for ascii, by default it starts from the current position - - - template - bool writeData(iOstream& os, - const span& data); - - -}; - -template<> -inline -bool pFlow::dataIO::writeData -( - iOstream& os, - const span& data -) -{ - if( !writeAsciiEnd(os, data) ) - { - fatalErrorInFunction; - return false; - } - return true; -} - -template<> -inline -bool pFlow::dataIO::readData( - iIstream& is, - std::vector& vec, - bool resume) -{ - if(!readAscii(is, vec)) - { - fatalErrorInFunction; - return false; - } - return true; -}*/ \ No newline at end of file diff --git a/src/phasicFlow/streams/dataIO/dataIONoMPI.cpp b/src/phasicFlow/streams/dataIO/dataIONoMPI.cpp deleted file mode 100644 index a2dfd6be..00000000 --- a/src/phasicFlow/streams/dataIO/dataIONoMPI.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -#include "dataIONoMPI.hpp" - - -pFlow::dataIONoMPI::dataIONoMPI -( - IOPattern::IOType iotype, - word exeMode -) -: - dataIO(iotype, exeMode) -{} - - -bool pFlow::dataIONoMPI::gatherData( span sp ) -{ - /// in serial mode, no gathering is required. - buffer_ = sp; - return true; -} \ No newline at end of file diff --git a/src/phasicFlow/streams/dataIO/dataIONoMPI.hpp b/src/phasicFlow/streams/dataIO/dataIONoMPI.hpp deleted file mode 100644 index 64878fe2..00000000 --- a/src/phasicFlow/streams/dataIO/dataIONoMPI.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef __datIONoMPI_hpp__ -#define __datIONoMPI_hpp__ - -#include "dataIO.hpp" - -namespace pFlow -{ - - -class dataIONoMPI -: - public dataIO -{ -protected: - -public: - - TypeInfo("dataIO"); - - dataIONoMPI(IOPattern::IOType iotype, word exeMode); - - dataIONoMPI(const dataIONoMPI&) = default; - - dataIONoMPI(dataIONoMPI&&) = default; - - - dataIONoMPI& operator=(const dataIONoMPI&) = default; - - dataIONoMPI& operator=(dataIONoMPI&&) = default; - - ~dataIONoMPI() = default; - - add_vCtor - ( - dataIO, - dataIONoMPI, - word - ); - - bool gatherData(span sp ) override; - -}; - - -} - - -#endif \ No newline at end of file diff --git a/src/phasicFlow/streams/dataIO/dataIORegular.hpp b/src/phasicFlow/streams/dataIO/dataIORegular.hpp new file mode 100644 index 00000000..08f66a2a --- /dev/null +++ b/src/phasicFlow/streams/dataIO/dataIORegular.hpp @@ -0,0 +1,47 @@ +#ifndef __datIONoMPI_hpp__ +#define __datIONoMPI_hpp__ + +#include "dataIO.hpp" + +namespace pFlow +{ +template +class dataIORegular +: + public dataIO +{ +protected: + + bool gatherData(span data ) override + { + /// in serial mode, no gathering is required. + this->bufferSpan_ = data; + return true; + } + +public: + + TypeInfo("dataIO"); + + dataIORegular(const IOPattern& iop) + : + dataIO(iop) + {} + + dataIORegular(const dataIORegular&) = default; + + dataIORegular(dataIORegular&&) = default; + + dataIORegular& operator=(const dataIORegular&) = default; + + dataIORegular& operator=(dataIORegular&&) = default; + + ~dataIORegular() = default; + +}; + + +} + + +#endif \ No newline at end of file diff --git a/src/phasicFlow/streams/dataIO/dataIOTemplate.cpp b/src/phasicFlow/streams/dataIO/dataIOTemplate.cpp index a485d2b1..82478821 100644 --- a/src/phasicFlow/streams/dataIO/dataIOTemplate.cpp +++ b/src/phasicFlow/streams/dataIO/dataIOTemplate.cpp @@ -1,9 +1,9 @@ template -bool pFlow::dataIO::writeData(iOstream& os, span data) +bool pFlow::dataIO::writeData(iOstream& os, span data) { /// first gather data from all processors (if any) - if(!gatherData( createSpan(data) ) ) + if(!gatherData( data ) ) { fatalErrorInFunction<< "Error in gathering data for out stream "<< os.name()< data) { if( os.isBinary() ) { - // first write the size of data - uint64 len = buffer_.size()/sizeof(T); - os<< len << endl; + // first write the number of data + uint64 numData = bufferSpan_.size(); + os<< numData << endl; - if(!os.write(buffer_.data(), buffer_.size())) + // write the bindary data + auto chBuffer = charSpan(bufferSpan_); + + if(!os.write(chBuffer.data(), chBuffer.size())) { fatalErrorInFunction<< "error in writing binary data to "< data) } else { - - /// cast the data into T - span allData( - reinterpret_cast(buffer_.data()), - buffer_.size()/sizeof(T)); - - if( !allData.writeASCII(os) ) + if( !bufferSpan_.writeASCII(os) ) { fatalErrorInFunction<< "error in writing ASCII data to "< data) } } +template<> +inline +bool pFlow::dataIO::writeData(iOstream& os, span data) +{ + notImplementedFunction; + fatalExit; + /// first gather data from all processors (if any) + if(!gatherData( data ) ) + { + fatalErrorInFunction<< + "Error in gathering data for out stream "<< os.name()< -bool pFlow::dataIO::readData +bool pFlow::dataIO::readData ( iIstream& is, std::vector& data ) { - data.clear(); - if(ioPattern_.thisProcReadData()) { if(is.isBinary()) { + // read length of data token firstToken(is); @@ -98,7 +119,7 @@ bool pFlow::dataIO::readData } template -bool pFlow::dataIO::readAscii +bool pFlow::dataIO::readAscii ( iIstream& is, std::vector& vec @@ -107,7 +128,6 @@ bool pFlow::dataIO::readAscii if( !ioPattern_.thisProcReadData() ) return true; - is.fatalCheck(FUNCTION_NAME); vec.clear(); @@ -161,331 +181,10 @@ bool pFlow::dataIO::readAscii if(len>0&& len != vec.size()) { - warningInFunction<<"vector lendth specified "<< len << + warningInFunction<<"vector length specified "<< len << " is different from number of elements "<< vec.size()< -bool pFlow::dataIO::writeDataEnd( - const word& wordPath, - const span& data) -{ - - if( ioPattern_.thisProcWriteData() ) - { - span charSpan( - reinterpret_cast (const_cast(data.data())), - data.size()*sizeof(T)); - - if( ioPattern_.isParallel() ) - { - return writeDataToFileEndMPI(wordPath, charSpan); - } - else - { - return writeDataToFileEndSTD(wordPath, charSpan); - } - } - else - { - return true; - } - - return false; -} - -template -bool pFlow::dataIO::writeAsciiEnd -( - iOstream& os, - const span& data -) -{ - if(ioPattern_.thisProcWriteData()) - { - return data.writeASCII(os); - } - else - return true; -} - - - -template -bool pFlow::dataIO::readDataBinary -( - const word& wordPath, - std::vector& data, - uint64 startPos -) -{ - - std::vector chunkSizes; - uint64 startPosBinaryBlock; - - data.clear(); - - if( ioPattern_.thisProcReadData()) - { - - // read meta - if(!readMetaSTD( - wordPath, - chunkSizes, - startPos, - startPosBinaryBlock)) - { - fatalErrorInFunction; - return false; - } - - - if( ioPattern_.isMasterProcessor() || - ioPattern_.isAllProcessorSimilar() - ) - { - - auto sizeOfData = std::accumulate( - chunkSizes.begin(), - chunkSizes.end(), - static_cast(0)); - - - data.resize(sizeOfData/sizeof(T)); - - span charSpan( - reinterpret_cast(data.data()), - data.size()*sizeof(T)); - - if(!readDataSTD(wordPath, chunkSizes, charSpan, startPosBinaryBlock)) - { - fatalErrorInFunction; - return false; - } - - return true; - - } - else if( ioPattern_.isAllProcessorDifferent() ) - { - - if(chunkSizes.size() != ioPattern_.globalSize()) - { - if( ioPattern_.isMaster()) - { - auto sizeOfData = std::accumulate( - chunkSizes.begin(), - chunkSizes.end(), - static_cast(0)); - - - data.resize(sizeOfData/sizeof(T)); - - span charSpan( - reinterpret_cast(data.data()), - data.size()*sizeof(T)); - - if(!readDataSTD(wordPath, chunkSizes, charSpan, startPosBinaryBlock)) - { - fatalErrorInFunction; - return false; - } - return true; - - } - else - { - return true; - } - } - else - { - auto thisProc = ioPattern_.globalRank(); - - data.resize(chunkSizes[thisProc]/sizeof(T)); - - span charSpan( - reinterpret_cast(data.data()), - data.size()*sizeof(T)); - - - if( !readDataMPI(wordPath, chunkSizes, charSpan, startPosBinaryBlock) ) - { - fatalErrorInFunction; - return false; - } - return true; - } - - - } - else - { - fatalErrorInFunction; - return false; - } - } - else - { - return true; - } - - return false; - - -} - -template -bool pFlow::dataIO::readAscii -( - iIstream& is, - std::vector& vec -) -{ - - if( !ioPattern_.thisProcReadData() ) return true; - - - is.fatalCheck(FUNCTION_NAME); - - vec.clear(); - - token firstToken(is); - - size_t len = 0; - if( firstToken.isInt64()) - { - len = firstToken.int64Token(); - vec.reserve(len); - firstToken = token(is); - } - - T val{}; - if( firstToken.isPunctuation() ) // start of vector - { - if(firstToken != token::BEGIN_LIST) - { - warningInFunction - << "expected token "<< token::BEGIN_LIST - << " but found "<< firstToken ; - return false; - - } - - token lastToken(is); - - is.fatalCheck(FUNCTION_NAME); - - while(!(lastToken.isPunctuation() - && lastToken == token::END_LIST )) - { - - is.putBack(lastToken); - - is >> val; - vec.push_back(val); - - is >> lastToken; - is.fatalCheck(FUNCTION_NAME); - } - - } else - { - warningInFunction - << "expected token "<< token::BEGIN_LIST - << " but found "<< firstToken<0&& len != vec.size()) - { - warningInFunction<<"vector lendth specified "<< len << - " is different from number of elements "<< vec.size()< -bool pFlow::dataIO::readData -( - iIstream& is, - std::vector& vec, - bool resume -) -{ - if(is.isBinary()) - { - uint64 currPos = 0; - if( resume ) - { - currPos = is.tell(); - } - - if(! BcastPos(currPos) ) return false; - - if(!this->readDataBinary(is.name(), vec, currPos)) - { - fatalErrorInFunction; - return false; - } - - auto lastPos = lastPosRead_; - maxReduction( lastPos, lastPosRead_); - //std::cout<<"last post read "<< lastPosRead_< -bool pFlow::dataIO::writeData -( - iOstream& os, - const span& sp -) -{ - if( os.isBinary() ) - { - os.startOfBinaryStreaming(); - - if(!writeDataEnd(os.name(), sp)) - { - fatalErrorInFunction; - return false; - } - - os.endOfBinaryStreaming(); - - } - else - { - if( !writeAsciiEnd(os, sp) ) - { - fatalErrorInFunction; - return false; - } - } - return true; - -}*/ - - - +} \ No newline at end of file diff --git a/src/phasicFlow/structuredData/box/box.hpp b/src/phasicFlow/structuredData/box/box.hpp index 5ad65de9..4e78f2fc 100644 --- a/src/phasicFlow/structuredData/box/box.hpp +++ b/src/phasicFlow/structuredData/box/box.hpp @@ -97,6 +97,18 @@ public: return max_; } + INLINE_FUNCTION_HD + realx3& minPoint() + { + return min_; + } + + INLINE_FUNCTION_HD + realx3& maxPoint() + { + return max_; + } + //// - IO operation FUNCTION_H bool read(iIstream & is); diff --git a/src/phasicFlow/structuredData/domain/domain.cpp b/src/phasicFlow/structuredData/domain/domain.cpp index 8a6b9939..e81c0471 100644 --- a/src/phasicFlow/structuredData/domain/domain.cpp +++ b/src/phasicFlow/structuredData/domain/domain.cpp @@ -56,4 +56,25 @@ pFlow::domain::domain(const box& db) realx3(db.minPoint().x(), db.maxPoint().y(), db.maxPoint().z())) { -} \ No newline at end of file +} + + +FUNCTION_H +pFlow::iIstream& pFlow::operator >>( + pFlow::iIstream& is, + pFlow::domain& d) +{ + box b; + is>>b; + d = domain(b); + return is; +} + +FUNCTION_H +pFlow::iOstream& pFlow::operator << ( + pFlow::iOstream& os, + const pFlow::domain& d) +{ + os<< d.domainBox(); + return os; +} diff --git a/src/phasicFlow/structuredData/domain/domain.hpp b/src/phasicFlow/structuredData/domain/domain.hpp index 15f57090..f29b33ab 100644 --- a/src/phasicFlow/structuredData/domain/domain.hpp +++ b/src/phasicFlow/structuredData/domain/domain.hpp @@ -156,17 +156,12 @@ bool operator ==(const domain& d1, const domain& d2) return equal(d1, d2); } -/*FUNCTION_H -iIstream& operator >>(iIstream& is, box& b); +FUNCTION_H +iIstream& operator >>(iIstream& is, domain& d); FUNCTION_H -iOstream& operator << (iOstream& os, const box& b); +iOstream& operator << (iOstream& os, const domain& d); -INLINE_FUNCTION_HD -box extendBox(const box& b, const realx3& dl) -{ - return box(b.minPoint()-dl , b.maxPoint()+dl); -}*/ } diff --git a/src/phasicFlow/structuredData/domain/regularSimulationDomain.cpp b/src/phasicFlow/structuredData/domain/regularSimulationDomain.cpp index 74fd61da..999f6b0e 100644 --- a/src/phasicFlow/structuredData/domain/regularSimulationDomain.cpp +++ b/src/phasicFlow/structuredData/domain/regularSimulationDomain.cpp @@ -50,37 +50,52 @@ bool pFlow::regularSimulationDomain::setThisDomain() return true; } -pFlow::regularSimulationDomain::regularSimulationDomain( - const dictionary &dict) - : simulationDomain(dict) -{ -} - -bool pFlow::regularSimulationDomain::updateDomains +pFlow::regularSimulationDomain::regularSimulationDomain ( - const realx3Vector& pointPos + const dictionary &dict ) +: + simulationDomain(dict) +{} + +bool pFlow::regularSimulationDomain::initialUpdateDomains(span pointPos) { - thisNumPoints_ = pointPos.size(); - if(!createBoundaryDicts()) return false; - if(!setThisDomain()) return false; - + initialNumPoints_ = pointPos.size(); + if(!setThisDomain()) return false; + if(!createBoundaryDicts()) return false; return true; } -pFlow::uint32 pFlow::regularSimulationDomain::thisNumPoints() const +pFlow::uint32 pFlow::regularSimulationDomain::initialNumberInThis() const { - return thisNumPoints_; + return initialNumPoints_; } -bool pFlow::regularSimulationDomain::transferBlockData +/*bool pFlow::regularSimulationDomain::updateDomains( + span pointPos, + pFlagTypeHost flags) +{ + return true; +}*/ + +pFlow::uint32 pFlow::regularSimulationDomain::numberToBeImported() const +{ + return 0; +} + +pFlow::uint32 pFlow::regularSimulationDomain::numberToBeExported() const +{ + return 0; +} + +bool pFlow::regularSimulationDomain::initialTransferBlockData ( span src, span dst, - uint32 sizeOfBlock + size_t sizeOfElement ) { - size_t requiredSize = sizeOfBlock*thisNumPoints(); + size_t requiredSize = sizeOfElement*initialNumberInThis(); if(dst.size() < requiredSize) { fatalErrorInFunction<< @@ -103,6 +118,54 @@ bool pFlow::regularSimulationDomain::transferBlockData return true; } +bool pFlow::regularSimulationDomain::initialTransferBlockData +( + span src, + span dst +) +{ + return initialTransferBlockData( + charSpan(src), + charSpan(dst), + sizeof(realx3)); +} + +bool pFlow::regularSimulationDomain::initialTransferBlockData +( + span src, + span dst +) +{ + return initialTransferBlockData( + charSpan(src), + charSpan(dst), + sizeof(real)); +} + +bool pFlow::regularSimulationDomain::initialTransferBlockData +( + span src, + span dst +) +{ + return initialTransferBlockData( + charSpan(src), + charSpan(dst), + sizeof(uint32)); +} + +bool pFlow::regularSimulationDomain::initialTransferBlockData +( + span src, + span dst +) +{ + return initialTransferBlockData( + charSpan(src), + charSpan(dst), + sizeof(int32)); +} + const pFlow::dictionary &pFlow::regularSimulationDomain::thisBoundaryDict() const { return globalDomainDict_.subDict("regularSimulationDomainBoundaries"); diff --git a/src/phasicFlow/structuredData/domain/regularSimulationDomain.hpp b/src/phasicFlow/structuredData/domain/regularSimulationDomain.hpp index 011e8d2c..074ffc64 100644 --- a/src/phasicFlow/structuredData/domain/regularSimulationDomain.hpp +++ b/src/phasicFlow/structuredData/domain/regularSimulationDomain.hpp @@ -13,7 +13,7 @@ class regularSimulationDomain { protected: - uint32 thisNumPoints_=0; + uint32 initialNumPoints_=0; bool createBoundaryDicts() override; @@ -35,16 +35,44 @@ public: dictionary ); - bool updateDomains( - const realx3Vector& pointPos)override; + bool initialUpdateDomains(span pointPos) override; - uint32 thisNumPoints()const override; + uint32 initialNumberInThis()const override; - - bool transferBlockData( + /*bool updateDomains( + span pointPos, + pFlagTypeHost flags) override;*/ + + uint32 numberToBeImported()const override; + + uint32 numberToBeExported()const override; + + bool initialTransferBlockData( span src, span dst, - uint32 sizeOfBlock) override; + size_t sizeOfElement) override; + + + /// @brief + /// @param src + /// @param dst + /// @return + bool initialTransferBlockData( + span src, + span dst) override; + + bool initialTransferBlockData( + span src, + span dst) override; + + bool initialTransferBlockData( + span src, + span dst) override; + + bool initialTransferBlockData( + span src, + span dst) override; + const dictionary& thisBoundaryDict()const override; diff --git a/src/phasicFlow/structuredData/domain/simulationDomain.cpp b/src/phasicFlow/structuredData/domain/simulationDomain.cpp index 1fb0867d..b45758b5 100644 --- a/src/phasicFlow/structuredData/domain/simulationDomain.cpp +++ b/src/phasicFlow/structuredData/domain/simulationDomain.cpp @@ -19,23 +19,23 @@ Licence: -----------------------------------------------------------------------------*/ #include "simulationDomain.hpp" -#include "processors.hpp" +#include "pFlowProcessors.hpp" pFlow::simulationDomain::simulationDomain(const dictionary& dict) : globalBox_(dict.subDict("globalBox")), globalDomainDict_(dict) { - + } pFlow::uniquePtr pFlow::simulationDomain::create(const dictionary &dict) { - word sType = angleBracketsNames( "simulationDomain", - processors::runTypeName()); + pFlowProcessors().localRunTypeName()); + if( dictionaryvCtorSelector_.search(sType) ) { diff --git a/src/phasicFlow/structuredData/domain/simulationDomain.hpp b/src/phasicFlow/structuredData/domain/simulationDomain.hpp index 5844f437..205762ba 100644 --- a/src/phasicFlow/structuredData/domain/simulationDomain.hpp +++ b/src/phasicFlow/structuredData/domain/simulationDomain.hpp @@ -17,19 +17,22 @@ Licence: implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -----------------------------------------------------------------------------*/ - #ifndef __simulationDomain_hpp__ #define __simulationDomain_hpp__ -#include "domain.hpp" -#include "virtualConstructor.hpp" -#include "Vectors.hpp" +#include +#include "domain.hpp" +#include "span.hpp" #include "streams.hpp" +#include "virtualConstructor.hpp" +#include "pointFlag.hpp" namespace pFlow { +//class pFlagTypeHost; + class simulationDomain { private: @@ -56,9 +59,9 @@ protected: bool boundariesSet_ = false; - virtual bool createBoundaryDicts() = 0; + virtual bool createBoundaryDicts() = 0; - virtual bool setThisDomain() = 0; + virtual bool setThisDomain() = 0; public: @@ -84,23 +87,64 @@ public: virtual const dictionary& thisBoundaryDict()const = 0; + virtual + bool initialUpdateDomains(span pointPos) = 0; - virtual - bool updateDomains( - const realx3Vector& pointPos) = 0; + virtual + uint32 initialNumberInThis()const = 0; - //virtual getImportExportList() = 0; - - //virtual getNumberInThisList() = 0; - - virtual - uint32 thisNumPoints()const = 0; - - virtual - bool transferBlockData( + virtual + bool initialTransferBlockData( span src, span dst, - uint32 sizeOfBlock) = 0; + size_t sizeOfElement) = 0; + + virtual + bool initialTransferBlockData( + span src, + span dst) = 0; + + virtual + bool initialTransferBlockData( + span src, + span dst) = 0; + + virtual + bool initialTransferBlockData( + span src, + span dst) = 0; + + virtual + bool initialTransferBlockData( + span src, + span dst) = 0; + + + /*template + bool initialTransferBlockData( + span src, + span dst ) + { + size_t el=sizeof(T); + return initialTransferBlockData + ( + charSpan(src), + charSpan(dst), + el + ); + }*/ + + + + /// @brief Number of points to be imported after updating domains + /// @return number of points + virtual + uint32 numberToBeImported()const = 0; + + virtual + uint32 numberToBeExported()const = 0; + + virtual bool requiresDataTransfer() const = 0; diff --git a/src/phasicFlow/structuredData/infinitePlane/infinitePlane.hpp b/src/phasicFlow/structuredData/infinitePlane/infinitePlane.hpp index 14aea880..28c548bc 100644 --- a/src/phasicFlow/structuredData/infinitePlane/infinitePlane.hpp +++ b/src/phasicFlow/structuredData/infinitePlane/infinitePlane.hpp @@ -29,7 +29,7 @@ Licence: namespace pFlow { -class infinitePlane +class infinitePlane { protected: @@ -137,6 +137,33 @@ public: return t*normal_ + p; } + INLINE_FUNCTION_HD + bool parallel(const infinitePlane& pln)const + { + return equal(normal_, pln.normal_) || + equal(normal_,-pln.normal_); + } + + INLINE_FUNCTION_HD + bool parallelTouch(const infinitePlane& pln)const + { + if(equal(normal_, pln.normal_) && equal(d_, pln.d_))return true; + if(equal(normal_,-pln.normal_) && equal(d_,-pln.d_))return true; + return false; + } + + INLINE_FUNCTION_HD + const auto& normal()const + { + return normal_; + } + + INLINE_FUNCTION_HD + const auto& d()const + { + return d_; + } + //// - IO operation FUNCTION_H diff --git a/src/phasicFlow/structuredData/plane/plane.cpp b/src/phasicFlow/structuredData/plane/plane.cpp index fbac188c..547c9cc0 100644 --- a/src/phasicFlow/structuredData/plane/plane.cpp +++ b/src/phasicFlow/structuredData/plane/plane.cpp @@ -54,13 +54,11 @@ pFlow::plane pFlow::plane::parallelPlane(real distance)const return plane(pp1, pp2, pp3, pp4); } -bool pFlow::plane::validPlane4 -( - const realx3& p1, - const realx3& p2, - const realx3& p3, - const realx3& p4 -) +bool pFlow::plane::validPlane4( + const realx3 &p1, + const realx3 &p2, + const realx3 &p3, + const realx3 &p4) { if( !validPlane3(p1,p2,p3)) return false; if( !infinitePlane(p1,p2,p3).pointOnPlane(p4)) return false; diff --git a/src/phasicFlow/structuredData/plane/plane.hpp b/src/phasicFlow/structuredData/plane/plane.hpp index 7fbdea03..239b700b 100644 --- a/src/phasicFlow/structuredData/plane/plane.hpp +++ b/src/phasicFlow/structuredData/plane/plane.hpp @@ -122,6 +122,7 @@ public: // return the parallel plane to this plane plane parallelPlane(real distance)const; + static bool validPlane4( const realx3& p1, diff --git a/src/phasicFlow/structuredData/pointStructure/internalPoints.cpp b/src/phasicFlow/structuredData/pointStructure/internalPoints.cpp index 96b763e6..d64e35af 100644 --- a/src/phasicFlow/structuredData/pointStructure/internalPoints.cpp +++ b/src/phasicFlow/structuredData/pointStructure/internalPoints.cpp @@ -173,20 +173,48 @@ pFlow::internalPoints::internalPoints } -const pFlow::internalPoints::pFlagTypeDevice& +const pFlow::pFlagTypeDevice& pFlow::internalPoints::activePointsMaskD() const { return pFlagsD_; } -const pFlow::internalPoints::pFlagTypeHost& +const pFlow::pFlagTypeHost& pFlow::internalPoints::activePointsMaskH() const { syncPFlag(); return pFlagsH_; } +FUNCTION_H +const pFlow::realx3Field_D& + pFlow::internalPoints::pointPosition()const +{ + return pointPosition_; +} + +pFlow::hostViewType1D + pFlow::internalPoints::activePointsHost() const +{ + auto maskH = activePointsMaskH(); + auto pointsH = pointPositionHost(); + + hostViewType1D aPoints("Active pointst", maskH.numActive()); + auto aRange = maskH.activeRange(); + uint32 n = 0; + for(auto i=aRange.start(); i> fRead("internalPoints", "internalPoints"); - if( !fRead.read(is, iotype)) + if( !fRead.read(is, iop)) { fatalErrorInFunction<< "Error in reading pointPosition from stream "<< is.name()<; - - using pFlagTypeHost = pointFlag; - - protected: //// - data members @@ -120,11 +115,19 @@ public: FUNCTION_H realx3Field_D& pointPosition(); - /*INLINE_FUNCTION_H - auto pointPositionHostAll() - { - return pointPosition_.hostVectorAll(); - }*/ + INLINE_FUNCTION_H + auto pointPositionHost()const + { + return pointPosition_.hostVector(); + } + + INLINE_FUNCTION_H + auto pointPositionDevice()const + { + return pointPosition_.deviceVector(); + } + + hostViewType1D activePointsHost()const; // - size of data structure INLINE_FUNCTION_H @@ -216,12 +219,12 @@ public: /// Read FUNCTION_H - bool read(iIstream& is, IOPattern::IOType iotype); + bool read(iIstream& is, const IOPattern& iop); /// Write FUNCTION_H - bool write(iOstream& os, IOPattern::IOType iotype)const; + bool write(iOstream& os, const IOPattern& iop)const; }; diff --git a/src/phasicFlow/structuredData/pointStructure/pointFlag.hpp b/src/phasicFlow/structuredData/pointStructure/pointFlag.hpp index 62861957..e863e583 100644 --- a/src/phasicFlow/structuredData/pointStructure/pointFlag.hpp +++ b/src/phasicFlow/structuredData/pointStructure/pointFlag.hpp @@ -244,6 +244,9 @@ public: }; +using pFlagTypeDevice = pointFlag; + +using pFlagTypeHost = pointFlag; } diff --git a/src/phasicFlow/structuredData/pointStructure/pointFlagKernels.hpp b/src/phasicFlow/structuredData/pointStructure/pointFlagKernels.hpp index 95fcd517..f63efa00 100644 --- a/src/phasicFlow/structuredData/pointStructure/pointFlagKernels.hpp +++ b/src/phasicFlow/structuredData/pointStructure/pointFlagKernels.hpp @@ -258,8 +258,6 @@ void pFlow::pointFlag::fillNeighborsLists }); Kokkos::fence(); } - - } template diff --git a/src/phasicFlow/structuredData/pointStructure/pointStructure.cpp b/src/phasicFlow/structuredData/pointStructure/pointStructure.cpp index 30e2e187..173cdb43 100644 --- a/src/phasicFlow/structuredData/pointStructure/pointStructure.cpp +++ b/src/phasicFlow/structuredData/pointStructure/pointStructure.cpp @@ -1,3 +1,4 @@ + /*------------------------------- phasicFlow --------------------------------- O C enter of O O E ngineering and @@ -19,53 +20,61 @@ Licence: -----------------------------------------------------------------------------*/ #include "pointStructure.hpp" -#include "simulationDomain.hpp" +#include "systemControl.hpp" +#include "vocabs.hpp" -#include "streams.hpp" -bool pFlow::pointStructure::distributePoints -( - const realx3Vector &points -) +bool pFlow::pointStructure::setupPointStructure(const realx3Vector &points) { - uint32 thisN = simulationDomain_->thisNumPoints(); + if(!simulationDomain_->initialUpdateDomains(points.getSpan())) + { + fatalErrorInFunction<< + "error in updating domains"<initialNumberInThis(); - Field> internal( + Field> internal + ( "internalPoints", "internalPoints", thisN, thisN, - RESERVE()); + RESERVE() + ); + auto pSpan = makeSpan(points); + auto iSpan = internal.getSpan(); - auto l = sizeof(realx3); - auto pointsSpan = span( - reinterpret_cast - ( - const_cast(points.data()) - ), - points.size()*l ); - - auto internalSpan = span(reinterpret_cast(internal.data()), internal.size()*l); - - if(!simulationDomain_->transferBlockData(pointsSpan, internalSpan, l)) + if(!simulationDomain_->initialTransferBlockData(pSpan, iSpan)) { fatalErrorInFunction<< "Error in transfering the block data "<updateDomains(posVec) ) + if(!setupPointStructure(posVec)) { fatalErrorInFunction<< - "Failed to update domains."<> fRead("file_internalPoints", "internalPoints"); - + Field> + fRead("file_internalPoints", "internalPoints"); - if( !fRead.read(is, iotype)) + if( !fRead.read(is, iop)) { fatalErrorInFunction<< "Error in reading pointPosition from stream "<< is.name()<updateDomains(fRead)) + return setupPointStructure(fRead); +} + +bool pFlow::pointStructure::write +( + iOstream& os, + const IOPattern& iop +)const +{ + + hostViewType1D pointsH; + + if(isAllActive()) + { + pointsH = pointPositionHost(); + } + else + { + pointsH = activePointsHost(); + } + + auto data = span(pointsH.data(), pointsH.size()); + + if( !writeSpan(os, data, iop) ) { fatalErrorInFunction<< - "error in updating domains"< simulationDomain_ = nullptr; boundaryList boundaries_; - - - bool distributePoints(const realx3Vector& points); + + + bool setupPointStructure(const realx3Vector& points); + + bool initializePoints(const realx3Vector& points); public: @@ -63,19 +68,12 @@ public: systemControl& control, const realx3Vector& posVec); - // - copy construct - // - // should be changed, may causs undefined behavior - ////////////////////////////////////////////////////////////// pointStructure(const pointStructure&) = delete; // - no move construct pointStructure(pointStructure&&) = delete; - // - copy assignment - // - // should be changed, may causs undefined behavior - ////////////////////////////////////////////////////////////// + pointStructure& operator=(const pointStructure&) = delete; // - no move assignment @@ -122,15 +120,14 @@ public: /// @brief read the point structure from the input stream. /// @param is: input stream - /// @param iotype: type of input pattern + /// @param iop: type of input pattern /// @return true on success - FUNCTION_H - bool read(iIstream& is, IOPattern::IOType iotype); + bool read(iIstream& is, const IOPattern& iop) override; /// Write - /*FUNCTION_H - bool write(iOstream& os, IOPattern::IOType iotype)const; */ + bool write(iOstream& os, const IOPattern& iop)const override; + @@ -141,6 +138,16 @@ public: }; +/*inline iOstream& operator << (iOstream& os, const pointStructure& ps ) +{ + if( !ps.write(os, IOPattern::AllProcessorsDifferent) ) + { + ioErrorInFile(os.name(), os.lineNumber()); + fatalExit; + } + return os; +}*/ + } // pFlow diff --git a/src/phasicFlow/structuredData/trisurfaceStructure/stlFile.hpp b/src/phasicFlow/structuredData/trisurfaceStructure/stlFile.hpp index b072690f..6f47fbd5 100644 --- a/src/phasicFlow/structuredData/trisurfaceStructure/stlFile.hpp +++ b/src/phasicFlow/structuredData/trisurfaceStructure/stlFile.hpp @@ -106,10 +106,10 @@ public: size_t size()const; // - vertecies of ith solid - const realx3x3Vector& solid(label i)const; + const realx3x3Vector& solid(uint64 i)const; // - name of ith solid - const word& name(label i)const; + const word& name(uint64 i)const; }; diff --git a/src/phasicFlow/types/triple/triple.hpp b/src/phasicFlow/types/triple/triple.hpp index 356e5a00..34b12176 100644 --- a/src/phasicFlow/types/triple/triple.hpp +++ b/src/phasicFlow/types/triple/triple.hpp @@ -146,6 +146,8 @@ struct triple /// access component INLINE_FUNCTION_HD const T & z()const { return z_; } + INLINE_FUNCTION_HD const T& comp(uint32 i) const {return *(this+i);} + //// methods /// Dot product of two vectors diff --git a/src/setHelpers/finalize.hpp b/src/setHelpers/finalize.hpp index f98c8069..cd4b1990 100644 --- a/src/setHelpers/finalize.hpp +++ b/src/setHelpers/finalize.hpp @@ -23,7 +23,7 @@ Licence: // initilized and finalize should be placed in onc scope } -pFlow::output<< "\nFinalizing host/device execution space ...."< + auto objCPDict = IOobject::make ( objectFile ( @@ -92,11 +81,10 @@ int main( int argc, char* argv[] ) objectFile::READ_ALWAYS, objectFile::WRITE_ALWAYS ), - "particlesDict", - true + "particlesDict" ); - auto& cpDict = objCPDict().getObject(); + auto& cpDict = objCPDict().getObject(); pointStructure* pStructPtr = nullptr; @@ -128,19 +116,19 @@ int main( int argc, char* argv[] ) pStructPtr = &pStruct; - REPORT(1)<< "Created pStruct with "<< pStruct.size() << " points and capacity "<< pStruct.capacity()<<" . . ."<< END_REPORT; - REPORT(1)<< "Writing pStruct to " << Control.time().path()+ pointStructureFile__<< END_REPORT< @@ -163,8 +151,8 @@ int main( int argc, char* argv[] ) if(!positionOnly) { - - auto& pStruct = *pStructPtr; + WARNING<< "setFields is not active "< allCells( box(minP, maxP), cellsize); + cells allCells( box(minP, maxP), cellsize); Vector indMor(position.size(),RESERVE()); indMor.clear(); - size_t ind=0; + uint64 ind=0; for(const auto& p:position) { auto cellInd = allCells.pointIndex(p); @@ -68,9 +68,10 @@ pFlow::realx3Vector pFlow::positionParticles::sortByMortonCode(realx3Vector& pos for(auto& ind:indMor) { sortedPos.push_back( position[ind.index] ); - } + }*/ - return sortedPos; + WARNING<<"Morton sorting is inactive!"<(10000)); + maxNumberOfParticles_ = dict.getValOrSet("maxNumberOfParticles", static_cast(10000)); mortonSorting_ = dict.getValOrSet("mortonSorting", Logical("Yes")); @@ -90,11 +91,13 @@ pFlow::positionParticles::positionParticles } else if(dict.containsDictionay("cylinder")) { - region_ = makeUnique>(dict.subDict("cylinder")); + WARNING<<"cylinder region is not set!"<>(dict.subDict("cylinder")); } else if(dict.containsDictionay("sphere")) { - region_ = makeUnique>(dict.subDict("sphere")); + WARNING<<"sphere region is not set!"<>(dict.subDict("sphere")); } else { @@ -112,7 +115,7 @@ pFlow::realx3Vector pFlow::positionParticles::getFinalPosition() } else { - realx3Vector vec(position().capacity(), RESERVE()); + realx3Vector vec("final position",position().capacity(), 0 , RESERVE()); vec.assign( position().begin(), position().end()); return std::move(vec); @@ -132,7 +135,7 @@ pFlow::uniquePtr if( dictionaryvCtorSelector_.search(method) ) { - return dictionaryvCtorSelector_[method] (dict); + return dictionaryvCtorSelector_[method] (control, dict); } else {