OpenLB 1.7
Loading...
Searching...
No Matches
latticePhysHeatFluxBoundary3D.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_PHYS_HEAT_FLUX_BOUNDARY_3D_HH
26#define LATTICE_PHYS_HEAT_FLUX_BOUNDARY_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, typename TDESCRIPTOR>
46 SuperLattice<T, TDESCRIPTOR>& sLattice, SuperGeometry<T,3>& superGeometry,
47 const int material, const ThermalUnitConverter<T,DESCRIPTOR,TDESCRIPTOR>& converter,
48 IndicatorF3D<T>& indicator)
49 : SuperLatticeThermalPhysF3D<T, DESCRIPTOR, TDESCRIPTOR>(sLattice, converter, 1),
50 _superGeometry(superGeometry), _material(material)
51{
52 this->getName() = "physHeatFluxBoundary";
53 const int maxC = this->_sLattice.getLoadBalancer().size();
54 this->_blockF.reserve(maxC);
55 for (int iC = 0; iC < maxC; iC++) {
56 this->_blockF.emplace_back(
58 this->_sLattice.getBlock(iC),
59 _superGeometry.getBlockGeometry(iC),
60 _material,
61 this->_converter,
62 indicator)
63 );
64 }
65}
66
67// constructor calculates the normal of the boundary on every lattice for one specific material number
68template <typename T, typename DESCRIPTOR, typename TDESCRIPTOR>
70 BlockLattice<T,TDESCRIPTOR>& blockLattice,
71 BlockGeometry<T,3>& blockGeometry,
72 int material,
74 IndicatorF3D<T>& indicator)
75 : BlockLatticeThermalPhysF3D<T,DESCRIPTOR,TDESCRIPTOR>(blockLattice,converter,1),
76 _blockGeometry(blockGeometry),
77 _material(material)
78{
79 this->getName() = "physHeatFluxBoundary";
80 const T scaling = this->_converter.getConversionFactorLength() * 0.1;
81 std::vector<int> discreteNormalOutwards(4, 0);
82
83 for (int iX = 1 ; iX < _blockGeometry.getNx() - 1; iX++) {
84 _discreteNormal.resize(_blockGeometry.getNx() - 2);
85 _normal.resize(_blockGeometry.getNx() - 2);
86
87 for (int iY = 1; iY < _blockGeometry.getNy() - 1; iY++) {
88 _discreteNormal[iX-1].resize(_blockGeometry.getNy() - 2);
89 _normal[iX-1].resize(_blockGeometry.getNy() - 2);
90
91 for (int iZ = 1; iZ < _blockGeometry.getNz() - 1; iZ++) {
92 _discreteNormal[iX-1][iY-1].resize(_blockGeometry.getNz() - 2);
93 _normal[iX-1][iY-1].resize(_blockGeometry.getNz() - 2);
94
95 if (_blockGeometry.get({iX, iY, iZ}) == _material) {
96 discreteNormalOutwards = _blockGeometry.getStatistics().getType(iX, iY, iZ);
97 _discreteNormal[iX - 1][iY - 1][iZ - 1].resize(3);
98 _normal[iX - 1][iY - 1][iZ - 1].resize(3);
99
100 _discreteNormal[iX - 1][iY- 1][iZ- 1][0] = -discreteNormalOutwards[1];
101 _discreteNormal[iX- 1][iY- 1][iZ- 1][1] = -discreteNormalOutwards[2];
102 _discreteNormal[iX- 1][iY- 1][iZ- 1][2] = -discreteNormalOutwards[3];
103
104 T physR[3];
105 _blockGeometry.getPhysR(physR,{iX, iY, iZ});
106 Vector<T,3> origin(physR[0],physR[1],physR[2]);
107 Vector<T,3> direction(-_discreteNormal[iX- 1][iY- 1][iZ- 1][0] * scaling,
108 -_discreteNormal[iX- 1][iY- 1][iZ- 1][1] * scaling,
109 -_discreteNormal[iX- 1][iY- 1][iZ- 1][2] * scaling);
110 Vector<T,3> normal(0.,0.,0.);
111 origin[0] = physR[0];
112 origin[1] = physR[1];
113 origin[2] = physR[2];
114
115 indicator.normal(normal, origin, direction);
116 normalize(normal);
117
118 _normal[iX- 1][iY- 1][iZ- 1][0] = normal[0];
119 _normal[iX- 1][iY- 1][iZ- 1][1] = normal[1];
120 _normal[iX- 1][iY- 1][iZ- 1][2] = normal[2];
121 }
122 }
123 }
124 }
125}
126
127// functor calculates specific heat flux for one lattice, which is selected with the input
128template<typename T, typename DESCRIPTOR, typename TDESCRIPTOR>
130{
131 output[0] = T();
132
133 if (this->_blockLattice.getNeighborhoodRadius(input) < 1) {
134#ifdef OLB_DEBUG
135 std::cout << "Input address not mapped by _discreteNormal, overlap too small" << std::endl;
136#endif
137 return true;
138 }
139
140 if (_blockGeometry.get(input) == _material) {
141
142 // lattice temperature next to the boundary in the direction of the normal
143 T temp1 = this->_blockLattice.get(
144 input[0] + _discreteNormal[input[0]-1][input[1]-1][input[2]-1][0],
145 input[1] + _discreteNormal[input[0]-1][input[1]-1][input[2]-1][1],
146 input[2] + _discreteNormal[input[0]-1][input[1]-1][input[2]-1][2]).computeRho();
147
148 // second lattice temperature in the direction of the normal
149 T temp2 = this->_blockLattice.get(
150 input[0] + 2*_discreteNormal[input[0]-1][input[1]-1][input[2]-1][0],
151 input[1] + 2*_discreteNormal[input[0]-1][input[1]-1][input[2]-1][1],
152 input[2] + 2*_discreteNormal[input[0]-1][input[1]-1][input[2]-1][2]).computeRho();
153
154 // calculation of deltaX with the normal, yields higher accuracy for deltaX
155 T deltaX = util::sqrt( _normal[input[0]-1][input[1]-1][input[2]-1][0] *
156 _normal[input[0]-1][input[1]-1][input[2]-1][0] +
157 _normal[input[0]-1][input[1]-1][input[2]-1][1] *
158 _normal[input[0]-1][input[1]-1][input[2]-1][1] +
159 _normal[input[0]-1][input[1]-1][input[2]-1][2] *
160 _normal[input[0]-1][input[1]-1][input[2]-1][2] );
161
162 // lattice temperature on the boundary
163 // ATTENTION: here the temperature is hardcoded as the characteristic high temperature
164 T temp0 = 1.5;
165
166 //return of specific heat flux in direction of the normal
167 output[0] = this->_converter.getThermalConductivity() *
168 this->_converter.getCharPhysTemperatureDifference() *
169 (1.5 * temp0 - 2.0 * temp1 + 0.5 * temp2) /
170 this->_converter.getPhysLength(deltaX);
171
172 return true;
173 }
174 else {
175 return true;
176 }
177}
178
179}
180#endif
Representation of a block geometry.
const BlockGeometryStatistics< T, D > & getStatistics() const
Read only access to the associated block statistic.
Vector< T, D > getPhysR(LatticeR< D > latticeR)
std::enable_if_t< sizeof...(L)==D, int > get(L... latticeR) const
Read-only access to a material number.
functor returns pointwise phys heat flux on a boundary with a given material on local lattice
BlockLatticePhysHeatFluxBoundary3D(BlockLattice< T, TDESCRIPTOR > &blockLattice, BlockGeometry< T, 3 > &blockGeometry, int material, const ThermalUnitConverter< T, DESCRIPTOR, TDESCRIPTOR > &converter, IndicatorF3D< T > &indicator)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
represents all thermal functors that operate on a DESCRIPTOR with output in Phys, e....
const ThermalUnitConverter< T, DESCRIPTOR, TDESCRIPTOR > & _converter
Platform-abstracted block lattice for external access and inter-block interaction.
int getNy() const
Read only access to block height.
int getNx() const
Read only access to block width.
int getNz() const
Read only access to block height.
std::string & getName()
read and write access to name
Definition genericF.hh:51
IndicatorF3D is an application from .
virtual bool normal(Vector< S, 3 > &normal, const Vector< S, 3 > &origin, const Vector< S, 3 > &direction, int iC=-1)
returns true and the normal if there was one found for an given origin and direction
std::vector< std::unique_ptr< BlockF3D< T > > > _blockF
Super functors may consist of several BlockF3D<W> derived functors.
Representation of a statistic for a parallel 2D geometry.
BlockGeometry< T, D > & getBlockGeometry(int locIC)
Read and write access to a single block geometry.
SuperLattice< T, TDESCRIPTOR > & _sLattice
SuperLatticePhysHeatFluxBoundary3D(SuperLattice< T, TDESCRIPTOR > &sLattice, SuperGeometry< T, 3 > &superGeometry, const int material, const ThermalUnitConverter< T, DESCRIPTOR, TDESCRIPTOR > &converter, IndicatorF3D< T > &indicator)
represents all thermal functors that operate on a DESCRIPTOR with output in Phys, e....
Super class maintaining block lattices for a cuboid decomposition.
BlockLattice< T, DESCRIPTOR > & getBlock(int locC)
Return BlockLattice with local index locC.
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
Conversion between physical and lattice units, as well as discretization specialized for thermal appl...
constexpr T getConversionFactorLength() const
access (read-only) to private member variable
Plain old scalar vector.
Definition vector.h:47
Wrapper functions that simplify the use of MPI.
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
Definition pack.h:100
Top level namespace for all of OpenLB.
constexpr Vector< T, D > normalize(const ScalarVector< T, D, IMPL > &a, T scale=T{1})
Definition vector.h:245
Representation of a parallel 2D geometry – header file.