Microflow 3D  v1.0
ParametersConversion.h
Go to the documentation of this file.
1 // ==============================================================================================
2 // Microflow 3D, http://www.microflow.pwr.edu.pl/
3 // Created by Roman Szafran on 18.05.19.
4 // Copyright (c) 2019 Wroclaw University of Science and Technology.
5 // Distributed under the Apache License, Version 2.0. You may obtain a copy of the License at
6 // http://www.apache.org/licenses/LICENSE-2.0 or see accompanying file license.txt.
7 // Redistributions of source code must retain the above copyright and license notice.
8 // ==============================================================================================
9 
10 # pragma once
11 
12 // OpenVDB
13 #include <openvdb/openvdb.h>
14 
17 #include "MFDatabase/Vec3.h"
18 
19 namespace MF {
20  namespace LBPC {
21 
24  public:
25 
26  ParametersConversion() = default;
27 
28  ~ParametersConversion() = default;
29 
30  static void Initialize (const std::shared_ptr<MF::Database::ConfigData>& ConfigData_Ptr, const std::shared_ptr<MF::GU::LatticeParametersD3Q19>& LatticeParameters_Ptr) {
31 
32  u_ch_phys = ConfigData_Ptr->getCaseFloatParam("CharactersticParams.CharactVelocityPhysical_U_CH_Phys");
33  l_ch_phys = ConfigData_Ptr->getCaseFloatParam("CharactersticParams.CharactLengthPhysical_L_CH_Phys");
34  nu_phys = ConfigData_Ptr->getCaseFloatParam("PhysicalParams.FluidPhysicalViscosity_Nu_Phys");
35  dx_phys = ConfigData_Ptr->getCaseFloatParam("GeometryParams.PhysicalVoxelSize");
36  TAU = ConfigData_Ptr->getCaseFloatParam("PhysicalParams.Tau");
37  csq = LatticeParameters_Ptr->LatticeConstant_CSQ;
38  rho0_LB = ConfigData_Ptr->getCaseFloatParam("InitialCondition.ReferenceDensityLB_Rho0_LB");
39  rho0_phys = ConfigData_Ptr->getCaseFloatParam("PhysicalParams.FluidPhysicalReferenceDensity_Rho0_Phys");
40  FluidFlowModel_MT = ConfigData_Ptr->getFlowType();
41  };
42 
43  private:
44  static double Re;
45  static double l_ch_LB;
46  static double u_ch_LB;
47  static double dt_phys;
48  static double nu_LB;
49  static double Cu;
50  static double TAU, csq, rho0_LB, rho0_phys, u_ch_phys, l_ch_phys, nu_phys, dx_phys;
51  static int FluidFlowModel_MT;
52 
53  public:
55  static void ComputeBasicParameters(const std::shared_ptr<MF::Solver_CPU::CaseParameters>& CaseParameters_Ptr,const openvdb::Int64Grid::Ptr& VDBGrid_Ptr);
56 
58  static inline double ULB_toPhys(double u_LB)
59  {
60  return ((u_LB * l_ch_LB * nu_phys) / (nu_LB * l_ch_phys));
61  };
62 
66  u_phys.x = (u_LB.x * l_ch_LB * nu_phys) / (nu_LB * l_ch_phys);
67  u_phys.y = (u_LB.y * l_ch_LB * nu_phys) / (nu_LB * l_ch_phys);
68  u_phys.z = (u_LB.z * l_ch_LB * nu_phys) / (nu_LB * l_ch_phys);
69  return u_phys;
70  };
71 
73  static inline double UPhys_toLB(double u_phys)
74  {
75  return ((u_phys * l_ch_phys * nu_LB) / (nu_phys * l_ch_LB));
76  };
77 
81  u_LB.x = (u_phys.x * l_ch_phys * nu_LB) / (nu_phys * l_ch_LB);
82  u_LB.y = (u_phys.y * l_ch_phys * nu_LB) / (nu_phys * l_ch_LB);
83  u_LB.z = (u_phys.z * l_ch_phys * nu_LB) / (nu_phys * l_ch_LB);
84  return u_LB;
85  }
86 
88  static inline double RhoLB_toPressurePhys(double rho_LB)
89  {
90  return (csq * (rho_LB - rho0_LB) * rho0_phys / rho0_LB * ((dx_phys * dx_phys) / (dt_phys * dt_phys)));
91  };
92 
94  static inline double PressurePhys_toRhoLB(double p_phys)
95  {
96  return (rho0_LB + ((p_phys * rho0_LB) / (rho0_phys * csq)) * ((dt_phys * dt_phys) / (dx_phys * dx_phys)));
97  };
98 
100  static inline double RhoLB_toRhoPhys(double rho_LB)
101  {
102  double RhoPhys = 0;
103  if(FluidFlowModel_MT == 1) // Incompressible
104  RhoPhys = rho0_phys;
105  else
106  RhoPhys = rho0_phys / rho0_LB * rho_LB;
107  return (RhoPhys);
108  };
109 
111  static inline double RhoPhys_toRhoLB(double rho_phys)
112  {
113  return (rho_phys * rho0_LB / rho0_phys);
114  };
115 
117  static inline double FPhys_toFLB(double F_phys)
118  {
119  return (F_phys / (rho0_phys / rho0_LB * dx_phys / (dt_phys * dt_phys)));
120  }
121 
124  {
126  FLB.x = F_phys.x / (rho0_phys / rho0_LB * dx_phys / (dt_phys * dt_phys));
127  FLB.y = F_phys.y / (rho0_phys / rho0_LB * dx_phys / (dt_phys * dt_phys));
128  FLB.z = F_phys.z / (rho0_phys / rho0_LB * dx_phys / (dt_phys * dt_phys));
129  return (FLB);
130  }
131 
133  static inline double FLB_toFPhys(double F_LB)
134  {
135  return (F_LB * rho0_phys / rho0_LB * dx_phys / (dt_phys * dt_phys));
136  };
137  };
138 
139 
140  } /* namespace LBPC */
141 } /* namespace MF */
T y
Y direction value.
Definition: Vec3.h:20
T z
Z direction value.
Definition: Vec3.h:21
The class of methods converting between LB and physical values and vice versa.
T x
X direction value.
Definition: Vec3.h:19
static double RhoLB_toRhoPhys(double rho_LB)
Converts rho LB to physical density.
static void Initialize(const std::shared_ptr< MF::Database::ConfigData > &ConfigData_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 MF::Database::Vec3< double > ULB_toPhys(MF::Database::Vec3< double > u_LB)
Converts vector data: LB velocity to physical velocity.
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.
static double FLB_toFPhys(double F_LB)
LB force to physical force.
static double RhoPhys_toRhoLB(double rho_phys)
Converts physical density to rho LB.
static MF::Database::Vec3< double > FPhys_toFLB(MF::Database::Vec3< double > F_phys)
Physical force to LB force.
static double RhoLB_toPressurePhys(double rho_LB)
Converts rho LB to physical pressure.
static double ULB_toPhys(double u_LB)
Converts LB velocity to physical velocity.
static MF::Database::Vec3< double > UPhys_toLB(MF::Database::Vec3< double > u_phys)
Converts vector data: physical velocity to LB velocity.