| 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 ASLPROBE_H |
| 25 |
#define ASLPROBE_H |
| 26 |
|
| 27 |
#include <acl/Kernels/aclKernel.h> |
| 28 |
#include <math/aslVectors.h> |
| 29 |
#include <iostream> |
| 30 |
#include <fstream> |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
using namespace std; |
| 35 |
|
| 36 |
namespace acl |
| 37 |
{ |
| 38 |
class VectorOfElementsData; |
| 39 |
typedef std::shared_ptr<VectorOfElementsData> SPVectorOfElementsData; |
| 40 |
|
| 41 |
} |
| 42 |
namespace asl |
| 43 |
{ |
| 44 |
|
| 45 |
class AbstractData; |
| 46 |
typedef std::shared_ptr<AbstractData> SPAbstractData; |
| 47 |
|
| 48 |
/// Collects point values from the input data |
| 49 |
/** |
| 50 |
/// \ingroup DataAnalysis |
| 51 |
The class takes in |
| 52 |
*/ |
| 53 |
class Probe |
| 54 |
{ |
| 55 |
protected: |
| 56 |
SPAbstractData data; |
| 57 |
acl::Kernel k; |
| 58 |
|
| 59 |
std::vector<int> indices; |
| 60 |
acl::SPVectorOfElementsData indicesACL; |
| 61 |
|
| 62 |
vector<vector<double>> values; |
| 63 |
acl::SPVectorOfElementsData valuesACL; |
| 64 |
|
| 65 |
void loadIndicesToACL(); |
| 66 |
void loadValuesFromACL(); |
| 67 |
|
| 68 |
public: |
| 69 |
Probe(SPAbstractData d); |
| 70 |
void addPoint(AVec<int> p); |
| 71 |
/// initialization of internal kernels and data |
| 72 |
void init(); |
| 73 |
/// Updates data in output |
| 74 |
void update(); |
| 75 |
const unsigned int getNComponents() const; |
| 76 |
const unsigned int getNDimensions() const; |
| 77 |
inline vector<double> & getComponent(unsigned int i); |
| 78 |
inline AVec<double> getValue(unsigned int pointNumber); |
| 79 |
}; |
| 80 |
|
| 81 |
/// Collects point values from the input data with linear interpolation |
| 82 |
/** |
| 83 |
/// \ingroup DataAnalysis |
| 84 |
*/ |
| 85 |
class ProbeLI |
| 86 |
{ |
| 87 |
protected: |
| 88 |
SPAbstractData data; |
| 89 |
acl::Kernel k; |
| 90 |
|
| 91 |
std::vector<AVec<>> points; |
| 92 |
acl::SPVectorOfElementsData pointsACL; |
| 93 |
|
| 94 |
vector<vector<double>> values; |
| 95 |
acl::SPVectorOfElementsData valuesACL; |
| 96 |
|
| 97 |
void loadPointsToACL(); |
| 98 |
void loadValuesFromACL(); |
| 99 |
|
| 100 |
public: |
| 101 |
ProbeLI(SPAbstractData d); |
| 102 |
void addPoint(AVec<> p); |
| 103 |
/// initialization of internal kernels and data |
| 104 |
void init(); |
| 105 |
/// Updates data in output |
| 106 |
void update(); |
| 107 |
const unsigned int getNComponents() const; |
| 108 |
const unsigned int getNDimensions() const; |
| 109 |
inline vector<double> & getComponent(unsigned int i); |
| 110 |
inline AVec<double> getValue(unsigned int pointNumber); |
| 111 |
}; |
| 112 |
|
| 113 |
|
| 114 |
// -------------------------- Implementation ------------------------------ |
| 115 |
|
| 116 |
inline vector<double> & Probe::getComponent(unsigned int i) |
| 117 |
{ |
| 118 |
return values[i]; |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
inline AVec<double> Probe::getValue(unsigned int pointNumber) |
| 123 |
{ |
| 124 |
unsigned int nC(getNComponents()); |
| 125 |
AVec<double> value(nC); |
| 126 |
for (unsigned int i(0); i < nC; ++i) |
| 127 |
value[i] = values[i][pointNumber]; |
| 128 |
|
| 129 |
return value; |
| 130 |
} |
| 131 |
|
| 132 |
inline vector<double> & ProbeLI::getComponent(unsigned int i) |
| 133 |
{ |
| 134 |
return values[i]; |
| 135 |
} |
| 136 |
|
| 137 |
|
| 138 |
inline AVec<double> ProbeLI::getValue(unsigned int pointNumber) |
| 139 |
{ |
| 140 |
unsigned int nC(getNComponents()); |
| 141 |
AVec<double> value(nC); |
| 142 |
for (unsigned int i(0); i < nC; ++i) |
| 143 |
value[i] = values[i][pointNumber]; |
| 144 |
|
| 145 |
return value; |
| 146 |
} |
| 147 |
|
| 148 |
} |
| 149 |
|
| 150 |
#endif |
| 151 |
|