OpenLB 1.7
Loading...
Searching...
No Matches
latticeIndicatorSmoothIndicatorIntersection3D.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_INDICATOR_SMOOTH_INDICATOR_INTERSECTION_3D_HH
26#define LATTICE_INDICATOR_SMOOTH_INDICATOR_INTERSECTION_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, bool HLBM>
47 SuperGeometry<T,3>& superGeometry,
48 IndicatorF3D<T>& normalInd, SmoothIndicatorF3D<T,T,HLBM>& smoothInd )
49 : SuperLatticeF3D<T,DESCRIPTOR>(sLattice, 1)
50{
51 this->getName() = "Indicator-SmoothIndicator Intersection";
52 int maxC = this->_sLattice.getLoadBalancer().size();
53 this->_blockF.reserve(maxC);
54 for (int iC = 0; iC < maxC; iC++) {
55 this->_blockF.emplace_back( new BlockLatticeIndicatorSmoothIndicatorIntersection3D<T,DESCRIPTOR,HLBM>(this->_sLattice.getBlock(iC), superGeometry.getBlockGeometry(iC), normalInd, smoothInd));
56 }
57}
58
59template <typename T, typename DESCRIPTOR, bool HLBM>
61{
62 output[0] = 0.;
63 for (int iC = 0; iC < this->_sLattice.getLoadBalancer().size(); ++iC) {
64 int globiC = this->_sLattice.getLoadBalancer().glob(iC);
65 if ( this->_sLattice.getLoadBalancer().rank(globiC) == singleton::mpi().getRank() ) {
66 this->getBlockF(iC)(output,&input[1]);
67 }
68 }
69
70#ifdef PARALLEL_MODE_MPI
71 singleton::mpi().reduceAndBcast(output[0], MPI_MAX);
72#endif
73 return true;
74
75}
76
77template<typename T, typename DESCRIPTOR, bool HLBM>
79 BlockLattice<T, DESCRIPTOR>& blockLattice,
80 BlockGeometry<T,3>& blockGeometry,
81 IndicatorF3D<T>& normalInd,
83 : BlockLatticeF3D<T, DESCRIPTOR>(blockLattice, 1),
84 _blockGeometry(blockGeometry), _normalInd(normalInd), _smoothInd(smoothInd)
85{
86 this->getName() = "Indicator-SmoothIndicator Intersection";
87}
88
89template<typename T, typename DESCRIPTOR, bool HLBM>
91{
92 output[0] = 0.;
93 int start[3] = {0};
94 int end[3] = {0};
95 // check for intersection of cuboid and smoothIndicator
96 Cuboid3D<T> tmpCuboid(_blockGeometry.getOrigin()[0], _blockGeometry.getOrigin()[1], _blockGeometry.getOrigin()[2], _blockGeometry.getDeltaR(), _blockGeometry.getNx(), _blockGeometry.getNy(), _blockGeometry.getNz());
97 T posXmin = _smoothInd.getPos()[0] - _smoothInd.getCircumRadius();
98 T posXmax = _smoothInd.getPos()[0] + _smoothInd.getCircumRadius();
99 T posYmin = _smoothInd.getPos()[1] - _smoothInd.getCircumRadius();
100 T posYmax = _smoothInd.getPos()[1] + _smoothInd.getCircumRadius();
101 T posZmin = _smoothInd.getPos()[2] - _smoothInd.getCircumRadius();
102 T posZmax = _smoothInd.getPos()[2] + _smoothInd.getCircumRadius();
103 if (tmpCuboid.checkInters(posXmin, posXmax, posYmin, posYmax, posZmin, posZmax, start[0],
104 end[0], start[1], end[1], start[2], end[2])) {
105
106 for (int k=0; k<3; k++) {
107 start[k] -= 1;
108 if (start[k] < 0) {
109 start[k] = 0;
110 }
111 end[k] += 2;
112 if (end[k] > _blockGeometry.getExtent()[k]) {
113 end[k] = _blockGeometry.getExtent()[k];
114 }
115 }
116
117 // iterate over cells in the constructed intersection box
118 for (int iX = start[0]; iX < end[0]; iX++) {
119 for (int iY = start[1]; iY < end[1]; iY++) {
120 for (int iZ = start[2]; iZ < end[2]; iZ++) {
121
122 // check if cell belongs to particle
123 T insideT[1] = {0.};
124 T posIn[3] = {0.};
125 _blockGeometry.getPhysR(posIn, {iX, iY, iZ});
126 _smoothInd( insideT, posIn);
127 if ( !util::nearZero(insideT[0]) && this->_blockGeometry.get({iX,iY,iZ})==1) {
128 // Return true if at least one cell is found to be inside both A and B
129 bool insideBool[1] = {false};
130 _normalInd(insideBool, posIn);
131 if (insideBool[0]) {
132 output[0] = 1.;
133 return true;
134 }
135 }
136 }
137 }
138 }
139 }
140
141 return true;
142}
143
144}
145#endif
Representation of a block geometry.
represents all functors that operate on a DESCRIPTOR in general, e.g. getVelocity(),...
functor that returns 1 if SmoothIndicatorF A intersects IndicatorF B; otherwise, 0
BlockLatticeIndicatorSmoothIndicatorIntersection3D(BlockLattice< T, DESCRIPTOR > &blockLattice, BlockGeometry< T, 3 > &blockGeometry, IndicatorF3D< T > &normalInd, SmoothIndicatorF3D< T, T, HLBM > &smoothInd)
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.
A regular single 3D cuboid is the basic component of a 3D cuboid structure which defines the grid.
Definition cuboid3D.h:58
bool checkInters(T globX0, T globX1, T globY0, T globY1, T globZ0, T globZ1, int overlap=0) const
Checks whether there is an intersection with the cuboid extended with an layer of size overlap*delta.
Definition cuboid3D.hh:409
std::string & getName()
read and write access to name
Definition genericF.hh:51
IndicatorF3D is an application from .
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.
represents all functors that operate on a SuperLattice in general, e.g. getVelocity(),...
SuperLattice< T, DESCRIPTOR > & _sLattice
SuperLatticeIndicatorSmoothIndicatorIntersection3D(SuperLattice< T, DESCRIPTOR > &sLattice, SuperGeometry< T, 3 > &superGeometry, IndicatorF3D< T > &normalInd, SmoothIndicatorF3D< T, T, HLBM > &smoothInd)
Super class maintaining block lattices for a cuboid decomposition.
void reduceAndBcast(T &reductVal, MPI_Op op, int root=0, MPI_Comm comm=MPI_COMM_WORLD)
Reduction operation, followed by a broadcast.
int getRank() const
Returns the process ID.
Wrapper functions that simplify the use of MPI.
MpiManager & mpi()
bool nearZero(const ADf< T, DIM > &a)
Definition aDiff.h:1087
Top level namespace for all of OpenLB.
Representation of a parallel 2D geometry – header file.