diff --git a/source/Applications/Thermoplast/config.txt b/source/Applications/Thermoplast/config.txt index 44596f0d0c83c76123bd51631e3c210519db10ca..a8778ae1343a3373f79ff90da0a0df7af1756293 100644 --- a/source/Applications/Thermoplast/config.txt +++ b/source/Applications/Thermoplast/config.txt @@ -9,7 +9,7 @@ boundingBox = 60 1370 130 190 1530 320 #test bb blocknx = 10 10 10 #blocknx = 300 420 320 -endTime = 10000 +endTime = 1000 outTime = 1000 availMem = 25e9 uLB = 0.1 @@ -31,11 +31,14 @@ pathGeo = d:/Projects/ThermoPlast/SimGeo michel = /michel.stl plexiglas = /plexiglas.stl -pathOut = g:/temp/thermoplast +pathOut = g:/temp/thermoplast2 + +logToFile = false #restart -cpStart = 20000000 -cpStep = 20000000 -restart = false +cpStart = 1000 +cpStep = 1000 +restart = true +restartStep = 20 nupsTime = 10 10 1000000 \ No newline at end of file diff --git a/source/Applications/Thermoplast/thermoplast.cpp b/source/Applications/Thermoplast/thermoplast.cpp index a6c7cc098c31c5816fb19061002ef7626cf8366f..971cc6e9656a428b756c86b1eab275a6bcfffffb 100644 --- a/source/Applications/Thermoplast/thermoplast.cpp +++ b/source/Applications/Thermoplast/thermoplast.cpp @@ -186,6 +186,7 @@ void thermoplast(string configname) double cpStart = config.getValue<double>("cpStart"); double cpStep = config.getValue<double>("cpStep"); bool restart = config.getValue<bool>("restart"); + int restartStep = config.getValue<int>("restartStep"); peMinOffset = config.getVector<double>("peMinOffset"); peMaxOffset = config.getVector<double>("peMaxOffset"); @@ -195,6 +196,25 @@ void thermoplast(string configname) vector<int> nupsTime = config.getVector<int>("nupsTime"); + bool logToFile = config.getValue<bool>("logToFile"); + if (logToFile) + { +#if defined(__unix__) + if (myid==0) + { + const char* str = pathOut.c_str(); + mkdir(str, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH); + } +#endif + + if (myid==0) + { + stringstream logFilename; + logFilename<<pathOut+"/logfile"+UbSystem::toString(UbSystem::getTimeStamp())+".txt"; + UbLog::output_policy::setStream(logFilename.str()); + } + } + //parameters //string pathOut = "d:/temp/thermoplast3"; //string pathGeo = "d:/Projects/ThermoPlast/Geometrie"; @@ -464,6 +484,19 @@ void thermoplast(string configname) if (myid == 0) UBLOG(logINFO, "Preprocess - end"); } + //restart + //UBLOG(logINFO, "restart definition - start, rank="<<myid); + SPtr<UbScheduler> restartSch(new UbScheduler(cpStep, cpStart)); + //SPtr<MPIIORestartCoProcessor> restartCoProcessor(new MPIIORestartCoProcessor(grid, restartSch, pathOut, comm)); + SPtr<MPIIOMigrationCoProcessor> restartCoProcessor(new MPIIOMigrationCoProcessor(grid, restartSch, pathOut, comm)); + restartCoProcessor->setLBMKernel(kernel); + restartCoProcessor->setBCProcessor(bcProc); + + if (restart) + { + //restartStep = restartCoProcessor->readCpTimeStep(); + restartCoProcessor->restart(restartStep); + } //PE initialization double refLengthLb = radiusLB*2.0; @@ -486,20 +519,19 @@ void thermoplast(string configname) SPtr<CreateDemObjectsCoProcessor> createSphereCoProcessor(new CreateDemObjectsCoProcessor(grid, sphereScheduler, comm, demCoProcessor, sphereMaterial)); //UBLOG(logINFO, "generating spheres - stop, rank="<<myid); - //restart - //UBLOG(logINFO, "restart definition - start, rank="<<myid); - SPtr<UbScheduler> restartSch(new UbScheduler(cpStep, cpStart)); - SPtr<MPIIORestartCoProcessor> restartCoProcessor(new MPIIORestartCoProcessor(grid, restartSch, pathOut, comm)); - restartCoProcessor->setLBMKernel(kernel); - restartCoProcessor->setBCProcessor(bcProc); + ////restart + ////UBLOG(logINFO, "restart definition - start, rank="<<myid); + //SPtr<UbScheduler> restartSch(new UbScheduler(cpStep, cpStart)); + ////SPtr<MPIIORestartCoProcessor> restartCoProcessor(new MPIIORestartCoProcessor(grid, restartSch, pathOut, comm)); + //SPtr<MPIIOMigrationCoProcessor> restartCoProcessor(new MPIIOMigrationCoProcessor(grid, restartSch, pathOut, comm)); + //restartCoProcessor->setLBMKernel(kernel); + //restartCoProcessor->setBCProcessor(bcProc); SPtr<RestartDemObjectsCoProcessor> restartDemObjectsCoProcessor(new RestartDemObjectsCoProcessor(grid, restartSch, pathOut, demCoProcessor, createSphereCoProcessor, radiusLB, comm)); //UBLOG(logINFO, "restart definition - stop, rank="<<myid); if (restart) { - int startStep = restartCoProcessor->readCpTimeStep(); - restartCoProcessor->restart(startStep); - restartDemObjectsCoProcessor->restart(startStep); + restartDemObjectsCoProcessor->restart(restartStep); } //set connectors @@ -517,7 +549,7 @@ void thermoplast(string configname) //sphere prototypes //UBLOG(logINFO, "sphere prototypes - start, rank="<<myid); double d = 2.0*radiusLB; - Vector3D origin1(g_minX1+peMinOffset[0]+radiusLB, geoInjector5->getX2Minimum()+1.5*d, geoInjector5->getX3Minimum()+1.5*d); + Vector3D origin1(g_minX1+peMinOffset[0]+radiusLB, geoInjector5->getX2Minimum()+1.4*d, geoInjector5->getX3Minimum()+1.5*d); createSpheres(radiusLB,origin1,uLB,createSphereCoProcessor); //Vector3D origin2(g_minX1+peMinOffset[0]+radius, geoInjector4->getX2Minimum()+3.0*d, geoInjector4->getX3Minimum()+2.0*d); @@ -557,15 +589,18 @@ void thermoplast(string configname) SPtr<UbScheduler> visSch(new UbScheduler(outTime)); SPtr<WriteMacroscopicQuantitiesCoProcessor> writeMQCoProcessor(new WriteMacroscopicQuantitiesCoProcessor(grid, visSch, pathOut, WbWriterVtkXmlBinary::getInstance(), SPtr<LBMUnitConverter>(new LBMUnitConverter()), comm)); - writeMQCoProcessor->process(0); SPtr<WriteBoundaryConditionsCoProcessor> writeBCCoProcessor(new WriteBoundaryConditionsCoProcessor(grid, visSch, pathOut, WbWriterVtkXmlBinary::getInstance(), comm)); - writeBCCoProcessor->process(0); SPtr<WriteDemObjectsCoProcessor> writeDemObjectsCoProcessor(new WriteDemObjectsCoProcessor(grid, visSch, pathOut, WbWriterVtkXmlBinary::getInstance(), demCoProcessor, comm)); - writeDemObjectsCoProcessor->process(0); + if (!restart) + { + writeMQCoProcessor->process(0); + writeBCCoProcessor->process(0); + writeDemObjectsCoProcessor->process(0); + } ////performance control SPtr<UbScheduler> nupsSch(new UbScheduler(nupsTime[0], nupsTime[1], nupsTime[2])); SPtr<NUPSCounterCoProcessor> npr(new NUPSCounterCoProcessor(grid, nupsSch, numOfThreads, comm)); @@ -581,8 +616,8 @@ void thermoplast(string configname) calculator->addCoProcessor(writeBCCoProcessor); calculator->addCoProcessor(writeDemObjectsCoProcessor); calculator->addCoProcessor(writeMQCoProcessor); - //calculator->addCoProcessor(restartDemObjectsCoProcessor); - //calculator->addCoProcessor(restartCoProcessor); + calculator->addCoProcessor(restartDemObjectsCoProcessor); + calculator->addCoProcessor(restartCoProcessor); if (myid == 0) UBLOG(logINFO, "Simulation-start"); calculator->calculate(); diff --git a/source/DemCoupling/CreateDemObjectsCoProcessor.cpp b/source/DemCoupling/CreateDemObjectsCoProcessor.cpp index 71bd6e678f4bd7532d83f87783858593757009fd..b60c6f226265713ff5ff261745f0b160edf03822 100644 --- a/source/DemCoupling/CreateDemObjectsCoProcessor.cpp +++ b/source/DemCoupling/CreateDemObjectsCoProcessor.cpp @@ -54,17 +54,17 @@ void CreateDemObjectsCoProcessor::process(double step) createGeoObjects(); #ifdef TIMING - if (comm->isRoot()) UBLOG(logINFO, "createGeoObjects() time = "<<timer.stop()<<" s"); - if (comm->isRoot()) UBLOG(logINFO, "number of objects = "<<(int)(geoObjectPrototypeVector.size())); - if (comm->isRoot()) UBLOG(logINFO, "total number of objects = "<<demCounter); +// if (comm->isRoot()) UBLOG(logINFO, "createGeoObjects() time = "<<timer.stop()<<" s"); +// if (comm->isRoot()) UBLOG(logINFO, "number of objects = "<<(int)(geoObjectPrototypeVector.size())); +// if (comm->isRoot()) UBLOG(logINFO, "total number of objects = "<<demCounter); if (comm->isRoot()) UBLOG(logINFO, "CreateDemObjectsCoProcessor::process stop step: " << istep); #endif - demCoProcessor->distributeIDs(); + //demCoProcessor->distributeIDs(); -#ifdef TIMING - if (comm->isRoot()) UBLOG(logINFO, "demCoProcessor->distributeIDs() time = "<<timer.stop()<<" s"); -#endif +//#ifdef TIMING +// if (comm->isRoot()) UBLOG(logINFO, "demCoProcessor->distributeIDs() time = "<<timer.stop()<<" s"); +//#endif } @@ -101,5 +101,18 @@ void CreateDemObjectsCoProcessor::createGeoObjects() demCoProcessor->addInteractor(geoObjectInt, demObjectMaterial, initalVelocity[i]); demCounter++; } + +#ifdef TIMING + if (comm->isRoot()) UBLOG(logINFO, "createGeoObjects() time = "<<timer.stop()<<" s"); + if (comm->isRoot()) UBLOG(logINFO, "number of objects = "<<(int)(geoObjectPrototypeVector.size())); + if (comm->isRoot()) UBLOG(logINFO, "total number of objects = "<<demCounter); + //if (comm->isRoot()) UBLOG(logINFO, "CreateDemObjectsCoProcessor::process stop step: " << istep); +#endif + + demCoProcessor->distributeIDs(); + +#ifdef TIMING + if (comm->isRoot()) UBLOG(logINFO, "demCoProcessor->distributeIDs() time = "<<timer.stop()<<" s"); +#endif } diff --git a/source/DemCoupling/DemCoProcessor.cpp b/source/DemCoupling/DemCoProcessor.cpp index f29d76ff175af014fb405a1cd64687c76ee6c863..a7f5a8f68b2e08409291f52ad3cb53a9cd2b23f1 100644 --- a/source/DemCoupling/DemCoProcessor.cpp +++ b/source/DemCoupling/DemCoProcessor.cpp @@ -358,6 +358,7 @@ void DemCoProcessor::getObjectsPropertiesVector(std::vector<double>& p) { if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) { + p.push_back(i); p.push_back(interactors[i]->getGbObject3D()->getX1Centroid()); p.push_back(interactors[i]->getGbObject3D()->getX2Centroid()); p.push_back(interactors[i]->getGbObject3D()->getX3Centroid()); diff --git a/source/DemCoupling/RestartDemObjectsCoProcessor.cpp b/source/DemCoupling/RestartDemObjectsCoProcessor.cpp index 1a63501b20e1fd3783271bc83af9bb2f2e80a092..1cc39ad6ebfb2879b3774b5e0f8d0956448e502f 100644 --- a/source/DemCoupling/RestartDemObjectsCoProcessor.cpp +++ b/source/DemCoupling/RestartDemObjectsCoProcessor.cpp @@ -53,12 +53,32 @@ void RestartDemObjectsCoProcessor::write(int step) if (comm->isRoot()) { + std::map< int, std::vector< double> > infMap; + int size = (int)rvalues.size(); + for (int i = 0; i < size; i += 7) + { + std::vector< double> infVector(6); + for (int j = 0; j < 6; j ++) + { + infVector[j] = rvalues[i+1+j]; + } + infMap.insert(std::make_pair((int)rvalues[i], infVector)); + } + std::vector< double> wvalues; + typedef std::map< int, std::vector< double> >::iterator it_type; + for (it_type iterator = infMap.begin(); iterator != infMap.end(); iterator++) + { + // iterator->first = key + // iterator->second = value + std::vector<double>::iterator it = wvalues.end(); + it = wvalues.insert(it, iterator->second.begin(), iterator->second.end()); + } std::string subfolder = "dem_cp_"+UbSystem::toString(step); std::string filePath = path+"/dem_cp/"+subfolder+"/dem_cp.bin"; UbFileOutputBinary fo(filePath); - fo.writeInteger((int)rvalues.size()); - fo.writeVector<double>(rvalues); - UBLOG(logINFO, "RestartDemObjectsCoProcessor::write number of objects = " << rvalues.size()/6); + fo.writeInteger((int)wvalues.size()); + fo.writeVector<double>(wvalues); + UBLOG(logINFO, "RestartDemObjectsCoProcessor::write number of objects = " << wvalues.size()/6); } if (comm->isRoot()) UBLOG(logINFO, "RestartDemObjectsCoProcessor::write stop "); } diff --git a/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp index 25034d6a93e7dec8f287222a2a5ab027395acba0..b81bbe2587085deff92fd7345a3c640d961e31ec 100644 --- a/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp +++ b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp @@ -160,29 +160,36 @@ std::shared_ptr< walberla::blockforest::BlockForest > PePhysicsEngineSolverAdapt void PePhysicsEngineSolverAdapter::saveToFile(const std::string & path) { - //forest->saveToFile(path+"SerializeDeserialize.sbf"); - //forest->saveBlockData("SerializeDeserialize.dump", *storageId.get()); + forest->saveToFile(path+"SerializeDeserialize.sbf"); + forest->saveBlockData("SerializeDeserialize.dump", *storageId.get()); } void PePhysicsEngineSolverAdapter::loadFromFile(const std::string & path) { //forest = std::make_shared< walberla::blockforest::BlockForest >( walberla::uint_c( walberla::MPIManager::instance()->rank() ), path+"SerializeDeserialize.sbf", true, false ); - //storageId = std::make_shared< walberla::domain_decomposition::BlockDataID >(forest->loadBlockData(path+"SerializeDeserialize.dump", walberla::pe::createStorageDataHandling<BodyTypeTuple>(), "Storage")); - // - //auto ccdID = forest->addBlockData(walberla::pe::ccd::createHashGridsDataHandling(globalBodyStorage, *storageId), "CCD"); - //auto fcdID = forest->addBlockData(walberla::pe::fcd::createGenericFCDDataHandling<BodyTypeTuple, walberla::pe::fcd::AnalyticCollideFunctor>(), "FCD"); - - //cr = std::make_shared<walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers>(globalBodyStorage, forest, *storageId, ccdID, fcdID); - //cr->setMaxIterations(peParameter->maxPeIterations); - //cr->setRelaxationModel(walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers::ApproximateInelasticCoulombContactByDecoupling); - //cr->setRelaxationParameter(walberla::real_t(peParameter->relaxationParameter)); - //cr->setGlobalLinearAcceleration(PeConverter::convert(peParameter->globalLinearAcceleration)); - - //for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) - //{ - // walberla::pe::ccd::ICCD* ccd = blockIt->getData< walberla::pe::ccd::ICCD >(ccdID); - // ccd->reloadBodies(); - //} + std::string file = path+"SerializeDeserialize.sbf"; + forest = std::shared_ptr < walberla::blockforest::BlockForest > (new walberla::blockforest::BlockForest( walberla::uint_c( walberla::MPIManager::instance()->rank() ), file.c_str(), true, false )); + storageId = std::make_shared< walberla::domain_decomposition::BlockDataID >(forest->loadBlockData(path+"SerializeDeserialize.dump", walberla::pe::createStorageDataHandling<BodyTypeTuple>(), "Storage")); + + this->initalPeIntegrator(); + + auto ccdID = forest->addBlockData(walberla::pe::ccd::createHashGridsDataHandling(globalBodyStorage, *storageId), "CCD"); + auto fcdID = forest->addBlockData(walberla::pe::fcd::createGenericFCDDataHandling<BodyTypeTuple, walberla::pe::fcd::AnalyticCollideFunctor>(), "FCD"); + + cr = std::make_shared<walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers>(globalBodyStorage, forest, *storageId, ccdID, fcdID); + cr->setMaxIterations(peParameter->maxPeIterations); + cr->setRelaxationModel(walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers::ApproximateInelasticCoulombContactByDecoupling); + cr->setRelaxationParameter(walberla::real_t(peParameter->relaxationParameter)); + cr->setGlobalLinearAcceleration(PeConverter::convert(peParameter->globalLinearAcceleration)); + + this->executePeBodyTypeTuple(); + this->initialPeChannel(); + + for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) + { + walberla::pe::ccd::ICCD* ccd = blockIt->getData< walberla::pe::ccd::ICCD >(ccdID); + ccd->reloadBodies(); + } } std::shared_ptr<walberla::blockforest::BlockForest> PePhysicsEngineSolverAdapter::getBlockForest()