2012-02-02 10:45:26 +00:00
|
|
|
/*
|
2014-10-09 19:20:31 +00:00
|
|
|
* Copyright (C) 2012-2014 Thorsten Liebig (Thorsten.Liebig@gmx.de)
|
2012-02-02 10:45:26 +00:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NF2FF_CALC_H
|
|
|
|
#define NF2FF_CALC_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <cmath>
|
|
|
|
#include <complex>
|
|
|
|
#include <boost/thread.hpp>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
class nf2ff_calc;
|
|
|
|
|
2014-10-09 19:20:31 +00:00
|
|
|
#define MIRROR_OFF 0
|
|
|
|
#define MIRROR_PEC 1
|
|
|
|
#define MIRROR_PMC 2
|
|
|
|
|
2012-02-02 10:45:26 +00:00
|
|
|
// data structure to exchange data between thread-controller and worker-threads
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
//local working data IN
|
|
|
|
int ny;
|
2012-02-10 11:02:25 +00:00
|
|
|
int mesh_type;
|
2012-02-02 10:45:26 +00:00
|
|
|
float* normDir;
|
|
|
|
unsigned int* numLines;
|
|
|
|
float **lines;
|
|
|
|
float* edge_length_P;
|
|
|
|
float* edge_length_PP;
|
|
|
|
|
|
|
|
complex<float>**** E_field;
|
|
|
|
complex<float>**** H_field;
|
|
|
|
complex<float>**** Js;
|
|
|
|
complex<float>**** Ms;
|
|
|
|
|
|
|
|
//local working data OUT
|
2012-09-17 10:33:30 +00:00
|
|
|
complex<double>** m_Nt;
|
|
|
|
complex<double>** m_Np;
|
|
|
|
complex<double>** m_Lt;
|
|
|
|
complex<double>** m_Lp;
|
2012-02-02 10:45:26 +00:00
|
|
|
|
|
|
|
} nf2ff_data;
|
|
|
|
|
|
|
|
class nf2ff_calc_thread
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nf2ff_calc_thread(nf2ff_calc* nfc, unsigned int start, unsigned int stop, unsigned int threadID, nf2ff_data &data);
|
|
|
|
void operator()();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
unsigned int m_start, m_stop, m_threadID;
|
|
|
|
nf2ff_calc *m_nf_calc;
|
|
|
|
|
|
|
|
nf2ff_data m_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
class nf2ff_calc
|
|
|
|
{
|
|
|
|
// allow full data access to nf2ff_calc_thread class
|
|
|
|
friend class nf2ff_calc_thread;
|
|
|
|
public:
|
2012-02-10 11:02:25 +00:00
|
|
|
nf2ff_calc(float freq, vector<float> theta, vector<float> phi, vector<float> center);
|
2012-02-02 10:45:26 +00:00
|
|
|
~nf2ff_calc();
|
|
|
|
|
2013-06-03 19:44:12 +00:00
|
|
|
void SetRadius(float radius) {m_radius=radius;}
|
|
|
|
void SetPermittivity(float permittivity) {m_permittivity=permittivity;}
|
|
|
|
void SetPermeability(float permeability) {m_permeability=permeability;}
|
|
|
|
|
2012-09-17 10:33:30 +00:00
|
|
|
double GetTotalRadPower() const {return m_radPower;}
|
|
|
|
double GetMaxDirectivity() const {return m_maxDir;}
|
2012-02-02 10:45:26 +00:00
|
|
|
|
2012-09-17 10:33:30 +00:00
|
|
|
complex<double>** GetETheta() const {return m_E_theta;}
|
|
|
|
complex<double>** GetEPhi() const {return m_E_phi;}
|
|
|
|
double** GetRadPower() const {return m_P_rad;}
|
2012-02-02 10:45:26 +00:00
|
|
|
|
|
|
|
unsigned int GetNumThreads() const {return m_numThreads;}
|
|
|
|
void SetNumThreads(unsigned int n) {m_numThreads=n;}
|
|
|
|
|
2014-10-09 19:20:31 +00:00
|
|
|
void SetMirror(int type, int dir, float pos);
|
|
|
|
|
2012-02-10 11:02:25 +00:00
|
|
|
bool AddPlane(float **lines, unsigned int* numLines, complex<float>**** E_field, complex<float>**** H_field, int MeshType=0);
|
2012-02-02 10:45:26 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
float m_freq;
|
|
|
|
float m_radius;
|
|
|
|
|
2013-06-03 19:44:12 +00:00
|
|
|
float m_permittivity; //relative electric permittivity
|
|
|
|
float m_permeability; //relative magnetic permeability
|
|
|
|
|
2012-09-17 10:33:30 +00:00
|
|
|
double m_radPower;
|
|
|
|
double m_maxDir;
|
2012-02-02 10:45:26 +00:00
|
|
|
|
2012-09-17 10:33:30 +00:00
|
|
|
complex<double>** m_E_theta;
|
|
|
|
complex<double>** m_E_phi;
|
|
|
|
complex<double>** m_H_theta;
|
|
|
|
complex<double>** m_H_phi;
|
|
|
|
double** m_P_rad;
|
2012-02-02 10:45:26 +00:00
|
|
|
|
|
|
|
float m_centerCoord[3];
|
|
|
|
unsigned int m_numTheta;
|
|
|
|
unsigned int m_numPhi;
|
|
|
|
float* m_theta;
|
|
|
|
float* m_phi;
|
|
|
|
|
2014-10-09 19:20:31 +00:00
|
|
|
//mirror settings
|
|
|
|
bool m_EnableMirror;
|
|
|
|
int m_MirrorType[3];
|
|
|
|
float m_MirrorPos[3];
|
|
|
|
|
|
|
|
int GetNormalDir(unsigned int* numLines);
|
|
|
|
bool AddSinglePlane(float **lines, unsigned int* numLines, complex<float>**** E_field, complex<float>**** H_field, int MeshType=0);
|
|
|
|
bool AddMirrorPlane(int n, float **lines, unsigned int* numLines, complex<float>**** E_field, complex<float>**** H_field, int MeshType=0);
|
|
|
|
|
2012-02-02 10:45:26 +00:00
|
|
|
//boost multi-threading
|
|
|
|
unsigned int m_numThreads;
|
|
|
|
boost::thread_group m_thread_group;
|
|
|
|
boost::barrier *m_Barrier;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // NF2FF_CALC_H
|