1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
/* This file is part of the OpenLB library
*
* Copyright (C) 2018 Mathias J. Krause, Benedict Hasenauer
* E-mail contact: info@openlb.net
* The most recent release of OpenLB can be downloaded at
* <http://www.openlb.net/>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef SUPER_LATTICE_TIME_AVERAGED_F3_D_HH
#define SUPER_LATTICE_TIME_AVERAGED_F3_D_HH
#include<vector> // for generic i/o
#include<cmath> // for lpnorm
#include<limits>
#include "superLatticeTimeAveraged3D.h"
namespace olb {
template <typename T>
SuperLatticeTimeAveragedF3D<T>:: SuperLatticeTimeAveragedF3D( SuperF3D<T,T>& sFunctor)
: SuperF3D<T,T>(sFunctor.getSuperStructure(),sFunctor.getTargetDim()*2), _ensembles(0), _sFunctor(sFunctor), _sData(_sFunctor.getSuperStructure().getCuboidGeometry(),_sFunctor.getSuperStructure().getLoadBalancer(),_sFunctor.getSuperStructure().getOverlap(),_sFunctor.getTargetDim()), _sDataP2(_sData)
{
this->getName() = "Time Averaged " + _sFunctor.getName();
};
template <typename T>
bool SuperLatticeTimeAveragedF3D<T>::operator() (T output[], const int input[])
{
T iCloc = _sData.getLoadBalancer().loc(input[0]);
for ( int iDim = 0; iDim < _sData.getDataSize(); iDim++) {
output[iDim] = _sData.get(iCloc,input[1],input[2],input[3],iDim) / _ensembles;
}
for (int iDim = _sData.getDataSize(); iDim < _sData.getDataSize()*2; iDim++)
if (_sDataP2.get(iCloc,input[1],input[2],input[3],(int) iDim-_sDataP2.getDataSize())/_ensembles - _sData.get(iCloc,input[1],input[2],input[3],(int) iDim-_sDataP2.getDataSize())*_sData.get(iCloc,input[1],input[2],input[3],(int) iDim-_sDataP2.getDataSize())/_ensembles/_ensembles<0) {
output[iDim]=0;
}
else {
output[iDim] = sqrt(_sDataP2.get(iCloc,input[1],input[2],input[3],(int) iDim-_sDataP2.getDataSize())/_ensembles - _sData.get(iCloc,input[1],input[2],input[3],(int) iDim-_sDataP2.getDataSize())*_sData.get(iCloc,input[1],input[2],input[3],(int) iDim-_sDataP2.getDataSize())/_ensembles/_ensembles);
}
return true;
};
template <typename T>
int SuperLatticeTimeAveragedF3D<T>::getEnsembles()
{
return _ensembles;
};
template <typename T>
void SuperLatticeTimeAveragedF3D<T>::addEnsemble()
{
int i[4];
int iX,iY,iZ;
for (int iCloc=0; iCloc < _sData.getLoadBalancer().size(); ++iCloc) {
i[0] = _sData.getLoadBalancer().glob(iCloc);
for (iX=0; iX < _sData.get(iCloc).getNx(); iX++) {
for (iY=0; iY < _sData.get(iCloc).getNy(); iY++) {
for (iZ=0; iZ < _sData.get(iCloc).getNz(); iZ++) {
i[1] = iX - _sData.getOverlap();
i[2] = iY - _sData.getOverlap();
i[3] = iZ - _sData.getOverlap();
BaseType tmp[_sFunctor.getTargetDim()];
_sFunctor(tmp, i);
for (int iDim=0; iDim<_sFunctor.getTargetDim(); iDim++) {
_sData.get(iCloc).get(iX, iY, iZ, iDim) += (BaseType)(tmp[iDim]) ;
_sDataP2.get(iCloc).get(iX, iY, iZ, iDim) += (BaseType)(tmp[iDim]) *(BaseType)(tmp[iDim]) ;
}
}
}
}
}
_ensembles++;
};
template <typename T>
int SuperLatticeTimeAveragedF3D<T>::getBlockFSize() const
{
return 0;
};
template <typename T>
SuperLatticeTimeAveragedCrossCorrelationF3D<T>::SuperLatticeTimeAveragedCrossCorrelationF3D(SuperF3D<T,T>& sFunctorM,SuperF3D<T,T>& sFunctorN)
: SuperF3D<T,T>(sFunctorM.getSuperStructure(),sFunctorM.getTargetDim()*sFunctorN.getTargetDim()),_sFunctorM(sFunctorM),_sFunctorN(sFunctorN), _ensembles(0), _sDataM(_sFunctorM.getSuperStructure().getCuboidGeometry(),_sFunctorM.getSuperStructure().getLoadBalancer(),_sFunctorM.getSuperStructure().getOverlap(),_sFunctorM.getTargetDim()),_sDataN(_sFunctorN.getSuperStructure().getCuboidGeometry(),_sFunctorN.getSuperStructure().getLoadBalancer(),_sFunctorN.getSuperStructure().getOverlap(),_sFunctorN.getTargetDim()),_sDataMN(_sFunctorM.getSuperStructure().getCuboidGeometry(),_sFunctorM.getSuperStructure().getLoadBalancer(),_sFunctorM.getSuperStructure().getOverlap(),_sFunctorM.getTargetDim()*_sFunctorN.getTargetDim())
{
this->getName() = "Time Averaged Corss Correlation " + _sFunctorM.getName()+"-"+_sFunctorN.getName();
};
template <typename T>
void SuperLatticeTimeAveragedCrossCorrelationF3D<T>::addEnsemble()
{
int i[4];
int iX,iY,iZ;
int iDimMN;
for (int iCloc=0; iCloc < _sDataMN.getLoadBalancer().size(); ++iCloc) {
i[0] = _sDataMN.getLoadBalancer().glob(iCloc);
for (iX=0; iX < _sDataMN.get(iCloc).getNx(); iX++) {
for (iY=0; iY < _sDataMN.get(iCloc).getNy(); iY++) {
for (iZ=0; iZ < _sDataMN.get(iCloc).getNz(); iZ++) {
i[1] = iX - _sDataMN.getOverlap();
i[2] = iY - _sDataMN.getOverlap();
i[3] = iZ - _sDataMN.getOverlap();
BaseType tmpN[_sFunctorN.getTargetDim()];
BaseType tmpM[_sFunctorM.getTargetDim()];
_sFunctorN(tmpN, i);
_sFunctorM(tmpM, i);
iDimMN=0;
for (int iDimM=0; iDimM<_sFunctorM.getTargetDim(); iDimM++) {
for (int iDimN=0; iDimN<_sFunctorN.getTargetDim(); iDimN++) {
_sDataMN.get(iCloc).get(iX, iY, iZ, iDimMN) += (BaseType)(tmpM[iDimM])*(BaseType)(tmpN[iDimN]) ;
iDimMN++;
}
}
for (int iDim=0; iDim<_sFunctorN.getTargetDim(); iDim++) {
_sDataN.get(iCloc).get(iX, iY, iZ, iDim) += (BaseType)(tmpN[iDim]) ;
}
for (int iDim=0; iDim<_sFunctorM.getTargetDim(); iDim++) {
_sDataM.get(iCloc).get(iX, iY, iZ, iDim) += (BaseType)(tmpM[iDim]) ;
}
}
}
}
}
_ensembles++;
};
template <typename T>
bool SuperLatticeTimeAveragedCrossCorrelationF3D<T>::operator() (T output[], const int input[])
{
int iDim =0;
T iCloc = _sDataMN.getLoadBalancer().loc(input[0]);
for (int iDimM=0; iDimM<_sFunctorM.getTargetDim(); iDimM++) {
for (int iDimN=0; iDimN<_sFunctorN.getTargetDim(); iDimN++) {
output[iDim] = _sDataMN.get(iCloc,input[1],input[2],input[3],iDim)-_sDataM.get(iCloc,input[1],input[2],input[3],iDimM) *_sDataN.get(iCloc,input[1],input[2],input[3],iDimN)/_ensembles;
iDim++;
}
}
return true;
};
template <typename T>
SuperLatticeTimeAveraged3DL2Norm<T>::SuperLatticeTimeAveraged3DL2Norm(SuperF3D<T,T>& sFunctorM,SuperF3D<T,T>& sFunctorN,SuperGeometry3D<T>& sGeometry,int material)
: SuperF3D<T,T>(sFunctorM.getSuperStructure(),sFunctorM.getTargetDim()), _sFunctorM(sFunctorM), _sFunctorN(sFunctorN), _sGeometry(sGeometry),_material(material)
{
this->getName() = "SuperLatticeTimeAveraged3DL2Norm";
};
template <typename T>
bool SuperLattice
|