2025-02-10 15:12:42 +00:00
|
|
|
/*------------------------------- 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"
|
2025-02-16 04:31:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "streams.hpp"
|
|
|
|
// #include "token.hpp"
|
|
|
|
#include "fileSystem.hpp"
|
2025-02-10 15:12:42 +00:00
|
|
|
#include "iFstream.hpp"
|
2025-02-16 04:31:11 +00:00
|
|
|
#include "oFstream.hpp"
|
2025-02-10 15:12:42 +00:00
|
|
|
|
|
|
|
bool pFlow::positionFile::positionPointsFile()
|
|
|
|
{
|
2025-02-16 04:31:11 +00:00
|
|
|
REPORT(0) << "Reading user defined position file....";
|
2025-02-10 15:12:42 +00:00
|
|
|
|
|
|
|
position_.clear();
|
|
|
|
|
2025-02-16 04:31:11 +00:00
|
|
|
// Read position data from file.
|
|
|
|
iFstream is(fileName_);
|
2025-02-10 15:12:42 +00:00
|
|
|
|
2025-02-16 04:31:11 +00:00
|
|
|
realx3 tempPoint;
|
2025-02-10 15:12:42 +00:00
|
|
|
|
2025-02-16 04:31:11 +00:00
|
|
|
token tok;
|
2025-02-10 15:12:42 +00:00
|
|
|
|
2025-02-24 10:25:56 +00:00
|
|
|
while (!is.bad())
|
2025-02-16 04:31:11 +00:00
|
|
|
{
|
|
|
|
// read position x
|
2025-02-24 10:25:56 +00:00
|
|
|
|
|
|
|
is >> tok;
|
|
|
|
if(tok.good()&& tok.isNumber()&& !is.eof())
|
|
|
|
{
|
|
|
|
tempPoint.x() = tok.realToken();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ioErrorInFile(is.name(), is.lineNumber())<< "Bad char or end of file in reading position x!\n";
|
|
|
|
return false;
|
|
|
|
}
|
2025-02-10 15:12:42 +00:00
|
|
|
|
2025-02-16 04:31:11 +00:00
|
|
|
if(commaSeparated_)
|
|
|
|
{
|
|
|
|
is >> tok;
|
2025-02-24 10:25:56 +00:00
|
|
|
if( !tok.isComma() || is.eof())
|
2025-02-16 04:31:11 +00:00
|
|
|
{
|
2025-02-24 10:25:56 +00:00
|
|
|
ioErrorInFile(is.name(), is.lineNumber())<< "Bad char or end of file in reading comma!\n";
|
2025-02-16 04:31:11 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// read position y
|
2025-02-24 10:25:56 +00:00
|
|
|
is >> tok;
|
|
|
|
if(tok.good()&& tok.isNumber()&& !is.eof())
|
|
|
|
{
|
|
|
|
tempPoint.y() = tok.realToken();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ioErrorInFile(is.name(), is.lineNumber())<< "Bad char or end of file in reading position y!\n";
|
|
|
|
return false;
|
|
|
|
}
|
2025-02-16 04:31:11 +00:00
|
|
|
|
|
|
|
if(commaSeparated_)
|
|
|
|
{
|
|
|
|
is >> tok;
|
2025-02-24 10:25:56 +00:00
|
|
|
if(!tok.isComma() || is.eof())
|
2025-02-16 04:31:11 +00:00
|
|
|
{
|
2025-02-24 10:25:56 +00:00
|
|
|
ioErrorInFile(is.name(), is.lineNumber())<< "Bad char or end of file in reading comma!\n";
|
2025-02-16 04:31:11 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// read position z
|
2025-02-24 10:25:56 +00:00
|
|
|
is >> tok;
|
|
|
|
if(tok.good()&& tok.isNumber()&& !is.eof())
|
|
|
|
{
|
|
|
|
tempPoint.z() = tok.realToken();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ioErrorInFile(is.name(), is.lineNumber())<< "Bad char or end of file in reading position z!\n";
|
|
|
|
return false;
|
|
|
|
}
|
2025-02-16 04:31:11 +00:00
|
|
|
|
|
|
|
// insert position data to vector
|
2025-02-10 15:12:42 +00:00
|
|
|
position_.push_back(tempPoint);
|
2025-02-24 10:25:56 +00:00
|
|
|
|
|
|
|
is>>tok;
|
|
|
|
if(is.eof()) break;
|
|
|
|
|
|
|
|
is.putBack(tok);
|
2025-02-10 15:12:42 +00:00
|
|
|
}
|
|
|
|
|
2025-02-16 04:31:11 +00:00
|
|
|
REPORT(0) << "Done!" << END_REPORT;
|
2025-02-10 15:12:42 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
pFlow::positionFile::positionFile
|
|
|
|
(
|
|
|
|
systemControl& control,
|
|
|
|
const dictionary& dict
|
|
|
|
)
|
|
|
|
:
|
|
|
|
positionParticles(control, dict),
|
|
|
|
poDict_
|
|
|
|
(
|
|
|
|
dict.subDict("fileInfo")
|
|
|
|
),
|
|
|
|
fileName_
|
|
|
|
(
|
|
|
|
poDict_.getVal<word>("name")
|
|
|
|
),
|
2025-02-16 04:31:11 +00:00
|
|
|
commaSeparated_
|
2025-02-10 15:12:42 +00:00
|
|
|
(
|
2025-02-16 04:31:11 +00:00
|
|
|
poDict_.getValOrSet("commaSeparated", Logical("Yes"))
|
2025-02-10 15:12:42 +00:00
|
|
|
),
|
|
|
|
position_
|
|
|
|
(
|
|
|
|
"position",
|
2025-02-24 10:25:56 +00:00
|
|
|
1,
|
2025-02-16 04:31:11 +00:00
|
|
|
0,
|
2025-02-10 15:12:42 +00:00
|
|
|
RESERVE()
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if(!positionPointsFile())
|
|
|
|
{
|
|
|
|
fatalExit;
|
|
|
|
}
|
|
|
|
}
|