CEPS  24.01
Cardiac ElectroPhysiology Simulator
SAFunc.hpp
Go to the documentation of this file.
1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2  This file is part of CEPS.
3 
4  CEPS is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  CEPS is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with CEPS (see file LICENSE at root of project).
16  If not, see <https://www.gnu.org/licenses/>.
17 
18 
19  Copyright 2019-2024 Inria, Universite de Bordeaux
20 
21  Authors, in alphabetical order:
22 
23  Pierre-Elliott BECUE, Florian CARO, Yves COUDIERE(*), Andjela DAVIDOVIC,
24  Charlie DOUANLA-LONTSI, Marc FUENTES, Mehdi JUHOOR, Michael LEGUEBE(*),
25  Pauline MIGERDITICHAN, Valentin PANNETIER(*), Nejib ZEMZEMI.
26  * : currently active authors
27 
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
30 #pragma once
37 
38 // namespace ceps
39 // {
40 // /// @brief Extractor from CepsStandardArgs
41 // template <CepsFunctionFlag _Flag>
42 // auto get (CepsStandardArgs);
43 
44 // /// @brief Extract t from CepsStandardArgs
45 // template <>
46 // auto
47 // get<CepsFunctionFlag::Time> (CepsStandardArgs args);
48 
49 // /// @brief Extract x from CepsStandardArgs
50 // template <>
51 // auto
52 // get<CepsFunctionFlag::Space> (CepsStandardArgs args);
53 
54 // /// @brief Extract u from CepsStandardArgs
55 // template <>
56 // auto
57 // get<CepsFunctionFlag::Solution> (CepsStandardArgs args);
58 
59 // /// @brief Extract attributes from CepsStandardArgs
60 // template <>
61 // auto
62 // get<CepsFunctionFlag::Attribute> (CepsStandardArgs args);
63 
64 // /// @brief Extract dofId from CepsStandardArgs
65 // template <>
66 // auto
67 // get<CepsFunctionFlag::DofIndex> (CepsStandardArgs args);
68 
69 // /// @brief Extract cellId from CepsStandardArgs
70 // template <>
71 // auto
72 // get<CepsFunctionFlag::CellIndex> (CepsStandardArgs args);
73 
74 // /// @brief Extract nodeId from CepsStandardArgs
75 // template <>
76 // auto
77 // get<CepsFunctionFlag::NodeIndex> (CepsStandardArgs args);
78 
79 // /// @brief Extract uId from CepsStandardArgs
80 // template <>
81 // auto
82 // get<CepsFunctionFlag::UnknownIndex> (CepsStandardArgs args);
83 
84 // /// @brief Get the returned type from CepsStandardArgs deduced from the templated flag
85 // template <CepsFunctionFlag _Flag>
86 // using DeducedTypeFromFlag = decltype (ceps::get<_Flag> ({}));
87 
88 // } // namespace ceps
89 
98 template <typename _Result>
99 class SAFunc : public ceps::Function<_Result(CepsStandardArgs)>
100 {
101 
102  public:
105  using BaseFunction::BaseFunction;
106  using BaseFunction::operator=;
107 
109  SAFunc(const SAFunc&) = default;
110 
112  SAFunc&
113  operator=(const SAFunc&) = default;
114 
116  CepsEnum
117  virtual getFlags() const = 0;
118 
120  void
121  virtual getLocalData();
122 
124  void
125  virtual releaseLocalData();
126 
128  CepsBool
130 
131 };
132 
139 
140 namespace ceps
141 {
143  template <typename _Fn>
144  CepsEnum
145  getFlagsOf(_Fn f);
146 
148  // template <typename _Fn>
149  // CepsEnum
150  // getFlagsOf(_Fn* f);
151  template <typename _Result>
152  CepsEnum
154 
155 }
156 
157 // =================================================================================================
158 
159 
161 template<char _Op, typename _Res1,typename _Res2>
162 class OperatorSAFunc: public SAFunc<ceps::ResultOfOperation<_Op, _Res1, _Res2>>
163 {
164 
165  public:
166 
173 
175  OperatorSAFunc(Fn1* fn1, Fn2* fn2);
176 
178  ~OperatorSAFunc() override;
179 
182  operator=(const OperatorSAFunc&) = default;
183 
185  CepsEnum
186  getFlags() const override;
187 
189  void
190  getLocalData() override;
191 
193  void
194  releaseLocalData() override;
195 
197  Result
199 
201  void
203 
204 
205  protected:
206 
211 
212 };
213 
215 template<typename _Res1,typename _Res2>
218 
220 template<typename _Res1,typename _Res2>
221 OperatorSAFunc<'-',_Res1,_Res2>*
223 
225 template<typename _Res1,typename _Res2>
228 
230 template<typename _Res1,typename _Res2>
231 OperatorSAFunc<'/',_Res1,_Res2>*
233 
234 // Template definitions
CepsFunctionFlag
Enum for CepsStandardArgs functions.
Definition: CepsEnums.hpp:137
int CepsEnum
Enum type.
Definition: CepsTypes.hpp:216
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
OperatorSAFunc<'-', _Res1, _Res2 > * newDiffSAFunc(SAFunc< _Res1 > *, SAFunc< _Res2 > *)
Get a new substraction object without having to look after return types of fn1 and fn2.
OperatorSAFunc<'+', _Res1, _Res2 > * newSumSAFunc(SAFunc< _Res1 > *, SAFunc< _Res2 > *)
Get a new addition object without having to look after return types of fn1 and fn2.
OperatorSAFunc<'/', _Res1, _Res2 > * newDivSAFunc(SAFunc< _Res1 > *, SAFunc< _Res2 > *)
Get a new division object without having to look after return types of fn1 and fn2.
OperatorSAFunc<' *', _Res1, _Res2 > * newProductSAFunc(SAFunc< _Res1 > *, SAFunc< _Res2 > *)
Get a new product object without having to look after return types of fn1 and fn2.
Operation on two SA Funcs.
Definition: SAFunc.hpp:163
Result eval(CepsStandardArgs) override
Returns the operation on evals of fn1, fn2.
OperatorSAFunc & operator=(const OperatorSAFunc &)=default
We allow the assignement from a functor to another.
CepsBool m_ownedFn1
Fn1 will be deleted with product.
Definition: SAFunc.hpp:209
ceps::ResultOfOperation< _Op, _Res1, _Res2 > Result
Type of result.
Definition: SAFunc.hpp:172
CepsBool m_ownedFn2
Fn2 will be deleted with product.
Definition: SAFunc.hpp:210
void setOwned(CepsBool o1, CepsBool o2)
Tells if operands will be deleted by product function (false by default)
OperatorSAFunc(Fn1 *fn1, Fn2 *fn2)
Constructor.
~OperatorSAFunc() override
Destructor.
CepsEnum getFlags() const override
Could be none, but better make it pure virtual.
void releaseLocalData() override
Authorize access to data for solvecSAFunc, other derived classes : nothing.
Fn2 * m_fn2
right operand
Definition: SAFunc.hpp:208
void getLocalData() override
Authorize access to data for solvecSAFunc, other derived classes : nothing.
Fn1 * m_fn1
left operand
Definition: SAFunc.hpp:207
A SAFunc is a ceps::Function that uses CepsStandardArgs as argument of call operator (),...
Definition: SAFunc.hpp:100
SAFunc & operator=(const SAFunc &)=default
We allow the assignement from a functor to another.
virtual void releaseLocalData()
Authorize access to data for solvecSAFunc, other derived classes : nothing.
virtual CepsEnum getFlags() const =0
Could be none, but better make it pure virtual.
CepsBool hasOption(CepsFunctionFlag flag)
Tells if option is activated.
SAFunc(const SAFunc &)=default
We allow the copy from a functor to another.
virtual void getLocalData()
Authorize access to data for solvecSAFunc, other derived classes : nothing.
A namespace for all utility methods.
typename ResultOfOperationStruct< _Op, _T1, _T2 >::type ResultOfOperation
Shortcut for type of result of operation.
CepsEnum getFlagsOf(ArraySAFunc< _Result > *f)
get functor options
Structure used to pass arguments to SAFunc (see pde directory) The flags of the SAFunc allows extract...
Definition: CepsTypes.hpp:239
function caller : abstract base, only contains an variadic operator()