OpenLB 1.8.1
Loading...
Searching...
No Matches
latticePhysWallShearStress3D.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, Jonathan Jeppener-Haltenhoff
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_WALL_SHEAR_STRESS_3D_HH
26#define LATTICE_PHYS_WALL_SHEAR_STRESS_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>
46 SuperLattice<T, DESCRIPTOR>& sLattice, SuperGeometry<T,3>& superGeometry,
47 const int material, const UnitConverter<T,DESCRIPTOR>& converter,
48 IndicatorF3D<T>& indicator)
49 : SuperLatticePhysF3D<T, DESCRIPTOR>(sLattice, converter, 1),
50 _superGeometry(superGeometry), _material(material)
51{
52 this->getName() = "physWallShearStress";
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
67template <typename T, typename DESCRIPTOR>
69 BlockLattice<T,DESCRIPTOR>& blockLattice,
70 BlockGeometry<T,3>& blockGeometry,
71 int material,
72 const UnitConverter<T,DESCRIPTOR>& converter,
73 IndicatorF3D<T>& indicator)
74 : BlockLatticePhysF3D<T,DESCRIPTOR>(blockLattice,converter,1),
75 _blockGeometry(blockGeometry),
76 _material(material),
77 _discreteNormal(blockGeometry.getNcells()),
78 _normal(blockGeometry.getNcells())
79{
80 this->getName() = "physWallShearStress";
81 const T scaling = this->_converter.getConversionFactorLength() * 0.1;
82 const T omega = 1. / this->_converter.getLatticeRelaxationTime();
83 const T dt = this->_converter.getConversionFactorTime();
84 const auto& blockGeometryStructure = const_cast<BlockGeometry<T,3>&>(_blockGeometry);
85 _physFactor = -omega * descriptors::invCs2<T,DESCRIPTOR>() / dt * this->_converter.getPhysDensity() * this->_converter.getPhysViscosity();
86 std::vector<int> discreteNormalOutwards(4, 0);
87
88 blockGeometryStructure.forSpatialLocations([&](auto iX, auto iY, auto iZ) {
89 if (blockGeometryStructure.getNeighborhoodRadius({iX,iY,iZ}) >= 1) {
90 if (_blockGeometry.get({iX, iY, iZ}) == _material) {
91 discreteNormalOutwards = blockGeometryStructure.getStatistics().getType(iX, iY, iZ);
92 if (!( discreteNormalOutwards[0] == 0
93 && discreteNormalOutwards[1] == 0
94 && discreteNormalOutwards[2] == 0)) {
95 auto discreteNormal = -1 * Vector<int,3>(discreteNormalOutwards.data()+1);
96 _discreteNormal.getRowPointer(blockGeometryStructure.getCellId(iX,iY,iZ)) = discreteNormal;
97
98 Vector<T,3> physR;
99 _blockGeometry.getPhysR(physR, {iX, iY, iZ});
100 Vector<T,3> direction = discreteNormal * -scaling;
101 Vector<T,3> normal{};
102
103 if (indicator.normal(normal, physR, direction)) {
104 normal = normalize(normal);
105 _normal.getRowPointer(blockGeometryStructure.getCellId(iX,iY,iZ)) = Vector<T,3>(normal);
106 }
107 }
108 }
109 }
110 });
111}
112
113template<typename T, typename DESCRIPTOR>
115{
116 output[0] = T();
117 if (_blockGeometry.get({input[0],input[1],input[2]}) == _material) {
118 auto discreteNormal = _discreteNormal.getRowPointer(_blockGeometry.getCellId(LatticeR<3>(input)));
119 auto normal = _normal.getRowPointer(_blockGeometry.getCellId(LatticeR<3>(input)));
120
121 T traction[3];
122 T stress[6];
123 T rho = this->_blockLattice.get(input[0] + discreteNormal[0],
124 input[1] + discreteNormal[1],
125 input[2] + discreteNormal[2]).computeRho();
126 this->_blockLattice.get(input[0] + discreteNormal[0],
127 input[1] + discreteNormal[1],
128 input[2] + discreteNormal[2]).computeStress(stress);
129
130 traction[0] = stress[0]*_physFactor/rho*normal[0] +
131 stress[1]*_physFactor/rho*normal[1] +
132 stress[2]*_physFactor/rho*normal[2];
133 traction[1] = stress[1]*_physFactor/rho*normal[0] +
134 stress[3]*_physFactor/rho*normal[1] +
135 stress[4]*_physFactor/rho*normal[2];
136 traction[2] = stress[2]*_physFactor/rho*normal[0] +
137 stress[4]*_physFactor/rho*normal[1] +
138 stress[5]*_physFactor/rho*normal[2];
139
140 T traction_normal_SP;
141 T tractionNormalComponent[3];
142 // scalar product of traction and normal vector
143 traction_normal_SP = traction[0] * normal[0] +
144 traction[1] * normal[1] +
145 traction[2] * normal[2];
146 tractionNormalComponent[0] = traction_normal_SP * normal[0];
147 tractionNormalComponent[1] = traction_normal_SP * normal[1];
148 tractionNormalComponent[2] = traction_normal_SP * normal[2];
149
150 T WSS[3];
151 WSS[0] = traction[0] - tractionNormalComponent[0];
152 WSS[1] = traction[1] - tractionNormalComponent[1];
153 WSS[2] = traction[2] - tractionNormalComponent[2];
154 // magnitude of the wall shear stress vector
155 output[0] = util::sqrt(WSS[0]*WSS[0] + WSS[1]*WSS[1] + WSS[2]*WSS[2]);
156
157 return true;
158 }
159 else {
160 return true;
161 }
162}
163
164}
165#endif
Representation of a block geometry.
Vector< T, D > getPhysR(LatticeR< D > latticeR) const
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(),...
Definition aliases.h:325
const UnitConverter< T, DESCRIPTOR > & _converter
functor returns pointwise phys wall shear stress acting on a boundary with a given material on local ...
BlockLatticePhysWallShearStress3D(BlockLattice< T, DESCRIPTOR > &blockLattice, BlockGeometry< T, 3 > &blockGeometry, int material, const UnitConverter< T, DESCRIPTOR > &converter, IndicatorF3D< T > &indicator)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
ptr getRowPointer(std::size_t i)
std::string & getName()
Definition genericF.hh:51
IndicatorF3D is an application from .
Definition aliases.h:244
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< W > > > _blockF
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(),...
Definition aliases.h:315
SuperLatticePhysWallShearStress3D(SuperLattice< T, DESCRIPTOR > &sLattice, SuperGeometry< T, 3 > &superGeometry, const int material, const UnitConverter< T, DESCRIPTOR > &converter, IndicatorF3D< 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.
Wrapper functions that simplify the use of MPI.
constexpr T invCs2() any_platform
Definition functions.h:107
Expr sqrt(Expr x)
Definition expr.cpp:225
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:284
Representation of a parallel 2D geometry – header file.