OpenLB 1.7
Loading...
Searching...
No Matches
superGeometryFaces2D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2018 Adrian Kummerlaender
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 SUPER_GEOMETRY_FACES_2D_HH
25#define SUPER_GEOMETRY_FACES_2D_HH
26
29
30namespace olb {
31
32
33template<typename T>
35 FunctorPtr<SuperIndicatorF2D<T>>&& indicatorF, T latticeL)
36 : SuperF2D<T>(indicatorF->getSuperStructure(), 5),
37 _indicatorF(std::move(indicatorF))
38{
39 this->getName() = "superGeometryFaces";
40 for (int iC = 0; iC < this->getSuperStructure().getLoadBalancer().size(); ++iC) {
41 this->_blockF.emplace_back(
42 new BlockGeometryFaces2D<T>(indicatorF->getBlockIndicatorF(iC), latticeL));
43 }
44}
45
46template<typename T>
48 SuperGeometry<T,2>& superGeometry, const int material, T latticeL)
49 : SuperGeometryFaces2D(superGeometry.getMaterialIndicator(material), latticeL)
50{ }
51
52template<typename T>
53bool SuperGeometryFaces2D<T>::operator()(T output[], const int input[])
54{
55 this->getSuperStructure().communicate();
56
57 T blockOutput[5] = { };
58 for (int iDim = 0; iDim < this->getTargetDim(); ++iDim) {
59 output[iDim] = T();
60 }
61
62 for (int iC = 0; iC < this->getSuperStructure().getLoadBalancer().size(); ++iC) {
63 this->getBlockF(iC)(blockOutput, input);
64 for (int iDim = 0; iDim < this->getTargetDim(); ++iDim) {
65 output[iDim] += blockOutput[iDim];
66 }
67 }
68
69#ifdef PARALLEL_MODE_MPI
70 for (int iDim = 0; iDim < this->getTargetDim(); ++iDim) {
71 singleton::mpi().reduceAndBcast(output[iDim], MPI_SUM);
72 }
73#endif
74 return true;
75}
76
77template <typename T, bool HLBM>
79 SuperGeometry<T,2>& superGeometry,
81 const int material, T deltaX)
82 : GenericF<T,int>(5,0), _superGeometry(superGeometry), _indicator(indicator),
83 _material(material), _latticeL(deltaX)
84{
85 this->getName() = "superGeometryFacesInd";
86}
87
88template <typename T, bool HLBM>
89bool SuperGeometryFacesIndicator2D<T,HLBM>::operator() (T output[], const int input[])
90{
91 _superGeometry.communicate();
92 for (int iDim = 0; iDim < 5; ++iDim) {
93 output[iDim]=T();
94 }
95 for (int iC = 0; iC < _superGeometry.getLoadBalancer().size(); ++iC) {
96 BlockGeometryFacesIndicator2D<T,HLBM> f(_superGeometry.getBlockGeometry(iC),
97 _indicator, _material, _latticeL);
98 T outputTmp[f.getTargetDim()];
99 f(outputTmp,input);
100 for (int iDim = 0; iDim < 5; ++iDim) {
101 output[iDim] += outputTmp[iDim];
102 }
103 }
104#ifdef PARALLEL_MODE_MPI
105 for (int iDim = 0; iDim < 5; ++iDim) {
106 singleton::mpi().reduceAndBcast( output[iDim], MPI_SUM);
107 }
108#endif
109 return true;
110}
111
112}
113
114#endif
Smart pointer for managing the various ways of passing functors around.
Definition functorPtr.h:60
GenericF is a base class, that can represent continuous as well as discrete functions.
Definition genericF.h:50
int getTargetDim() const
read only access to member variable _n
Definition genericF.hh:45
std::string & getName()
read and write access to name
Definition genericF.hh:51
represents all functors that operate on a SuperStructure<T,2> in general
std::vector< std::unique_ptr< BlockF2D< W > > > _blockF
Super functors may consist of several BlockF2D<W> derived functors.
SuperStructure< T, 2 > & getSuperStructure()
Accumulates the discrete surface of indicated cells facing unit directions and returns the individual...
SuperGeometryFaces2D(FunctorPtr< SuperIndicatorF2D< T > > &&indicatorF, T _latticeL)
Constructor accepting solid cell indicator and custom lattice length.
bool operator()(T output[], const int input[]) override
SuperGeometryFacesIndicator2D(SuperGeometry< T, 2 > &superGeometry, SmoothIndicatorF2D< T, T, HLBM > &indicator, const int material, T deltaX)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
Representation of a statistic for a parallel 2D geometry.
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
void reduceAndBcast(T &reductVal, MPI_Op op, int root=0, MPI_Comm comm=MPI_COMM_WORLD)
Reduction operation, followed by a broadcast.
MpiManager & mpi()
Top level namespace for all of OpenLB.
Representation of a parallel 2D geometry – header file.