Microflow 3D  v1.0
Initialization.cpp
Go to the documentation of this file.
1 // ==============================================================================================
2 // Microflow 3D, http://www.microflow.pwr.edu.pl/
3 // Created by Roman Szafran on 03.06.19.
4 // Modified by Roman Szafran, last on 07.09.19.
5 // Copyright (c) 2019 Wroclaw University of Science and Technology.
6 // Distributed under the Apache License, Version 2.0. You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0 or see accompanying file license.txt.
8 // Redistributions of source code must retain the above copyright and license notice.
9 // ==============================================================================================
10 
11 #include "Initialization.h"
12 
13 void MF::Solver_CPU::Initialization::ThreadDataInitialize(const std::shared_ptr<MF::Database::ThreadArray>& ThreadArray_Ptr, const std::shared_ptr<MF::Database::ConfigData>& ConfigData_Ptr) {
14 
15  double pressure_fiz;
16  MF::Database::Vec3<double> velocity_fiz;
17  MF::Database::Vec3<double> XYZForce_fiz;
18 
19  for (auto & Thread_it : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
20  if (Thread_it->m_uidThreadNr > 0) {
21  int32_t uidThread = Thread_it->m_uidThreadNr - 1;
22  if (ConfigData_Ptr->getThreadParamLength(uidThread, "Pressure_fiz") > 0) {
23  pressure_fiz = ConfigData_Ptr->getThreadFloatParam(uidThread, "Pressure_fiz");
24  Thread_it->m_BoundaryValue_RhoLB = MF::LBPC::ParametersConversion::PressurePhys_toRhoLB(pressure_fiz);
25  }
26  if (ConfigData_Ptr->getThreadParamLength(uidThread, "IsInletBalanceSurface") > 0) {
27  Thread_it->m_IsInletBalanceSurface = ConfigData_Ptr->getThreadBooleanParam(uidThread, "IsInletBalanceSurface");
28  }
29  if (ConfigData_Ptr->getThreadParamLength(uidThread, "IsOutletBalanceSurface") > 0) {
30  Thread_it->m_IsOutletBalanceSurface = ConfigData_Ptr->getThreadBooleanParam(uidThread, "IsOutletBalanceSurface");
31  }
32  if (ConfigData_Ptr->getThreadParamLength(uidThread, "Velocity_fiz") > 0) {
33  velocity_fiz.x = ConfigData_Ptr->getThreadFloatVectorParam(0, uidThread, "Velocity_fiz");
34  velocity_fiz.y = ConfigData_Ptr->getThreadFloatVectorParam(1, uidThread, "Velocity_fiz");
35  velocity_fiz.z = ConfigData_Ptr->getThreadFloatVectorParam(2, uidThread, "Velocity_fiz");
36  Thread_it->m_BoundaryValue_ULB = MF::LBPC::ParametersConversion::UPhys_toLB(velocity_fiz);
37  }
38  if (ConfigData_Ptr->getThreadParamLength(uidThread, "XYZForce_fiz") > 0) {
39  XYZForce_fiz.x = ConfigData_Ptr->getThreadFloatVectorParam(0, uidThread, "XYZForce_fiz");
40  XYZForce_fiz.y = ConfigData_Ptr->getThreadFloatVectorParam(1, uidThread, "XYZForce_fiz");
41  XYZForce_fiz.z = ConfigData_Ptr->getThreadFloatVectorParam(2, uidThread, "XYZForce_fiz");
42  Thread_it->m_XYZForce_LB = MF::LBPC::ParametersConversion::FPhys_toFLB(XYZForce_fiz);
43  }
44  if (ConfigData_Ptr->getThreadParamLength(uidThread, "ThreadName") > 0){
45  Thread_it->m_ThreadName = ConfigData_Ptr->getThreadStringParam(uidThread, "ThreadName");
46  }
47  }
48  }
49 }
50 
51 void MF::Solver_CPU::Initialization::EquilibriumQcompr(const std::shared_ptr<MF::Database::ThreadArray>& ThreadArray_Ptr, const std::shared_ptr<MF::Solver_CPU::CaseParameters>& CaseParameters_Ptr) {
52 
54 
55  for (auto & Thread_it : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
56  if (Thread_it->m_DoPreCollision && Thread_it->m_uidThreadNr > 0) { // Boundary nodes that are initialized from thread .cfg file
57  Vector4.x = Thread_it->m_BoundaryValue_ULB.x;
58  Vector4.y = Thread_it->m_BoundaryValue_ULB.y;
59  Vector4.z = Thread_it->m_BoundaryValue_ULB.z;
60  Vector4.rho = Thread_it->m_BoundaryValue_RhoLB;
61  }
62  else { // Fluid nodes and boundary nodes that are not initialized in thread .cfg file
63  // Boundary nodes
64  if (Thread_it->m_DoPreCollision) {
65  Thread_it->m_BoundaryValue_RhoLB = CaseParameters_Ptr->ReferenceDensityLB_Rho0_LB;
66  Thread_it->m_BoundaryValue_ULB.x = 0;
67  Thread_it->m_BoundaryValue_ULB.y = 0;
68  Thread_it->m_BoundaryValue_ULB.z = 0;
69 
70  Vector4.x = Thread_it->m_BoundaryValue_ULB.x;
71  Vector4.y = Thread_it->m_BoundaryValue_ULB.y;
72  Vector4.z = Thread_it->m_BoundaryValue_ULB.z;
73  Vector4.rho = Thread_it->m_BoundaryValue_RhoLB;
74  }
75  else { // Fluid nodes
76  Thread_it->m_BoundaryValue_RhoLB = CaseParameters_Ptr->ReferenceDensityLB_Rho0_LB;
77  Thread_it->m_BoundaryValue_ULB.x = CaseParameters_Ptr->XInitialVelocityLBu_Ux0_LB;
78  Thread_it->m_BoundaryValue_ULB.y = CaseParameters_Ptr->YInitialVelocityLBu_Uy0_LB;
79  Thread_it->m_BoundaryValue_ULB.z = CaseParameters_Ptr->ZInitialVelocityLBu_Uz0_LB;
80 
81  Vector4.x = Thread_it->m_BoundaryValue_ULB.x;
82  Vector4.y = Thread_it->m_BoundaryValue_ULB.y;
83  Vector4.z = Thread_it->m_BoundaryValue_ULB.z;
84  Vector4.rho = Thread_it->m_BoundaryValue_RhoLB;
85  }
86  }
87 
88  //FEQ initialization
89  for (auto & Node_it : *Thread_it->m_NodeArray_Ptr) {
90  for (unsigned char k = 0; k < MFQ19; k++) {
91  Node_it.FQ19[k] = MF::Solver_CPU::Collision::GetBGKFeq_Qcompr(Vector4, k);
92  }
93  }
94  }
95 }
96 
97 void MF::Solver_CPU::Initialization::EquilibriumIncompr(const std::shared_ptr<MF::Database::ThreadArray>& ThreadArray_Ptr, const std::shared_ptr<MF::Solver_CPU::CaseParameters>& CaseParameters_Ptr) {
98 
100 
101  for (auto & Thread_it : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
102  if (Thread_it->m_DoPreCollision && Thread_it->m_uidThreadNr > 0) { // Boundary nodes that are initialized from thread .cfg file
103  Vector4.x = Thread_it->m_BoundaryValue_ULB.x;
104  Vector4.y = Thread_it->m_BoundaryValue_ULB.y;
105  Vector4.z = Thread_it->m_BoundaryValue_ULB.z;
106  Vector4.rho = Thread_it->m_BoundaryValue_RhoLB;
107  }
108  else { // Fluid nodes and boundary nodes that are not initialized in thread .cfg file
109  // Boundary nodes
110  if (Thread_it->m_DoPreCollision) {
111  Thread_it->m_BoundaryValue_RhoLB = CaseParameters_Ptr->ReferenceDensityLB_Rho0_LB;
112  Thread_it->m_BoundaryValue_ULB.x = 0;
113  Thread_it->m_BoundaryValue_ULB.y = 0;
114  Thread_it->m_BoundaryValue_ULB.z = 0;
115 
116  Vector4.x = Thread_it->m_BoundaryValue_ULB.x;
117  Vector4.y = Thread_it->m_BoundaryValue_ULB.y;
118  Vector4.z = Thread_it->m_BoundaryValue_ULB.z;
119  Vector4.rho = Thread_it->m_BoundaryValue_RhoLB;
120  }
121  else { // Fluid nodes
122  Thread_it->m_BoundaryValue_RhoLB = CaseParameters_Ptr->ReferenceDensityLB_Rho0_LB;
123  Thread_it->m_BoundaryValue_ULB.x = CaseParameters_Ptr->XInitialVelocityLBu_Ux0_LB;
124  Thread_it->m_BoundaryValue_ULB.y = CaseParameters_Ptr->YInitialVelocityLBu_Uy0_LB;
125  Thread_it->m_BoundaryValue_ULB.z = CaseParameters_Ptr->ZInitialVelocityLBu_Uz0_LB;
126 
127  Vector4.x = Thread_it->m_BoundaryValue_ULB.x;
128  Vector4.y = Thread_it->m_BoundaryValue_ULB.y;
129  Vector4.z = Thread_it->m_BoundaryValue_ULB.z;
130  Vector4.rho = Thread_it->m_BoundaryValue_RhoLB;
131  }
132  }
133 
134  for (auto & Node_it : *Thread_it->m_NodeArray_Ptr) {
135  for (unsigned char k = 0; k < MFQ19; k++) {
136  Node_it.FQ19[k] = MF::Solver_CPU::Collision::GetBGKFeq_Incompr(Vector4, k);
137  }
138  }
139  }
140 }
141 
142 void MF::Solver_CPU::Initialization::ThreadDefaultDataInitialize(const std::shared_ptr<MF::Database::ThreadArray> &ThreadArray_Ptr, const std::shared_ptr<MF::Solver_CPU::CaseParameters>& CaseParameters_Ptr) {
143 
144  for (auto & Thread_it : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
145 
146  // Force initialization from default values.
147  Thread_it->m_XYZForce_LB.x = CaseParameters_Ptr->ForceX_LB;
148  Thread_it->m_XYZForce_LB.y = CaseParameters_Ptr->ForceY_LB;
149  Thread_it->m_XYZForce_LB.z = CaseParameters_Ptr->ForceZ_LB;
150  }
151 }
T rho
Rho value.
Definition: Vec4.h:22
static double GetBGKFeq_Incompr(const MF::Database::Vec4< double > &Vector4, const unsigned char &k)
Gets FEQ from quasi incompressible BGK model.
Definition: Collision.cpp:634
T y
Y direction value.
Definition: Vec3.h:20
#define MFQ19
Number of lattice directions D3Q19.
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.
T z
Z direction value.
Definition: Vec3.h:21
T z
Z direction value.
Definition: Vec4.h:21
T x
X direction value.
Definition: Vec3.h:19
static double GetBGKFeq_Qcompr(const MF::Database::Vec4< double > &Vector4, const unsigned char &k)
Gets FEQ from quasi compressible BGK model.
Definition: Collision.cpp:630
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 double PressurePhys_toRhoLB(double p_phys)
Converts physical pressure to rho LB.
static double FPhys_toFLB(double F_phys)
Physical force to LB force.
static double UPhys_toLB(double u_phys)
Converts physical velocity to LB velocity.
T x
X direction value.
Definition: Vec4.h:19
T y
Y direction value.
Definition: Vec4.h:20