summaryrefslogtreecommitdiff
path: root/src/functors/lattice/reductionF2D.hh
blob: c4707e326fcdf4b6fd53dd1fad829da3a16b81d3 (plain)
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
/*  This file is part of the OpenLB library
 *
 *  Copyright (C) 2012 Lukas Baron, Tim Dornieden, Mathias J. Krause,
 *  Albert Mink
 *  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 REDUCTION_F_2D_HH
#define REDUCTION_F_2D_HH

#include "functors/lattice/reductionF2D.h"
#include "core/superLattice2D.h"
#include "dynamics/lbHelpers.h"

namespace olb {


template <typename T, typename DESCRIPTOR>
SuperLatticeFfromAnalyticalF2D<T,DESCRIPTOR>::SuperLatticeFfromAnalyticalF2D(
  FunctorPtr<AnalyticalF2D<T,T>>&& f,
  SuperLattice2D<T, DESCRIPTOR>&   sLattice)
  : SuperLatticeF2D<T, DESCRIPTOR>(sLattice, f->getTargetDim()),
    _f(std::move(f))
{
  this->getName() = "fromAnalyticalF(" + _f->getName() + ")";

  LoadBalancer<T>&     load   = sLattice.getLoadBalancer();
  CuboidGeometry2D<T>& cuboid = sLattice.getCuboidGeometry();

  for (int iC = 0; iC < load.size(); ++iC) {
    this->_blockF.emplace_back(
      new BlockLatticeFfromAnalyticalF2D<T,DESCRIPTOR>(
        *_f,
        sLattice.getExtendedBlockLattice(iC),
        cuboid.get(load.glob(iC)))
    );
  }
}

template <typename T, typename DESCRIPTOR>
bool SuperLatticeFfromAnalyticalF2D<T,DESCRIPTOR>::operator()(T output[], const int input[])
{
  T physR[2] = {};
  this->_sLattice.getCuboidGeometry().getPhysR(physR,input);
  return _f(output,physR);
}


template<typename T, typename DESCRIPTOR>
BlockLatticeFfromAnalyticalF2D<T, DESCRIPTOR>::BlockLatticeFfromAnalyticalF2D(
  AnalyticalF2D<T, T>&                    f,
  BlockLatticeStructure2D<T, DESCRIPTOR>& lattice,
  Cuboid2D<T>&                            cuboid)
  : BlockLatticeF2D<T, DESCRIPTOR>(lattice, f.getTargetDim()),
    _f(f),
    _cuboid(cuboid)
{
  this->getName() = "blockFfromAnalyticalF(" + _f.getName() + ")";
}

template<typename T, typename DESCRIPTOR>
bool BlockLatticeFfromAnalyticalF2D<T, DESCRIPTOR>::operator()(
  T output[], const int input[])
{
  T physR[2] = {};
  _cuboid.getPhysR(physR,input);
  return _f(output,physR);
}


} // end namespace olb

#endif