OpenLB 1.7
Loading...
Searching...
No Matches
latticeInterpPhysVelocity2D.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_2D_HH
26#define LATTICE_INTERP_PHYS_VELOCITY_2D_HH
27
28#include<vector> // for generic i/o
29#include<cmath> // for lpnorm
30#include<math.h>
31
33#include "superBaseF2D.h"
36#include "dynamics/lbm.h" // for computation of lattice rho and velocity
38#include "blockBaseF2D.h"
41
42namespace olb {
43
44template<typename T, typename DESCRIPTOR>
47 : SuperLatticePhysF2D<T, DESCRIPTOR>(sLattice, converter, 2)
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 Cuboid2D<T>& c)
84 : BlockLatticePhysF2D<T, DESCRIPTOR>(blockLattice, converter, 2),
85 _cuboid(c)
86{
87 this->getName() = "BlockLatticeInterpVelocity2D";
88}
89
90template<typename T, typename DESCRIPTOR>
93 BlockLatticePhysF2D<T, DESCRIPTOR>(rhs._blockLattice, rhs._converter, 2),
94 _cuboid(rhs._cuboid)
95{
96}
97
98template<typename T, typename DESCRIPTOR>
100{
101 T u[2], rho, volume;
102 T d[2], e[2];
103 int latIntPos[2] = {0};
104 T latPhysPos[2] = {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
112 e[0] = 1. - d[0];
113 e[1] = 1. - d[1];
114
115 this->_blockLattice.get(latIntPos[0], latIntPos[1]).computeRhoU(rho, u);
116 volume = e[0] * e[1];
117 output[0] = u[0] * volume;
118 output[1] = u[1] * volume;
119
120 this->_blockLattice.get(latIntPos[0], latIntPos[1] + 1).computeRhoU(rho, u);
121 volume = e[0] * d[1];
122 output[0] += u[0] * volume;
123 output[1] += u[1] * volume;
124
125 this->_blockLattice.get(latIntPos[0] + 1, latIntPos[1]).computeRhoU(rho, u);
126 volume = d[0] * e[1];
127 output[0] += u[0] * volume;
128 output[1] += u[1] * volume;
129
130 this->_blockLattice.get(latIntPos[0] + 1, latIntPos[1] + 1).computeRhoU(rho, u);
131 volume = d[0] * d[1];
132 output[0] += u[0] * volume;
133 output[1] += u[1] * volume;
134
135 output[0] = this->_converter.getPhysVelocity(output[0]);
136 output[1] = this->_converter.getPhysVelocity(output[1]);
137}
138
139}
140#endif
BlockLatticeInterpPhysVelocity2D(BlockLattice< T, DESCRIPTOR > &blockLattice, const UnitConverter< T, DESCRIPTOR > &conv, const Cuboid2D< T > &c)
bool operator()(T output[2], const int input[2]) override
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 2D cuboid is the basic component of a 2D cuboid structure which defines the grid.
Definition cuboid2D.h:54
std::string & getName()
read and write access to name
Definition genericF.hh:51
std::vector< std::unique_ptr< BlockF2D< T > > > _blockF
Super functors may consist of several BlockF2D<W> derived functors.
SuperLattice< T, DESCRIPTOR > & _sLattice
SuperLatticeInterpPhysVelocity2D(SuperLattice< T, DESCRIPTOR > &sLattice, UnitConverter< T, DESCRIPTOR > const &converter)
bool operator()(T output[], const int input[]) override
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.