/*------------------------------- 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. -----------------------------------------------------------------------------*/ #include "sphereParticles.hpp" #include "systemControl.hpp" #include "vocabs.hpp" #include "sphereParticlesKernels.hpp" //#include "setFieldList.hpp" /*pFlow::uniquePtr> pFlow::sphereParticles::getFieldObjectList()const { auto objListPtr = particles::getFieldObjectList(); objListPtr().push_back( static_cast(&I_) ); return objListPtr; } bool pFlow::sphereParticles::diameterMassInertiaPropId ( const word& shName, real& diam, real& mass, real& I, int8& propIdx ) { uint32 idx; if( !shapes_.nameToIndex(shName, idx) ) { printKeys(fatalErrorInFunction<< " wrong shape name in the input: "<< shName<(pIdx); return true; } bool pFlow::sphereParticles::initializeParticles() { int32IndexContainer indices( 0, static_cast(shapeName_.size())); return insertSphereParticles(shapeName_, indices, false); }*/ /*bool pFlow::sphereParticles::beforeIteration() { particles::beforeIteration(); intPredictTimer_.start(); //INFO<<"before dyn predict"<dt(), accelertion_); //INFO<<"after dyn predict"<dt(),rVelocity_, rAcceleration_); //INFO<<"after rvel predict"<>; auto [minIndex, maxIndex] = minMax(shapeIndex().internal()); if( !spheres_.indexValid(maxIndex) ) { fatalErrorInFunction<< "the maximum value of shapeIndex is "<< maxIndex << " which is not valid."<(shapeNames.size()); propIds.clear(); propIds.reserve(numNew); diams.clear(); diams.reserve(numNew); m.clear(); m.reserve(numNew); Is.clear(); Is.reserve(numNew); shIndex.clear(); shIndex.reserve(numNew); for(const auto& name:shapeNames) { uint32 indx; if(spheres_.shapeNameToIndex(name,indx)) { shIndex.push_back(indx); Is.push_back( spheres_.Inertia(indx)); m.push_back(spheres_.mass(indx)); diams.push_back(spheres_.boundingDiameter(indx)); propIds.push_back( spheres_.propertyId(indx)); } else { fatalErrorInFunction<<"Shape name "<< name << "does not exist. The list is "<(0.0000000001) ), rVelocity_ ( objectFile ( "rVelocity", "", objectFile::READ_IF_PRESENT, objectFile::WRITE_ALWAYS ), dynPointStruct(), zero3 ), rAcceleration_ ( objectFile( "rAcceleration", "", objectFile::READ_IF_PRESENT, objectFile::WRITE_ALWAYS ), dynPointStruct(), zero3 ), boundarySphereParticles_ ( dynPointStruct().boundaries(), *this ), accelerationTimer_( "Acceleration", &this->timers() ), intPredictTimer_( "Integration-predict", &this->timers() ), intCorrectTimer_( "Integration-correct", &this->timers() ), fieldUpdateTimer_( "fieldUpdate", &this->timers() ) { auto intMethod = control.settingsDict().getVal("integrationMethod"); REPORT(1)<<"Creating integration method "<needSetInitialVals()) { auto indexHD = pStruct().insertedPointIndex(); auto n = indexHD.size(); auto index = indexHD.indicesHost(); realx3Vector rvel(n,RESERVE()); const auto hrVel = rVelocity_.hostView(); for(auto i=0; isetInitialVals(indexHD, rvel); } return true; }*/ /*bool pFlow::sphereParticles::insertParticles ( const realx3Vector& position, const wordVector& shapes, const setFieldList& setField ) { if( position.size() != shapes.size() ) { fatalErrorInFunction<< " size of vectors position ("<activeRange(); REPORT(1)<< "Active range is "<numActive())<< " and pointStructure capacity is "<capacity())<dt(); dynPointStruct().predict(dt, accelertion()); rVelIntegration_().predict(dt,rVelocity_, rAcceleration_); intPredictTimer_.end(); fieldUpdateTimer_.start(); propertyId_.updateBoundariesSlaveToMasterIfRequested(); diameter_.updateBoundariesSlaveToMasterIfRequested(); mass_.updateBoundariesSlaveToMasterIfRequested(); I_.updateBoundariesSlaveToMasterIfRequested(); rVelocity_.updateBoundariesSlaveToMasterIfRequested(); rAcceleration_.updateBoundariesSlaveToMasterIfRequested(); rVelIntegration_().updateBoundariesSlaveToMasterIfRequested(); fieldUpdateTimer_.end(); return true; } bool pFlow::sphereParticles::iterate() { timeInfo ti = TimeInfo(); realx3 g = control().g(); particles::iterate(); accelerationTimer_.start(); pFlow::sphereParticlesKernels::acceleration( g, mass().deviceViewAll(), contactForce().deviceViewAll(), I().deviceViewAll(), contactTorque().deviceViewAll(), dynPointStruct().activePointsMaskDevice(), accelertion().deviceViewAll(), rAcceleration().deviceViewAll() ); for(auto& bndry:boundarySphereParticles_) { bndry->acceleration(ti, g); } accelerationTimer_.end(); intCorrectTimer_.start(); if(!dynPointStruct().correct(dt(), accelertion())) { return false; } if(!rVelIntegration_().correct( dt(), rVelocity_, rAcceleration_)) { return false; } intCorrectTimer_.end(); return true; } bool pFlow::sphereParticles::insertParticles ( const realx3Vector &position, const wordVector &shapesNames, const anyList &setVarList ) { anyList newVarList(setVarList); realVector mass("mass"); realVector I("I"); realVector diameter("diameter"); uint32Vector propId("propId"); uint32Vector shapeIdx("shapeIdx"); if(!getParticlesInfoFromShape( shapesNames, propId, diameter, mass, I, shapeIdx)) { return false; } newVarList.emplaceBack( mass_.name()+"Vector", std::move(mass)); newVarList.emplaceBack( I_.name()+"Vector", std::move(I)); newVarList.emplaceBack( diameter_.name()+"Vector", std::move(diameter)); newVarList.emplaceBack( propertyId_.name()+"Vector", std::move(propId)); newVarList.emplaceBack( shapeIndex().name()+"Vector", std::move(shapeIdx)); if(!dynPointStruct().insertPoints(position, newVarList)) { return false; } return true; } pFlow::word pFlow::sphereParticles::shapeTypeName()const { return "sphere"; } const pFlow::shape &pFlow::sphereParticles::getShapes() const { return spheres_; } void pFlow::sphereParticles::boundingSphereMinMax ( real & minDiam, real& maxDiam )const { minDiam = spheres_.minBoundingSphere(); maxDiam = spheres_.maxBoundingSphere(); }