/*------------------------------- 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 "grainDEMSystem.hpp" #include "vocabs.hpp" bool pFlow::grainDEMSystem::loop() { do { // if(! insertion_().insertParticles( Control().time().currentIter(), Control().time().currentTime(), Control().time().dt() ) ) { fatalError<< "particle insertion failed in grainDEMSystem.\n"; return false; } geometry_->beforeIteration(); interaction_->beforeIteration(); particles_->beforeIteration(); interaction_->iterate(); particles_->iterate(); geometry_->iterate(); particles_->afterIteration(); geometry_->afterIteration(); }while(Control()++); return true; } pFlow::grainDEMSystem::grainDEMSystem( word demSystemName, const std::vector& domains, int argc, char* argv[], bool requireRVel) : DEMSystem(demSystemName, domains, argc, argv), requireRVel_(requireRVel) { REPORT(0)<<"\nReading proprties . . . "<( propertyFile__, Control().caseSetup().path()); REPORT(0)<< "\nCreating surface geometry for grainDEMSystem . . . "<(Control(), Property()); insertion_ = makeUnique( particles_(), particles_().grains()); REPORT(0)<<"\nCreating interaction model for grain-grain contact and grain-wall contact . . ."<(domains, maxD); } pFlow::grainDEMSystem::~grainDEMSystem() { } bool pFlow::grainDEMSystem::updateParticleDistribution( real extentFraction, const std::vector domains) { if(!particleDistribution_->changeDomainsSize( extentFraction, maxBounndingSphereSize(), domains)) { fatalErrorInFunction<< "cannot change the domain size"<locateParticles( positionHost_, particles_->pStruct().activePointsMaskHost())) { fatalErrorInFunction<< "error in locating particles among sub-domains"< pFlow::grainDEMSystem::numParInDomains()const { const auto& distribute = particleDistribution_(); int32 numDomains = distribute.numDomains(); std::vector nums(numDomains); for(int32 i=0; i pFlow::grainDEMSystem::parIndexInDomain(int32 di)const { return particleDistribution_->particlesInDomain(di); } pFlow::span pFlow::grainDEMSystem::diameter() { return span(diameterHost_.data(), diameterHost_.size()); } pFlow::span pFlow::grainDEMSystem::courseGrainFactor() { return span(particles_->courseGrainFactorHost().data(), particles_->courseGrainFactorHost().size()); } pFlow::span pFlow::grainDEMSystem::acceleration() { return span(nullptr, 0); } pFlow::span pFlow::grainDEMSystem::velocity() { return span(velocityHost_.data(), velocityHost_.size()); } pFlow::span pFlow::grainDEMSystem::position() { return span(positionHost_.data(), positionHost_.size()); } pFlow::span pFlow::grainDEMSystem::rAcceleration() { return span(nullptr, 0); } pFlow::span pFlow::grainDEMSystem::rVelocity() { return span(rVelocityHost_.data(), rVelocityHost_.size()); } pFlow::span pFlow::grainDEMSystem::rPosition() { return span(nullptr, 0); } pFlow::span pFlow::grainDEMSystem::parFluidForce() { auto& hVec = particles_->fluidForceHost(); return span(hVec.data(), hVec.size()); } pFlow::span pFlow::grainDEMSystem::parFluidTorque() { auto& hVec = particles_->fluidTorqueHost(); return span(hVec.data(), hVec.size()); } bool pFlow::grainDEMSystem::sendFluidForceToDEM() { particles_->fluidForceHostUpdatedSync(); return true; } bool pFlow::grainDEMSystem::sendFluidTorqueToDEM() { particles_->fluidTorqueHostUpdatedSync(); return true; } bool pFlow::grainDEMSystem::beforeIteration() { velocityHost_ = std::as_const(particles_()).velocity().hostView(); positionHost_ = std::as_const(particles_()).pointPosition().hostView(); diameterHost_ = particles_->diameter().hostView(); if(requireRVel_) rVelocityHost_ = std::as_const(particles_()).rVelocity().hostView(); return true; } bool pFlow::grainDEMSystem::iterate( real upToTime, real timeToWrite, word timeName) { Control().time().setStopAt(upToTime); Control().time().setOutputToFile(timeToWrite, timeName); return loop(); return true; } bool pFlow::grainDEMSystem::iterate(real upToTime) { Control().time().setStopAt(upToTime); return loop(); return true; } pFlow::real pFlow::grainDEMSystem::maxBounndingSphereSize()const { real minD, maxD; particles_->boundingSphereMinMax(minD, maxD); return maxD; }