first modifications for coupling

This commit is contained in:
hamidrezanorouzi
2022-12-03 12:12:56 +03:30
parent 14ef70bfdf
commit 2b514d0302
31 changed files with 701 additions and 47 deletions

View File

@ -2,6 +2,7 @@
set(SourceFiles
vtkFile.C
readFromTimeFolder.C
readControlDict.C
)
set(link_libs Kokkos::kokkos phasicFlow Particles Geometry)

View File

@ -0,0 +1,121 @@
/*------------------------------- 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 "readControlDict.H"
#include "iFstream.H"
#include "timeFolder.H"
pFlow::word pFlow::readControlDict::convertTimeToName(
const real t,
const int32 precision)const
{
std::ostringstream buf;
if( formatType_ == "general")
buf.setf(ios_base::fmtflags(0), ios_base::floatfield);
else if(formatType_ == "scientific")
buf.setf(ios_base::fmtflags(ios_base::scientific), ios_base::floatfield);
else if(formatType_ == "fixed")
buf.setf(ios_base::fmtflags(ios_base::fixed), ios_base::floatfield);
else
{
fatalErrorInFunction<<"the timeFormat is not correct, it should be "
" (genral, scientific, fixe) but you supplied "<< formatType_<<endl;
fatalExit;
}
buf.precision(precision);
buf << t;
return buf.str();
}
bool pFlow::readControlDict::read()
{
iFstream cdFile(cdPath_);
word startFrom;
if( !cdFile.findTokenAndNextSilent("startFrom", startFrom))
{
startFrom = "latestTime";
}
if(startFrom == "startTime")
{
if(!cdFile.findKeywordAndVal("startTime", startTime_ ))
{
fatalErrorInFunction<<"Could not read startTime from file "<< cdPath_<<endl;
return false;
}
}
else
{
timeFolder folders(rootPath_);
if(startFrom == "firstTime")
{
startTime_ = folders.startTime();
}
else if( startFrom == "latestTime")
{
startTime_ = folders.endTime();
}
else
{
fatalErrorInFunction<<
"expected firstTime, latestTime, or startTime in front of StartFrom, "<<endl<<
"but found "<<startFrom<<endl;
return false;
}
}
if(!cdFile.findKeywordAndVal("endTime", endTime_ ))
{
fatalErrorInFunction<<
"Could not read endTime from file "<< cdPath_<<endl;
return false;
}
if(!cdFile.findKeywordAndVal("writeInterval", saveInterval_))
{
fatalErrorInFunction<<
"Could not read writeInterval from file "<< cdPath_<<endl;
return false;
}
formatType_ = cdFile.lookupDataOrSet<word>("timeFormat", "general");
precision_ = cdFile.lookupDataOrSet("timePrecision", 6);
return true;
}
pFlow::readControlDict::readControlDict(
const fileSystem& rootPath,
const fileSystem& cdPath)
:
rootPath_(rootPath),
cdPath_(cdPath)
{
if(!read())
{
fatalExit;
}
}

View File

@ -0,0 +1,87 @@
/*------------------------------- 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 __readControlDict_H__
#define __readControlDict_H__
#include "fileSystem.H"
namespace pFlow
{
class
readControlDict
{
protected:
fileSystem rootPath_;
fileSystem cdPath_;
real startTime_;
real endTime_;
real saveInterval_;
word formatType_;
int32 precision_;
inline static fileSystem defaultRootPath = CWD();
inline static fileSystem defaultCDPath = CWD()/"system"+"controlDict";
word convertTimeToName(const real t, const int32 precision)const;
bool read();
public:
readControlDict(
const fileSystem& rootPath = defaultRootPath,
const fileSystem& cdPath = defaultCDPath);
auto startTime()const
{
return startTime_;
}
auto endTime()const
{
return endTime_;
}
auto saveInterval()const
{
return saveInterval_;
}
auto startTimeName()const
{
return convertTimeToName(startTime_, precision_);
}
};
}
#endif //__readControlDict_H__

View File

@ -7,6 +7,6 @@ stlWall/stlWall.C
cylinderWall/cylinderWall.C
cuboidWall/cuboidWall.C
)
set(link_lib phasicFlow Geometry Kokkos::kokkos)
set(link_lib phasicFlow Geometry Kokkos::kokkos Utilities)
pFlow_make_executable_install(geometryPhasicFlow source_files link_lib)

View File

@ -23,6 +23,8 @@ Licence:
#include "Wall.H"
#include "multiTriSurface.H"
#include "geometryMotion.H"
#include "commandLine.H"
#include "readControlDict.H"
using pFlow::output;
using pFlow::endl;
@ -33,10 +35,25 @@ using pFlow::wordVector;
using pFlow::Wall;
using pFlow::geometry;
using pFlow::multiTriSurface;
using pFlow::commandLine;
int main( int argc, char* argv[] )
{
commandLine cmds(
"geometryPhasicFlow",
"Converts the supplied informaiton for sufraces in"
" geometryDict into PhasicFlow geometry data structure");
bool isCoupling = false;
cmds.add_flag(
"-c,--coupling",
isCoupling,
"Is this a fluid-particle coupling simulation?");
if(!cmds.parse(argc, argv)) return 0;
// this should be palced in each main
#include "initialize_Control.H"

View File

@ -25,6 +25,8 @@ Licence:
#include "timeFolder.H"
#include "commandLine.H"
#include "ranges.H"
#include "readControlDict.H"
using pFlow::word;
using pFlow::wordVector;
@ -80,6 +82,8 @@ int main(int argc, char** argv )
"a space separated lists of time folders, or a strided range begin:stride:end, or an interval begin:end",
" ");
bool isCoupling = false;
if(!cmds.parse(argc, argv)) return 0;

View File

@ -6,6 +6,6 @@ positionOrdered/positionOrdered.C
positionRandom/positionRandom.C
empty/empty.C
)
set(link_lib phasicFlow Kokkos::kokkos Interaction)
set(link_lib phasicFlow Kokkos::kokkos Interaction Utilities)
pFlow_make_executable_install(particlesPhasicFlow source_files link_lib)

View File

@ -24,6 +24,7 @@ Licence:
#include "setFields.H"
#include "systemControl.H"
#include "commandLine.H"
#include "readControlDict.H"
using pFlow::output;
using pFlow::endl;
@ -45,7 +46,7 @@ int main( int argc, char* argv[] )
"createParticles",
"Read the dictionary createParticles and create particles"
" based on the two sub-dictionaries positionParticles and setFields.\n"
"First executespositionParticles and then setFields, except "
"First executes positionParticles and then setFields, except "
"otherwise selected in the command line.");
@ -62,6 +63,11 @@ int main( int argc, char* argv[] )
"Exectue the setFields part only. Read the pointStructure from "
"time folder and setFields and save the result in the same time folder.");
bool isCoupling = false;
cmds.add_flag(
"-c,--coupling",
isCoupling,
"Is this a fluid-particle coupling simulation");
if(!cmds.parse(argc, argv)) return 0;

View File

@ -22,6 +22,7 @@ Licence:
#include "timeFolder.H"
#include "commandLine.H"
#include "ranges.H"
#include "readControlDict.H"
#include "postprocess.H"
@ -65,6 +66,8 @@ int main(int argc, char** argv )
withZeroFolder,
"Do NOT exclude zero folder from processing time folders");
bool isCoupling = false;
if(!cmds.parse(argc, argv)) return 0;
#include "initialize_Control.H"