OpenLB 1.8.1
Loading...
Searching...
No Matches
latticeInterpPhysVelocity3D.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_INTERP_PHYS_VELOCITY_3D_HH
26#define LATTICE_INTERP_PHYS_VELOCITY_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 : SuperLatticePhysF3D<T, DESCRIPTOR>(sLattice, converter, 3)
48{
49 this->getName() = "InterpVelocity";
50 int maxC = this->_sLattice.getLoadBalancer().size();
51 this->_blockF.reserve(maxC);
52 for (int lociC = 0; lociC < maxC; lociC++) {
53 int globiC = this->_sLattice.getLoadBalancer().glob(lociC);
54
55 this->_blockF.emplace_back(
57 sLattice.getBlock(lociC),
58 converter,
59 sLattice.getCuboidDecomposition().get(globiC))
60 );
61 }
62}
63
64template<typename T, typename DESCRIPTOR>
66{
67 return false;
68}
69
70template<typename T, typename DESCRIPTOR>
72 const T input[], const int globiC)
73{
74 if (this->_sLattice.getLoadBalancer().isLocal(globiC)) {
76 this->_blockF[this->_sLattice.getLoadBalancer().loc(globiC)].get()
77 )->operator()(output, input);
78 }
79}
80
81template<typename T, typename DESCRIPTOR>
83 BlockLattice<T, DESCRIPTOR>& blockLattice, UnitConverter<T,DESCRIPTOR> const& converter, const Cuboid3D<T>& c)
84 : BlockLatticePhysF3D<T, DESCRIPTOR>(blockLattice, converter, 3),
85 _cuboid(c)
86{
87 this->getName() = "BlockLatticeInterpVelocity3D";
88}
89
90template<typename T, typename DESCRIPTOR>
93 BlockLatticePhysF3D<T, DESCRIPTOR>(rhs._blockLattice, rhs._converter, 3),
94 _cuboid(rhs._cuboid)
95{
96}
97
98template<typename T, typename DESCRIPTOR>
100{
101 T u[3], rho, volume;
102 T d[3], e[3];
103 auto latIntPos = _cuboid.getFloorLatticeR(&input[0]);
104 auto latPhysPos = _cuboid.getPhysR(latIntPos);
105
106 T deltaRinv = 1. / _cuboid.getDeltaR();
107 d[0] = (input[0] - latPhysPos[0]) * deltaRinv;
108 d[1] = (input[1] - latPhysPos[1]) * deltaRinv;
109 d[2] = (input[2] - latPhysPos[2]) * deltaRinv;
110
111 e[0] = 1. - d[0];
112 e[1] = 1. - d[1];
113 e[2] = 1. - d[2];
114
115 this->_blockLattice.get(latIntPos[0], latIntPos[1],
116 latIntPos[2]).computeRhoU(rho, u);
117 volume = e[0] * e[1] * e[2];
118 output[0] = u[0] * volume;
119 output[1] = u[1] * volume;
120 output[2] = u[2] * volume;
121
122 this->_blockLattice.get(latIntPos[0], latIntPos[1] + 1,
123 latIntPos[2]).computeRhoU(rho, u);
124 volume = e[0] * d[1] * e[2];
125 output[0] += u[0] * volume;
126 output[1] += u[1] * volume;
127 output[2] += u[2] * volume;
128
129 this->_blockLattice.get(latIntPos[0] + 1, latIntPos[1],
130 latIntPos[2]).computeRhoU(rho, u);
131 volume = d[0] * e[1] * e[2];
132 output[0] += u[0] * volume;
133 output[1] += u[1] * volume;
134 output[2] += u[2] * volume;
135
136 this->_blockLattice.get(latIntPos[0] + 1, latIntPos[1] + 1,
137 latIntPos[2]).computeRhoU(rho, u);
138 volume = d[0] * d[1] * e[2];
139 output[0] += u[0] * volume;
140 output[1] += u[1] * volume;
141 output[2] += u[2] * volume;
142
143 this->_blockLattice.get(latIntPos[0], latIntPos[1],
144 latIntPos[2] + 1).computeRhoU(rho,
145 u);
146 volume = e[0] * e[1] * d[2];
147 output[0] += u[0] * volume;
148 output[1] += u[1] * volume;
149 output[2] += u[2] * volume;
150
151 this->_blockLattice.get(latIntPos[0], latIntPos[1] + 1,
152 latIntPos[2] + 1).computeRhoU(rho,
153 u);
154 volume = e[0] * d[1] * d[2];
155 output[0] += u[0] * volume;
156 output[1] += u[1] * volume;
157 output[2] += u[2] * volume;
158
159 this->_blockLattice.get(latIntPos[0] + 1, latIntPos[1],
160 latIntPos[2] + 1).computeRhoU(rho,
161 u);
162 volume = d[0] * e[1] * d[2];
163 output[0] += u[0] * volume;
164 output[1] += u[1] * volume;
165 output[2] += u[2] * volume;
166
167 this->_blockLattice.get(latIntPos[0] + 1, latIntPos[1] + 1,
168 latIntPos[2] + 1).computeRhoU(rho,
169 u);
170 volume = d[0] * d[1] * d[2];
171 output[0] += u[0] * volume;
172 output[1] += u[1] * volume;
173 output[2] += u[2] * volume;
174
175 output[0] = this->_converter.getPhysVelocity(output[0]);
176 output[1] = this->_converter.getPhysVelocity(output[1]);
177 output[2] = this->_converter.getPhysVelocity(output[2]);
178}
179
180}
181#endif
bool operator()(T output[3], const int input[3]) override
BlockLatticeInterpPhysVelocity3D(BlockLattice< T, DESCRIPTOR > &blockLattice, const UnitConverter< T, DESCRIPTOR > &conv, const Cuboid3D< T > &c)
represents all functors that operate on a DESCRIPTOR with output in Phys, e.g. physVelocity(),...
Definition aliases.h:325
std::string & getName()
Definition genericF.hh:51
std::vector< std::unique_ptr< BlockF3D< W > > > _blockF
SuperLattice< T, DESCRIPTOR > & _sLattice
bool operator()(T output[], const int input[]) override
SuperLatticeInterpPhysVelocity3D(SuperLattice< T, DESCRIPTOR > &sLattice, UnitConverter< T, DESCRIPTOR > const &converter)
represents all functors that operate on a DESCRIPTOR with output in Phys, e.g. physVelocity(),...
Definition aliases.h:315
Super class maintaining block lattices for a cuboid decomposition.
BlockLattice< T, DESCRIPTOR > & getBlock(int locC)
Return BlockLattice with local index locC.
CuboidDecomposition< T, D > & getCuboidDecomposition()
Read and write access to cuboid geometry.
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.
Representation of a parallel 2D geometry – header file.