Microflow 3D  v1.0
MF::Solver_CPU::ConsoleWriter Class Reference

 The ConsoleWriter class collects functions that prints information on console. More...

#include <ConsoleWriter.h>

Public Member Functions

 ConsoleWriter ()=default
 
 ~ConsoleWriter ()=default
 

Static Public Member Functions

static void ThreadsArrayInfo (const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
 Prints on console information about all MFThreads. More...
 
static void ThreadsNodeInfo (const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
 Prints on console information about all Threads node. More...
 
static void ExtendedInfo (const std::shared_ptr< MF::Solver_CPU::ProgramParameters > &ProgramParameters_Ptr, const std::shared_ptr< MF::Solver_CPU::CaseParameters > &CaseParameters_Ptr, const std::shared_ptr< MF::Database::ConfigData > &ConfigData_Ptr)
 Prints on console case and program parameters and also uid-threads defined in thread_params.cfg. More...
 
static void PrintComputationParameters (const std::shared_ptr< MF::Solver_CPU::CaseParameters > &CaseParameters_Ptr)
 Prints on console basic solution parameters. More...
 
static void PrintGridStatistics (const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
 Prints on console basic grid statistics. More...
 
static void PrintCPUInfo (const int &CPU_ThreadsNr)
 Prints on console CPU usage info. More...
 
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. More...
 
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. More...
 
static int parseFileLine (char *line)
 
static int getMemoryUsageValue ()
 

Static Public Attributes

static double m_VSum = 1
 
static double m_minMLUPS = 0
 
static double m_maxMLUPS = 0
 
static unsigned int m_SimPreviousStep = 0
 
static unsigned int m_iter = 0
 
static std::chrono::time_point< std::chrono::high_resolution_clock > m_TimePreviousStep
 

Detailed Description

 The ConsoleWriter class collects functions that prints information on console.

Definition at line 30 of file ConsoleWriter.h.

Constructor & Destructor Documentation

◆ ConsoleWriter()

MF::Solver_CPU::ConsoleWriter::ConsoleWriter ( )
default

◆ ~ConsoleWriter()

MF::Solver_CPU::ConsoleWriter::~ConsoleWriter ( )
default

Member Function Documentation

◆ ExtendedInfo()

void MF::Solver_CPU::ConsoleWriter::ExtendedInfo ( const std::shared_ptr< MF::Solver_CPU::ProgramParameters > &  ProgramParameters_Ptr,
const std::shared_ptr< MF::Solver_CPU::CaseParameters > &  CaseParameters_Ptr,
const std::shared_ptr< MF::Database::ConfigData > &  ConfigData_Ptr 
)
static

Prints on console case and program parameters and also uid-threads defined in thread_params.cfg.

Definition at line 219 of file ConsoleWriter.cpp.

References MF::Solver_CPU::BGK, MF::Solver_CPU::D3Q19, MF::RW::CSVReader::DataReadFromCSVFile(), MF::Solver_CPU::FBGK, MF::Solver_CPU::FromSTL, MF::Solver_CPU::Incompressible, MF::Solver_CPU::MRT, and MF::Solver_CPU::QuasiCompressible.

221  {
222 
223  std::cout << std::endl << "**********************************************************************************" << std::endl;
224  std::cout << "VERBOSE INFO ---program parameters---" << std::endl << std::endl;
225 
226  // Program parameters from the Microflow.cfg file
227  std::cout << "File paths:" << std::endl;
228  std::cout << "\t CaseFolder = " << ProgramParameters_Ptr->CaseFolder << std::endl;
229  std::cout << "\t GeometryFolder = " << ProgramParameters_Ptr->GeometryFolder << std::endl;
230  std::cout << "\t GeometryFile = " << ProgramParameters_Ptr->GeometryFileName << std::endl;
231  std::cout << "\t CaseParametersFile = " << ProgramParameters_Ptr->CaseParametersFile << std::endl;
232  std::cout << "\t ThreadParametersFile = " << ProgramParameters_Ptr->ThreadParametersFile << std::endl;
233  std::cout << "\t ProgramParametersFile = " << ProgramParameters_Ptr->ProgramParametersFile << std::endl;
234  std::cout << "\t CheckPointFile = " << ProgramParameters_Ptr->CheckPointFile << std::endl;
235  std::cout << "\t OutputFile = " << ProgramParameters_Ptr->OutputFile << std::endl;
236 
237  std::cout << std::endl;
238  std::cout.width(82);
239  std::cout.fill('*');
240  std::cout << "*" << std::endl;
241 
242  // Case parameters from the case_params.cfg file
243  std::cout << "VERBOSE INFO ---case parameters---" << std::endl << std::endl;
244  std::cout << "BasicParams:" << std::endl;
245  if (CaseParameters_Ptr->GeometryDefinition == MF::Solver_CPU::GeometryDefinitionClass::FromSTL)
246  std::cout << "\t GeometryDefinition = " << "FromSTL" << std::endl;
247  else
248  std::cout << "Unrecognized parameter " << std::endl;
249  if (CaseParameters_Ptr->FluidFlowModel_MT == MF::Solver_CPU::FlowTypeClass::Incompressible)
250  std::cout << "\t FluidFlowModel_MT = " << "Incompressible" << std::endl;
251  else if (CaseParameters_Ptr->FluidFlowModel_MT == MF::Solver_CPU::FlowTypeClass::QuasiCompressible)
252  std::cout << "\t FluidFlowModel_MT = " << "QuasiCompressible" << std::endl;
253  else
254  std::cout << "Unrecognized parameter " << std::endl;
255  if (CaseParameters_Ptr->CollisionModel_KT == MF::Solver_CPU::ModelTypeClass::BGK)
256  std::cout << "\t CollisionModel_KT = " << "BGK" << std::endl;
257  else if (CaseParameters_Ptr->CollisionModel_KT == MF::Solver_CPU::ModelTypeClass::MRT)
258  std::cout << "\t CollisionModel_KT = " << "MRT" << std::endl;
259  else if (CaseParameters_Ptr->CollisionModel_KT == MF::Solver_CPU::ModelTypeClass::FBGK)
260  std::cout << "\t CollisionModel_KT = " << "FBGK" << std::endl;
261  else
262  std::cout << "Unrecognized parameter " << std::endl;
263  if (CaseParameters_Ptr->LatticeType_La == MF::Solver_CPU::LatticeTypeClass::D3Q19)
264  std::cout << "\t LatticeType_La = " << "D3Q19" << std::endl;
265  else
266  std::cout << "Unrecognized parameter " << std::endl;
267  std::cout << "\t XNodesNumber_Nx1 = " << CaseParameters_Ptr->XNodesNumber_Nx1 << std::endl;
268  std::cout << "\t YNodesNumber_Ny1 = " << CaseParameters_Ptr->YNodesNumber_Ny1 << std::endl;
269  std::cout << "\t ZNodesNumber_Nz1 = " << CaseParameters_Ptr->ZNodesNumber_Nz1 << std::endl;
270 
271  std::cout << std::endl << "Physical params:" << std::endl;
272  std::cout << "\t FluidPhysicalViscosity_Nu_Phys = " << CaseParameters_Ptr->FluidPhysicalViscosity_Nu_Phys << std::endl;
273  std::cout << "\t FluidPhysicalReferenceDensity_Rho0_Phys = " << CaseParameters_Ptr->FluidPhysicalReferenceDensity_Rho0_Phys << std::endl;
274  std::cout << "\t Tau = " << CaseParameters_Ptr->Tau << std::endl;
275  std::cout << "\t ForceX_fiz = " << CaseParameters_Ptr->ForceX_fiz << std::endl;
276  std::cout << "\t ForceY_fiz = " << CaseParameters_Ptr->ForceY_fiz << std::endl;
277  std::cout << "\t ForceZ_fiz = " << CaseParameters_Ptr->ForceZ_fiz << std::endl;
278 
279  std::cout << std::endl << "Characterstic params:" << std::endl;
280  std::cout << "\t CharacteristicLengthNNodes_L_CH_LB = " << CaseParameters_Ptr->CharacteristicLength_L_CH_LB << std::endl;
281  std::cout << "\t CharactLengthPhysical_L_CH_Phys = " << CaseParameters_Ptr->CharactLengthPhysical_L_CH_Phys << std::endl;
282  std::cout << "\t CharactVelocityPhysical_U_CH_Phys = " << CaseParameters_Ptr->CharactVelocityPhysical_U_CH_Phys << std::endl;
283 
284  std::cout << std::endl << "Termination conditions:" << std::endl;
285  std::cout << "\t Sc_VelocityResidueError_ErrV = " << CaseParameters_Ptr->Sc_VelocityResidueError_ErrV << std::endl;
286 
287  std::cout << std::endl << "Initial conditions:" << std::endl;
288  std::cout << "\t ReferenceDensityLB_Rho0_LB = " << CaseParameters_Ptr->ReferenceDensityLB_Rho0_LB << std::endl;
289  std::cout << "\t XInitialVelocityUx0_Phys = " << CaseParameters_Ptr->XInitialVelocityUx0_Phys << std::endl;
290  std::cout << "\t YInitialVelocityUy0_Phys = " << CaseParameters_Ptr->YInitialVelocityUy0_Phys << std::endl;
291  std::cout << "\t ZInitialVelocityUz0_Phys = " << CaseParameters_Ptr->ZInitialVelocityUz0_Phys << std::endl;
292 
293  std::cout << std::endl << "Default boundary conditions:" << std::endl;
294  std::cout << "\t DefaultWallNode_BN = " << CaseParameters_Ptr->DefaultWallNode_BN << std::endl;
295  std::cout << "\t DefaultNode_NN = " << CaseParameters_Ptr->DefaultNode_NN << std::endl;
296 
297  std::cout << std::endl << "RWParams:" << std::endl;
298  std::cout << "\t CheckPointNumberRead_CHP_R = " << CaseParameters_Ptr->CheckPointNumberRead_CHP_R << std::endl;
299  std::cout << "\t ConsoleWriteStep_K_W = " << CaseParameters_Ptr->ConsoleWriteStep_K_W << std::endl;
300  std::cout << "\t VTKWriteStep_VTK_W = " << CaseParameters_Ptr->VTKWriteStep_VTK_W << std::endl;
301  std::cout << "\t VTKFileMaxNumber_VTK_Max = " << CaseParameters_Ptr->VTKFileMaxNumber_VTK_Max << std::endl;
302 
303  std::cout << std::endl << "ThreadParams:" << std::endl;
304  std::cout << "\t ThreadMaxSize = " << CaseParameters_Ptr->ThreadMaxSize << std::endl;
305 
306  //Mass balance surface choice params
307  std::cout << std::endl << "BalanceParams:" << std::endl;
308  std::cout << "\t AutomaticSurfaceChoice = " << CaseParameters_Ptr->AutomaticSurfaceChoice << std::endl;
309 
310  // CPU parameters
311  std::cout << std::endl << "CPUParams:" << std::endl;
312  std::cout << "\t CPU_ThreadsNr = " << CaseParameters_Ptr->CPU_ThreadsNr << std::endl;
313 
314  std::cout << std::endl << "**********************************************************************************" << std::endl << std::endl;
315 
316  // Thread file reader -------------------------------------------------------------------------------------
317  std::cout << "Threads defined in thread_params.cfg file" << std::endl;
318  std::cout << "Total number of threads = " << ConfigData_Ptr->getThreadsNumber() << std::endl;
319  for (int j = 0; j < ConfigData_Ptr->getThreadsNumber(); j++) {
320  std::cout << "#########################################################################################################################" << std::endl;
321  std::cout << "ThreadID = " << j << std::endl;
322  std::cout << "ThreadName = " << ConfigData_Ptr->getThreadStringParam(j, "ThreadName") << std::endl;
323  std::cout << "GridType = " << ConfigData_Ptr->getThreadStringParam(j, "GridType") << std::endl;
324  if (ConfigData_Ptr->getThreadParamLength(j, "NodeTypeID") > 0)
325  std::cout << "NodeTypeID = " << ConfigData_Ptr->getThreadIntParam(j, "NodeTypeID") << std::endl;
326  std::cout << "Data number = " << ConfigData_Ptr->getThreadParamLength(j, "uid-Node") << std::endl;
327  if (ConfigData_Ptr->getThreadParamLength(j, "uid-Node") > 0)
328  for (int i = 0; i < ConfigData_Ptr->getThreadParamLength(j, "uid-Node"); i++) {
329  if (i > 0) std::cout << std::endl;
330  std::cout << "Node, Coordinate = " << "[" << ConfigData_Ptr->getThreadDataIntVectorParam(0, j, i, "uid-Node", "Coordinate") << ", "
331  << ConfigData_Ptr->getThreadDataIntVectorParam(1, j, i, "uid-Node", "Coordinate")
332  << ", " << ConfigData_Ptr->getThreadDataIntVectorParam(2, j, i, "uid-Node", "Coordinate") << "]";
333  if (ConfigData_Ptr->getThreadDataVectorParamLength(j, i, "uid-Node", "Velocity") > 0)
334  std::cout << ", Velocity = " << "[" << ConfigData_Ptr->getThreadDataFloatVectorParam(0, j, i, "uid-Node", "Velocity") << ", "
335  << ConfigData_Ptr->getThreadDataFloatVectorParam(1, j, i, "uid-Node", "Velocity")
336  << ", " << ConfigData_Ptr->getThreadDataFloatVectorParam(2, j, i, "uid-Node", "Velocity") << "]";
337  if (i == ConfigData_Ptr->getThreadParamLength(j, "uid-Node") - 1) std::cout << std::endl;
338  }
339  if (ConfigData_Ptr->getThreadParamLength(j, "Velocity_fiz") > 0)
340  std::cout << "Velocity = " << "[" << ConfigData_Ptr->getThreadFloatVectorParam(0, j, "Velocity_fiz") << ", " << ConfigData_Ptr->getThreadFloatVectorParam(1, j, "Velocity_fiz")
341  << ", " << ConfigData_Ptr->getThreadFloatVectorParam(2, j, "Velocity_fiz") << "]" << std::endl;
342  if (ConfigData_Ptr->getThreadParamLength(j, "NodeCoordinateFileColumnNames") > 0)
343  std::cout << "NodeCoordinateFileColumnNames = " << "[" << ConfigData_Ptr->getThreadStringVectorParam(0, j, "NodeCoordinateFileColumnNames")
344  << ", " << ConfigData_Ptr->getThreadStringVectorParam(1, j, "NodeCoordinateFileColumnNames") << ", "
345  << ConfigData_Ptr->getThreadStringVectorParam(2, j, "NodeCoordinateFileColumnNames") << "]" << std::endl;
346  if (ConfigData_Ptr->getThreadParamLength(j, "NodeFilePath") > 0) {
347  std::cout << "NodeFilePath = " << ConfigData_Ptr->getThreadStringParam(j, "NodeFilePath") << std::endl;
348  std::string FilePath =
349  ConfigData_Ptr->CaseFolder + ConfigData_Ptr->getProgramStringParam("GeometryFolder") + ConfigData_Ptr->getThreadStringParam(j, "NodeFilePath");
350  auto data_Ptr = std::make_unique<std::vector<double>>();
351  std::vector<std::string> VariableNameList{ConfigData_Ptr->getThreadStringVectorParam(0, j, "NodeCoordinateFileColumnNames"),
352  ConfigData_Ptr->getThreadStringVectorParam(1, j, "NodeCoordinateFileColumnNames"),
353  ConfigData_Ptr->getThreadStringVectorParam(2, j, "NodeCoordinateFileColumnNames")};
354  MF::RW::CSVReader::DataReadFromCSVFile(FilePath, VariableNameList, data_Ptr.get());
355  for (auto i=data_Ptr->begin(); i != data_Ptr->end(); i++) {
356  std::cout << "[" << *i; i++; std::cout << ", " << *i; i++; std::cout << ", " << *i << "]" << std::endl;
357  }
358  }
359 
360  if (ConfigData_Ptr->getThreadParamLength(j, "Pressure_fiz") > 0)
361  std::cout << "Pressure = " << ConfigData_Ptr->getThreadFloatParam(j, "Pressure") << std::endl;
362 
363  std::cout << "#########################################################################################################################" << std::endl;
364  }
365 }
static void DataReadFromCSVFile(const std::string &DataFilePath, const std::vector< std::string > &VariableNameList, std::vector< double > *pDataArray)
Reads data from text file.
Definition: CSVReader.cpp:13

◆ getMemoryUsageValue()

int MF::Solver_CPU::ConsoleWriter::getMemoryUsageValue ( )
static

Definition at line 31 of file ConsoleWriter.cpp.

References parseFileLine().

Referenced by PrintComputationStatistics().

31  { //Note: this value is in KB!
32  FILE* file = fopen("/proc/self/status", "r");
33  int result = -1;
34  char line[128];
35 
36  while (fgets(line, 128, file) != NULL){
37  if (strncmp(line, "VmRSS:", 6) == 0){
38  result = parseFileLine(line);
39  break;
40  }
41  }
42  fclose(file);
43  return result;
44 }
static int parseFileLine(char *line)

◆ parseFileLine()

int MF::Solver_CPU::ConsoleWriter::parseFileLine ( char *  line)
static

Definition at line 21 of file ConsoleWriter.cpp.

Referenced by getMemoryUsageValue().

21  {
22  // This assumes that a digit will be found and the line ends in " Kb".
23  int i = strlen(line);
24  const char* p = line;
25  while (*p <'0' || *p > '9') p++;
26  line[i-3] = '\0';
27  i = atoi(p);
28  return i;
29 }

◆ PrintComputationParameters()

void MF::Solver_CPU::ConsoleWriter::PrintComputationParameters ( const std::shared_ptr< MF::Solver_CPU::CaseParameters > &  CaseParameters_Ptr)
static

Prints on console basic solution parameters.

Definition at line 63 of file ConsoleWriter.cpp.

Referenced by main().

63  {
64 
65  std::cout << std::endl;
66  std::cout << "Re = " << CaseParameters_Ptr->ReynoldsNumber_Re << std::endl;
67  std::cout << "U_Ch_LB = " << CaseParameters_Ptr->CharacteristicVelocityLBu_U_Ch_LB << std::endl;
68  std::cout << "Dt_phys [s] = " << CaseParameters_Ptr->DTPhysical_Dt_Phys << std::endl;
69  std::cout << "L_ch_LB [Lu] = " << CaseParameters_Ptr->CharacteristicLength_L_CH_LB << std::endl;
70  std::cout << "Nu_LB = " << CaseParameters_Ptr->FluidLBuViscosity_Nu_LB << std::endl;
71  std::cout << "Fx_LB = " << CaseParameters_Ptr->ForceX_LB << std::endl;
72  std::cout << "Fy_LB = " << CaseParameters_Ptr->ForceY_LB << std::endl;
73  std::cout << "Fz_LB = " << CaseParameters_Ptr->ForceZ_LB << "\n" << std::endl;
74 }

◆ PrintComputationStatistics()

void MF::Solver_CPU::ConsoleWriter::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 
)
static

Prints on console final computation statistics.

Definition at line 46 of file ConsoleWriter.cpp.

References getMemoryUsageValue(), MF::Solver_CPU::Calculations::getTotalNodeNumber(), m_maxMLUPS, and m_minMLUPS.

Referenced by main().

46  {
47 
48  double cpu_time = std::chrono::duration_cast<std::chrono::duration<double, std::ratio<1> >> (TimeStop - TimeStart).count();
49  double MLUPS = SimStep * MF::Solver_CPU::Calculations::getTotalNodeNumber(ThreadArray_Ptr) / cpu_time / 1e6;
50  std::cout << "\n" << "Solver statistics : " << std::endl;
51  std::cout.unsetf(std::ios::scientific);
52  std::cout << "Computation time [s] = " << std::setw(15) << cpu_time << "mean MLUPS = " << std::setw(15) << MLUPS << "min MLUPS = " << std::setw(15) << m_minMLUPS << "max MLUPS = " << std::setw(15) << m_maxMLUPS << "Average memory usage [kB] = " << MF::Solver_CPU::ConsoleWriter::getMemoryUsageValue() << "\n" << std::endl;
53 
54 }
static uint64_t getTotalNodeNumber(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Returns total number of computational nodes (non-solid).

◆ PrintCPUInfo()

void MF::Solver_CPU::ConsoleWriter::PrintCPUInfo ( const int &  CPU_ThreadsNr)
static

Prints on console CPU usage info.

Definition at line 56 of file ConsoleWriter.cpp.

Referenced by main().

56  {
57  std::cout << "\n" << "CPU info: " << std::endl;
58  std::cout << "Maximum number of available threads = " << omp_get_max_threads() << std::endl;
59  std::cout << "Maximum number of available processor cores (including virtual) = " << omp_get_num_procs() << std::endl;
60  std::cout << "Number of CPU threads allocated for solver = " << CPU_ThreadsNr << "\n" << std::endl;
61 }

◆ PrintGridStatistics()

void MF::Solver_CPU::ConsoleWriter::PrintGridStatistics ( const std::shared_ptr< MF::Database::ThreadArray > &  ThreadArray_Ptr)
static

Prints on console basic grid statistics.

Definition at line 76 of file ConsoleWriter.cpp.

References MF::Solver_CPU::Calculations::getBBNodeNumber_61(), MF::Solver_CPU::Calculations::getFluidNodeNumber_1(), MF::Solver_CPU::Calculations::getPeriodicNodeNumber_4(), MF::Solver_CPU::Calculations::getPressureNodeNumber_30(), MF::Solver_CPU::Calculations::getSolidNodeNumber_1(), MF::Solver_CPU::Calculations::getTotalNodeNumber(), MF::Solver_CPU::Calculations::getVelocity0NodeNumber_40(), and MF::Solver_CPU::Calculations::getVelocityNodeNumber_20().

Referenced by main().

76  {
77 
78  // Console output formatting
79  std::cout.fill(' ');
80  std::cout.setf(std::ios::left);
81  std::cout.setf(std::ios::scientific);
82 
83  std::cout<<"Grid statistics: " << std::endl;
84  std::cout<<"Total number of computational nodes = " << MF::Solver_CPU::Calculations::getTotalNodeNumber(ThreadArray_Ptr) << std::endl;
85  std::cout<<"Number of solid (0) nodes = " << MF::Solver_CPU::Calculations::getSolidNodeNumber_1(ThreadArray_Ptr) << std::endl;
86  std::cout<<"Number of fluid (1) nodes = " << MF::Solver_CPU::Calculations::getFluidNodeNumber_1(ThreadArray_Ptr) << std::endl;
87  std::cout<<"Number of bounce back (61) nodes = " << MF::Solver_CPU::Calculations::getBBNodeNumber_61(ThreadArray_Ptr) << std::endl;
88  std::cout<<"Number of velocity (20) nodes = " << MF::Solver_CPU::Calculations::getVelocityNodeNumber_20(ThreadArray_Ptr) << std::endl;
89  std::cout<<"Number of velocity0 (40) nodes = " << MF::Solver_CPU::Calculations::getVelocity0NodeNumber_40(ThreadArray_Ptr) << std::endl;
90  std::cout<<"Number of pressure (30) nodes = " << MF::Solver_CPU::Calculations::getPressureNodeNumber_30(ThreadArray_Ptr) << std::endl;
91  std::cout << "Number of periodic (4) and (5) nodes = " << MF::Solver_CPU::Calculations::getPeriodicNodeNumber_4(ThreadArray_Ptr) << std::endl;
92  double total = MF::Solver_CPU::Calculations::getTotalNodeNumber(ThreadArray_Ptr);
93  double fluid = MF::Solver_CPU::Calculations::getFluidNodeNumber_1(ThreadArray_Ptr);
94  float ratio = (total-fluid)/total*100;
95  std::cout.unsetf(std::ios::scientific);
96  std::cout<<"Ratio of non-fluid nodes to total number of computational nodes [%] = " << ratio << std::endl;
97  std::cout<<"Number of MFThreads = " << ThreadArray_Ptr->m_ThreadsTable_Ptr->size() << std::endl;
98  std::cout.setf(std::ios::scientific);
99 }
static uint64_t getSolidNodeNumber_1(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Returns number of solid nodes.
static uint64_t getVelocityNodeNumber_20(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Returns number of boundary velocity nodes.
static uint64_t getTotalNodeNumber(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Returns total number of computational nodes (non-solid).
static uint64_t getPeriodicNodeNumber_4(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Returns number of boundary periodic nodes.
static uint64_t getBBNodeNumber_61(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Returns number of bounce-back nodes.
static uint64_t getVelocity0NodeNumber_40(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Returns number of boundary velocity 0 nodes.
static uint64_t getPressureNodeNumber_30(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Returns number of boundary pressure nodes.
static uint64_t getFluidNodeNumber_1(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Returns number of fluid nodes.

◆ PrintTimeStepStatistics()

void MF::Solver_CPU::ConsoleWriter::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 
)
static

Prints on console time step statistics.

Definition at line 101 of file ConsoleWriter.cpp.

References MF::Solver_CPU::Calculations::DeltaMassFlow_fiz(), MF::Solver_CPU::Calculations::DeltaMassFlowLB(), MF::Solver_CPU::Calculations::DeltaMassFlowThread_fiz(), MF::Solver_CPU::Calculations::DeltaMassFlowThread_LB(), MF::Solver_CPU::Calculations::getTotalNodeNumber(), MF::Solver_CPU::Calculations::getULBmaks(), m_iter, m_maxMLUPS, m_minMLUPS, m_SimPreviousStep, m_TimePreviousStep, m_VSum, MF::Solver_CPU::Calculations::VelocityFizMeanForInlet(), MF::Solver_CPU::Calculations::VelocityFizMeanForOutlet(), MF::Solver_CPU::Calculations::VelocityFizMeanForPNodes(), MF::Solver_CPU::Calculations::VelocityFizMeanForVNodes(), and MF::Solver_CPU::Calculations::VelocityLBVolumeSum().

Referenced by main().

101  {
102  auto VSum2 = MF::Solver_CPU::Calculations::VelocityLBVolumeSum(ThreadArray_Ptr);
103  auto uLB_maks = MF::Solver_CPU::Calculations::getULBmaks(ThreadArray_Ptr);
104  auto Time_now = std::chrono::high_resolution_clock::now();
105  double cpu_time = std::chrono::duration_cast<std::chrono::duration<double, std::ratio<1> >> (Time_now - m_TimePreviousStep).count();
106  double MLUPS = (SimStep - m_SimPreviousStep) * MF::Solver_CPU::Calculations::getTotalNodeNumber(ThreadArray_Ptr) / cpu_time / 1e6;
107  double SimError_Vel = fabs((VSum2 - m_VSum) * 2 / (VSum2 + m_VSum) / (SimStep - m_SimPreviousStep));
108 
109  if (m_minMLUPS == 0)
110  m_minMLUPS = MLUPS;
111  else if (m_minMLUPS > MLUPS)
112  m_minMLUPS = MLUPS;
113  if (m_maxMLUPS < MLUPS)
114  m_maxMLUPS = MLUPS;
115  m_VSum = VSum2;
116  m_SimPreviousStep = SimStep;
117  m_TimePreviousStep = Time_now;
118  m_iter ++;
119 
120  // Velocity error calculations
121  if (CaseParameters_Ptr->Sc_VelocityResidueError_ErrV > 0)
122  V_SimError = SimError_Vel;
123  else
124  V_SimError = 0;
125 
126  double OutVMean, InVMean, DMF, DMF_LB;
127 
128  if (CaseParameters_Ptr->AutomaticSurfaceChoice){
129  OutVMean = MF::Solver_CPU::Calculations::VelocityFizMeanForPNodes(ThreadArray_Ptr);
131  DMF = MF::Solver_CPU::Calculations::DeltaMassFlow_fiz(ThreadArray_Ptr,CaseParameters_Ptr);
132  DMF_LB = MF::Solver_CPU::Calculations::DeltaMassFlowLB(ThreadArray_Ptr,CaseParameters_Ptr);
133  }
134  else{
135  OutVMean = MF::Solver_CPU::Calculations::VelocityFizMeanForOutlet(ThreadArray_Ptr);
137  DMF = MF::Solver_CPU::Calculations::DeltaMassFlowThread_fiz(ThreadArray_Ptr,CaseParameters_Ptr);
138  DMF_LB = MF::Solver_CPU::Calculations::DeltaMassFlowThread_LB(ThreadArray_Ptr,CaseParameters_Ptr);
139  }
140 
141  // Mass flow error calculations
142  if (CaseParameters_Ptr->MassFlowError_ErrM > 0)
143  M_SimError = fabs(DMF);
144  else
145  M_SimError = 0;
146 
147  //Table legend
148  if (m_iter == 1){
149  std::cout << "Table legend: " << "Sc = Scaled, " << "M = Mean, " << "MLUPS = Million of Lattice nodes Updated Per Second." << std::endl;
150  }
151 
152  //Table header
153  if (m_iter % 20 == 0 || m_iter == 1) {
154  std::cout << std::setw(194) << std::setfill('=') << "=" << std::setfill(' ') << std::endl;
155  std::cout << "|" << " Step " << "|" << " Sc velocity residue, [-] " << "|" << " Maximal LB velocity, [-] " << "|" << " M outlet velocity, [m/s] " << "|" << " M inlet velocity, [m/s] "
156  << "|" << " Error mass flow, [%] " << "|" << " Error mass flow LB, [%] " << "|" << " MLUPS, [-] " << "|" << std::endl;
157  std::cout << std::setw(194) << std::setfill('=') << "=" << std::setfill(' ') << std::endl;
158  }
159 
160  //Table values
161  std::cout << "| " << std::setw(8) << SimStep << "|" << " DeltaV = " << std::setw(16) << SimError_Vel << "|" << " uLB_maks = " << std::setw(14) << uLB_maks << "|"
162  << " OutVMean = " << std::setw(15) << OutVMean << "|" << " InVMean = " << std::setw(15) << InVMean << "|" << " DMF = " << std::setw(15) << DMF << "|"
163  << " DMF_LB = " << std::setw(15) << DMF_LB << "|" << " MLUPS = " << std::setw(15) << MLUPS << "|" << std::endl;
164 
165  return;
166 }
static double VelocityFizMeanForOutlet(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Scaled (surface weighted) fiz velocity for all outlet threads.
static double VelocityFizMeanForPNodes(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Scaled (surface weighted) fiz velocity for all nodes type 30.
static unsigned int m_iter
Definition: ConsoleWriter.h:38
static double VelocityFizMeanForVNodes(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Mean Fiz velocity for all nodes type 20.
static double DeltaMassFlowThread_LB(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr, const std::shared_ptr< MF::Solver_CPU::CaseParameters > &CaseParameters_Ptr)
Returns the difference in mass flow rate in LB units (inlet-outlet)/inlet*100. Surfaces are defined i...
static double DeltaMassFlow_fiz(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr, const std::shared_ptr< MF::Solver_CPU::CaseParameters > &CaseParameters_Ptr)
Returns the difference in mass flow rate (inlet-outlet)/inlet*100. Surfaces are automatically detecte...
static double VelocityFizMeanForInlet(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Mean Fiz velocity for all inlet threads.
static double DeltaMassFlowLB(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr, const std::shared_ptr< MF::Solver_CPU::CaseParameters > &CaseParameters_Ptr)
Returns the difference in mass flow rate in LB units (inlet-outlet)/inlet*100. Surfaces are automatic...
static unsigned int m_SimPreviousStep
Definition: ConsoleWriter.h:37
static std::chrono::time_point< std::chrono::high_resolution_clock > m_TimePreviousStep
Definition: ConsoleWriter.h:39
static uint64_t getTotalNodeNumber(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Returns total number of computational nodes (non-solid).
static double getULBmaks(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Returns the maximal value of LB velocity noticed in lattice node.
static double DeltaMassFlowThread_fiz(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr, const std::shared_ptr< MF::Solver_CPU::CaseParameters > &CaseParameters_Ptr)
Returns the difference in mass flow rate (inlet-outlet)/inlet*100. Surfaces are defined in thread_par...
static double VelocityLBVolumeSum(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Mean LB velocity for all fluid nodes type 1.

◆ ThreadsArrayInfo()

void MF::Solver_CPU::ConsoleWriter::ThreadsArrayInfo ( const std::shared_ptr< MF::Database::ThreadArray > &  ThreadArray_Ptr)
static

Prints on console information about all MFThreads.

Definition at line 168 of file ConsoleWriter.cpp.

Referenced by main().

168  {
169  int nr = 0;
170  for (auto & jt : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
171  std::cout << std::endl << "---- Thread nr = " << ++nr << " ----" << std::endl;
172  std::cout << "Thread name = " << jt.get()->m_ThreadName << std::endl;
173  std::cout << "NodeTypeID = " << jt.get()->m_NodeType << std::endl;
174  std::cout << "uidThreadNr = " << jt.get()->m_uidThreadNr << std::endl;
175  std::cout << "m_ThreadCount = " << jt.get()->m_ThreadCount << std::endl;
176  std::cout << "m_ComponentNr = " << (int)jt.get()->m_ComponentNr << std::endl;
177  std::cout << "m_PhaseNr = " << (int)jt.get()->m_PhaseNr << std::endl;
178  std::cout << "Do pre-collision = " << std::boolalpha << jt.get()->m_DoPreCollision << std::endl;
179  std::cout << "Do collision = " << std::boolalpha << jt.get()->m_DoCollision << std::endl;
180  std::cout << "Is on inlet surface = " << std::boolalpha << jt.get()->m_IsInletBalanceSurface << std::endl;
181  std::cout << "Is on outlet surface = " << std::boolalpha << jt.get()->m_IsOutletBalanceSurface << std::endl;
182  std::cout << "Boundary value ULB = " << "[" << jt.get()->m_BoundaryValue_ULB.x << "," << jt.get()->m_BoundaryValue_ULB.y << "," << jt.get()->m_BoundaryValue_ULB.z << "]" << std::endl;
183  std::cout << "Boundary value RhoLB = " << jt.get()->m_BoundaryValue_RhoLB << std::endl;
184  std::cout << "pBoundaryFunction = " << reinterpret_cast<void*>(jt.get()->m_pBoundaryFunction) << std::endl;
185  std::cout << "pVRhoFunction = " << reinterpret_cast<double*>(jt.get()->m_pVRLBFunction) << std::endl;
186  std::cout << "pCollideFunction = " << reinterpret_cast<void*>(jt.get()->m_pColideFunc) << std::endl;
187  std::cout << "Nodes number = " << jt.get()->m_NodeArray_Ptr->size() << std::endl;
188  }
189 }

◆ ThreadsNodeInfo()

void MF::Solver_CPU::ConsoleWriter::ThreadsNodeInfo ( const std::shared_ptr< MF::Database::ThreadArray > &  ThreadArray_Ptr)
static

Prints on console information about all Threads node.

Definition at line 191 of file ConsoleWriter.cpp.

191  {
192  int nr = 0;
193  for (auto & jt : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
194  std::cout << std::endl << "---- Thread nr = " << ++nr << " ----" << std::endl;
195  std::cout << "Thread name = " << jt.get()->m_ThreadName << std::endl;
196  std::cout << "NodeTypeID = " << jt.get()->m_NodeType << std::endl;
197  std::cout << "uidThreadNr = " << jt.get()->m_uidThreadNr << std::endl;
198  std::cout << "m_ThreadCount = " << jt.get()->m_ThreadCount << std::endl;
199  std::cout << "m_ComponentNr = " << (int)jt.get()->m_ComponentNr << std::endl;
200  std::cout << "m_PhaseNr = " << (int)jt.get()->m_PhaseNr << std::endl;
201  std::cout << "Do pre-collision = " << std::boolalpha << jt.get()->m_DoPreCollision << std::endl;
202  std::cout << "Do collision = " << std::boolalpha << jt.get()->m_DoCollision << std::endl;
203  std::cout << "Is on inlet surface = " << std::boolalpha << jt.get()->m_IsInletBalanceSurface << std::endl;
204  std::cout << "Is on outlet surface = " << std::boolalpha << jt.get()->m_IsOutletBalanceSurface << std::endl;
205  std::cout << "Boundary value ULB = " << "[" << jt.get()->m_BoundaryValue_ULB.x << "," << jt.get()->m_BoundaryValue_ULB.y << "," << jt.get()->m_BoundaryValue_ULB.z << "]" << std::endl;
206  std::cout << "Boundary value RhoLB = " << jt.get()->m_BoundaryValue_RhoLB << std::endl;
207  std::cout << "pBoundaryFunction = " << reinterpret_cast<void*>(jt.get()->m_pBoundaryFunction) << std::endl;
208  std::cout << "pVRhoFunction = " << reinterpret_cast<double*>(jt.get()->m_pVRLBFunction) << std::endl;
209  std::cout << "pCollideFunction = " << reinterpret_cast<void*>(jt.get()->m_pColideFunc) << std::endl;
210  std::cout << "Nodes number = " << jt.get()->m_NodeArray_Ptr->size() << std::endl;
211  for (auto node = 0; node < jt->m_Coordinate_Ptr.get()->size(); node++){
212  std::cout << "Node nr = " << node << " = [" << jt->m_Coordinate_Ptr->at(node).x << "," << jt->m_Coordinate_Ptr->at(node).y << "," << jt->m_Coordinate_Ptr->at(node).z <<"]" << std::endl;
213  }
214  std::cout << std::endl << "**********************************************************************************" << std::endl;
215  }
216 }

Field Documentation

◆ m_iter

unsigned int MF::Solver_CPU::ConsoleWriter::m_iter = 0
static

Definition at line 38 of file ConsoleWriter.h.

Referenced by PrintTimeStepStatistics().

◆ m_maxMLUPS

double MF::Solver_CPU::ConsoleWriter::m_maxMLUPS = 0
static

Definition at line 36 of file ConsoleWriter.h.

Referenced by PrintComputationStatistics(), and PrintTimeStepStatistics().

◆ m_minMLUPS

double MF::Solver_CPU::ConsoleWriter::m_minMLUPS = 0
static

Definition at line 36 of file ConsoleWriter.h.

Referenced by PrintComputationStatistics(), and PrintTimeStepStatistics().

◆ m_SimPreviousStep

unsigned int MF::Solver_CPU::ConsoleWriter::m_SimPreviousStep = 0
static

Definition at line 37 of file ConsoleWriter.h.

Referenced by PrintTimeStepStatistics().

◆ m_TimePreviousStep

std::chrono::time_point< std::chrono::high_resolution_clock > MF::Solver_CPU::ConsoleWriter::m_TimePreviousStep
static

Definition at line 39 of file ConsoleWriter.h.

Referenced by main(), and PrintTimeStepStatistics().

◆ m_VSum

double MF::Solver_CPU::ConsoleWriter::m_VSum = 1
static

Definition at line 36 of file ConsoleWriter.h.

Referenced by PrintTimeStepStatistics().


The documentation for this class was generated from the following files: