OpenLB 1.7
Loading...
Searching...
No Matches
latticeIndicatorSmoothIndicatorIntersection2D.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_INDICATOR_SMOOTH_INDICATOR_INTERSECTION_2D_HH
25#define LATTICE_INDICATOR_SMOOTH_INDICATOR_INTERSECTION_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
41
42namespace olb {
43
44template <typename T, typename DESCRIPTOR, bool HLBM>
47 SuperGeometry<T,2>& superGeometry,
48 IndicatorF2D<T>& normalInd, SmoothIndicatorF2D<T,T,HLBM>& smoothInd )
49 : SuperLatticeF2D<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 BlockLatticeIndicatorSmoothIndicatorIntersection2D<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,2>& blockGeometry,
81 IndicatorF2D<T>& normalInd, SmoothIndicatorF2D<T,T,HLBM>& smoothInd )
82 : BlockLatticeF2D<T, DESCRIPTOR>(blockLattice, 1),
83 _blockGeometry(blockGeometry), _normalInd(normalInd), _smoothInd(smoothInd)
84{
85 this->getName() = "Indicator-SmoothIndicator Intersection";
86}
87
88template<typename T, typename DESCRIPTOR, bool HLBM>
90{
91 output[0] = 0.;
92 int start[2] = {0};
93 int end[2] = {0};
94 // check for intersection of cuboid and smoothIndicator
95 Cuboid2D<T> tmpCuboid(_blockGeometry.getOrigin()[0], _blockGeometry.getOrigin()[1], _blockGeometry.getDeltaR(), _blockGeometry.getNx(), _blockGeometry.getNy());
96 T posXmin = _smoothInd.getPos()[0] - _smoothInd.getCircumRadius();
97 T posXmax = _smoothInd.getPos()[0] + _smoothInd.getCircumRadius();
98 T posYmin = _smoothInd.getPos()[1] - _smoothInd.getCircumRadius();
99 T posYmax = _smoothInd.getPos()[1] + _smoothInd.getCircumRadius();
100 if (tmpCuboid.checkInters(posXmin, posXmax, posYmin, posYmax, start[0], end[0], start[1], end[1])) {
101
102 for (int k=0; k<2; k++) {
103 start[k] -= 1;
104 if (start[k] < 0) {
105 start[k] = 0;
106 }
107 end[k] += 2;
108 if (end[k] > _blockGeometry.getExtent()[k]) {
109 end[k] = _blockGeometry.getExtent()[k];
110 }
111 }
112
113 // iterate over cells in the constructed intersection box
114 for (int iX = start[0]; iX < end[0]; iX++) {
115 for (int iY = start[1]; iY < end[1]; iY++) {
116
117 // check if cell belongs to particle
118 T insideT[1] = {0.};
119 T posIn[2] = {0.};
120 _blockGeometry.getPhysR(posIn, {iX, iY});
121 _smoothInd( insideT, posIn);
122 if ( !util::nearZero(insideT[0]) && this->_blockGeometry.get({iX,iY})==1) {
123 // Return 1 if at least one cell is found to be inside both A and B
124 bool insideBool[1] = {false};
125 _normalInd(insideBool, posIn);
126 if (insideBool[0]) {
127 output[0] = 1.;
128 return true;
129 }
130 }
131 }
132 }
133 }
134
135 return true;
136}
137
138}
139#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
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockLatticeIndicatorSmoothIndicatorIntersection2D(BlockLattice< T, DESCRIPTOR > &blockLattice, BlockGeometry< T, 2 > &blockGeometry, IndicatorF2D< T > &normalInd, SmoothIndicatorF2D< T, T, HLBM > &smoothInd)
Platform-abstracted block lattice for external access and inter-block interaction.
A regular single 2D cuboid is the basic component of a 2D cuboid structure which defines the grid.
Definition cuboid2D.h:54
bool checkInters(T globX0, T globX1, T globY0, T globY1, int overlap=0) const
Checks whether there is an intersection with the cuboid extended with an layer of size overlap*delta.
Definition cuboid2D.hh:241
std::string & getName()
read and write access to name
Definition genericF.hh:51
IndicatorF2D is an application from .
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.
represents all functors that operate on a SuperLattice in general, e.g. getVelocity(),...
SuperLattice< T, DESCRIPTOR > & _sLattice
SuperLatticeIndicatorSmoothIndicatorIntersection2D(SuperLattice< T, DESCRIPTOR > &sLattice, SuperGeometry< T, 2 > &superGeometry, IndicatorF2D< T > &normalInd, SmoothIndicatorF2D< 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.
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.
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.