summaryrefslogtreecommitdiff
path: root/src/functors/genericF.h
blob: 2987c0476044690d1f76b972f44f8056a9cc7e25 (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
91
92
/*  This file is part of the OpenLB library
 *
 *  Copyright (C) 2012-2013 Lukas Baron, 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.
*/

/** \file genericF.h
 * The description of a generic interface for all functor classes
 * -- header file.
 */


#ifndef GENERIC_F_H
#define GENERIC_F_H

#include<string>
#include<memory>

namespace olb {

/**
 *  GenericF is a base class, that can represent continuous as well as discrete
 *  functions.
 *  Please take care about the source and target dimensions in the constructor.
 *                F: S^m -> T^n (S=source, T=target)
 *
 *  \param _m     source dimension
 *  \param _n     target dimension
 *  \param _name  is functor name e.g. velocity, pressure
 *  \param _ptrCalcC  stores arithmeticClasses
 */
template <typename T, typename S>
class GenericF {
protected:
  // constructor
  GenericF(int targetDim, int sourceDim);

private:
  std::string _name;
  int _n;
  int _m;
  // private copy constructor
  GenericF(const GenericF&) = delete;
  // copy assignment operator
  GenericF& operator=(const GenericF&) = delete;

public:
  // virtual destructor
  virtual ~GenericF();
  /// memory management, frees resouces (calcClass)
  std::shared_ptr< GenericF<T,S> > _ptrCalcC;
  /// read only access to member variable _m
  int getSourceDim() const;
  /// read only access to member variable _n
  int getTargetDim() const;
  /// read and write access to name
  std::string& getName();
  /// read only access to name
  std::string const& getName() const;
  /// has to be implemented for 'every' derived class
  virtual bool operator() (T output[], const S input[])=0;
  /// wrapper that call the pure virtual operator() (T output[], const S input[]) from above
  // it is aimed that it even calls the implemented pure virtual operator() of derived classes
  // how to use: derived class handles the overloaded operators by including:
  // using GenericF<T,S>::operator();
  bool operator() (T output[]);
  bool operator() (T output[], S input0);
  bool operator() (T output[], S input0, S input1);
  bool operator() (T output[], S input0, S input1, S input2);
  bool operator() (T output[], S input0, S input1, S input2, S input3);
};

} // end namespace olb

#endif