2022-09-05 06:44:41 +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.
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
2022-12-09 22:02:54 +00:00
|
|
|
#include "positionParticles.hpp"
|
|
|
|
#include "pointStructure.hpp"
|
2024-01-13 06:24:23 +00:00
|
|
|
//#include "setFields.hpp"
|
2022-12-09 22:02:54 +00:00
|
|
|
#include "systemControl.hpp"
|
|
|
|
#include "commandLine.hpp"
|
2023-12-25 10:29:24 +00:00
|
|
|
#include "vocabs.hpp"
|
|
|
|
|
2023-12-17 11:57:05 +00:00
|
|
|
//#include "readControlDict.hpp"
|
2022-09-05 06:44:41 +00:00
|
|
|
|
2024-01-13 06:24:23 +00:00
|
|
|
using namespace pFlow;
|
2022-09-05 06:44:41 +00:00
|
|
|
|
|
|
|
int main( int argc, char* argv[] )
|
|
|
|
{
|
|
|
|
|
|
|
|
commandLine cmds(
|
|
|
|
"createParticles",
|
|
|
|
"Read the dictionary createParticles and create particles"
|
|
|
|
" based on the two sub-dictionaries positionParticles and setFields.\n"
|
2022-12-03 08:42:56 +00:00
|
|
|
"First executes positionParticles and then setFields, except "
|
2022-09-05 06:44:41 +00:00
|
|
|
"otherwise selected in the command line.");
|
|
|
|
|
|
|
|
|
|
|
|
bool positionOnly = false;
|
|
|
|
cmds.add_flag(
|
|
|
|
"--positionParticles-only",
|
|
|
|
positionOnly,
|
|
|
|
"Exectue the positionParticles part only and store the created "
|
|
|
|
"pointStructure in the time folder.");
|
|
|
|
|
|
|
|
bool setOnly = false;
|
|
|
|
cmds.add_flag("--setFields-only",
|
|
|
|
setOnly,
|
|
|
|
"Exectue the setFields part only. Read the pointStructure from "
|
|
|
|
"time folder and setFields and save the result in the same time folder.");
|
|
|
|
|
2022-12-03 08:42:56 +00:00
|
|
|
bool isCoupling = false;
|
|
|
|
cmds.add_flag(
|
|
|
|
"-c,--coupling",
|
|
|
|
isCoupling,
|
|
|
|
"Is this a fluid-particle coupling simulation");
|
2022-09-05 06:44:41 +00:00
|
|
|
|
|
|
|
if(!cmds.parse(argc, argv)) return 0;
|
|
|
|
|
|
|
|
if(setOnly && positionOnly)
|
|
|
|
{
|
2022-12-24 11:30:00 +00:00
|
|
|
ERR<<
|
2023-12-25 10:29:24 +00:00
|
|
|
"Options --positionParticles-only and --setFields-only cannot be used simeltanuously. \n"<<END_ERR;
|
2022-09-05 06:44:41 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this should be palced in each main
|
2022-12-09 22:02:54 +00:00
|
|
|
#include "initialize_Control.hpp"
|
2022-09-05 06:44:41 +00:00
|
|
|
|
2024-01-13 06:24:23 +00:00
|
|
|
auto objCPDict = IOobject::make<fileDictionary>
|
2022-09-05 06:44:41 +00:00
|
|
|
(
|
|
|
|
objectFile
|
|
|
|
(
|
2022-09-05 12:28:23 +00:00
|
|
|
"particlesDict",
|
2022-09-05 06:44:41 +00:00
|
|
|
Control.settings().path(),
|
|
|
|
objectFile::READ_ALWAYS,
|
|
|
|
objectFile::WRITE_ALWAYS
|
|
|
|
),
|
2024-01-13 06:24:23 +00:00
|
|
|
"particlesDict"
|
2022-09-05 06:44:41 +00:00
|
|
|
);
|
|
|
|
|
2024-01-13 06:24:23 +00:00
|
|
|
auto& cpDict = objCPDict().getObject<fileDictionary>();
|
2022-09-05 06:44:41 +00:00
|
|
|
|
2023-04-12 05:19:36 +00:00
|
|
|
pointStructure* pStructPtr = nullptr;
|
|
|
|
|
2022-09-05 06:44:41 +00:00
|
|
|
|
|
|
|
if(!setOnly)
|
|
|
|
{
|
|
|
|
|
|
|
|
// position particles based on the dict content
|
2023-12-25 10:29:24 +00:00
|
|
|
REPORT(0)<< "Positioning points . . . \n"<<END_REPORT;
|
|
|
|
auto pointPosition = positionParticles::create(Control, cpDict.subDict("positionParticles"));
|
2022-09-05 06:44:41 +00:00
|
|
|
|
|
|
|
fileSystem pStructPath = Control.time().path()+pointStructureFile__;
|
|
|
|
|
|
|
|
auto finalPos = pointPosition().getFinalPosition();
|
|
|
|
|
|
|
|
|
2023-04-12 05:19:36 +00:00
|
|
|
auto& pStruct = Control.time().emplaceObject<pointStructure>
|
2022-09-05 06:44:41 +00:00
|
|
|
(
|
|
|
|
objectFile
|
|
|
|
(
|
|
|
|
pointStructureFile__,
|
|
|
|
Control.time().path(),
|
|
|
|
objectFile::READ_NEVER,
|
|
|
|
objectFile::WRITE_ALWAYS
|
|
|
|
),
|
2023-12-25 10:29:24 +00:00
|
|
|
Control,
|
|
|
|
finalPos
|
2022-09-05 06:44:41 +00:00
|
|
|
);
|
|
|
|
|
2023-04-12 05:19:36 +00:00
|
|
|
pStructPtr = &pStruct;
|
2022-09-05 06:44:41 +00:00
|
|
|
|
2023-04-12 05:19:36 +00:00
|
|
|
REPORT(1)<< "Created pStruct with "<< pStruct.size() << " points and capacity "<<
|
2023-12-25 10:29:24 +00:00
|
|
|
pStruct.capacity()<<" . . ."<< END_REPORT;
|
2022-09-05 06:44:41 +00:00
|
|
|
|
2024-01-13 06:24:23 +00:00
|
|
|
//REPORT(1)<< "Writing pStruct to " << Control.time().path()+ pointStructureFile__<< END_REPORT<<endl<<endl;
|
|
|
|
|
|
|
|
/*if( !Control.time().write())
|
2022-09-05 06:44:41 +00:00
|
|
|
{
|
|
|
|
fatalErrorInFunction<<
|
2022-12-24 11:30:00 +00:00
|
|
|
"ERRor in writing to file. \n ";
|
2022-09-05 06:44:41 +00:00
|
|
|
return 1;
|
2024-01-13 06:24:23 +00:00
|
|
|
}*/
|
|
|
|
}
|
|
|
|
else
|
2022-09-05 06:44:41 +00:00
|
|
|
{
|
2023-04-12 05:19:36 +00:00
|
|
|
|
|
|
|
auto& pStruct = Control.time().emplaceObject<pointStructure>
|
2022-09-05 06:44:41 +00:00
|
|
|
(
|
|
|
|
objectFile
|
|
|
|
(
|
|
|
|
pointStructureFile__,
|
|
|
|
Control.time().path(),
|
2023-04-12 05:19:36 +00:00
|
|
|
objectFile::READ_NEVER,
|
|
|
|
objectFile::WRITE_ALWAYS
|
2023-12-25 10:29:24 +00:00
|
|
|
),
|
|
|
|
Control
|
2022-09-05 06:44:41 +00:00
|
|
|
);
|
2023-04-12 05:19:36 +00:00
|
|
|
|
|
|
|
pStructPtr = &pStruct;
|
|
|
|
|
2022-09-05 06:44:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!positionOnly)
|
|
|
|
{
|
2024-01-13 06:24:23 +00:00
|
|
|
WARNING<< "setFields is not active "<<END_WARNING;
|
|
|
|
/* auto& pStruct = *pStructPtr;
|
2022-09-05 06:44:41 +00:00
|
|
|
|
|
|
|
auto& sfDict = cpDict.subDict("setFields");
|
|
|
|
|
|
|
|
setFieldList defValueList(sfDict.subDict("defaultValue"));
|
|
|
|
|
|
|
|
for(auto& sfEntry: defValueList)
|
|
|
|
{
|
|
|
|
if( !sfEntry.setPointFieldDefaultValueNewAll(Control.time(), pStruct, true))
|
|
|
|
{
|
2023-12-25 10:29:24 +00:00
|
|
|
ERR<< "\n error occured in setting default value fields.\n"<<END_ERR;
|
2022-09-05 06:44:41 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
output<<endl;
|
|
|
|
|
|
|
|
auto& selectorsDict = sfDict.subDict("selectors");
|
|
|
|
|
|
|
|
auto selNames = selectorsDict.dictionaryKeywords();
|
|
|
|
|
|
|
|
for(auto name: selNames)
|
|
|
|
{
|
2023-12-25 10:29:24 +00:00
|
|
|
REPORT(1)<< "Applying selector " << Green_Text(name) <<END_REPORT;
|
2022-09-05 06:44:41 +00:00
|
|
|
|
|
|
|
if(
|
|
|
|
!applySelector(Control, pStruct, selectorsDict.subDict(name))
|
|
|
|
)
|
|
|
|
{
|
2023-12-25 10:29:24 +00:00
|
|
|
ERR<<"\n error occured in setting selector. \n"<<END_ERR;
|
2022-09-05 06:44:41 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
output<<endl;
|
2024-01-13 06:24:23 +00:00
|
|
|
}*/
|
2022-09-05 06:44:41 +00:00
|
|
|
}
|
|
|
|
|
2024-01-13 06:24:23 +00:00
|
|
|
|
|
|
|
if( !Control.time().write(true))
|
|
|
|
{
|
|
|
|
fatalErrorInFunction<<
|
|
|
|
"ERRor in writing to file. \n ";
|
|
|
|
return 1;
|
|
|
|
}
|
2023-12-25 10:29:24 +00:00
|
|
|
REPORT(0)<< Green_Text("\nFinished successfully.\n")<<END_REPORT;
|
2022-09-05 06:44:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
// this should be palced in each main
|
2022-12-09 22:02:54 +00:00
|
|
|
#include "finalize.hpp"
|
2022-09-05 06:44:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2023-04-12 05:19:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
uniquePtr<IOobject> pStructObj{nullptr};
|
|
|
|
|
|
|
|
if(!setOnly)
|
|
|
|
{
|
|
|
|
|
|
|
|
// position particles based on the dict content
|
|
|
|
REPORT(0)<< "Positioning points . . . \n"<<endREPORT;
|
|
|
|
auto pointPosition = positionParticles::create(cpDict.subDict("positionParticles"));
|
|
|
|
|
|
|
|
fileSystem pStructPath = Control.time().path()+pointStructureFile__;
|
|
|
|
|
|
|
|
auto finalPos = pointPosition().getFinalPosition();
|
|
|
|
|
|
|
|
|
|
|
|
pStructObj = IOobject::make<pointStructure>
|
|
|
|
(
|
|
|
|
objectFile
|
|
|
|
(
|
|
|
|
pointStructureFile__,
|
|
|
|
Control.time().path(),
|
|
|
|
objectFile::READ_NEVER,
|
|
|
|
objectFile::WRITE_ALWAYS
|
|
|
|
),
|
|
|
|
finalPos
|
|
|
|
);
|
|
|
|
|
|
|
|
auto& pSruct = pStructObj().getObject<pointStructure>();
|
|
|
|
|
|
|
|
REPORT(1)<< "Created pStruct with "<< pSruct.size() << " points and capacity "<<
|
|
|
|
pSruct.capacity()<<" . . ."<< endREPORT;
|
|
|
|
|
|
|
|
REPORT(1)<< "Writing pStruct to " << pStructObj().path() << endREPORT<<endl<<endl;
|
|
|
|
|
|
|
|
if( !pStructObj().write())
|
|
|
|
{
|
|
|
|
fatalErrorInFunction<<
|
|
|
|
"ERRor in writing to file. \n ";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
pStructObj = IOobject::make<pointStructure>
|
|
|
|
(
|
|
|
|
objectFile
|
|
|
|
(
|
|
|
|
pointStructureFile__,
|
|
|
|
Control.time().path(),
|
|
|
|
objectFile::READ_ALWAYS,
|
|
|
|
objectFile::WRITE_NEVER
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!positionOnly)
|
|
|
|
{
|
|
|
|
|
|
|
|
auto& pStruct = pStructObj().getObject<pointStructure>();
|
|
|
|
|
|
|
|
auto& sfDict = cpDict.subDict("setFields");
|
|
|
|
|
|
|
|
setFieldList defValueList(sfDict.subDict("defaultValue"));
|
|
|
|
|
|
|
|
for(auto& sfEntry: defValueList)
|
|
|
|
{
|
|
|
|
if( !sfEntry.setPointFieldDefaultValueNewAll(Control.time(), pStruct, true))
|
|
|
|
{
|
|
|
|
ERR<< "\n error occured in setting default value fields.\n"<<endERR;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
output<<endl;
|
|
|
|
|
|
|
|
auto& selectorsDict = sfDict.subDict("selectors");
|
|
|
|
|
|
|
|
auto selNames = selectorsDict.dictionaryKeywords();
|
|
|
|
|
|
|
|
for(auto name: selNames)
|
|
|
|
{
|
|
|
|
REPORT(1)<< "Applying selector " << greenText(name) <<endREPORT;
|
|
|
|
|
|
|
|
if(
|
|
|
|
!applySelector(Control, pStruct, selectorsDict.subDict(name))
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ERR<<"\n error occured in setting selector. \n"<<endERR;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
output<<endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|