OpenLB 1.7
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.getCuboidGeometry().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 int latIntPos[3] = {0};
104 T latPhysPos[3] = {T()};
105 _cuboid.getFloorLatticeR(latIntPos, &input[0]);
106 _cuboid.getPhysR(latPhysPos, latIntPos);
107
108 T deltaRinv = 1. / _cuboid.getDeltaR();
109 d[0] = (input[0] - latPhysPos[0]) * deltaRinv;
110 d[1] = (input[1] - latPhysPos[1]) * deltaRinv;
111 d[2] = (input[2] - latPhysPos[2]) * deltaRinv;
112
113 e[0] = 1. - d[0];
114 e[1] = 1. - d[1];
115 e[2] = 1. - d[2];
116
117 this->_blockLattice.get(latIntPos[0], latIntPos[1],
118 latIntPos[2]).computeRhoU(rho, u);
119 volume = e[0] * e[1] * e[2];
120 output[0] = u[0] * volume;
121 output[1] = u[1] * volume;
122 output[2] = u[2] * volume;
123
124 this->_blockLattice.get(latIntPos[0], latIntPos[1] + 1,
125 latIntPos[2]).computeRhoU(rho, u);
126 volume = e[0] * d[1] * e[2];
127 output[0] += u[0] * volume;
128 output[1] += u[1] * volume;
129 output[2] += u[2] * volume;
130
131 this->_blockLattice.get(latIntPos[0] + 1, latIntPos[1],
132 latIntPos[2]).computeRhoU(rho, u);
133 volume = d[0] * e[1] * e[2];
134 output[0] += u[0] * volume;
135 output[1] += u[1] * volume;
136 output[2] += u[2] * volume;
137
138 this->_blockLattice.get(latIntPos[0] + 1, latIntPos[1] + 1,
139 latIntPos[2]).computeRhoU(rho, u);
140 volume = d[0] * d[1] * e[2];
141 output[0] += u[0] * volume;
142 output[1] += u[1] * volume;
143 output[2] += u[2] * volume;
144
145 this->_blockLattice.get(latIntPos[0], latIntPos[1],
146 latIntPos[2] + 1).computeRhoU(rho,
147 u);
148 volume = e[0] * e[1] * d[2];
149 output[0] += u[0] * volume;
150 output[1] += u[1] * volume;
151 output[2] += u[2] * volume;
152
153 this->_blockLattice.get(latIntPos[0], latIntPos[1] + 1,
154 latIntPos[2] + 1).computeRhoU(rho,
155 u);
156 volume = e[0] * d[1] * d[2];
157 output[0] += u[0] * volume;
158 output[1] += u[1] * volume;
159 output[2] += u[2] * volume;
160
161 this->_blockLattice.get(latIntPos[0] + 1, latIntPos[1],
162 latIntPos[2] + 1).computeRhoU(rho,
163 u);
164 volume = d[0] * e[1] * d[2];
165 output[0] += u[0] * volume;
166 output[1] += u[1] * volume;
167 output[2] += u[2] * volume;
168
169 this->_blockLattice.get(latIntPos[0] + 1, latIntPos[1] + 1,
170 latIntPos[2] + 1).computeRhoU(rho,
171 u);
172 volume = d[0] * d[1] * d[2];
173 output[0] += u[0] * volume;
174 output[1] += u[1] * volume;
175 output[2] += u[2] * volume;
176
177 output[0] = this->_converter.getPhysVelocity(output[0]);
178 output[1] = this->_converter.getPhysVelocity(output[1]);
179 output[2] = this->_converter.getPhysVelocity(output[2]);
180}
181
182}
183#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(),...
Platform-abstracted block lattice for external access and inter-block interaction.
A regular single 3D cuboid is the basic component of a 3D cuboid structure which defines the grid.
Definition cuboid3D.h:58
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.
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(),...
Super class maintaining block lattices for a cuboid decomposition.
BlockLattice< T, DESCRIPTOR > & getBlock(int locC)
Return BlockLattice with local index locC.
CuboidGeometry< T, D > & getCuboidGeometry()
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.