update rapid filling

This commit is contained in:
wanqing0421 2025-02-16 12:31:11 +08:00
parent 29d922e3c5
commit ae251598a4
5 changed files with 59 additions and 24 deletions

View File

View File

@ -1,3 +1,3 @@
2
0.049302 0.00425012 -0.0068537
0.0456989 -0.0209381 -0.00786771

View File

@ -39,11 +39,7 @@ positionParticles // positions particles
{
name dataFile; // the name of the file that contains position and particle data, the data format is ASCII. The file is located at the root case folder
numPoints 10000;
fields ( (velocity realx3) (shapeName word) ); // (optional, it could be an empty list or omitted) list of other fields/data that should be read from the file
commaSeparated No; // optional (default is No). if Yes, then fields are separated by a comma
commaSeparated No; // optional (default is No). if Yes, then fields are separated by a comma
}
regionType box; // other options: cylinder and sphere

View File

@ -21,29 +21,63 @@ Licence:
#include "error.hpp"
#include "dictionary.hpp"
#include "positionFile.hpp"
#include "streams.hpp"
// #include "token.hpp"
#include "fileSystem.hpp"
#include "iFstream.hpp"
#include "oFstream.hpp"
bool pFlow::positionFile::positionPointsFile()
{
std::cout << "Reading user defined position file....";
REPORT(0) << "Reading user defined position file....";
position_.clear();
// ToDo: read position data from file.
std::ifstream inFile(fileName_);
inFile >> numPoints_;
// Read position data from file.
iFstream is(fileName_);
realx3 tempPoint;
for(int i = 0; i < numPoints_; i++)
token tok;
while (!is.eof() || !is.bad())
{
inFile >> tempPoint.x_ >> tempPoint.y_ >> tempPoint.z_;
// read position x
is >> tempPoint.x_;
if(commaSeparated_)
{
is >> tok;
if(tok.type() != token::COMMA)
{
fatalErrorInFunction << "Error datafile format, the data not comma separated!";
return false;
}
}
// read position y
is >> tempPoint.y_;
if(commaSeparated_)
{
is >> tok;
if(tok.type() != token::COMMA)
{
fatalErrorInFunction << "Error datafile format, the data not comma separated!";
return false;
}
}
// read position z
is >> tempPoint.z_;
// insert position data to vector
position_.push_back(tempPoint);
}
std::cout << "Done!" << std::endl;
REPORT(0) << "Done!" << END_REPORT;
return true;
}
@ -63,15 +97,15 @@ pFlow::positionFile::positionFile
(
poDict_.getVal<word>("name")
),
numPoints_
commaSeparated_
(
poDict_.getVal<uint64>("numPoints")
poDict_.getValOrSet("commaSeparated", Logical("Yes"))
),
position_
(
"position",
max(maxNumberOfParticles(), numPoints_),
numPoints_ ,
max(maxNumberOfParticles(), position_.size()),
0,
RESERVE()
)
{

View File

@ -35,12 +35,14 @@ private:
dictionary poDict_;
word fileName_;
// word fileName_;
uint32 numPoints_;
fileSystem fileName_;
realx3Vector position_;
Logical commaSeparated_;
bool positionPointsFile();
public:
@ -77,6 +79,11 @@ public:
return 0;
}
// bool commaSeparated()const
// {
// return commaSeparated_();
// }
// - const access to position
const realx3Vector& position()const final
{
@ -88,8 +95,6 @@ public:
{
return position_;
}
};