25#ifndef PL_UNITCONVERTER_HH
26#define PL_UNITCONVERTER_HH
37template <
typename T,
typename DESCRIPTOR>
38void PowerLawUnitConverter<T, DESCRIPTOR>::print(std::ostream& clout)
const
40 clout <<
"----------------- UnitConverter information ------------------" << std::endl;
41 clout <<
"-- Parameters:" << std::endl;
42 clout <<
"Resolution: N= " << this->getResolution() << std::endl;
43 clout <<
"Lattice velocity: latticeU= " << this->getCharLatticeVelocity() << std::endl;
44 clout <<
"Lattice relaxation frequency: omega= " << this->getLatticeRelaxationFrequency( ) << std::endl;
45 clout <<
"Lattice relaxation time: tau= " << this->getLatticeRelaxationTime() << std::endl;
46 clout <<
"Characteristical length(m): charL= " << this->getCharPhysLength() << std::endl;
47 clout <<
"Characteristical speed(m/s): charU= " << this->getCharPhysVelocity() << std::endl;
48 clout <<
"Phys. char kinematic visco(m^2/s): charNu= " << this->getPhysViscosity() << std::endl;
49 clout <<
"Phys. consistency coeff(m^2 s^(n-2)): charM= " << this->getPhysConsistencyCoeff() << std::endl;
50 clout <<
"Power-law index: n= " << this->getPowerLawIndex() << std::endl;
51 clout <<
"Phys. density(kg/m^d): charRho= " << this->getPhysDensity() << std::endl;
52 clout <<
"Characteristical pressure(N/m^2): charPressure= " << this->getCharPhysPressure() << std::endl;
53 clout <<
"Reynolds number: reynoldsNumber= " << this->getReynoldsNumber() << std::endl;
56 clout <<
"-- Conversion factors:" << std::endl;
57 clout <<
"Voxel length(m): physDeltaX= " << this->getConversionFactorLength() << std::endl;
58 clout <<
"Time step(s): physDeltaT= " << this->getConversionFactorTime() << std::endl;
59 clout <<
"Velocity factor(m/s): physVelocity= " << this->getConversionFactorVelocity() << std::endl;
60 clout <<
"Density factor(kg/m^3): physDensity= " << this->getConversionFactorDensity() << std::endl;
61 clout <<
"Mass factor(kg): physMass= " << this->getConversionFactorMass() << std::endl;
62 clout <<
"Viscosity factor(m^2/s): physViscosity= " << this->getConversionFactorViscosity() << std::endl;
63 clout <<
"Force factor(N): physForce= " << this->getConversionFactorForce() << std::endl;
64 clout <<
"Pressure factor(N/m^2): physPressure= " << this->getConversionFactorPressure() << std::endl;
66 clout <<
"--------------------------------------------------------------" << std::endl;
70template <
typename T,
class DESCRIPTOR>
71void PowerLawUnitConverter<T, DESCRIPTOR>::print()
const
76template <
typename T,
typename DESCRIPTOR>
77void PowerLawUnitConverter<T, DESCRIPTOR>::write(std::string
const& fileName)
const
82 std::ofstream fout(dataFile.c_str(), std::ios::trunc);
84 clout <<
"error write() function: can not open std::ofstream" << std::endl;
93template<
typename T,
typename DESCRIPTOR>
105 T physConsistencyCoeff;
108 T charPhysPressure = 0;
111 T latticeRelaxationTime;
112 T charLatticeVelocity;
118 params[
"Application"][
"PhysParameters"][
"CharPhysLength"].
read(charPhysLength);
119 params[
"Application"][
"PhysParameters"][
"CharPhysVelocity"].
read(charPhysVelocity);
120 params[
"Application"][
"PhysParameters"][
"PhysConsistencyCoeff"].
read(physConsistencyCoeff);
121 params[
"Application"][
"PhysParameters"][
"powerLawIndex"].
read(powerLawIndex);
122 params[
"Application"][
"PhysParameters"][
"PhysDensity"].
read(physDensity);
123 params[
"Application"][
"PhysParameters"][
"CharPhysPressure"].
read(charPhysPressure);
125 physViscosity = physConsistencyCoeff *
util::pow(charPhysVelocity / (2*charPhysLength), powerLawIndex-1);
127 std::vector<std::string> discretizationParam = {
"PhysDeltaX",
"Resolution",
128 "CharLatticeVelocity",
"PhysDeltaT",
"LatticeRelaxationTime"};
130 for(
int i = 0; i<discretizationParam.size(); i++){
132 if(params[
"Application"][
"Discretization"][discretizationParam[i]].read(test,
false)){
137 clout <<
"WARNING: More than 2 discretization parameters provided" << std::endl;
140 if (!params[
"Application"][
"Discretization"][
"PhysDeltaX"].read(physDeltaX,
false)) {
141 if (!params[
"Application"][
"Discretization"][
"Resolution"].read<int>(resolution,
false)) {
142 if (!params[
"Application"][
"Discretization"][
"CharLatticeVelocity"].read(charLatticeVelocity,
false)) {
144 clout <<
"Error: Have not found PhysDeltaX, Resolution or CharLatticeVelocity in XML file."
150 if (params[
"Application"][
"Discretization"][
"PhysDeltaT"].read(physDeltaT,
false)) {
151 physDeltaX = charPhysVelocity / charLatticeVelocity * physDeltaT;
153 else if (params[
"Application"][
"Discretization"][
"LatticeRelaxationTime"].read(latticeRelaxationTime,
false)) {
154 physDeltaX = physViscosity * charLatticeVelocity / charPhysVelocity * descriptors::invCs2<T,DESCRIPTOR>() / (latticeRelaxationTime - 0.5);
160 physDeltaX = charPhysLength / resolution;
164 if (!params[
"Application"][
"Discretization"][
"PhysDeltaT"].read(physDeltaT,
false)) {
165 if (!params[
"Application"][
"Discretization"][
"LatticeRelaxationTime"].read(latticeRelaxationTime,
false)) {
166 if (!params[
"Application"][
"Discretization"][
"CharLatticeVelocity"].read(charLatticeVelocity,
false)) {
168 clout <<
"Error: Have not found PhysDeltaT, LatticeRelaxationTime or CharLatticeVelocity in XML file."
174 physDeltaT = charLatticeVelocity / charPhysVelocity * physDeltaX;
179 physDeltaT = (latticeRelaxationTime - 0.5) / descriptors::invCs2<T,DESCRIPTOR>() * physDeltaX * physDeltaX / physViscosity;
183 return new PowerLawUnitConverter<T, DESCRIPTOR>(physDeltaX, physDeltaT, charPhysLength, charPhysVelocity, physConsistencyCoeff, powerLawIndex, physDensity, charPhysPressure);
class for marking output with some text
void setWarningsOn(bool warnings) const
switch warnings on/off
bool read(T &value, bool verboseOn=true, bool exitIfMissing=false) const
Prints out the XML structure read in, mostly for debugging purposes.
std::string getLogOutDir() const
These functions help you to create file names.
Directories & directories()
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
void print(U data, const std::string &name="", OstreamManager clout=OstreamManager(std::cout,"print"), const char delimiter=',')
Top level namespace for all of OpenLB.
PowerLawUnitConverter< T, DESCRIPTOR > * createPowerLawUnitConverter(XMLreader const ¶ms)
Definition of singletons: global, publicly available information.