update to console output
parent
ea31ec1d7a
commit
abc705767f
|
@ -92,7 +92,8 @@ unsigned int Operator::GetNyquistNum(double fmax)
|
||||||
{
|
{
|
||||||
if (dT==0) return 1;
|
if (dT==0) return 1;
|
||||||
double T0 = 1/fmax;
|
double T0 = 1/fmax;
|
||||||
return floor(T0/2/dT);
|
m_nyquistTS = floor(T0/2/dT);
|
||||||
|
return m_nyquistTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Operator::SnapToMesh(double* dcoord, unsigned int* uicoord, bool lower)
|
bool Operator::SnapToMesh(double* dcoord, unsigned int* uicoord, bool lower)
|
||||||
|
@ -207,29 +208,35 @@ struct Operator::Grid_Path Operator::FindPath(double start[], double stop[])
|
||||||
double Operator::GetNumberCells()
|
double Operator::GetNumberCells()
|
||||||
{
|
{
|
||||||
if (numLines)
|
if (numLines)
|
||||||
return (numLines[0]-1)*(numLines[1]-1)*(numLines[2]-1);
|
return (numLines[0])*(numLines[1])*(numLines[2]); //it's more like number of nodes???
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Operator::ShowSize()
|
void Operator::ShowStat()
|
||||||
{
|
{
|
||||||
unsigned int OpSize = 12*numLines[0]*numLines[1]*numLines[2]*sizeof(FDTD_FLOAT);
|
unsigned int OpSize = 12*numLines[0]*numLines[1]*numLines[2]*sizeof(FDTD_FLOAT);
|
||||||
unsigned int FieldSize = 6*numLines[0]*numLines[1]*numLines[2]*sizeof(FDTD_FLOAT);
|
unsigned int FieldSize = 6*numLines[0]*numLines[1]*numLines[2]*sizeof(FDTD_FLOAT);
|
||||||
double MBdiff = 1024*1024;
|
double MBdiff = 1024*1024;
|
||||||
|
|
||||||
cout << "---- Stat: FDTD Operator ----" << endl;
|
cout << "------- Stat: FDTD Operator -------" << endl;
|
||||||
cout << "Dimensions : " << numLines[0] << "x" << numLines[1] << "x" << numLines[2] << " = " << numLines[0]*numLines[1]*numLines[2] << " Cells (" << numLines[0]*numLines[1]*numLines[2]/1e6 << " MCells)" << endl;
|
cout << "Dimensions : " << numLines[0] << "x" << numLines[1] << "x" << numLines[2] << " = " << numLines[0]*numLines[1]*numLines[2] << " Cells (" << numLines[0]*numLines[1]*numLines[2]/1e6 << " MCells)" << endl;
|
||||||
cout << "Size of Operator : " << OpSize << " Byte (" << (double)OpSize/MBdiff << " MB) " << endl;
|
cout << "Size of Operator : " << OpSize << " Byte (" << (double)OpSize/MBdiff << " MB) " << endl;
|
||||||
cout << "Size of Field-Data: " << FieldSize << " Byte (" << (double)FieldSize/MBdiff << " MB) " << endl;
|
cout << "Size of Field-Data : " << FieldSize << " Byte (" << (double)FieldSize/MBdiff << " MB) " << endl;
|
||||||
cout << "-----------------------------" << endl;
|
cout << "-----------------------------------" << endl;
|
||||||
|
cout << "Timestep (s) : " << dT << endl;
|
||||||
|
cout << "Nyquist criteria (TS) : " << m_nyquistTS << endl;
|
||||||
|
cout << "Nyquist criteria (s) : " << m_nyquistTS*dt << endl;
|
||||||
|
cout << "Excitation Length (TS) : " << ExciteLength << endl;
|
||||||
|
cout << "Excitation Length (s) : " << ExciteLength*dT << endl;
|
||||||
|
cout << "-----------------------------------" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Operator::CalcGaussianPulsExcitation(double f0, double fc)
|
unsigned int Operator::CalcGaussianPulsExcitation(double f0, double fc)
|
||||||
{
|
{
|
||||||
if (dT==0) return false;
|
if (dT==0) return 0;
|
||||||
|
|
||||||
ExciteLength = (unsigned int)(2.0 * 9.0/(2.0*PI*fc) / dT);
|
ExciteLength = (unsigned int)(2.0 * 9.0/(2.0*PI*fc) / dT);
|
||||||
cerr << "Operator::CalcGaussianPulsExcitation: Length of the excite signal: " << ExciteLength << " timesteps" << endl;
|
// cerr << "Operator::CalcGaussianPulsExcitation: Length of the excite signal: " << ExciteLength << " timesteps" << endl;
|
||||||
delete[] ExciteSignal;
|
delete[] ExciteSignal;
|
||||||
ExciteSignal = new FDTD_FLOAT[ExciteLength+1];
|
ExciteSignal = new FDTD_FLOAT[ExciteLength+1];
|
||||||
ExciteSignal[0]=0.0;
|
ExciteSignal[0]=0.0;
|
||||||
|
@ -238,16 +245,16 @@ bool Operator::CalcGaussianPulsExcitation(double f0, double fc)
|
||||||
ExciteSignal[n] = cos(2.0*PI*f0*(n*dT-9.0/(2.0*PI*fc)))*exp(-1*pow(2.0*PI*fc*n*dT/3.0-3,2));
|
ExciteSignal[n] = cos(2.0*PI*f0*(n*dT-9.0/(2.0*PI*fc)))*exp(-1*pow(2.0*PI*fc*n*dT/3.0-3,2));
|
||||||
// cerr << ExciteSignal[n] << endl;
|
// cerr << ExciteSignal[n] << endl;
|
||||||
}
|
}
|
||||||
return true;
|
return GetNyquistNum(f0+fc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Operator::CalcSinusExcitation(double f0, int nTS)
|
unsigned int Operator::CalcSinusExcitation(double f0, int nTS)
|
||||||
{
|
{
|
||||||
if (dT==0) return false;
|
if (dT==0) return 0;
|
||||||
if (nTS<=0) return false;
|
if (nTS<=0) return 0;
|
||||||
|
|
||||||
ExciteLength = (unsigned int)(nTS);
|
ExciteLength = (unsigned int)(nTS);
|
||||||
cerr << "Operator::CalcSinusExcitation: Length of the excite signal: " << ExciteLength << " timesteps" << endl;
|
// cerr << "Operator::CalcSinusExcitation: Length of the excite signal: " << ExciteLength << " timesteps" << endl;
|
||||||
delete[] ExciteSignal;
|
delete[] ExciteSignal;
|
||||||
ExciteSignal = new FDTD_FLOAT[ExciteLength+1];
|
ExciteSignal = new FDTD_FLOAT[ExciteLength+1];
|
||||||
ExciteSignal[0]=0.0;
|
ExciteSignal[0]=0.0;
|
||||||
|
@ -256,7 +263,7 @@ bool Operator::CalcSinusExcitation(double f0, int nTS)
|
||||||
ExciteSignal[n] = sin(2.0*PI*f0*n*dT);
|
ExciteSignal[n] = sin(2.0*PI*f0*n*dT);
|
||||||
// cerr << ExciteSignal[n] << endl;
|
// cerr << ExciteSignal[n] << endl;
|
||||||
}
|
}
|
||||||
return true;
|
return GetNyquistNum(f0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Operator::DumpOperator2File(string filename)
|
void Operator::DumpOperator2File(string filename)
|
||||||
|
|
|
@ -37,10 +37,10 @@ public:
|
||||||
|
|
||||||
virtual int CalcECOperator();
|
virtual int CalcECOperator();
|
||||||
|
|
||||||
//! Calculate an excitation with center of f0 and the half bandwidth fc
|
//! Calculate an excitation with center of f0 and the half bandwidth fc \return number of Nyquist timesteps
|
||||||
virtual bool CalcGaussianPulsExcitation(double f0, double fc);
|
virtual unsigned int CalcGaussianPulsExcitation(double f0, double fc);
|
||||||
//! Calculate a sinusoidal excitation with frequency f0 and a duration of nTS number of timesteps
|
//! Calculate a sinusoidal excitation with frequency f0 and a duration of nTS number of timesteps \return number of Nyquist timesteps
|
||||||
virtual bool CalcSinusExcitation(double f0, int nTS);
|
virtual unsigned int CalcSinusExcitation(double f0, int nTS);
|
||||||
|
|
||||||
virtual void ApplyElectricBC(bool* dirs); //applied by default to all boundaries
|
virtual void ApplyElectricBC(bool* dirs); //applied by default to all boundaries
|
||||||
virtual void ApplyMagneticBC(bool* dirs);
|
virtual void ApplyMagneticBC(bool* dirs);
|
||||||
|
@ -49,7 +49,7 @@ public:
|
||||||
unsigned int GetNyquistNum(double fmax);
|
unsigned int GetNyquistNum(double fmax);
|
||||||
double GetNumberCells();
|
double GetNumberCells();
|
||||||
|
|
||||||
void ShowSize();
|
void ShowStat();
|
||||||
|
|
||||||
void DumpOperator2File(string filename);
|
void DumpOperator2File(string filename);
|
||||||
void DumpMaterial2File(string filename);
|
void DumpMaterial2File(string filename);
|
||||||
|
@ -86,6 +86,7 @@ protected:
|
||||||
//Calc timestep only internal use
|
//Calc timestep only internal use
|
||||||
virtual double CalcTimestep();
|
virtual double CalcTimestep();
|
||||||
double dT; //FDTD timestep!
|
double dT; //FDTD timestep!
|
||||||
|
unsigned int m_nyquistTS;
|
||||||
|
|
||||||
//EC elements, internal only!
|
//EC elements, internal only!
|
||||||
bool Calc_EC();
|
bool Calc_EC();
|
||||||
|
|
15
openems.cpp
15
openems.cpp
|
@ -191,10 +191,11 @@ int openEMS::SetupFDTD(const char* file)
|
||||||
if (FDTD_Op->SetGeometryCSX(&CSX)==false) return(-1);
|
if (FDTD_Op->SetGeometryCSX(&CSX)==false) return(-1);
|
||||||
|
|
||||||
FDTD_Op->CalcECOperator();
|
FDTD_Op->CalcECOperator();
|
||||||
|
unsigned int Nyquist = 0;
|
||||||
if (Excit_Type==0)
|
if (Excit_Type==0)
|
||||||
{
|
{
|
||||||
if (!FDTD_Op->CalcGaussianPulsExcitation(f0,fc))
|
Nyquist = FDTD_Op->CalcGaussianPulsExcitation(f0,fc);
|
||||||
|
if (!Nyquist)
|
||||||
{
|
{
|
||||||
cerr << "openEMS: excitation setup failed!!" << endl;
|
cerr << "openEMS: excitation setup failed!!" << endl;
|
||||||
exit(2);
|
exit(2);
|
||||||
|
@ -202,7 +203,8 @@ int openEMS::SetupFDTD(const char* file)
|
||||||
}
|
}
|
||||||
else if (Excit_Type==1)
|
else if (Excit_Type==1)
|
||||||
{
|
{
|
||||||
if (!FDTD_Op->CalcSinusExcitation(f0,NrTS))
|
Nyquist = FDTD_Op->CalcSinusExcitation(f0,NrTS);
|
||||||
|
if (!Nyquist)
|
||||||
{
|
{
|
||||||
cerr << "openEMS: excitation setup failed!!" << endl;
|
cerr << "openEMS: excitation setup failed!!" << endl;
|
||||||
exit(2);
|
exit(2);
|
||||||
|
@ -225,13 +227,10 @@ int openEMS::SetupFDTD(const char* file)
|
||||||
|
|
||||||
time_t OpDoneTime=time(NULL);
|
time_t OpDoneTime=time(NULL);
|
||||||
|
|
||||||
FDTD_Op->ShowSize();
|
FDTD_Op->ShowStat();
|
||||||
|
|
||||||
FDTD_Op->ApplyMagneticBC(PMC);
|
FDTD_Op->ApplyMagneticBC(PMC);
|
||||||
|
|
||||||
cout << "Nyquist number of timesteps: " << FDTD_Op->GetNyquistNum(f0+fc) << endl;
|
|
||||||
unsigned int Nyquist = FDTD_Op->GetNyquistNum(f0+fc);
|
|
||||||
|
|
||||||
cout << "Creation time for operator: " << difftime(OpDoneTime,startTime) << " s" << endl;
|
cout << "Creation time for operator: " << difftime(OpDoneTime,startTime) << " s" << endl;
|
||||||
|
|
||||||
//create FDTD engine
|
//create FDTD engine
|
||||||
|
@ -316,7 +315,7 @@ int openEMS::SetupFDTD(const char* file)
|
||||||
|
|
||||||
void openEMS::RunFDTD()
|
void openEMS::RunFDTD()
|
||||||
{
|
{
|
||||||
cout << "Running FDTD engine... this may take a while... grab a coup of coffee?!?" << endl;
|
cout << "Running FDTD engine... this may take a while... grab a cup of coffee?!?" << endl;
|
||||||
|
|
||||||
timeval currTime;
|
timeval currTime;
|
||||||
gettimeofday(&currTime,NULL);
|
gettimeofday(&currTime,NULL);
|
||||||
|
|
Loading…
Reference in New Issue