Microflow 3D  v1.0
FluidFunctions.cpp
Go to the documentation of this file.
1 // ==============================================================================================
2 // Microflow 3D, http://www.microflow.pwr.edu.pl/
3 // Created by Roman Szafran on 26.05.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 "FluidFunctions.h"
12 
13 #define f(x) (pNode->FQ19[x])
14 
15 void MF::Solver_CPU::FluidFunctions::SetFluidSolidNodePointerToFunc(const std::shared_ptr<MF::Database::ThreadArray>& ThreadArray_Ptr) {
16 
17  for (auto & Thread_Ptr : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
18  switch (Thread_Ptr->m_NodeType) {
19  case 4: //Periodic boundary
20  case 1: { //Fluid node
21  if (its_CaseParameters_Ptr->FluidFlowModel_MT == MF::Solver_CPU::FlowTypeClass::Incompressible) { //Incompressible flow
22  if (its_CaseParameters_Ptr->CollisionModel_KT == MF::Solver_CPU::ModelTypeClass::FBGK) { //FBGK
23  Thread_Ptr->m_pVRLBFunction = MF::Solver_CPU::FluidFunctions::VRFluidLB_FBGKIncompr;
24  }
25  else { //BGK, MRT, MRT2 incompressible
26  Thread_Ptr->m_pVRLBFunction = MF::Solver_CPU::FluidFunctions::VRFluidLB_Incompr;
27  }
28  }
29  else { //Quasi compressible flow
30  if (its_CaseParameters_Ptr->CollisionModel_KT == MF::Solver_CPU::ModelTypeClass::FBGK) { //FBGK
31  Thread_Ptr->m_pVRLBFunction = MF::Solver_CPU::FluidFunctions::VRFluidLB_FBGKQuasiCompr;
32  }
33  else {//BGK, MRT, MRT2 quasi compressible
34  Thread_Ptr->m_pVRLBFunction = MF::Solver_CPU::FluidFunctions::VRFluidLB_QuasiCompr;
35  }
36  }
37  break;
38  }
39  case 0: {
40  Thread_Ptr->m_pVRLBFunction = MF::Solver_CPU::FluidFunctions::DoNothing;
41  Thread_Ptr->m_DoPropagation = false;
42  Thread_Ptr->m_DoCollision = false;
43  Thread_Ptr->m_DoPreCollision = false;
44  break;} // Solid node
45 
46  default: {break;} // All other nodes
47  }
48  }
49 }
50 
51 MF::Database::Vec4<double> MF::Solver_CPU::FluidFunctions::VRFluidLB_QuasiCompr(const MF::Database::Node *pNode)
52 {
53  MF::Database::Vec4<double> Vector4 = {0,0,0,0};
54  for (unsigned char k=0; k < MFQ19; k++){
55  Vector4.rho += f(k); //Rho_LB
59  }
60  Vector4.x /= Vector4.rho;
61  Vector4.y /= Vector4.rho;
62  Vector4.z /= Vector4.rho;
63  return Vector4;
64 }
65 
66 MF::Database::Vec4<double> MF::Solver_CPU::FluidFunctions::VRFluidLB_Incompr(const MF::Database::Node *pNode)
67 {
68  MF::Database::Vec4<double> Vector4 = {0,0,0,0};
69  for (unsigned char k=0; k < MFQ19; k++) {
70  Vector4.rho += f(k); //Rho_LB
74  }
75  return Vector4;
76 }
77 
78 MF::Database::Vec4<double> MF::Solver_CPU::FluidFunctions::VRFluidLB_FBGKQuasiCompr(const MF::Database::Node *pNode)
79 {
80  MF::Database::Vec4<double> Vector4 = {0,0,0,0};
81  for (unsigned char k=0; k < MFQ19; k++) {
82  Vector4.rho += f(k); //Rho_LB
86  }
87  Vector4.x += 0.5*MF::Solver_CPU::FluidFunctions::its_CaseParameters_Ptr->ForceX_LB; //XForce
88  Vector4.y += 0.5*MF::Solver_CPU::FluidFunctions::its_CaseParameters_Ptr->ForceY_LB; //YForce
89  Vector4.z += 0.5*MF::Solver_CPU::FluidFunctions::its_CaseParameters_Ptr->ForceZ_LB; //ZForce
90  Vector4.x /= Vector4.rho;
91  Vector4.y /= Vector4.rho;
92  Vector4.z /= Vector4.rho;
93  return Vector4;
94 }
95 
96 MF::Database::Vec4<double> MF::Solver_CPU::FluidFunctions::VRFluidLB_FBGKIncompr(const MF::Database::Node *pNode)
97 {
98  MF::Database::Vec4<double> Vector4 = {0,0,0};
99  for (unsigned char k=0; k < MFQ19; k++) {
100  Vector4.rho += f(k); //Rho_LB
104  }
105  Vector4.x += 0.5*MF::Solver_CPU::FluidFunctions::its_CaseParameters_Ptr->ForceX_LB; //XForce
106  Vector4.y += 0.5*MF::Solver_CPU::FluidFunctions::its_CaseParameters_Ptr->ForceY_LB; //YForce
107  Vector4.z += 0.5*MF::Solver_CPU::FluidFunctions::its_CaseParameters_Ptr->ForceZ_LB; //ZForce
108  return Vector4;
109 }
110 
111 MF::Database::Vec4<double> MF::Solver_CPU::FluidFunctions::DoNothing(const MF::Database::Node *pNode)
112 {
113  MF::Database::Vec4<double> Vector4 = {0,0,0};
114  return Vector4;
115 }
T rho
Rho value.
Definition: Vec4.h:22
static std::shared_ptr< MF::Solver_CPU::CaseParameters > its_CaseParameters_Ptr
#define MFQ19
Number of lattice directions D3Q19.
#define f(x)
Basic data structure for storing f(i) data for each computational grid node.
Definition: Node.h:26
static std::shared_ptr< MF::GU::LatticeParametersD3Q19 > its_LatticeParameters_Ptr
T z
Z direction value.
Definition: Vec4.h:21
static void SetFluidSolidNodePointerToFunc(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
Sets pointers to fluid functions of MFThread.
#define DirectionVectorComponent_Cx(x)
Definition: Collision.cpp:18
#define DirectionVectorComponent_Cz(x)
Definition: Collision.cpp:20
#define DirectionVectorComponent_Cy(x)
Definition: Collision.cpp:19
T x
X direction value.
Definition: Vec4.h:19
T y
Y direction value.
Definition: Vec4.h:20