// * * * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * * // void twoWayFiles::getData ( word name, word type, double ** const& field, label step ) const { // get input path fileName particleFilePath = getFilePath(name,true); Info << "reading from file: " << particleFilePath << endl; // set file pointer IFstream* inputPtr = new IFstream(particleFilePath); // write data to variable int numberOfParticles; /*if(name != "outRegion1" && name != "inRegion1")*/ *inputPtr >> numberOfParticles; // give nr of particles to cloud setNumberOfParticles(numberOfParticles); // re-allocate arrays of cloud particleCloud_.reAllocArrays(); for(int index = 0;index < numberOfParticles; ++index) { if (type == "scalar-atom") { *inputPtr >> field[index][0]; } else if (type == "vector-atom")
void Foam::cfdemCloud::CheckExistanceAndReadDEMData() { int nmr_of_part=IOM().LookForDEMdata(); //IOM().getNumberOfParticles("positions_nh"); //if these files are not empty if(nmr_of_part>0) { Pout <<"Found "<< nmr_of_part<<" particles."<< endl; if(nmr_of_part>numberOfParticles()) { FatalError<< "Amount of memory for "<<nmr_of_part<<" particles from prev. simulation exceeds already allocated memory for "<<numberOfParticles()<<" particle. \nIncrease maxNumberOfParticles in coupllingProperties file." << abort(FatalError); } reAllocArrays(); setNumberOfParticles(nmr_of_part); Info << "- Starting to upload it."<< endl; //fetching data from files into DEM arrays IOM().getExistingDEMData("positions_nh","vector-atom",positions_); IOM().getExistingDEMData("r_nh","scalar-atom",radii_); IOM().getExistingDEMData("m_nh","scalar-atom",mass_); IOM().getExistingDEMData("v_nh","vector-atom",velocities_); IOM().getExistingDEMData("DEMForces_nh","vector-atom",DEMForces_); IOM().getExistingDEMData("tTurbs_nh","scalar-atom",tTurb_); IOM().getExistingDEMData("tTurbInts_nh","scalar-atom",tTurbInt_); IOM().getExistingDEMData("fluidTurbVels_nh","vector-atom",fluidTurbVel_); //pushing data to DEM code dataExchangeM().giveDataFromPreviosSimulation(nmr_of_part, positions_, velocities_, radii_, mass_,DEMForces_,tTurb_,tTurbInt_,fluidTurbVel_); //Info << "All data is loaded."<< endl<< endl; } else { //Info << "************** FILES PRESENT BUT EMPTY. ************************************"<< endl<< endl; } }
void Foam::InjectionModel<CloudType>::inject(TrackData& td) { if (!active()) { return; } const scalar time = owner_.db().time().value(); const scalar carrierDt = owner_.db().time().deltaTValue(); const polyMesh& mesh = owner_.mesh(); // Prepare for next time step label parcelsAdded = 0; scalar massAdded = 0.0; label newParcels = 0; scalar newVolume = 0.0; prepareForNextTimeStep(time, newParcels, newVolume); // Duration of injection period during this timestep const scalar deltaT = max(0.0, min(carrierDt, min(time - SOI_, timeEnd() - time0_))); // Pad injection time if injection starts during this timestep const scalar padTime = max(0.0, SOI_ - time0_); // Introduce new parcels linearly across carrier phase timestep for (label parcelI=0; parcelI<newParcels; parcelI++) { if (validInjection(parcelI)) { // Calculate the pseudo time of injection for parcel 'parcelI' scalar timeInj = time0_ + padTime + deltaT*parcelI/newParcels; // Determine the injection position and owner cell label cellI = -1; vector pos = vector::zero; setPositionAndCell(parcelI, newParcels, timeInj, pos, cellI); if (cellI > -1) { // Lagrangian timestep scalar dt = time - timeInj; // Apply corrections to position for 2-D cases meshTools::constrainToMeshCentre(mesh, pos); // Create a new parcel parcelType* pPtr = new parcelType(td.cloud(), pos, cellI); // Assign new parcel properties in injection model setProperties(parcelI, newParcels, timeInj, *pPtr); // Check new parcel properties td.cloud().checkParcelProperties(*pPtr, dt, fullyDescribed()); // Apply correction to velocity for 2-D cases meshTools::constrainDirection ( mesh, mesh.solutionD(), pPtr->U() ); // Number of particles per parcel pPtr->nParticle() = setNumberOfParticles ( newParcels, newVolume, pPtr->d(), pPtr->rho() ); // Add the new parcel td.cloud().addParticle(pPtr); massAdded += pPtr->nParticle()*pPtr->mass(); parcelsAdded++; } } } postInjectCheck(parcelsAdded, massAdded); }