OpenLB 1.7
Loading...
Searching...
No Matches
latticePhysWallShearStress2D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2019 Albert Mink, Mathias J. Krause, Lukas Baron
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef LATTICE_PHYS_WALL_SHEAR_STRESS_2D_HH
25#define LATTICE_PHYS_WALL_SHEAR_STRESS_2D_HH
26
27#include <vector>
28#include "utilities/omath.h"
29#include <limits>
30
32#include "dynamics/lbm.h" // for computation of lattice rho and velocity
35#include "blockBaseF2D.h"
36#include "functors/genericF.h"
40
41namespace olb {
42
43template<typename T, typename DESCRIPTOR>
45 SuperLattice<T, DESCRIPTOR>& sLattice, SuperGeometry<T,2>& superGeometry,
46 const int material, const UnitConverter<T,DESCRIPTOR>& converter,
47 IndicatorF2D<T>& indicator)
48 : SuperLatticePhysF2D<T, DESCRIPTOR>(sLattice, converter, 1),
49 _superGeometry(superGeometry), _material(material)
50{
51 this->getName() = "physWallShearStress";
52 const int maxC = this->_sLattice.getLoadBalancer().size();
53 this->_blockF.reserve(maxC);
54 for (int iC = 0; iC < maxC; iC++) {
55 this->_blockF.emplace_back(
57 this->_sLattice.getBlock(iC),
58 _superGeometry.getBlockGeometry(iC),
59 _material,
60 this->_converter,
61 indicator)
62 );
63 }
64}
65
66template <typename T, typename DESCRIPTOR>
68 BlockLattice<T,DESCRIPTOR>& blockLattice,
69 BlockGeometry<T,2>& blockGeometry,
70 int material,
71 const UnitConverter<T,DESCRIPTOR>& converter,
72 IndicatorF2D<T>& indicator)
73 : BlockLatticePhysF2D<T,DESCRIPTOR>(blockLattice,converter,1),
74 _blockGeometry(blockGeometry), _material(material)
75{
76 this->getName() = "physWallShearStress";
77 const T scaling = this->_converter.getConversionFactorLength() * 0.1;
78 const T omega = 1. / this->_converter.getLatticeRelaxationTime();
79 const T dt = this->_converter.getConversionFactorTime();
80 _physFactor = -omega * descriptors::invCs2<T,DESCRIPTOR>() / dt * this->_converter.getPhysDensity() * this->_converter.getPhysViscosity();
81 std::vector<int> discreteNormalOutwards(3, 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 if (_blockGeometry.get({iX, iY}) == _material) {
92 discreteNormalOutwards = _blockGeometry.getStatistics().getType(iX, iY);
93 _discreteNormal[iX-1][iY-1].resize(2);
94 _normal[iX-1][iY-1].resize(2);
95
96 _discreteNormal[iX-1][iY-1][0] = -discreteNormalOutwards[1];
97 _discreteNormal[iX-1][iY-1][1] = -discreteNormalOutwards[2];
98
99 T physR[2];
100 _blockGeometry.getPhysR(physR, {iX, iY});
101 Vector<T,2> origin(physR[0],physR[1]);
102 Vector<T,2> direction(-_discreteNormal[iX-1][iY-1][0] * scaling,
103 -_discreteNormal[iX-1][iY-1][1] * scaling);
104 Vector<T,2> normal(0.,0.);
105 origin[0] = physR[0];
106 origin[1] = physR[1];
107
108 indicator.normal(normal, origin, direction);
109 normal = normalize(normal);
110
111 _normal[iX-1][iY-1][0] = normal[0];
112 _normal[iX-1][iY-1][1] = normal[0];
113 }
114 }
115 }
116}
117
118template <typename T, typename DESCRIPTOR>
120{
121 output[0] = T();
122
123 if (_blockGeometry.getNeighborhoodRadius(input) < 1) {
124#ifdef OLB_DEBUG
125 std::cout << "Input address not mapped by _discreteNormal, overlap too small" << std::endl;
126#endif
127 return true;
128 }
129
130 if (this->_blockGeometry.get(input)==_material) {
131
132 T traction[2];
133 T stress[3];
134 T rho = this->_blockLattice.get(input[0] + _discreteNormal[input[0]-1][input[1]-1][0],
135 input[1] + _discreteNormal[input[0]-1][input[1]-1][1]).computeRho();
136
137 this->_blockLattice.get(input[0] + _discreteNormal[input[0]-1][input[1]-1][0],
138 input[1] + _discreteNormal[input[0]-1][input[1]-1][1]).computeStress(stress);
139
140 traction[0] = stress[0]*_physFactor/rho*_normal[input[0]-1][input[1]-1][0] +
141 stress[1]*_physFactor/rho*_normal[input[0]-1][input[1]-1][1];
142 traction[1] = stress[1]*_physFactor/rho*_normal[input[0]-1][input[1]-1][0] +
143 stress[2]*_physFactor/rho*_normal[input[0]-1][input[1]-1][1];
144
145 T traction_normal_SP;
146 T tractionNormalComponent[2];
147 // scalar product of traction and normal vector
148 traction_normal_SP = traction[0] * _normal[input[0]-1][input[1]-1][0] +
149 traction[1] * _normal[input[0]-1][input[1]-1][1];
150 tractionNormalComponent[0] = traction_normal_SP * _normal[input[0]-1][input[1]-1][0];
151 tractionNormalComponent[1] = traction_normal_SP * _normal[input[0]-1][input[1]-1][1];
152
153 T WSS[2];
154 WSS[0] = traction[0] - tractionNormalComponent[0];
155 WSS[1] = traction[1] - tractionNormalComponent[1];
156 // magnitude of the wall shear stress vector
157 output[0] = util::sqrt(WSS[0]*WSS[0] + WSS[1]*WSS[1]);
158 return true;
159 }
160 else {
161 return true;
162 }
163}
164
165}
166#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.
represents all functors that operate on a DESCRIPTOR with output in Phys, e.g. physVelocity(),...
const UnitConverter< T, DESCRIPTOR > & _converter
BlockLatticePhysBoundaryForce2D returns pointwise wall shear stress.
BlockLatticePhysWallShearStress2D(BlockLattice< T, DESCRIPTOR > &blockLattice, BlockGeometry< T, 2 > &blockGeometry, int material, const UnitConverter< T, DESCRIPTOR > &converter, IndicatorF2D< T > &indicator)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
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.
std::string & getName()
read and write access to name
Definition genericF.hh:51
IndicatorF2D is an application from .
virtual bool normal(Vector< S, 2 > &normal, const Vector< S, 2 > &origin, const Vector< S, 2 > &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< BlockF2D< T > > > _blockF
Super functors may consist of several BlockF2D<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, DESCRIPTOR > & _sLattice
represents all functors that operate on a DESCRIPTOR with output in Phys, e.g. physVelocity(),...
SuperLatticePhysWallShearStress2D(SuperLattice< T, DESCRIPTOR > &sLattice, SuperGeometry< T, 2 > &superGeometry, const int material, const UnitConverter< T, DESCRIPTOR > &converter, IndicatorF2D< T > &indicator)
Super class maintaining block lattices for a cuboid decomposition.
Conversion between physical and lattice units, as well as discretization.
Plain old scalar vector.
Definition vector.h:47
The description of a generic interface for all functor classes – header file.
This file contains indicator functions.
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.