2010-03-11 23:47:40 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2010-03-01 16:19:39 +08:00
|
|
|
#ifndef OPERATOR_H
|
|
|
|
#define OPERATOR_H
|
|
|
|
|
|
|
|
#include "ContinuousStructure.h"
|
|
|
|
#include "tools/AdrOp.h"
|
|
|
|
#include "tools/constants.h"
|
2010-05-04 00:33:14 +08:00
|
|
|
#include "excitation.h"
|
2010-03-01 16:19:39 +08:00
|
|
|
|
2010-04-26 03:59:05 +08:00
|
|
|
class Operator_Extension;
|
2010-05-09 00:12:44 +08:00
|
|
|
class Engine;
|
2010-04-26 03:59:05 +08:00
|
|
|
|
2010-03-01 16:19:39 +08:00
|
|
|
//! Abstract base-class for the FDTD-operator
|
|
|
|
class Operator
|
|
|
|
{
|
2010-05-07 04:55:59 +08:00
|
|
|
friend class Engine;
|
2010-07-06 16:01:26 +08:00
|
|
|
friend class Operator_Ext_LorentzMaterial; //we need to find a way around this... friend class Operator_Extension only would be nice
|
2010-03-01 16:19:39 +08:00
|
|
|
public:
|
2010-04-09 21:51:37 +08:00
|
|
|
//! Create a new operator
|
|
|
|
static Operator* New();
|
2010-03-01 16:19:39 +08:00
|
|
|
virtual ~Operator();
|
|
|
|
|
2010-05-10 02:27:17 +08:00
|
|
|
virtual Engine* CreateEngine() const;
|
2010-05-09 00:12:44 +08:00
|
|
|
|
2010-03-11 17:48:47 +08:00
|
|
|
virtual bool SetGeometryCSX(ContinuousStructure* geo);
|
2010-04-29 03:45:05 +08:00
|
|
|
virtual ContinuousStructure* GetGeometryCSX() {return CSX;}
|
2010-03-01 16:19:39 +08:00
|
|
|
|
2010-03-05 21:20:25 +08:00
|
|
|
virtual int CalcECOperator();
|
2010-03-01 16:19:39 +08:00
|
|
|
|
2010-05-01 01:40:08 +08:00
|
|
|
inline virtual FDTD_FLOAT& GetVV( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return vv[n][x][y][z]; }
|
|
|
|
inline virtual FDTD_FLOAT& GetVI( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return vi[n][x][y][z]; }
|
|
|
|
|
|
|
|
inline virtual FDTD_FLOAT& GetII( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return ii[n][x][y][z]; }
|
|
|
|
inline virtual FDTD_FLOAT& GetIV( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return iv[n][x][y][z]; }
|
|
|
|
|
2010-04-29 04:01:03 +08:00
|
|
|
virtual void SetBoundaryCondition(int* BCs) {for (int n=0;n<6;++n) m_BC[n]=BCs[n];}
|
2010-03-05 21:20:25 +08:00
|
|
|
virtual void ApplyElectricBC(bool* dirs); //applied by default to all boundaries
|
|
|
|
virtual void ApplyMagneticBC(bool* dirs);
|
2010-03-01 16:19:39 +08:00
|
|
|
|
2010-03-31 22:35:43 +08:00
|
|
|
double GetTimestep() const {return dT;};
|
|
|
|
double GetNumberCells() const;
|
2010-03-01 21:56:27 +08:00
|
|
|
|
2010-05-10 02:27:17 +08:00
|
|
|
//! Returns the number of lines as needed for post-processing etc. (for the engine, use GetOriginalNumLines)
|
2010-04-12 05:42:54 +08:00
|
|
|
virtual unsigned int GetNumberOfLines(int ny) const {return numLines[ny];}
|
2010-05-10 02:27:17 +08:00
|
|
|
//! Returns the number of lines as needed for the engine etc. (for post-processing etc, use GetOriginalNumLines)
|
|
|
|
virtual unsigned int GetOriginalNumLines(int ny) const {return numLines[ny];}
|
2010-04-12 05:42:54 +08:00
|
|
|
|
2010-05-19 17:42:56 +08:00
|
|
|
virtual void ShowStat() const;
|
2010-07-12 05:45:41 +08:00
|
|
|
virtual void ShowExtStat() const;
|
2010-03-01 16:19:39 +08:00
|
|
|
|
2010-05-29 18:47:07 +08:00
|
|
|
virtual void DumpOperator2File(string filename);
|
|
|
|
virtual void DumpMaterial2File(string filename);
|
2010-06-02 22:37:21 +08:00
|
|
|
virtual void DumpPEC2File( string filename );
|
2010-03-02 02:35:28 +08:00
|
|
|
|
2010-04-23 14:17:42 +08:00
|
|
|
//! Get the name for the given direction: 0 -> x, 1 -> y, 2 -> z
|
|
|
|
virtual string GetDirName(int ny) const;
|
|
|
|
|
2010-04-14 00:40:43 +08:00
|
|
|
virtual double GetGridDelta() const {return gridDelta;}
|
|
|
|
//! Get the mesh delta times the grid delta for a 3D position
|
2010-04-19 22:08:32 +08:00
|
|
|
virtual double GetMeshDelta(int n, const int* pos, bool dualMesh=false) const;
|
|
|
|
virtual double GetMeshDelta(int n, const unsigned int* pos, bool dualMesh=false) const;
|
2010-03-01 16:19:39 +08:00
|
|
|
|
2010-04-14 00:40:43 +08:00
|
|
|
//! Get the disc line in n direction
|
|
|
|
virtual double GetDiscLine(int n, int pos, bool dualMesh=false) const;
|
|
|
|
virtual double GetDiscLine(int n, unsigned int pos, bool dualMesh=false) const;
|
|
|
|
virtual bool SnapToMesh(double* coord, unsigned int* uicoord, bool lower=false, bool* inside=NULL);
|
2010-03-02 02:35:28 +08:00
|
|
|
|
2010-04-26 03:59:05 +08:00
|
|
|
virtual void AddExtension(Operator_Extension* op_ext);
|
2010-04-28 05:06:42 +08:00
|
|
|
virtual size_t GetNumberOfExtentions() const {return m_Op_exts.size();}
|
|
|
|
virtual Operator_Extension* GetExtension(size_t index) const {return m_Op_exts.at(index);}
|
2010-04-26 03:59:05 +08:00
|
|
|
|
2010-03-01 16:19:39 +08:00
|
|
|
protected:
|
2010-04-09 21:51:37 +08:00
|
|
|
//! use New() for creating a new Operator
|
|
|
|
Operator();
|
|
|
|
|
2010-03-01 16:19:39 +08:00
|
|
|
virtual void Init();
|
2010-04-14 00:40:43 +08:00
|
|
|
virtual void Reset();
|
2010-03-05 21:20:25 +08:00
|
|
|
virtual void InitOperator();
|
2010-05-04 00:33:14 +08:00
|
|
|
virtual void InitExcitation();
|
2010-03-05 21:20:25 +08:00
|
|
|
|
2010-03-26 18:28:54 +08:00
|
|
|
struct Grid_Path
|
2010-03-22 15:19:17 +08:00
|
|
|
{
|
|
|
|
vector<unsigned int> posPath[3];
|
|
|
|
vector<unsigned short> dir;
|
|
|
|
};
|
|
|
|
struct Grid_Path FindPath(double start[], double stop[]);
|
|
|
|
|
2010-03-01 16:19:39 +08:00
|
|
|
ContinuousStructure* CSX;
|
2010-03-05 21:20:25 +08:00
|
|
|
|
2010-04-29 04:01:03 +08:00
|
|
|
int m_BC[6];
|
|
|
|
|
2010-04-29 04:42:55 +08:00
|
|
|
//! Calculate the field excitations.
|
|
|
|
virtual bool CalcFieldExcitation();
|
2010-03-01 16:19:39 +08:00
|
|
|
|
2010-06-06 07:47:32 +08:00
|
|
|
unsigned int m_Nr_PEC[3]; //count PEC edges
|
2010-03-05 21:20:25 +08:00
|
|
|
virtual bool CalcPEC();
|
2010-06-06 07:47:32 +08:00
|
|
|
virtual void CalcPEC_Range(unsigned int startX, unsigned int stopX, unsigned int* counter); //internal to CalcPEC
|
2010-06-06 06:53:05 +08:00
|
|
|
virtual void CalcPEC_Curves(); //internal to CalcPEC
|
2010-03-05 21:20:25 +08:00
|
|
|
|
2010-03-01 16:19:39 +08:00
|
|
|
//Calc timestep only internal use
|
2010-03-05 21:20:25 +08:00
|
|
|
virtual double CalcTimestep();
|
2010-03-01 16:19:39 +08:00
|
|
|
double dT; //FDTD timestep!
|
2010-03-05 21:20:25 +08:00
|
|
|
|
2010-06-22 18:49:51 +08:00
|
|
|
double CalcTimestep_Var1();
|
|
|
|
double CalcTimestep_Var3();
|
|
|
|
|
2010-04-09 21:51:37 +08:00
|
|
|
//! Calc operator at certain pos
|
2010-04-21 21:43:39 +08:00
|
|
|
virtual void Calc_ECOperatorPos(int n, unsigned int* pos);
|
2010-04-09 21:51:37 +08:00
|
|
|
|
2010-03-05 21:20:25 +08:00
|
|
|
//EC elements, internal only!
|
2010-06-05 17:47:21 +08:00
|
|
|
virtual void Init_EC();
|
2010-04-09 21:51:37 +08:00
|
|
|
virtual bool Calc_EC();
|
|
|
|
virtual bool Calc_ECPos(int n, unsigned int* pos, double* inEC);
|
|
|
|
virtual bool Calc_EffMatPos(int n, unsigned int* pos, double* inMat);
|
2010-03-05 21:20:25 +08:00
|
|
|
double* EC_C[3];
|
|
|
|
double* EC_G[3];
|
|
|
|
double* EC_L[3];
|
|
|
|
double* EC_R[3];
|
2010-03-26 18:28:54 +08:00
|
|
|
|
2010-06-02 23:21:58 +08:00
|
|
|
int m_MeshType;
|
2010-03-26 18:28:54 +08:00
|
|
|
unsigned int numLines[3];
|
2010-04-02 23:07:56 +08:00
|
|
|
double* discLines[3];
|
|
|
|
double gridDelta;
|
|
|
|
AdrOp* MainOp;
|
|
|
|
AdrOp* DualOp;
|
2010-03-26 18:28:54 +08:00
|
|
|
|
2010-04-26 03:59:05 +08:00
|
|
|
vector<Operator_Extension*> m_Op_exts;
|
|
|
|
|
2010-04-14 00:40:43 +08:00
|
|
|
// engine/post-proc needs access
|
|
|
|
public:
|
2010-03-26 18:28:54 +08:00
|
|
|
//EC operator
|
|
|
|
FDTD_FLOAT**** vv; //calc new voltage from old voltage
|
|
|
|
FDTD_FLOAT**** vi; //calc new voltage from old current
|
|
|
|
FDTD_FLOAT**** ii; //calc new current from old current
|
|
|
|
FDTD_FLOAT**** iv; //calc new current from old voltage
|
|
|
|
|
2010-05-04 00:33:14 +08:00
|
|
|
Excitation* Exc;
|
2010-03-01 16:19:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // OPERATOR_H
|