| 1 |
/* |
| 2 |
* Advanced Simulation Library <http://asl.org.il> |
| 3 |
* |
| 4 |
* Copyright 2015 Avtech Scientific <http://avtechscientific.com> |
| 5 |
* |
| 6 |
* |
| 7 |
* This file is part of Advanced Simulation Library (ASL). |
| 8 |
* |
| 9 |
* ASL is free software: you can redistribute it and/or modify it |
| 10 |
* under the terms of the GNU Affero General Public License as |
| 11 |
* published by the Free Software Foundation, version 3 of the License. |
| 12 |
* |
| 13 |
* ASL is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Affero General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Affero General Public License |
| 19 |
* along with ASL. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
* |
| 21 |
*/ |
| 22 |
|
| 23 |
|
| 24 |
#ifndef ASLNUMMETHOD_H |
| 25 |
#define ASLNUMMETHOD_H |
| 26 |
|
| 27 |
#include <acl/aclStdIncludes.h> |
| 28 |
#include <memory> |
| 29 |
|
| 30 |
namespace asl |
| 31 |
{ |
| 32 |
/// Virtual class describes general interface for Numerical methods; |
| 33 |
/// \ingroup Numerics |
| 34 |
class NumMethod |
| 35 |
{ |
| 36 |
public: |
| 37 |
/// Executes the numerical procedure |
| 38 |
virtual void execute() = 0; |
| 39 |
/// Builds the necesery internal data and kernels |
| 40 |
virtual void init() = 0; |
| 41 |
virtual ~NumMethod(); |
| 42 |
}; |
| 43 |
|
| 44 |
typedef std::shared_ptr<NumMethod> SPNumMethod; |
| 45 |
|
| 46 |
|
| 47 |
template <class T> inline void initAll(std::vector<T*> &v); |
| 48 |
template <class T> inline void initAll(std::vector<std::shared_ptr<T> > & v); |
| 49 |
|
| 50 |
template <class T> inline void executeAll(std::vector<T*> &v); |
| 51 |
template <class T> inline void executeAll(std::vector<std::shared_ptr<T> > & v); |
| 52 |
|
| 53 |
//---------------------------- Implementation --------------------------- |
| 54 |
|
| 55 |
template <class T> void executeAll(std::vector<T*> &v) |
| 56 |
{ |
| 57 |
for (unsigned int i(0); i < v.size(); ++i) |
| 58 |
v[i]->execute(); |
| 59 |
} |
| 60 |
|
| 61 |
template <class T> void executeAll(std::vector<std::shared_ptr<T> > &v) |
| 62 |
{ |
| 63 |
for (unsigned int i(0); i < v.size(); ++i) |
| 64 |
v[i]->execute(); |
| 65 |
} |
| 66 |
|
| 67 |
template <class T> void initAll(std::vector<T*> &v) |
| 68 |
{ |
| 69 |
for (unsigned int i(0); i < v.size(); ++i) |
| 70 |
v[i]->init(); |
| 71 |
} |
| 72 |
|
| 73 |
template <class T> void initAll(std::vector<std::shared_ptr<T> > &v) |
| 74 |
{ |
| 75 |
for (unsigned int i(0); i < v.size(); ++i) |
| 76 |
v[i]->init(); |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
} //asl |
| 81 |
|
| 82 |
#endif //ASLNUMMETHOD_H |