OpenLB 1.7
Loading...
Searching...
No Matches
latticeTimeStepScale3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2012 Lukas Baron, Tim Dornieden, Mathias J. Krause,
4 * Albert Mink
5 * E-mail contact: info@openlb.net
6 * The most recent release of OpenLB can be downloaded at
7 * <http://www.openlb.net/>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23*/
24
25#ifndef LATTICE_TIME_STEP_SCALE_3D_HH
26#define LATTICE_TIME_STEP_SCALE_3D_HH
27
28#include<vector> // for generic i/o
29#include<cmath> // for lpnorm
30#include<math.h>
31
33#include "superBaseF3D.h"
36#include "dynamics/lbm.h" // for computation of lattice rho and velocity
38#include "blockBaseF3D.h"
41
42namespace olb {
43
44template<typename T, typename DESCRIPTOR>
47 T oldTau, const UnitConverter<T,DESCRIPTOR>& converter)
48 : SuperLatticeF3D<T, DESCRIPTOR>(sLattice, DESCRIPTOR::q)
49{
50 this->getName() = "latticeTimeStepScale";
51 const int maxC = this->_sLattice.getLoadBalancer().size();
52 this->_blockF.reserve(maxC);
53 for (int iC = 0; iC < maxC; iC++) {
54 this->_blockF.emplace_back(
56 this->_sLattice.getBlock(iC),
57 oldTau,
58 converter)
59 );
60 }
61}
62
63template <typename T, typename DESCRIPTOR>
65(BlockLattice<T,DESCRIPTOR>& blockLattice, T oldTau, const UnitConverter<T,DESCRIPTOR>& converter)
66 : BlockLatticeF3D<T,DESCRIPTOR>(blockLattice, DESCRIPTOR::q), _tau_old(oldTau), _converter(converter)
67{
68 this->getName() = "latticeTimeStepScale";
69}
70
71template <typename T, typename DESCRIPTOR>
73{
74
75 Cell<T,DESCRIPTOR> cell = this->_blockLattice.get(input[0], input[1], input[2]);
76 Dynamics<T,DESCRIPTOR>* dynamics = this->_blockLattice.getDynamics(input[0], input[1], input[2]);
77 T rho_old, rho_new, u_old[DESCRIPTOR::d], u_new[DESCRIPTOR::d];;
78 cell.computeRhoU(rho_old,u_old);
79 T fNeq[DESCRIPTOR::q];
80
81 T uSqr_old = util::normSqr<T,DESCRIPTOR::d>(u_old);
82
83 T tau_new = _converter.getLatticeRelaxationTime();
84
85 T physDeltaT_new = _converter.getPhysDeltaT();
86 T physDeltaT_old = physDeltaT_new * (_tau_old-0.5) / (tau_new-0.5);
87 T neqScaling = ((physDeltaT_new*tau_new)/(physDeltaT_old*_tau_old));
88
89 for (int iDim=0; iDim < DESCRIPTOR::d; iDim++) {
90 u_new[iDim] = u_old[iDim] * physDeltaT_new / physDeltaT_old ;
91 }
92
93 rho_new = (rho_old-1.0) * (physDeltaT_new / physDeltaT_old) * (physDeltaT_new / physDeltaT_old) + 1.0;
94
95 T uSqr_new = util::normSqr<T,DESCRIPTOR::d>(u_new);
96
97
98 for (int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
99 fNeq[iPop] = cell[iPop] - dynamics -> computeEquilibrium(iPop,rho_old,u_old,uSqr_old);
100// output[iPop] = cell[iPop];
101 output[iPop] = (dynamics -> computeEquilibrium(iPop,rho_old,u_old,uSqr_old)+descriptors::t<T,DESCRIPTOR>(iPop)// * ((dynamics -> computeEquilibrium(iPop,rho_old,u_new,uSqr_new)+descriptors::t<T,DESCRIPTOR>(iPop))/(dynamics -> computeEquilibrium(iPop,rho_old,u_old,uSqr_old)+descriptors::t<T,DESCRIPTOR>(iPop)))
102 + fNeq[iPop]*neqScaling)
103 * ((dynamics -> computeEquilibrium(iPop,rho_new,u_new,uSqr_new)+descriptors::t<T,DESCRIPTOR>(iPop))/(dynamics -> computeEquilibrium(iPop,rho_old,u_old,uSqr_old)+descriptors::t<T,DESCRIPTOR>(iPop))) - descriptors::t<T,DESCRIPTOR>(iPop);
104 }
105 return true;
106}
107
108}
109#endif
represents all functors that operate on a DESCRIPTOR in general, e.g. getVelocity(),...
functor to scale particle distributions to a time step
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockLatticeTimeStepScale3D(BlockLattice< T, DESCRIPTOR > &blockLattice, T oldTau, const UnitConverter< T, DESCRIPTOR > &converter)
Platform-abstracted block lattice for external access and inter-block interaction.
Highest-level interface to Cell data.
Definition cell.h:148
void computeRhoU(T &rho, T u[descriptors::d< DESCRIPTOR >()]) const
Compute fluid velocity and particle density on the cell.
Definition cell.hh:232
std::string & getName()
read and write access to name
Definition genericF.hh:51
std::vector< std::unique_ptr< BlockF3D< T > > > _blockF
Super functors may consist of several BlockF3D<W> derived functors.
represents all functors that operate on a SuperLattice in general, e.g. getVelocity(),...
SuperLattice< T, DESCRIPTOR > & _sLattice
SuperLatticeTimeStepScale3D(SuperLattice< T, DESCRIPTOR > &sLattice, T oldTau, const UnitConverter< T, DESCRIPTOR > &converter)
Super class maintaining block lattices for a cuboid decomposition.
Conversion between physical and lattice units, as well as discretization.
Wrapper functions that simplify the use of MPI.
Top level namespace for all of OpenLB.
Interface for per-cell dynamics.
Definition interface.h:54
Representation of a parallel 2D geometry – header file.