24#ifndef SUPER_STATISTIC_F3D_HH
25#define SUPER_STATISTIC_F3D_HH
33template <
typename T,
typename W>
37 :
SuperF3D<T,W>(f->getSuperStructure(), f->getTargetDim()+1),
39 _indicatorF(std::move(indicatorF)),
40 _expectedValue(expectedValue)
42 this->
getName() =
"Variance("+_f->getName()+
")";
47 if ( _f->getBlockFSize() == load.
size() &&
48 _indicatorF->getBlockFSize() == load.
size() ) {
49 for (
int iC = 0; iC < load.
size(); ++iC) {
52 _indicatorF->getBlockIndicatorF(iC),
60template <
typename T,
typename W>
66 std::forward<decltype(f)>(f),
67 superGeometry.getMaterialIndicator(material),
71template <
typename T,
typename W>
78 std::size_t voxels(0);
80 for (
int i = 0; i <= _f->getTargetDim(); ++i) {
84 if (this->_blockF.empty()) {
85 W outputTmp[_f->getTargetDim()];
86 for(
unsigned i=0; i<_f->getTargetDim(); ++i) {
89 int inputTmp[_f->getSourceDim()];
91 for (
int iC = 0; iC < load.
size(); ++iC) {
93 inputTmp[0] = load.
glob(iC);
94 for (inputTmp[1] = 0; inputTmp[1] < cuboid.
getNx(); ++inputTmp[1]) {
95 for (inputTmp[2] = 0; inputTmp[2] < cuboid.
getNy(); ++inputTmp[2]) {
96 for (inputTmp[3] = 0; inputTmp[3] < cuboid.
getNz(); ++inputTmp[3]) {
97 if (_indicatorF(inputTmp)) {
98 _f(outputTmp,inputTmp);
99 for (
int i = 0; i < _f->getTargetDim(); ++i) {
100 output[i] +=
util::pow(outputTmp[i] - _expectedValue, 2);
107 output[_f->getTargetDim()] += voxels;
111 for (
int iC = 0; iC < load.
size(); ++iC) {
112 this->getBlockF(iC)(output, input);
116#ifdef PARALLEL_MODE_MPI
117 for (
int i = 0; i <= this->getTargetDim(); ++i) {
122 for (
int i = 0; i < _f->getTargetDim(); ++i) {
123 output[i] = output[i] / output[_f->getTargetDim()];
134template <
typename T,
typename W>
138 :
SuperF3D<T,W>(f->getSuperStructure(), f->getTargetDim()+1),
140 _indicatorF(std::move(indicatorF)),
141 _expectedValue(expectedValue)
143 this->
getName() =
"Variance("+_f->getName()+
")";
148 if ( _f->getBlockFSize() == load.
size() &&
149 _indicatorF->getBlockFSize() == load.
size() ) {
150 for (
int iC = 0; iC < load.
size(); ++iC) {
153 _indicatorF->getBlockIndicatorF(iC),
161template <
typename T,
typename W>
167 std::forward<decltype(f)>(f),
168 superGeometry.getMaterialIndicator(material),
172template <
typename T,
typename W>
179 std::size_t voxels(0);
181 for (
int i = 0; i <= _f->getTargetDim(); ++i) {
185 if (this->_blockF.empty()) {
186 W outputTmp[_f->getTargetDim()];
187 for(
int i=0; i<_f->getTargetDim(); ++i) {
190 int inputTmp[_f->getSourceDim()];
192 for (
int iC = 0; iC < load.
size(); ++iC) {
194 inputTmp[0] = load.
glob(iC);
195 for (inputTmp[1] = 0; inputTmp[1] < cuboid.
getNx(); ++inputTmp[1]) {
196 for (inputTmp[2] = 0; inputTmp[2] < cuboid.
getNy(); ++inputTmp[2]) {
197 for (inputTmp[3] = 0; inputTmp[3] < cuboid.
getNz(); ++inputTmp[3]) {
198 if (_indicatorF(inputTmp)) {
199 _f(outputTmp,inputTmp);
200 for (
int i = 0; i < _f->getTargetDim(); ++i) {
201 output[i] +=
util::pow(outputTmp[i] - _expectedValue, 2);
208 output[_f->getTargetDim()] += voxels;
212 for (
int iC = 0; iC < load.
size(); ++iC) {
213 this->getBlockF(iC)(output, input);
217#ifdef PARALLEL_MODE_MPI
218 for (
int i = 0; i <= this->getTargetDim(); ++i) {
223 for (
int i = 0; i < _f->getTargetDim(); ++i) {
224 output[i] =
util::sqrt(output[i] / output[_f->getTargetDim()]);
BlockStdDeviationF3D returns the Deviation in each component of f on a indicated subset calcutalted w...
BlockVarianceF3D returns the Variance in each component of f on a indicated subset calcutalted with S...
A regular single 3D cuboid is the basic component of a 3D cuboid structure which defines the grid.
int getNz() const
Read access to cuboid depth.
int getNy() const
Read access to cuboid height.
int getNx() const
Read access to cuboid width.
A cuboid geometry represents a voxel mesh.
Cuboid3D< T > & get(int iC)
Read and write access to a single cuboid.
Smart pointer for managing the various ways of passing functors around.
std::string & getName()
read and write access to name
Base class for all LoadBalancer.
represents all functors that operate on a SuperStructure<T,3> in general
SuperStructure< T, 3 > & getSuperStructure()
std::vector< std::unique_ptr< BlockF3D< W > > > _blockF
Super functors may consist of several BlockF3D<W> derived functors.
Representation of a statistic for a parallel 2D geometry.
Base indicator functor (discrete)
SuperStdDeviaitonF3D returns the standard deviation in each component of f on a indicated subset calc...
SuperStdDeviationF3D(FunctorPtr< SuperF3D< T, W > > &&f, SuperGeometry< T, 3 > &superGeometry, const int material, T expectedValue)
Constructor for determining the standard deviation of f on a indicated subset.
bool operator()(W output[], const int input[]) override
virtual void communicate()
SuperVarianceF3D returns the Variance in each component of f on a indicated subset calcutalted with S...
bool operator()(W output[], const int input[]) override
Global average operator.
SuperVarianceF3D(FunctorPtr< SuperF3D< T, W > > &&f, SuperGeometry< T, 3 > &superGeometry, const int material, T expectedValue)
Constructor for determining the standard deviation of f on a indicated subset.
void reduceAndBcast(T &reductVal, MPI_Op op, int root=0, MPI_Comm comm=MPI_COMM_WORLD)
Reduction operation, followed by a broadcast.
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
Top level namespace for all of OpenLB.