1 /* 2 * Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de) 3 * 4 * This program 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 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef ENGINE_INTERFACE_BASE_H 19 #define ENGINE_INTERFACE_BASE_H 20 21 #include "tools/global.h" 22 23 class Operator_Base; 24 25 //! This is the abstact base for all Engine Interface classes. 26 /*! 27 This is the abstact base for all Engine Interface classes. It will provide unified access to the field information of the corresponding engine. 28 All processing methods should only access this base class. 29 */ 30 class Engine_Interface_Base 31 { 32 public: 33 enum InterpolationType { NO_INTERPOLATION, NODE_INTERPOLATE, CELL_INTERPOLATE }; 34 ~Engine_Interface_Base()35 virtual ~Engine_Interface_Base() {;} //!< provide a virtual destructor to correctly delete derived objects 36 37 //! Set the operator used for this engine interface. SetOperator(Operator_Base * base_op)38 virtual void SetOperator(Operator_Base* base_op) {m_Op_Base=base_op;} 39 //! Get the operator used for this engine interface. GetOperator()40 virtual const Operator_Base* GetOperator() const {return m_Op_Base;} 41 42 //! Set the current interpolation type \sa GetInterpolationType SetInterpolationType(InterpolationType type)43 void SetInterpolationType(InterpolationType type) {m_InterpolType=type;} 44 //! Set the current interpolation type \sa GetInterpolationType SetInterpolationType(int type)45 void SetInterpolationType(int type) {m_InterpolType=(InterpolationType)type;} 46 //! Get the current interpolation type as string \sa SetInterpolationType GetInterpolationType GetInterpolationNameByType GetInterpolationTypeString()47 std::string GetInterpolationTypeString() {return GetInterpolationNameByType(m_InterpolType);} 48 //! Get the current interpolation type \sa SetInterpolationType GetInterpolationType()49 InterpolationType GetInterpolationType() {return m_InterpolType;} 50 51 //! Get the (interpolated) electric field at \p pos. \sa SetInterpolationType 52 virtual double* GetEField(const unsigned int* pos, double* out) const =0; 53 //! Get the (interpolated) magnetic field at \p pos. \sa SetInterpolationType 54 virtual double* GetHField(const unsigned int* pos, double* out) const =0; 55 //! Get the (interpolated) electric current density field at \p pos. \sa SetInterpolationType 56 virtual double* GetJField(const unsigned int* pos, double* out) const =0; 57 //! Get the total current density field by rot(H) at \p pos. \sa SetInterpolationType 58 virtual double* GetRotHField(const unsigned int* pos, double* out) const =0; 59 //! Get the (interpolated) electric flux density field at \p pos. \sa SetInterpolationType 60 virtual double* GetDField(const unsigned int* pos, double* out) const =0; 61 //! Get the (interpolated) magnetic flux density field at \p pos. \sa SetInterpolationType 62 virtual double* GetBField(const unsigned int* pos, double* out) const =0; 63 64 //! Calculate the electric field integral along a given line 65 virtual double CalcVoltageIntegral(const unsigned int* start, const unsigned int* stop) const =0; 66 67 //! Convert the interpolation type into a string. 68 static std::string GetInterpolationNameByType(InterpolationType mode); 69 70 //! Get the current simulation time 71 virtual double GetTime(bool dualTime=false) const =0; 72 73 //! Get the current number of timesteps 74 virtual unsigned int GetNumberOfTimesteps() const =0; 75 76 //! Calc (roughly) the total energy 77 /*! 78 This method only calculates a very rough estimate of the total energy in the simulation domain. 79 The result may even be roughly proportional to the real system energy only. 80 Primary goal is speed, not accuracy. 81 */ 82 virtual double CalcFastEnergy() const =0; 83 84 protected: 85 Engine_Interface_Base(Operator_Base* base_op); 86 87 Operator_Base* m_Op_Base; 88 89 InterpolationType m_InterpolType; 90 }; 91 92 #endif // ENGINE_INTERFACE_BASE_H 93