diff --git a/FDTD/operator.cpp b/FDTD/operator.cpp index b8d2614..63e13c9 100644 --- a/FDTD/operator.cpp +++ b/FDTD/operator.cpp @@ -17,6 +17,7 @@ #include #include "operator.h" +#include "processfields.h" #include "tools/array_ops.h" Operator::Operator() @@ -202,6 +203,59 @@ void Operator::DumpOperator2File(string filename) file.close(); } +void Operator::DumpMaterial2File(string filename) +{ + FDTD_FLOAT*** epsilon; + FDTD_FLOAT*** mue; + FDTD_FLOAT*** kappa; + FDTD_FLOAT*** sigma; + unsigned int pos[3]; + double inMat[4]; + + ofstream file(filename.c_str(),ios_base::out); +// file.open; + if (file.is_open()==false) + { + cerr << "Operator::DumpMaterial2File: Can't open file: " << filename << endl; + return; + } + + epsilon = Create3DArray( numLines); + mue = Create3DArray( numLines); + kappa = Create3DArray( numLines); + sigma = Create3DArray( numLines); + for (pos[0]=0;pos[0]SetKappa(56e6); -// MSL = MSL_mat; - MSL = new CSPropMetal(CSX.GetParameterSet()); + CSPropMaterial* MSL_mat = new CSPropMaterial(CSX.GetParameterSet()); + MSL_mat->SetKappa(56e6); + MSL = MSL_mat; +// MSL = new CSPropMetal(CSX.GetParameterSet()); CSX.AddProperty(MSL); box = new CSPrimBox(CSX.GetParameterSet(),MSL); diff --git a/examples/MSL.xml b/examples/MSL.xml index c0f73ee..00f7d68 100644 --- a/examples/MSL.xml +++ b/examples/MSL.xml @@ -21,10 +21,16 @@ - + - + + + + + + + diff --git a/main.cpp b/main.cpp index 6b9ba3f..1a7437a 100644 --- a/main.cpp +++ b/main.cpp @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) #ifdef STANDALONE if (argc<=1) { - cerr << " usage: openEMS FDTD_XML_FILE [--disable-dumps]" << endl; + cout << " usage: openEMS FDTD_XML_FILE [--disable-dumps] [--debug-material]" << endl; exit(-1); } @@ -43,7 +43,17 @@ int main(int argc, char *argv[]) for (int n=2;nQueryIntAttribute("zmin",&bounds[4]); BC->QueryIntAttribute("zmax",&bounds[5]); - cerr << "Read Geometry..." << endl; + cout << "Read Geometry..." << endl; ContinuousStructure CSX; string EC(CSX.ReadFromXML(&doc)); if (EC.empty()==false) @@ -123,10 +124,15 @@ int openEMS::SetupFDTD(const char* file) PMC[n]=(bounds[n]==1); //*************** setup operator ************// - cerr << "Create Operator..." << endl; + cout << "Create Operator..." << endl; FDTD_Op = new Operator(); if (FDTD_Op->SetGeometryCSX(&CSX)==false) return(-1); + if (DebugMat) + { + FDTD_Op->DumpMaterial2File("material_dump.vtk"); + } + FDTD_Op->CalcECOperator(); if (Excit_Type==0) @@ -143,10 +149,10 @@ int openEMS::SetupFDTD(const char* file) FDTD_Op->ApplyMagneticBC(PMC); - cerr << "Nyquist number of timesteps: " << FDTD_Op->GetNyquistNum(f0+fc) << endl; + cout << "Nyquist number of timesteps: " << FDTD_Op->GetNyquistNum(f0+fc) << endl; unsigned int Nyquist = FDTD_Op->GetNyquistNum(f0+fc); - cerr << "Time for operator: " << difftime(OpDoneTime,startTime) << endl; + cout << "Creation time for operator: " << difftime(OpDoneTime,startTime) << " s" << endl; //create FDTD engine FDTD_Eng = new Engine(FDTD_Op); @@ -154,6 +160,7 @@ int openEMS::SetupFDTD(const char* file) time_t currTime = time(NULL); //*************** setup processing ************// + cout << "Setting up processing..." << endl; PA = new ProcessingArray(); double start[3]; @@ -229,6 +236,7 @@ int openEMS::SetupFDTD(const char* file) void openEMS::RunFDTD() { + cout << "Running FDTD engine... this may take a while... grab a coup of coffee?!?" << endl; time_t currTime = time(NULL); //*************** simulate ************// int step=PA->Process(); @@ -237,7 +245,7 @@ void openEMS::RunFDTD() { FDTD_Eng->IterateTS(step); step=PA->Process(); -// cerr << " do " << step << " steps; current: " << eng.GetNumberOfTimesteps() << endl; +// cout << " do " << step << " steps; current: " << eng.GetNumberOfTimesteps() << endl; if ((step<0) || (step>NrTS - FDTD_Eng->GetNumberOfTimesteps())) step=NrTS - FDTD_Eng->GetNumberOfTimesteps(); } @@ -247,6 +255,6 @@ void openEMS::RunFDTD() double t_diff = difftime(currTime,prevTime); - cerr << "Time for " << FDTD_Eng->GetNumberOfTimesteps() << " iterations with " << FDTD_Op->GetNumberCells() << " cells : " << t_diff << " sec" << endl; - cerr << "Speed: " << (double)FDTD_Op->GetNumberCells()*(double)FDTD_Eng->GetNumberOfTimesteps()/t_diff/1e6 << " MCells/s " << endl; + cout << "Time for " << FDTD_Eng->GetNumberOfTimesteps() << " iterations with " << FDTD_Op->GetNumberCells() << " cells : " << t_diff << " sec" << endl; + cout << "Speed: " << (double)FDTD_Op->GetNumberCells()*(double)FDTD_Eng->GetNumberOfTimesteps()/t_diff/1e6 << " MCells/s " << endl; } diff --git a/openems.h b/openems.h index 74e0d3d..a39d934 100644 --- a/openems.h +++ b/openems.h @@ -36,10 +36,13 @@ public: void SetEnableDumps(bool val) {Enable_Dumps=val;} + void DebugMaterial() {DebugMat=true;} + protected: //! Number of Timesteps int NrTS; bool Enable_Dumps; + bool DebugMat; Operator* FDTD_Op; Engine* FDTD_Eng; ProcessingArray* PA;