2010-02-28 21:48:03 +00:00
|
|
|
#include <iostream>
|
2010-03-01 18:35:28 +00:00
|
|
|
#include <fstream>
|
|
|
|
#include <sstream>
|
2010-02-28 21:48:03 +00:00
|
|
|
#include <time.h>
|
2010-03-01 18:35:28 +00:00
|
|
|
#include "tools/array_ops.h"
|
2010-03-05 13:20:25 +00:00
|
|
|
#include "FDTD/operator.h"
|
2010-03-01 13:56:27 +00:00
|
|
|
#include "FDTD/engine.h"
|
2010-03-01 18:35:28 +00:00
|
|
|
#include "FDTD/processvoltage.h"
|
2010-03-04 10:53:58 +00:00
|
|
|
#include "FDTD/processcurrent.h"
|
2010-03-02 13:54:50 +00:00
|
|
|
#include "FDTD/processfields_td.h"
|
2010-03-01 13:56:27 +00:00
|
|
|
|
2010-02-28 21:48:03 +00:00
|
|
|
#include "ContinuousStructure.h"
|
|
|
|
|
2010-03-07 11:49:38 +00:00
|
|
|
#include "examples/FDTD_examples.h"
|
2010-02-28 21:48:03 +00:00
|
|
|
|
2010-03-07 11:49:38 +00:00
|
|
|
using namespace std;
|
2010-02-28 22:42:10 +00:00
|
|
|
|
2010-02-28 21:48:03 +00:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
time_t startTime=time(NULL);
|
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
//*************** setup/read geometry ************//
|
2010-03-04 10:53:58 +00:00
|
|
|
cerr << "Create Geometry..." << endl;
|
2010-03-01 18:35:28 +00:00
|
|
|
ContinuousStructure CSX;
|
2010-03-02 21:55:50 +00:00
|
|
|
|
2010-03-04 10:53:58 +00:00
|
|
|
//BuildPlaneWave(CSX);
|
|
|
|
BuildMSL(CSX);
|
2010-02-28 21:48:03 +00:00
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
//*************** setup operator ************//
|
2010-03-04 10:53:58 +00:00
|
|
|
cerr << "Create Operator..." << endl;
|
2010-03-05 13:20:25 +00:00
|
|
|
Operator cop;
|
2010-02-28 21:48:03 +00:00
|
|
|
cop.SetGeometryCSX(&CSX);
|
|
|
|
|
|
|
|
cop.CalcECOperator();
|
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
double fmax=1e9;
|
2010-03-04 10:53:58 +00:00
|
|
|
cop.CalcGaussianPulsExcitation(fmax/2,fmax/2);
|
2010-03-01 13:56:27 +00:00
|
|
|
|
2010-02-28 21:48:03 +00:00
|
|
|
time_t OpDoneTime=time(NULL);
|
|
|
|
|
2010-03-01 13:56:27 +00:00
|
|
|
cop.ShowSize();
|
2010-03-04 10:53:58 +00:00
|
|
|
bool bnd[] = {1,1,0,1,0,1};
|
2010-03-02 18:01:03 +00:00
|
|
|
cop.ApplyMagneticBC(bnd);
|
2010-03-01 13:56:27 +00:00
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
cerr << "Nyquist number of timesteps: " << cop.GetNyquistNum(fmax) << endl;
|
2010-03-01 19:50:42 +00:00
|
|
|
unsigned int NrIter = cop.GetNyquistNum(fmax)/3;
|
2010-03-01 18:35:28 +00:00
|
|
|
|
2010-02-28 21:48:03 +00:00
|
|
|
cerr << "Time for operator: " << difftime(OpDoneTime,startTime) << endl;
|
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
//create FDTD engine
|
2010-03-01 13:56:27 +00:00
|
|
|
Engine eng(&cop);
|
|
|
|
|
|
|
|
time_t currTime = time(NULL);
|
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
//*************** setup processing ************//
|
|
|
|
ProcessVoltage PV(&cop,&eng);
|
|
|
|
PV.OpenFile("tmp/u1");
|
2010-03-04 10:53:58 +00:00
|
|
|
double start[]={0,50,0};
|
|
|
|
double stop[]={0,0,0};
|
2010-03-01 18:35:28 +00:00
|
|
|
PV.DefineStartStopCoord(start,stop);
|
2010-03-04 10:53:58 +00:00
|
|
|
|
|
|
|
ProcessCurrent PCurr(&cop,&eng);
|
|
|
|
PCurr.OpenFile("tmp/i1");
|
|
|
|
start[0]=-50;start[1]=40;start[2]=-0;
|
|
|
|
stop[0]=50;stop[1]=60;stop[2]=-0;
|
|
|
|
PCurr.DefineStartStopCoord(start,stop);
|
|
|
|
|
|
|
|
unsigned int maxIter = 1800;
|
2010-03-01 18:35:28 +00:00
|
|
|
|
2010-03-07 11:49:38 +00:00
|
|
|
vector<CSProperties*> DumpProps = CSX.GetPropertyByType(CSProperties::DUMPBOX);
|
|
|
|
vector<ProcessFieldsTD*> TD_Dump;
|
2010-03-02 13:54:50 +00:00
|
|
|
ProcessFieldsTD PETD(&cop,&eng);
|
2010-03-07 11:49:38 +00:00
|
|
|
if (DumpProps.size()>0)
|
|
|
|
{
|
|
|
|
CSPrimitives* prim = DumpProps.at(0)->GetPrimitive(0);
|
|
|
|
bool acc;
|
|
|
|
double* bnd = prim->GetBoundBox(acc);
|
|
|
|
start[0]= bnd[0];start[1]=bnd[2];start[2]=bnd[4];
|
|
|
|
stop[0] = bnd[1];stop[1] =bnd[3];stop[2] =bnd[5];
|
|
|
|
CSPropDumpBox* db = DumpProps.at(0)->ToDumpBox();
|
|
|
|
if (db)
|
|
|
|
{
|
|
|
|
if (db->GetEFieldDump())
|
|
|
|
{
|
|
|
|
PETD.SetDumpType(0);
|
|
|
|
PETD.SetFilePattern("tmp/Et_");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
PETD.SetEnable(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
PETD.SetEnable(false);
|
|
|
|
PETD.DefineStartStopCoord(start,stop);
|
|
|
|
}
|
2010-03-02 14:37:00 +00:00
|
|
|
|
2010-03-02 21:55:50 +00:00
|
|
|
PETD.SetEnable(true);
|
2010-03-02 18:01:03 +00:00
|
|
|
|
2010-03-01 19:50:42 +00:00
|
|
|
PV.Process();
|
2010-03-04 10:53:58 +00:00
|
|
|
PCurr.Process();
|
2010-03-02 13:54:50 +00:00
|
|
|
PETD.Process();
|
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
//*************** simulate ************//
|
|
|
|
for (unsigned int i=0;i<maxIter;i+=NrIter)
|
|
|
|
{
|
|
|
|
eng.IterateTS(NrIter);
|
|
|
|
PV.Process();
|
2010-03-04 10:53:58 +00:00
|
|
|
PCurr.Process();
|
2010-03-02 13:54:50 +00:00
|
|
|
PETD.Process();
|
2010-03-01 18:35:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*************** postproc ************//
|
2010-03-01 13:56:27 +00:00
|
|
|
time_t prevTime = currTime;
|
|
|
|
currTime = time(NULL);
|
|
|
|
|
|
|
|
double t_diff = difftime(currTime,prevTime);
|
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
cerr << "Time for " << eng.GetNumberOfTimesteps() << " iterations with " << cop.GetNumberCells() << " cells : " << t_diff << " sec" << endl;
|
2010-03-04 10:53:58 +00:00
|
|
|
cerr << "Speed: " << (double)cop.GetNumberCells()*(double)eng.GetNumberOfTimesteps()/t_diff/1e6 << " MCells/s " << endl;
|
2010-02-28 21:48:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|