32 #include <openvdb/openvdb.h> 38 #define defaultPathToProgramConfigFile "Config/Microflow.cfg" 39 #define defaultScope "MF01" 40 //------------------------------------------------------------------------------------------------------------- 42 int main(
int argc,
char** argv) {
48 const char* pPathToCaseFolder =
"Data/Validation_tests/Case_MEDIUM_straight_square_channel";
49 const char* pPathToCaseFile =
"";
50 const char* pPathToThreadFile =
"";
52 std::string tempString;
54 bool geometryOnly =
false;
56 auto CPU_ThreadsNr = 0;
60 cout <<
"----------------------------------------------------------------------------------------------------------------------------" << endl;
61 cout <<
"Microflow 3D v1.0 " << endl;
62 cout <<
"----------------------------------------------------------------------------------------------------------------------------" << endl;
65 cout <<
"Microflow framework >>> Initialization info:" << endl;
68 openvdb::initialize();
72 CmdLineArgsParser_Ptr->parseCmdLineArgs(argc, argv, pPathToProgramConfigFile, pPathToCaseFolder, pScope, verbose, geometryOnly, CPU_ThreadsNr);
78 cout <<
"----------------------------------------------------------------------------------------------------------------------------" << endl;
82 cout <<
"Microflow framework >>> Geometry building info: " << endl;
86 Geometry_Ptr->ReadGrid(verbose);
87 Geometry_Ptr->AutomaticBoundaryFind();
89 Geometry_Ptr->WriteGeometryGridToVtiFile();
90 Geometry_Ptr->WriteGeometryGridToVDBFile();
92 cout <<
"----------------------------------------------------------------------------------" << endl;
93 cout <<
"Geometry file has been generated ***** Goodbye *****" << endl;
94 cout <<
"----------------------------------------------------------------------------------" << endl;
97 Geometry_Ptr->FluidAddFromThreadFile();
98 Geometry_Ptr->SolidAddFromThreadFile();
99 Geometry_Ptr->BoundaryAddFromThreadFile();
100 Geometry_Ptr->Clean();
103 cout <<
"----------------------------------------------------------------------------------------------------------------------------" << endl;
107 cout <<
"MFSolver_CPU >>> Case and program parameters initialization info: " << endl;
116 if (CPU_ThreadsNr == 0 && CaseParameters_Ptr->CPU_ThreadsNr == 0)
117 CPU_ThreadsNr = omp_get_num_procs();
118 else if (CPU_ThreadsNr == 0 && CaseParameters_Ptr->CPU_ThreadsNr != 0)
119 CPU_ThreadsNr = CaseParameters_Ptr->CPU_ThreadsNr;
122 cout <<
"----------------------------------------------------------------------------------------------------------------------------" << endl;
126 cout <<
"MFDatabase >>> Threads building info: " << endl;
133 cout <<
"----------------------------------------------------------------------------------------------------------------------------" << endl;
137 cout <<
"MFSolver_CPU >>> Threads data initialization info: " << endl;
161 cout <<
"----------------------------------------------------------------------------------------------------------------------------" << endl;
165 cout <<
"MFSolver_CPU >>> Main loop info: " << endl;
168 unsigned int SimStep = 0;
171 std::string DataFileName;
172 const unsigned int ConsoleWriteStep = CaseParameters_Ptr->ConsoleWriteStep_K_W;
173 const unsigned int FileWriteStep = CaseParameters_Ptr->VTKWriteStep_VTK_W;
174 const unsigned int VTKFileMaxNumber = CaseParameters_Ptr->VTKFileMaxNumber_VTK_Max;
182 for (
auto & Thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
183 if (Thread->m_DoPreCollision && Thread->m_DoCollision) {
184 Thread->DoPreANDCollision(CPU_ThreadsNr);
186 else if (Thread->m_DoCollision) {
187 Thread->DoCollisionOnly(CPU_ThreadsNr);
189 else if (Thread->m_DoPreCollision) {
190 Thread->DoPreCollisionOnly(CPU_ThreadsNr);
195 DataFileName = (ConfigData_Ptr->CaseFolder + ConfigData_Ptr->getProgramStringParam(
"OutputFile") + std::to_string(SimStep));
196 Geometry_Ptr->m_MFGrid_GeometryGrid_Ptr->saveAllDataToVTIFile(ThreadArray_Ptr, ConfigData_Ptr, DataFileName);
197 std::cout << std::endl;
203 std::chrono::time_point<std::chrono::high_resolution_clock> TimeStart = std::chrono::high_resolution_clock::now();
205 V_SimError = CaseParameters_Ptr->Sc_VelocityResidueError_ErrV + 1;
206 M_SimError = M_SimError > CaseParameters_Ptr->MassFlowError_ErrM + 1;
208 while ((V_SimError > CaseParameters_Ptr->Sc_VelocityResidueError_ErrV) || (M_SimError > CaseParameters_Ptr->MassFlowError_ErrM)) {
210 for (
auto & Thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr)
211 if (Thread->m_DoPropagation)
212 Thread->DoPropagation(CPU_ThreadsNr);
214 if (SimStep % ConsoleWriteStep == 0)
217 if (FileWriteStep != 0 && SimStep % FileWriteStep == 0){
218 cout << std::setw(194) << std::setfill(
'=') <<
"=" << std::setfill(
' ') << std::endl;
219 if(VTKFileMaxNumber > 0 && SimStep / FileWriteStep > VTKFileMaxNumber) {
220 std::string ErraseFileName = (ConfigData_Ptr->CaseFolder + ConfigData_Ptr->getProgramStringParam(
"OutputFile") +
221 std::to_string(SimStep - VTKFileMaxNumber * FileWriteStep) +
".vti");
222 cout<<
"Errased file: ----> "<<ErraseFileName<<endl;
223 remove(ErraseFileName.c_str());
225 DataFileName = (ConfigData_Ptr->CaseFolder + ConfigData_Ptr->getProgramStringParam(
"OutputFile") + std::to_string(SimStep));
226 Geometry_Ptr->m_MFGrid_GeometryGrid_Ptr->saveAllDataToVTIFile(ThreadArray_Ptr, ConfigData_Ptr, DataFileName);
227 cout << std::setw(194) << std::setfill(
'=') <<
"=" << std::setfill(
' ') << std::endl;
230 for (
auto &Thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
231 if (Thread->m_DoPreCollision && Thread->m_DoCollision)
232 Thread->DoPreANDCollision(CPU_ThreadsNr);
233 else if (Thread->m_DoCollision)
234 Thread->DoCollisionOnly(CPU_ThreadsNr);
235 else if (Thread->m_DoPreCollision)
236 Thread->DoPreCollisionOnly(CPU_ThreadsNr);
242 for (
auto & Thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr)
243 Thread->DoPropagation(CPU_ThreadsNr);
249 auto TimeStop = std::chrono::high_resolution_clock::now();
252 cout << std::setw(194) << std::setfill(
'=') <<
"=" << std::setfill(
' ') << std::endl;
253 DataFileName = (ConfigData_Ptr->CaseFolder + ConfigData_Ptr->getProgramStringParam(
"OutputFile") + std::to_string(SimStep));
254 Geometry_Ptr->m_MFGrid_GeometryGrid_Ptr->saveAllDataToVTIFile(ThreadArray_Ptr, ConfigData_Ptr, DataFileName);
255 cout << std::setw(194) << std::setfill(
'=') <<
"=" << std::setfill(
' ') << std::endl;
264 cout <<
"----------------------------------------------------------------------------------" << endl;
265 cout <<
"Microflow 3D ***** Goodbye *****" << endl;
266 cout <<
"----------------------------------------------------------------------------------" << endl;
static std::shared_ptr< MF::GB::GeometryBuildFromSTL > New(const std::shared_ptr< MF::Database::ConfigData > &ConfigData_Ptr, const std::shared_ptr< MF::GU::LatticeParametersD3Q19 > &LatticeParameters_Ptr)
#define defaultPathToProgramConfigFile
Default path to program parameters.
static void GridThreading(const openvdb::Int64Grid::Ptr &VDBGrid_Ptr, std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Grid partitioning into MFThreads.
static void PrintTimeStepStatistics(double &V_SimError, double &M_SimError, const unsigned int &SimStep, const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr, const std::shared_ptr< MF::Solver_CPU::CaseParameters > &CaseParameters_Ptr)
Prints on console time step statistics.
static void PrintComputationStatistics(std::chrono::time_point< std::chrono::high_resolution_clock > TimeStart, std::chrono::time_point< std::chrono::high_resolution_clock > TimeStop, unsigned int SimStep, const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Prints on console final computation statistics.
static void ThreadDataInitialize(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr, const std::shared_ptr< MF::Database::ConfigData > &ConfigData_Ptr)
Initialization of MFThread boundary/initial values from thread.cfg file.
int main(int argc, char **argv)
static void EquilibriumInitialization(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr, const std::shared_ptr< MF::Solver_CPU::CaseParameters > &CaseParameters_Ptr)
Initialization of FEQ pre and post collision tables (equilibrium model).
static void PrintCPUInfo(const int &CPU_ThreadsNr)
Prints on console CPU usage info.
static std::shared_ptr< MF::Solver_CPU::CaseParameters > New(std::shared_ptr< MF::Database::ConfigData > ConfigData_Ptr)
static void Initialize(const std::shared_ptr< MF::Solver_CPU::CaseParameters > &CaseParameters_Ptr, const std::shared_ptr< MF::GU::LatticeParametersD3Q19 > &LatticeParameters_Ptr)
static void SetFluidSolidNodePointerToFunc(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Sets pointers to fluid functions of MFThread.
static void ThreadsArrayInfo(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Prints on console information about all MFThreads.
static void Initialize(const std::shared_ptr< MF::Solver_CPU::CaseParameters > &CaseParameters_Ptr, const std::shared_ptr< MF::GU::LatticeParametersD3Q19 > &LatticeParameters_Ptr)
static std::chrono::time_point< std::chrono::high_resolution_clock > m_TimePreviousStep
static std::shared_ptr< MF::Database::ThreadArray > New(const std::shared_ptr< MF::GU::LatticeParametersD3Q19 > &LatticeParameters_Ptr)
MFThreadArray allocator.
static void Initialize(const std::shared_ptr< MF::Database::ConfigData > &ConfigData_Ptr, const std::shared_ptr< MF::GU::LatticeParametersD3Q19 > &LatticeParameters_Ptr)
static void ThreadDefaultDataInitialize(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr, const std::shared_ptr< MF::Solver_CPU::CaseParameters > &CaseParameters_Ptr)
Initialization of MFThread boundary/initial values from thread.cfg file.
static void SetCollisionPointerToFunc(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Sets pointers to proper collision functions in MFThreads.
static void Initialize(const std::shared_ptr< MF::Solver_CPU::CaseParameters > &CaseParameters_Ptr, const std::shared_ptr< MF::GU::LatticeParametersD3Q19 > &LatticeParameters_Ptr)
static void ComputeBasicParameters(const std::shared_ptr< MF::Solver_CPU::CaseParameters > &CaseParameters_Ptr, const openvdb::Int64Grid::Ptr &VDBGrid_Ptr)
Compute: Re, l_ch_LB, Cu, u_ch_LB, dt_phys, nu_LB.
static void PrintGridStatistics(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Prints on console basic grid statistics.
static std::shared_ptr< MF::Solver_CPU::ProgramParameters > New(const std::shared_ptr< MF::Database::ConfigData > &ConfigData_Ptr)
static std::shared_ptr< MF::Database::ConfigData > New(const char *pPathToProgramConfigFile, const char *pPathToCaseFolder, const char *pScope, bool verbose)
static void PrintComputationParameters(const std::shared_ptr< MF::Solver_CPU::CaseParameters > &CaseParameters_Ptr)
Prints on console basic solution parameters.
static void SetBoundaryNodePointerToFunc(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Sets the pointer to the function that performs calculations for the edge node (Thread.h -> its_pBoundaryFunction).
#define defaultScope
Default scope in config files.
static std::shared_ptr< MF::Parser::CmdLineArgsParser > New()
static void ThreadPartitioning(const openvdb::Int64Grid::Ptr &VDBGrid_Ptr, const std::shared_ptr< MF::Database::ConfigData > &ConfigData_Ptr)
MFThreads partitioning.
static std::shared_ptr< MF::GU::LatticeParametersD3Q19 > New()