/* * Advanced Simulation Library * * Copyright 2015 Avtech Scientific * * * This file is part of Advanced Simulation Library (ASL). * * ASL is free software: you can redistribute it and/or modify it * under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, version 3 of the License. * * ASL 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with ASL. If not, see . * */ #ifndef ASLPROBE_H #define ASLPROBE_H #include #include #include #include using namespace std; namespace acl { class VectorOfElementsData; typedef std::shared_ptr SPVectorOfElementsData; } namespace asl { class AbstractData; typedef std::shared_ptr SPAbstractData; /// Collects point values from the input data /** /// \ingroup DataAnalysis The class takes in */ class Probe { protected: SPAbstractData data; acl::Kernel k; std::vector indices; acl::SPVectorOfElementsData indicesACL; vector> values; acl::SPVectorOfElementsData valuesACL; void loadIndicesToACL(); void loadValuesFromACL(); public: Probe(SPAbstractData d); void addPoint(AVec p); /// initialization of internal kernels and data void init(); /// Updates data in output void update(); const unsigned int getNComponents() const; const unsigned int getNDimensions() const; inline vector & getComponent(unsigned int i); inline AVec getValue(unsigned int pointNumber); }; /// Collects point values from the input data with linear interpolation /** /// \ingroup DataAnalysis */ class ProbeLI { protected: SPAbstractData data; acl::Kernel k; std::vector> points; acl::SPVectorOfElementsData pointsACL; vector> values; acl::SPVectorOfElementsData valuesACL; void loadPointsToACL(); void loadValuesFromACL(); public: ProbeLI(SPAbstractData d); void addPoint(AVec<> p); /// initialization of internal kernels and data void init(); /// Updates data in output void update(); const unsigned int getNComponents() const; const unsigned int getNDimensions() const; inline vector & getComponent(unsigned int i); inline AVec getValue(unsigned int pointNumber); }; // -------------------------- Implementation ------------------------------ inline vector & Probe::getComponent(unsigned int i) { return values[i]; } inline AVec Probe::getValue(unsigned int pointNumber) { unsigned int nC(getNComponents()); AVec value(nC); for (unsigned int i(0); i < nC; ++i) value[i] = values[i][pointNumber]; return value; } inline vector & ProbeLI::getComponent(unsigned int i) { return values[i]; } inline AVec ProbeLI::getValue(unsigned int pointNumber) { unsigned int nC(getNComponents()); AVec value(nC); for (unsigned int i(0); i < nC; ++i) value[i] = values[i][pointNumber]; return value; } } #endif