OpenLB 1.7
Loading...
Searching...
No Matches
superData.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2015 Mathias J. Krause, Benjamin Förster
4 * 2021 Adrian Kummerlaender
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 SUPER_DATA_HH
26#define SUPER_DATA_HH
27
28#include "superData.h"
29
32
35
36namespace olb {
37
38
39template<unsigned D, typename T, typename U>
41 LoadBalancer<T>& loadBalancer,
42 int overlap, int size)
43 : SuperStructure<T,D>(cuboidGeometry, loadBalancer, overlap),
44 _size(size)
45{
46 auto& load = this->getLoadBalancer();
47 for (int iC=0; iC < load.size(); ++iC) {
48 _block.emplace_back(
49 new BlockData<D,T,U>(cuboidGeometry.get(load.glob(iC)), overlap, size));
50 }
51
52 if (overlap >= 1) {
53 _communicator = std::make_unique<SuperCommunicator<T,SuperData>>(*this);
54 _communicator->template requestField<typename BlockData<D,T,U>::DUMMY_FIELD>();
55 _communicator->requestOverlap(overlap);
56 _communicator->exchangeRequests();
57 }
58}
60template<unsigned D, typename T, typename U>
62 : SuperData(rhs.getSuperStructure().getCuboidGeometry(),
63 rhs.getSuperStructure().getLoadBalancer(),
64 rhs.getSuperStructure().getOverlap(),
65 rhs.getTargetDim())
67 auto& load = this->getLoadBalancer();
68
69 int input[D+1];
70 U output[rhs.getTargetDim()];
71
72 for (int iC=0; iC < load.size(); ++iC) {
73 auto& block = getBlock(iC);
74 input[0] = load.glob(iC);
75 block.forCoreSpatialLocations([&](LatticeR<D> latticeR) {
76 for (unsigned iD=0; iD < D; ++iD) {
77 input[1+iD] = latticeR[iD];
78 }
79 rhs(output, input);
80 for (unsigned iD=0; iD < rhs.getTargetDim(); ++iD) {
81 block.get(latticeR,iD) = output[iD];
82 }
83 });
84 }
85}
86
87template<unsigned D, typename T, typename U>
89{
90 return *_block[iC];
91}
92
93template<unsigned D, typename T, typename U>
95{
96 return *_block[iC];
97}
98
99template<unsigned D, typename T, typename U>
100template <typename BLOCK>
102{
103 return *_block[iC];
104}
105
106template<unsigned D, typename T, typename U>
107template <typename BLOCK>
108const BLOCK& SuperData<D,T,U>::getBlock(int iC) const
109{
110 return *_block[iC];
111}
112
113template<unsigned D, typename T, typename U>
115{
116 if (_communicator) {
117 _communicator->communicate();
118 }
119}
120
121template<unsigned D, typename T, typename U>
123{
124 return _size;
125}
126
127template<unsigned D, typename T, typename U>
129{
130 return sizeof(U);
131}
132
133}
134
135#endif
Base class for all LoadBalancer.
const BlockData< D, T, U > & getBlock(int iC) const
Definition superData.hh:88
SuperData(CuboidGeometry< T, D > &cuboidGeometry, LoadBalancer< T > &loadBalancer, int overlap=2, int size=1)
Definition superData.hh:40
void communicate() override
Communicate overlaps.
Definition superData.hh:114
int getDataTypeSize() const
Read only access to the data type dim of the data of the super structure.
Definition superData.hh:128
int getDataSize() const
Read only access to the dim of the data of the super structure.
Definition superData.hh:122
std::unique_ptr< SuperCommunicator< T, SuperData > > _communicator
Inter-block communicator.
Definition superData.h:52
std::vector< std::unique_ptr< BlockData< D, T, U > > > _block
Vector of BlockData.
Definition superData.h:50
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
Plain old scalar vector.
Definition vector.h:47
The description of a vector of 2D cuboid – header file.
The description of a vector of 3D cuboid – header file.
Top level namespace for all of OpenLB.
std::conditional_t< D==2, SuperF2D< T, U >, SuperF3D< T, U > > SuperF
Definition aliases.h:198
std::conditional_t< D==2, CuboidGeometry2D< T >, CuboidGeometry3D< T > > CuboidGeometry
Definition aliases.h:47
Dynamics for a generic 2D super data – header file.