OpenLB
1.7
Loading...
Searching...
No Matches
src
functors
lattice
latticePorousMomentumLossForce3D.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_POROUS_MOMENTUM_LOSS_FORCE_3D_HH
26
#define LATTICE_POROUS_MOMENTUM_LOSS_FORCE_3D_HH
27
28
#include<vector>
// for generic i/o
29
#include<cmath>
// for lpnorm
30
#include<math.h>
31
32
#include "
latticePorousMomentumLossForce3D.h
"
33
#include "
superBaseF3D.h
"
34
#include "
functors/analytical/indicator/indicatorBaseF3D.h
"
35
#include "
indicator/superIndicatorF3D.h
"
36
#include "
dynamics/lbm.h
"
// for computation of lattice rho and velocity
37
#include "
geometry/superGeometry.h
"
38
#include "
blockBaseF3D.h
"
39
#include "
communication/mpiManager.h
"
40
#include "
utilities/vectorHelpers.h
"
41
42
namespace
olb
{
43
/*
44
template <typename T, typename DESCRIPTOR>
45
SuperLatticePorousMomentumLossForce3D<T,DESCRIPTOR>::SuperLatticePorousMomentumLossForce3D
46
(SuperLattice<T,DESCRIPTOR>& sLattice, SuperGeometry<T,3>& superGeometry,
47
std::vector<SmoothIndicatorF3D<T,T,true>* >& indicator, const UnitConverter<T,DESCRIPTOR>& converter)
48
: SuperLatticePhysF3D<T,DESCRIPTOR>(sLattice,converter,7*indicator.size())
49
{
50
this->getName() = "physPorousMomentumLossForce";
51
int maxC = this->_sLattice.getLoadBalancer().size();
52
this->_blockF.reserve(maxC);
53
for (int iC = 0; iC < maxC; iC++) {
54
this->_blockF.emplace_back( new BlockLatticePorousMomentumLossForce3D<T,DESCRIPTOR>(this->_sLattice.getBlock(iC), superGeometry.getBlockGeometry(iC), indicator, converter));
55
}
56
}
57
58
template <typename T, typename DESCRIPTOR>
59
bool SuperLatticePorousMomentumLossForce3D<T,DESCRIPTOR>::operator() (T output[],
60
const int input[])
61
{
62
for (int i=0; i<this->getTargetDim(); i++) {
63
output[i] = 0.;
64
}
65
for (int iC = 0; iC < this->_sLattice.getLoadBalancer().size(); ++iC) {
66
int globiC = this->_sLattice.getLoadBalancer().glob(iC);
67
if ( this->_sLattice.getLoadBalancer().rank(globiC) == singleton::mpi().getRank() ) {
68
this->getBlockF(iC)(output,&input[1]);
69
}
70
}
71
72
#ifdef PARALLEL_MODE_MPI
73
for (int i = 0; i < this->getTargetDim(); ++i) {
74
singleton::mpi().reduceAndBcast(output[i], MPI_SUM);
75
}
76
#endif
77
return true;
78
79
}
80
81
template<typename T, typename DESCRIPTOR>
82
BlockLatticePorousMomentumLossForce3D<T, DESCRIPTOR>::BlockLatticePorousMomentumLossForce3D(
83
BlockLattice<T, DESCRIPTOR>& blockLattice, BlockGeometry<T,3>& blockGeometry,
84
std::vector<SmoothIndicatorF3D<T,T,true>* >& indicator, const UnitConverter<T,DESCRIPTOR>& converter)
85
: BlockLatticePhysF3D<T, DESCRIPTOR>(blockLattice, converter, 7*indicator.size()), _blockGeometry(blockGeometry), _vectorOfIndicator(indicator)
86
{
87
this->getName() = "physPorousMomentumLossForce";
88
}
89
90
91
template<typename T, typename DESCRIPTOR>
92
bool BlockLatticePorousMomentumLossForce3D<T, DESCRIPTOR>::operator()(T output[], const int input[])
93
{
94
// iterate over all particles in _indicator
95
for (size_t iInd=0; iInd!=_vectorOfIndicator.size(); iInd++) {
96
97
int numVoxels = 0;
98
std::vector<int> start{0,0,0};
99
std::vector<int> end{0,0,0};
100
T invDeltaX = 1./this->_converter.getPhysDeltaX();
101
102
// check for intersection of cuboid and indicator
103
if (getRangeBlockGeometrySmoothIndicatorIntersection3D(_blockGeometry, *(_vectorOfIndicator[iInd]), invDeltaX, start, end)) {
104
105
// iterate over cells in the constructed intersection box
106
for (int iX = start[0]; iX < end[0]; iX++) {
107
for (int iY = start[1]; iY < end[1]; iY++) {
108
for (int iZ = start[2]; iZ < end[2]; iZ++) {
109
110
// check if cell belongs to particle
111
T inside[1] = {0.};
112
T posIn[3] = {0.};
113
_blockGeometry.getPhysR(posIn, {iX, iY, iZ});
114
(*(_vectorOfIndicator[iInd]))( inside, posIn);
115
if ( !util::nearZero(inside[0]) && this->_blockGeometry.get({iX,iY,iZ})==1) {
116
// compute momentum exchange force on particle
117
T tmpForce[3] = {0.,0.,0.};
118
tmpForce[0] += this->_blockLattice.get(iX, iY, iZ).template getFieldComponent<descriptors::VELOCITY_NUMERATOR>(0);
119
tmpForce[1] += this->_blockLattice.get(iX, iY, iZ).template getFieldComponent<descriptors::VELOCITY_NUMERATOR>(1);
120
tmpForce[2] += this->_blockLattice.get(iX, iY, iZ).template getFieldComponent<descriptors::VELOCITY_NUMERATOR>(2);
121
// reset external field for next timestep
122
T reset_to_zero[3] = {0.,0.,0.};
123
this->_blockLattice.get(iX, iY, iZ).template setField<descriptors::VELOCITY_NUMERATOR>(reset_to_zero);
124
// convert force to SI units and compute torque
125
numVoxels++;
126
// division bei length of lattice cell necessary due to converter handling of force
127
tmpForce[0] = this->_converter.getPhysForce(tmpForce[0]);
128
tmpForce[1] = this->_converter.getPhysForce(tmpForce[1]);
129
tmpForce[2] = this->_converter.getPhysForce(tmpForce[2]);
130
output[0+iInd*7] += tmpForce[0];
131
output[1+iInd*7] += tmpForce[1];
132
output[2+iInd*7] += tmpForce[2];
133
output[3+iInd*7] += (posIn[1]-_vectorOfIndicator[iInd]->getPos()[1])*tmpForce[2]
134
- (posIn[2]-_vectorOfIndicator[iInd]->getPos()[2])*tmpForce[1];
135
output[4+iInd*7] += (posIn[2]-_vectorOfIndicator[iInd]->getPos()[2])*tmpForce[0]
136
- (posIn[0]-_vectorOfIndicator[iInd]->getPos()[0])*tmpForce[2];
137
output[5+iInd*7] += (posIn[0]-_vectorOfIndicator[iInd]->getPos()[0])*tmpForce[1]
138
- (posIn[1]-_vectorOfIndicator[iInd]->getPos()[1])*tmpForce[0];
139
}
140
}
141
}
142
}
143
144
}
145
output[6+iInd*7] = numVoxels;
146
147
}
148
return true;
149
}
150
*/
151
}
152
#endif
blockBaseF3D.h
indicatorBaseF3D.h
latticePorousMomentumLossForce3D.h
lbm.h
mpiManager.h
Wrapper functions that simplify the use of MPI.
olb
Top level namespace for all of OpenLB.
Definition
boundaryPostProcessors2D.h:34
superBaseF3D.h
superGeometry.h
Representation of a parallel 2D geometry – header file.
superIndicatorF3D.h
vectorHelpers.h
Generated on Tue Mar 5 2024 09:57:49 for OpenLB by
1.10.0