From 29d922e3c5daa3cc635374aecce3d2440e37b64c Mon Sep 17 00:00:00 2001 From: wanqing0421 Date: Mon, 10 Feb 2025 23:12:42 +0800 Subject: [PATCH] A simple rapid filling demo --- utilities/particlesPhasicFlow/CMakeLists.txt | 1 + .../positionFile/positionFile.cpp | 82 ++++++++++++++ .../positionFile/positionFile.hpp | 100 ++++++++++++++++++ 3 files changed, 183 insertions(+) create mode 100755 utilities/particlesPhasicFlow/positionFile/positionFile.cpp create mode 100755 utilities/particlesPhasicFlow/positionFile/positionFile.hpp diff --git a/utilities/particlesPhasicFlow/CMakeLists.txt b/utilities/particlesPhasicFlow/CMakeLists.txt index 1ee6f3f8..6bea0938 100644 --- a/utilities/particlesPhasicFlow/CMakeLists.txt +++ b/utilities/particlesPhasicFlow/CMakeLists.txt @@ -4,6 +4,7 @@ particlesPhasicFlow.cpp positionParticles/positionParticles.cpp positionOrdered/positionOrdered.cpp positionRandom/positionRandom.cpp +positionFile/positionFile.cpp empty/empty.cpp ) #set(link_lib phasicFlow Kokkos::kokkos Interaction Utilities) diff --git a/utilities/particlesPhasicFlow/positionFile/positionFile.cpp b/utilities/particlesPhasicFlow/positionFile/positionFile.cpp new file mode 100755 index 00000000..039997f8 --- /dev/null +++ b/utilities/particlesPhasicFlow/positionFile/positionFile.cpp @@ -0,0 +1,82 @@ +/*------------------------------- 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 "error.hpp" +#include "dictionary.hpp" +#include "positionFile.hpp" +#include "iFstream.hpp" + +bool pFlow::positionFile::positionPointsFile() +{ + std::cout << "Reading user defined position file...."; + + position_.clear(); + + // ToDo: read position data from file. + + std::ifstream inFile(fileName_); + + inFile >> numPoints_; + + realx3 tempPoint; + + for(int i = 0; i < numPoints_; i++) + { + inFile >> tempPoint.x_ >> tempPoint.y_ >> tempPoint.z_; + position_.push_back(tempPoint); + } + + std::cout << "Done!" << std::endl; + + return true; +} + +pFlow::positionFile::positionFile +( + systemControl& control, + const dictionary& dict +) +: + positionParticles(control, dict), + poDict_ + ( + dict.subDict("fileInfo") + ), + fileName_ + ( + poDict_.getVal("name") + ), + numPoints_ + ( + poDict_.getVal("numPoints") + ), + position_ + ( + "position", + max(maxNumberOfParticles(), numPoints_), + numPoints_ , + RESERVE() + ) +{ + if(!positionPointsFile()) + { + fatalExit; + } +} \ No newline at end of file diff --git a/utilities/particlesPhasicFlow/positionFile/positionFile.hpp b/utilities/particlesPhasicFlow/positionFile/positionFile.hpp new file mode 100755 index 00000000..91b97ee8 --- /dev/null +++ b/utilities/particlesPhasicFlow/positionFile/positionFile.hpp @@ -0,0 +1,100 @@ +/*------------------------------- 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 __positionFile_hpp__ +#define __positionFile_hpp__ + +#include "positionParticles.hpp" + +namespace pFlow +{ + + +class positionFile +: + public positionParticles +{ +private: + + dictionary poDict_; + + word fileName_; + + uint32 numPoints_; + + realx3Vector position_; + + bool positionPointsFile(); + +public: + + // - type Info + TypeInfo("file"); + + positionFile( + systemControl& control, + const dictionary& dict); + + // - add this class to vCtor selection table + add_vCtor( + positionParticles, + positionFile, + dictionary); + + ~positionFile() final = default; + + //// - Methods + + uint32 numPoints()const final + { + return static_cast(position_.size()); + } + + uint32 size()const final + { + return static_cast(position_.size()); + } + + real maxDiameter() const final + { + return 0; + } + + // - const access to position + const realx3Vector& position()const final + { + return position_; + } + + // - access to position + realx3Vector& position() final + { + return position_; + } + + +}; + + +} + + + +#endif // __positionFile_hpp__