diff --git a/.gitignore b/.gitignore index 4852b50..f87fb20 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ Makefile* *~ *.so* *.pro.user* +*.orig openEMS diff --git a/Common/engine_interface_base.h b/Common/engine_interface_base.h index 0435ab8..547b2df 100644 --- a/Common/engine_interface_base.h +++ b/Common/engine_interface_base.h @@ -40,24 +40,24 @@ public: InterpolationType GetInterpolationType() {return m_InterpolType;} //! Get the (interpolated) electric field at \p pos. \sa SetInterpolationType - virtual double* GetEField(const unsigned int* pos, double* out) const {UNUSED(pos);return out;} + virtual double* GetEField(const unsigned int* pos, double* out) const {UNUSED(pos); return out;} //! Get the (interpolated) magnetic field at \p pos. \sa SetInterpolationType - virtual double* GetHField(const unsigned int* pos, double* out) const {UNUSED(pos);return out;} + virtual double* GetHField(const unsigned int* pos, double* out) const {UNUSED(pos); return out;} //! Calculate the electric field integral along a given line - virtual double CalcVoltageIntegral(const unsigned int* start, const unsigned int* stop) const {UNUSED(start);UNUSED(stop);return 0.0;} + virtual double CalcVoltageIntegral(const unsigned int* start, const unsigned int* stop) const {UNUSED(start); UNUSED(stop); return 0.0;} //! Convert the interpolation type into a string. static std::string GetInterpolationNameByType(InterpolationType mode); //! Get the current simulation time - virtual double GetTime(bool dualTime=false) const {UNUSED(dualTime);return 0.0;} + virtual double GetTime(bool dualTime=false) const {UNUSED(dualTime); return 0.0;} //! Get the current number of timesteps virtual unsigned int GetNumberOfTimesteps() const {return 0;} protected: - Engine_Interface_Base(); + Engine_Interface_Base(); InterpolationType m_InterpolType; }; diff --git a/Common/operator_base.cpp b/Common/operator_base.cpp index 09b98e8..4054253 100644 --- a/Common/operator_base.cpp +++ b/Common/operator_base.cpp @@ -39,15 +39,15 @@ std::string Operator_Base::GetDirName(int ny) const void Operator_Base::Init() { dT = 0; - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) discLines[n]=NULL; - for (int n=0;n<6;++n) + for (int n=0; n<6; ++n) m_BC[n]=0; } void Operator_Base::Reset() { - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) delete[] discLines[n]; Init(); } diff --git a/Common/operator_base.h b/Common/operator_base.h index 19eb931..a2842bc 100644 --- a/Common/operator_base.h +++ b/Common/operator_base.h @@ -44,32 +44,32 @@ public: virtual double GetGridDelta() const {return 0;} //! Get the mesh delta times the grid delta for a 3D position (unit is meter) - virtual double GetMeshDelta(int n, const unsigned int* pos, bool dualMesh=false) const {UNUSED(n);UNUSED(pos);UNUSED(dualMesh);return 0.0;} + virtual double GetMeshDelta(int n, const unsigned int* pos, bool dualMesh=false) const {UNUSED(n); UNUSED(pos); UNUSED(dualMesh); return 0.0;} //! Get the disc line in \a n direction (in drawing units) - virtual double GetDiscLine(int n, unsigned int pos, bool dualMesh=false) const {UNUSED(n);UNUSED(pos);UNUSED(dualMesh);return 0.0;} + virtual double GetDiscLine(int n, unsigned int pos, bool dualMesh=false) const {UNUSED(n); UNUSED(pos); UNUSED(dualMesh); return 0.0;} //! Get the node width for a given direction \a n and a given mesh position \a pos - virtual double GetNodeWidth(int ny, const unsigned int pos[3], bool dualMesh = false) const {UNUSED(ny);UNUSED(pos);UNUSED(dualMesh);return 0.0;} + virtual double GetNodeWidth(int ny, const unsigned int pos[3], bool dualMesh = false) const {UNUSED(ny); UNUSED(pos); UNUSED(dualMesh); return 0.0;} //! Get the node area for a given direction \a n and a given mesh position \a pos - virtual double GetNodeArea(int ny, const unsigned int pos[3], bool dualMesh = false) const {UNUSED(ny);UNUSED(pos);UNUSED(dualMesh);return 0.0;} + virtual double GetNodeArea(int ny, const unsigned int pos[3], bool dualMesh = false) const {UNUSED(ny); UNUSED(pos); UNUSED(dualMesh); return 0.0;} //! Get the length of an FDTD edge (unit is meter). - virtual double GetEdgeLength(int ny, const unsigned int pos[3], bool dualMesh = false) const {UNUSED(ny);UNUSED(pos);UNUSED(dualMesh);return 0.0;} + virtual double GetEdgeLength(int ny, const unsigned int pos[3], bool dualMesh = false) const {UNUSED(ny); UNUSED(pos); UNUSED(dualMesh); return 0.0;} //! Get the area around an edge for a given direction \a n and a given mesh posisition \a pos /*! This will return the area around an edge with a given direction, measured at the middle of the edge. In a cartesian mesh this is equal to the NodeArea, may be different in other coordinate systems. */ - virtual double GetEdgeArea(int ny, const unsigned int pos[3], bool dualMesh = false) const {UNUSED(ny);UNUSED(pos);UNUSED(dualMesh);return 0.0;} + virtual double GetEdgeArea(int ny, const unsigned int pos[3], bool dualMesh = false) const {UNUSED(ny); UNUSED(pos); UNUSED(dualMesh); return 0.0;} //! Snap the given coodinates to mesh indices - virtual bool SnapToMesh(double* coord, unsigned int* uicoord, bool lower=false, bool* inside=NULL) {UNUSED(coord);UNUSED(uicoord);UNUSED(lower);UNUSED(inside);return false;}; + virtual bool SnapToMesh(double* coord, unsigned int* uicoord, bool lower=false, bool* inside=NULL) {UNUSED(coord); UNUSED(uicoord); UNUSED(lower); UNUSED(inside); return false;}; //! Set the boundary conditions - virtual void SetBoundaryCondition(int* BCs) {for (int n=0;n<6;++n) m_BC[n]=BCs[n];} + virtual void SetBoundaryCondition(int* BCs) {for (int n=0; n<6; ++n) m_BC[n]=BCs[n];} protected: Operator_Base(); diff --git a/Common/process_efield.cpp b/Common/process_efield.cpp index f65b7b7..0aa55c4 100644 --- a/Common/process_efield.cpp +++ b/Common/process_efield.cpp @@ -37,8 +37,8 @@ void ProcessEField::InitProcess() file << "% time-domain E-field probe by openEMS " GIT_VERSION << endl; file << "% coords: (" << Op->GetDiscLine(0,start[0])*Op->GetGridDelta() << "," - << Op->GetDiscLine(1,start[1])*Op->GetGridDelta() << "," - << Op->GetDiscLine(2,start[2])*Op->GetGridDelta() << ") m -> [" << start[0] << "," << start[1] << "," << start[2] << "]" << endl; + << Op->GetDiscLine(1,start[1])*Op->GetGridDelta() << "," + << Op->GetDiscLine(2,start[2])*Op->GetGridDelta() << ") m -> [" << start[0] << "," << start[1] << "," << start[2] << "]" << endl; file << "% t/s\tEx/(V/m)\tEy/(V/m)\tEz/(V/m)" << endl; } @@ -65,12 +65,12 @@ void ProcessEField::Dump_FD_Data(vector value[3], double factor, time_t rawTime; time(&rawTime); file << "%dump by openEMS @" << ctime(&rawTime) << "%frequency\treal_x\timag_x\treal_y\timag_y\treal_z\timag_z\n"; - for (size_t n=0;nGetVolt(pol,start) / Op->GetMeshDelta(pol,start); field *= m_weight; - for (size_t n=0;nGetDiscLine(0,start[0],true)*Op->GetGridDelta() << "," - << Op->GetDiscLine(1,start[1],true)*Op->GetGridDelta() << "," - << Op->GetDiscLine(2,start[2],true)*Op->GetGridDelta() << ") m -> [" << start[0] << "," << start[1] << "," << start[2] << "]" << endl; + << Op->GetDiscLine(1,start[1],true)*Op->GetGridDelta() << "," + << Op->GetDiscLine(2,start[2],true)*Op->GetGridDelta() << ") m -> [" << start[0] << "," << start[1] << "," << start[2] << "]" << endl; file << "% t/s\tEx/(A/m)\tEy/(A/m)\tEz/(A/m)" << endl; } @@ -47,13 +47,14 @@ void ProcessHField::DefineStartStopCoord(double* dstart, double* dstop) if (Op->SnapToMesh(dstop,stop,true,m_stop_inside)==false) cerr << "ProcessHField::DefineStartStopCoord: Warning: Snapped line outside field domain!!" << endl; - if (g_settings.showProbeDiscretization()) { + if (g_settings.showProbeDiscretization()) + { cerr << m_Name << ": snapped coords: (" << Op->GetDiscLine( 0, start[0], true ) << "," - << Op->GetDiscLine( 1, start[1], true ) << "," << Op->GetDiscLine( 2, start[2], true ) << ") -> (" - << Op->GetDiscLine( 0, stop[0], true ) << ","<< Op->GetDiscLine( 1, stop[1], true ) << "," - << Op->GetDiscLine( 2, stop[2], true ) << ")"; + << Op->GetDiscLine( 1, start[1], true ) << "," << Op->GetDiscLine( 2, start[2], true ) << ") -> (" + << Op->GetDiscLine( 0, stop[0], true ) << ","<< Op->GetDiscLine( 1, stop[1], true ) << "," + << Op->GetDiscLine( 2, stop[2], true ) << ")"; cerr << " [" << start[0] << "," << start[1] << "," << start[2] << "] -> [" - << stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl; + << stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl; } } @@ -93,14 +94,14 @@ int ProcessHField::Process() { FDTD_FLOAT field = Eng->GetCurr(pol,start) / Op->GetMeshDelta(pol,start,true); field *= m_weight; - for (size_t n=0;nstop[n]) { @@ -75,55 +75,55 @@ double ProcessCurrent::CalcIntegral() case 0: //y-current if (m_stop_inside[0] && m_start_inside[2]) - for (unsigned int i=start[1]+1;i<=stop[1];++i) + for (unsigned int i=start[1]+1; i<=stop[1]; ++i) current+=Eng->GetCurr(1,stop[0],i,start[2]); //z-current if (m_stop_inside[0] && m_stop_inside[1]) - for (unsigned int i=start[2]+1;i<=stop[2];++i) + for (unsigned int i=start[2]+1; i<=stop[2]; ++i) current+=Eng->GetCurr(2,stop[0],stop[1],i); //y-current if (m_start_inside[0] && m_stop_inside[2]) - for (unsigned int i=start[1]+1;i<=stop[1];++i) + for (unsigned int i=start[1]+1; i<=stop[1]; ++i) current-=Eng->GetCurr(1,start[0],i,stop[2]); //z-current if (m_start_inside[0] && m_start_inside[1]) - for (unsigned int i=start[2]+1;i<=stop[2];++i) + for (unsigned int i=start[2]+1; i<=stop[2]; ++i) current-=Eng->GetCurr(2,start[0],start[1],i); break; case 1: //z-current if (m_start_inside[0] && m_start_inside[1]) - for (unsigned int i=start[2]+1;i<=stop[2];++i) + for (unsigned int i=start[2]+1; i<=stop[2]; ++i) current+=Eng->GetCurr(2,start[0],start[1],i); //x-current if (m_stop_inside[1] && m_stop_inside[2]) - for (unsigned int i=start[0]+1;i<=stop[0];++i) + for (unsigned int i=start[0]+1; i<=stop[0]; ++i) current+=Eng->GetCurr(0,i,stop[1],stop[2]); //z-current if (m_stop_inside[0] && m_stop_inside[1]) - for (unsigned int i=start[2]+1;i<=stop[2];++i) + for (unsigned int i=start[2]+1; i<=stop[2]; ++i) current-=Eng->GetCurr(2,stop[0],stop[1],i); //x-current if (m_start_inside[1] && m_start_inside[2]) - for (unsigned int i=start[0]+1;i<=stop[0];++i) + for (unsigned int i=start[0]+1; i<=stop[0]; ++i) current-=Eng->GetCurr(0,i,start[1],start[2]); break; case 2: //x-current if (m_start_inside[1] && m_start_inside[2]) - for (unsigned int i=start[0]+1;i<=stop[0];++i) + for (unsigned int i=start[0]+1; i<=stop[0]; ++i) current+=Eng->GetCurr(0,i,start[1],start[2]); //y-current if (m_stop_inside[0] && m_start_inside[2]) - for (unsigned int i=start[1]+1;i<=stop[1];++i) + for (unsigned int i=start[1]+1; i<=stop[1]; ++i) current+=Eng->GetCurr(1,stop[0],i,start[2]); //x-current if (m_stop_inside[1] && m_stop_inside[2]) - for (unsigned int i=start[0]+1;i<=stop[0];++i) + for (unsigned int i=start[0]+1; i<=stop[0]; ++i) current-=Eng->GetCurr(0,i,stop[1],stop[2]); //y-current if (m_start_inside[0] && m_stop_inside[2]) - for (unsigned int i=start[1]+1;i<=stop[1];++i) + for (unsigned int i=start[1]+1; i<=stop[1]; ++i) current-=Eng->GetCurr(1,start[0],i,stop[2]); break; default: diff --git a/Common/processfields.cpp b/Common/processfields.cpp index 87f2f24..957d507 100644 --- a/Common/processfields.cpp +++ b/Common/processfields.cpp @@ -29,7 +29,7 @@ ProcessFields::ProcessFields(Operator_Base* op) : Processing(op) SetSubSampling(1); SetPrecision(6); - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { numLines[n]=0; discLines[n]=NULL; @@ -38,7 +38,7 @@ ProcessFields::ProcessFields(Operator_Base* op) : Processing(op) ProcessFields::~ProcessFields() { - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { delete[] discLines[n]; discLines[n]=NULL; @@ -57,7 +57,7 @@ void ProcessFields::InitProcess() H5::H5File* file = new H5::H5File( m_filename , H5F_ACC_TRUNC ); H5::Group* group = new H5::Group( file->createGroup( "/Mesh" )); - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { hsize_t dimsf[1]; // dataset dimensions dimsf[0] = numLines[n]; @@ -66,7 +66,7 @@ void ProcessFields::InitProcess() H5::DataSet dataset = group->createDataSet( names[n].c_str(), datatype, dataspace ); //convert to float... float* array = new float[numLines[n]]; - for (unsigned int i=0;iSnapToMesh(dstop,stop,dualMesh)) cerr << "ProcessFields::DefineStartStopCoord: Warning: Snapping problem, check stop value!!" << endl; - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { // normalize order of start and stop if (start[n]>stop[n]) @@ -129,14 +129,14 @@ void ProcessFields::DefineStartStopCoord(double* dstart, double* dstop) // construct new discLines lines.clear(); - for (unsigned int i=start[n];i<=stop[n];i+=subSample[n]) + for (unsigned int i=start[n]; i<=stop[n]; i+=subSample[n]) { lines.push_back(Op->GetDiscLine(n,i,dualMesh)); } numLines[n] = lines.size(); delete[] discLines[n]; discLines[n] = new double[numLines[n]]; - for (unsigned int i=0;iSnapToMesh(dstop,stop)==false) cerr << "ProcessFields::DefineStartStopCoord: Warning: Snapping problem, check stop value!!" << endl; //create mesh - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { if (start[n]>stop[n]) { @@ -158,14 +158,14 @@ void ProcessFields::DefineStartStopCoord(double* dstart, double* dstop) // --stop[n]; // cerr << "start " << start[n] << "stop " << stop[n]; lines.clear(); - for (unsigned int i=start[n];i<=stop[n];i+=subSample[n]) + for (unsigned int i=start[n]; i<=stop[n]; i+=subSample[n]) { lines.push_back(Op->GetDiscLine(n,i));//0.5*(Op->discLines[n][i+1] + Op->discLines[n][i])); } numLines[n] = lines.size(); delete[] discLines[n]; discLines[n] = new double[numLines[n]]; - for (unsigned int i=0;iSnapToMesh(dstop,stop,true)==false) cerr << "ProcessFields::DefineStartStopCoord: Warning: Snapping problem, check stop value!!" << endl; //create dual mesh - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { - // cerr << "start " << start[n] << "stop " << stop[n]; + // cerr << "start " << start[n] << "stop " << stop[n]; if (start[n]>stop[n]) { unsigned int help = start[n]; @@ -186,27 +186,28 @@ void ProcessFields::DefineStartStopCoord(double* dstart, double* dstop) } ++stop[n]; lines.clear(); - for (unsigned int i=start[n];iGetDiscLine(n,i,true));//0.5*(Op->discLines[n][i+1] + Op->discLines[n][i])); } numLines[n] = lines.size(); delete[] discLines[n]; discLines[n] = new double[numLines[n]]; - for (unsigned int i=0;iGetDiscLine( 0, start[0], dualMesh ) << "," - << Op->GetDiscLine( 1, start[1], dualMesh ) << "," << Op->GetDiscLine( 2, start[2], dualMesh ) << ") -> (" - << Op->GetDiscLine( 0, stop[0], dualMesh ) << ","<< Op->GetDiscLine( 1, stop[1], dualMesh ) << "," - << Op->GetDiscLine( 2, stop[2], dualMesh ) << ")"; + << Op->GetDiscLine( 1, start[1], dualMesh ) << "," << Op->GetDiscLine( 2, start[2], dualMesh ) << ") -> (" + << Op->GetDiscLine( 0, stop[0], dualMesh ) << ","<< Op->GetDiscLine( 1, stop[1], dualMesh ) << "," + << Op->GetDiscLine( 2, stop[2], dualMesh ) << ")"; cerr << " [" << start[0] << "," << start[1] << "," << start[2] << "] -> [" - << stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl; + << stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl; } } @@ -222,11 +223,11 @@ double ProcessFields::CalcTotalEnergy() const const Engine* Eng = EI_FDTD->GetFDTDEngine(); unsigned int pos[3]; - for (pos[0]=0;pos[0]GetNumberOfLines(0);++pos[0]) + for (pos[0]=0; pos[0]GetNumberOfLines(0); ++pos[0]) { - for (pos[1]=0;pos[1]GetNumberOfLines(1);++pos[1]) + for (pos[1]=0; pos[1]GetNumberOfLines(1); ++pos[1]) { - for (pos[2]=0;pos[2]GetNumberOfLines(2);++pos[2]) + for (pos[2]=0; pos[2]GetNumberOfLines(2); ++pos[2]) { energy+=fabs(Eng->GetVolt(0,pos[0],pos[1],pos[2]) * Eng->GetCurr(1,pos[0],pos[1],pos[2])); energy+=fabs(Eng->GetVolt(0,pos[0],pos[1],pos[2]) * Eng->GetCurr(2,pos[0],pos[1],pos[2])); @@ -274,15 +275,15 @@ void ProcessFields::WriteVTKCartesianGridHeader(ofstream &file, double const* co file << "DATASET RECTILINEAR_GRID " << endl; file << "DIMENSIONS " << numLines[0] << " " << numLines[1] << " " << numLines[2] << endl; file << "X_COORDINATES " << numLines[0] << " " << __VTK_DATA_TYPE__ << endl; - for (unsigned int i=0;i(numLines); if (m_DumpType==E_FIELD_DUMP) { - for (pos[0]=0;pos[0]GetEField(OpPos,out); @@ -80,13 +80,13 @@ int ProcessFieldsTD::Process() if (m_DumpType==H_FIELD_DUMP) { - for (pos[0]=0;pos[0]GetHField(OpPos,out); @@ -101,7 +101,10 @@ int ProcessFieldsTD::Process() if (m_fileType==VTK_FILETYPE) { ofstream file(filename.c_str()); - if (file.is_open()==false) { cerr << "ProcessFieldsTD::Process: can't open file '" << filename << "' for writing... abort! " << endl;}; + if (file.is_open()==false) + { + cerr << "ProcessFieldsTD::Process: can't open file '" << filename << "' for writing... abort! " << endl; + }; DumpVectorArray2VTK(file,GetFieldNameByType(m_DumpType),field,discLines,numLines,m_precision,string("Interpolation: ")+m_Eng_Interface->GetInterpolationTypeString(), m_Mesh_Type, discLines_scaling); file.close(); } diff --git a/Common/processing.cpp b/Common/processing.cpp index 916fe78..251baf9 100644 --- a/Common/processing.cpp +++ b/Common/processing.cpp @@ -113,7 +113,7 @@ void Processing::AddStep(unsigned int step) void Processing::AddSteps(vector steps) { - for (size_t n=0;n *freqs) { - for (size_t n=0;nsize();++n) + for (size_t n=0; nsize(); ++n) { AddFrequency(freqs->at(n)); } @@ -156,13 +156,14 @@ void Processing::DefineStartStopCoord(double* dstart, double* dstop) if (Op->SnapToMesh(dstop,stop,m_dualMesh,m_stop_inside)==false) cerr << "Processing::DefineStartStopCoord: Warning: Snapped line outside field domain!!" << endl; - if (g_settings.showProbeDiscretization()) { + if (g_settings.showProbeDiscretization()) + { cerr << m_Name << ": snapped coords: (" << Op->GetDiscLine( 0, start[0], m_dualMesh ) << "," - << Op->GetDiscLine( 1, start[1], m_dualMesh ) << "," << Op->GetDiscLine( 2, start[2], m_dualMesh ) << ") -> (" - << Op->GetDiscLine( 0, stop[0], m_dualMesh ) << ","<< Op->GetDiscLine( 1, stop[1], m_dualMesh ) << "," - << Op->GetDiscLine( 2, stop[2], m_dualMesh ) << ")"; + << Op->GetDiscLine( 1, start[1], m_dualMesh ) << "," << Op->GetDiscLine( 2, start[2], m_dualMesh ) << ") -> (" + << Op->GetDiscLine( 0, stop[0], m_dualMesh ) << ","<< Op->GetDiscLine( 1, stop[1], m_dualMesh ) << "," + << Op->GetDiscLine( 2, stop[2], m_dualMesh ) << ")"; cerr << " [" << start[0] << "," << start[1] << "," << start[2] << "] -> [" - << stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl; + << stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl; } } @@ -191,15 +192,18 @@ void Processing::DumpBox2File( string vtkfilenameprefix, bool dualMesh ) const // normalize coordinates double s1[3], s2[3]; - for (int i=0; i<3; i++) { + for (int i=0; i<3; i++) + { s1[i] = min(Op->GetDiscLine(i,start[i],dualMesh),Op->GetDiscLine(i,stop[i],dualMesh)); s2[i] = max(Op->GetDiscLine(i,start[i],dualMesh),Op->GetDiscLine(i,stop[i],dualMesh)); } // fix degenerate box/plane -> line (paraview display problem) - if (((s1[0] == s2[0]) && (s1[1] == s2[1])) || ((s1[0] == s2[0]) && (s1[2] == s2[2])) || ((s1[2] == s2[2]) && (s1[1] == s2[1]))) { + if (((s1[0] == s2[0]) && (s1[1] == s2[1])) || ((s1[0] == s2[0]) && (s1[2] == s2[2])) || ((s1[2] == s2[2]) && (s1[1] == s2[1]))) + { // line are not displayed correctly -> enlarge - for (int i=0; i<3; i++) { + for (int i=0; i<3; i++) + { double delta = min( Op->GetMeshDelta( i, start,dualMesh ), Op->GetMeshDelta( i, stop,dualMesh ) ) / Op->GetGridDelta() / 4.0; s1[i] -= delta; s2[i] += delta; @@ -209,7 +213,8 @@ void Processing::DumpBox2File( string vtkfilenameprefix, bool dualMesh ) const // rescale coordinates #ifndef OUTPUT_IN_DRAWINGUNITS double scaling = Op->GetGridDelta(); - for (int i=0; i<3; i++) { + for (int i=0; i<3; i++) + { s1[i] *= scaling; s2[i] *= scaling; } @@ -243,9 +248,9 @@ void Processing::DumpBox2File( string vtkfilenameprefix, bool dualMesh ) const void Processing::Dump_FD_Data(vector value, double factor, string filename) { - if (value.size()==0) + if (value.size()==0) return; - if (value.size()!=m_FD_Samples.size()) + if (value.size()!=m_FD_Samples.size()) { cerr << "Processing::Dump_FD_Data: Error: Complex value and frequency vector have different size! This should never happend!!!" << endl; return; @@ -258,7 +263,7 @@ void Processing::Dump_FD_Data(vector value, double factor, strin time_t rawTime; time(&rawTime); file << "%dump by openEMS @" << ctime(&rawTime) << "%frequency\treal\timag\n"; - for (size_t n=0;nFlushNext(); } @@ -280,7 +285,7 @@ void ProcessingArray::FlushNext() void ProcessingArray::Reset() { - for (size_t i=0;iReset(); } @@ -288,7 +293,7 @@ void ProcessingArray::Reset() void ProcessingArray::DeleteAll() { - for (size_t i=0;iProcess(); if ((step>0) && (stepDumpBox2File( vtkfilenameprefix ); } diff --git a/Common/processintegral.cpp b/Common/processintegral.cpp index f9ded38..94d8c7b 100644 --- a/Common/processintegral.cpp +++ b/Common/processintegral.cpp @@ -37,7 +37,7 @@ void ProcessIntegral::InitProcess() m_filename = m_Name; OpenFile(m_filename); FD_Values.clear(); - for (size_t n=0;nGetNumberOfTimesteps()%m_FD_Interval==0) { double T = time; - for (size_t n=0;nSetInterpolationType(Engine_Interface_Base::NODE_INTERPOLATE); int Dump_Dim=0; - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { if (start[n]>stop[n]) { @@ -96,7 +96,7 @@ void ProcessModeMatch::InitProcess() return; } - for (int n=0;n<2;++n) + for (int n=0; n<2; ++n) { int ny = (m_ny+n+1)%3; int res = m_ModeParser[n]->Parse(m_ModeFunction[ny], "x,y,z,rho,a,r,t"); @@ -109,7 +109,7 @@ void ProcessModeMatch::InitProcess() } } - for (int n=0;n<2;++n) + for (int n=0; n<2; ++n) { m_ModeDist[n] = Create2DArray(m_numLines); } @@ -122,11 +122,11 @@ void ProcessModeMatch::InitProcess() discLine[m_ny] = Op->GetDiscLine(m_ny,pos[m_ny],m_dualMesh); double norm = 0; double area = 0; - for (unsigned int posP = 0;posPGetDiscLine(nP,pos[nP],m_dualMesh); - for (unsigned int posPP = 0;posPPGetDiscLine(nPP,pos[nPP],m_dualMesh); @@ -149,7 +149,7 @@ void ProcessModeMatch::InitProcess() var[6] = asin(1)-atan(var[2]/var[3]); //theta (t) } area = Op->GetNodeArea(m_ny,pos,m_dualMesh); - for (int n=0;n<2;++n) + for (int n=0; n<2; ++n) { m_ModeDist[n][posP][posPP] = m_ModeParser[n]->Eval(var); //calc mode template if ((isnan(m_ModeDist[n][posP][posPP])) || (isinf(m_ModeDist[n][posP][posPP]))) @@ -163,10 +163,10 @@ void ProcessModeMatch::InitProcess() norm = sqrt(norm); // cerr << norm << endl; // normalize template function... - for (unsigned int posP = 0;posP(m_ModeDist[n],m_numLines); m_ModeDist[n] = NULL; @@ -215,10 +215,10 @@ double* ProcessModeMatch::CalcMultipleIntegrals() double out[3]={0,0,0}; - for (unsigned int posP = 0;posPGetNodeArea(m_ny,pos,m_dualMesh); @@ -227,7 +227,7 @@ double* ProcessModeMatch::CalcMultipleIntegrals() if (m_ModeFieldType==1) m_Eng_Interface->GetHField(pos,out); - for (int n=0;n<2;++n) + for (int n=0; n<2; ++n) { field = out[(m_ny+n+1)%3]; value += field * m_ModeDist[n][posP][posPP] * area; diff --git a/FDTD/engine.cpp b/FDTD/engine.cpp index 30e3671..9d1dc9f 100644 --- a/FDTD/engine.cpp +++ b/FDTD/engine.cpp @@ -35,7 +35,7 @@ Engine::Engine(const Operator* op) m_type = BASIC; numTS = 0; Op = op; - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) numLines[n] = Op->GetOriginalNumLines(n); volt=NULL; curr=NULL; @@ -61,7 +61,7 @@ void Engine::Init() void Engine::InitExtensions() { - for (size_t n=0;nGetNumberOfExtentions();++n) + for (size_t n=0; nGetNumberOfExtentions(); ++n) { Operator_Extension* op_ext = Op->GetExtension(n); Engine_Extension* eng_ext = op_ext->CreateEngineExtention(); @@ -75,7 +75,7 @@ void Engine::InitExtensions() void Engine::ClearExtensions() { - for (size_t n=0;nExc->Volt_Count;++n) + for (unsigned int n=0; nExc->Volt_Count; ++n) { exc_pos = (int)numTS - (int)Op->Exc->Volt_delay[n]; exc_pos *= (exc_pos>0 && exc_pos<=(int)Op->Exc->Length); @@ -165,11 +165,11 @@ void Engine::UpdateCurrents(unsigned int startX, unsigned int numX) { unsigned int pos[3]; pos[0] = startX; - for (unsigned int posX=0;posXExc->Curr_Count;++n) + for (unsigned int n=0; nExc->Curr_Count; ++n) { exc_pos = (int)numTS - (int)Op->Exc->Curr_delay[n]; exc_pos *= (exc_pos>0 && exc_pos<=(int)Op->Exc->Length); @@ -215,7 +215,7 @@ void Engine::ApplyCurrentExcite() void Engine::DoPreVoltageUpdates() { //execute extensions in reverse order -> highest priority gets access to the voltages last - for (int n=m_Eng_exts.size()-1;n>=0;--n) + for (int n=m_Eng_exts.size()-1; n>=0; --n) m_Eng_exts.at(n)->DoPreVoltageUpdates(); } @@ -223,41 +223,41 @@ void Engine::DoPreVoltageUpdates() void Engine::DoPostVoltageUpdates() { //execute extensions in normal order -> highest priority gets access to the voltages first - for (size_t n=0;nDoPostVoltageUpdates(); } void Engine::Apply2Voltages() { //execute extensions in normal order -> highest priority gets access to the voltages first - for (size_t n=0;nApply2Voltages(); } void Engine::DoPreCurrentUpdates() { //execute extensions in reverse order -> highest priority gets access to the currents last - for (int n=m_Eng_exts.size()-1;n>=0;--n) + for (int n=m_Eng_exts.size()-1; n>=0; --n) m_Eng_exts.at(n)->DoPreCurrentUpdates(); } void Engine::DoPostCurrentUpdates() { //execute extensions in normal order -> highest priority gets access to the currents first - for (size_t n=0;nDoPostCurrentUpdates(); } void Engine::Apply2Current() { //execute extensions in normal order -> highest priority gets access to the currents first - for (size_t n=0;nApply2Current(); } bool Engine::IterateTS(unsigned int iterTS) { - for (unsigned int iter=0;iter #include "operator.h" -namespace NS_Engine_Multithread { - class thread; // evil hack to access numTS from multithreading context +namespace NS_Engine_Multithread +{ +class thread; // evil hack to access numTS from multithreading context } class Engine_Extension; diff --git a/FDTD/engine_cylindermultigrid.cpp b/FDTD/engine_cylindermultigrid.cpp index 956472c..480f23a 100644 --- a/FDTD/engine_cylindermultigrid.cpp +++ b/FDTD/engine_cylindermultigrid.cpp @@ -47,7 +47,7 @@ Engine_CylinderMultiGrid::Engine_CylinderMultiGrid(const Operator_CylinderMultiG m_InnerEng_Ext_MG->SetBarrier(m_WaitOnBase, m_WaitOnChild, m_WaitOnSync); // if already has a base extension, switch places ... seems to be faster... - for (size_t n=0;nm_Eng_exts.size();++n) + for (size_t n=0; nm_Eng_exts.size(); ++n) { Engine_Ext_CylinderMultiGrid* eng_mg = dynamic_cast(m_InnerEngine->m_Eng_exts.at(n)); if (eng_mg) @@ -114,9 +114,9 @@ bool Engine_CylinderMultiGrid::IterateTS(unsigned int iterTS) m_stopBarrier->wait(); //tell base and child to wait for another start event... //interpolate child data to base mesh... - for (unsigned int n=0;nm_Split_Pos-1;++n) + for (unsigned int n=0; nm_Split_Pos-1; ++n) InterpolVoltChild2Base(n); - for (unsigned int n=0;nm_Split_Pos-2;++n) + for (unsigned int n=0; nm_Split_Pos-2; ++n) InterpolCurrChild2Base(n); return true; @@ -131,7 +131,7 @@ void Engine_CylinderMultiGrid::InterpolVoltChild2Base(unsigned int rzPlane) pos[0] = rzPlane; bool isOdd, isEven; f4vector half, one_eighth, three_eighth; - for (int n=0;n<4;++n) + for (int n=0; n<4; ++n) { half.f[n]=0.5; one_eighth.f[n] = 1.0/8.0; @@ -195,7 +195,7 @@ void Engine_CylinderMultiGrid::InterpolCurrChild2Base(unsigned int rzPlane) pos[0] = rzPlane; bool isOdd, isEven; f4vector one_fourth, three_fourth; - for (int n=0;n<4;++n) + for (int n=0; n<4; ++n) { one_fourth.f[n] = 1.0/4.0; three_fourth.f[n] = 3.0/4.0; @@ -263,7 +263,7 @@ void Engine_CylinderMultiGrid_Thread::operator()() { m_startBarrier->wait(); //wait for Base engine to start the iterations... - while(*m_numTS>0) //m_numTS==0 request to terminate this thread... + while (*m_numTS>0) //m_numTS==0 request to terminate this thread... { if (m_isBase) m_Eng->Engine_Multithread::IterateTS(*m_numTS); diff --git a/FDTD/engine_cylindermultigrid.h b/FDTD/engine_cylindermultigrid.h index ac2f276..6adaa55 100644 --- a/FDTD/engine_cylindermultigrid.h +++ b/FDTD/engine_cylindermultigrid.h @@ -28,7 +28,7 @@ class Engine_CylinderMultiGrid : public Engine_Multithread { friend class Engine_Ext_CylinderMultiGrid; public: - Engine_CylinderMultiGrid(); + Engine_CylinderMultiGrid(); static Engine_CylinderMultiGrid* New(const Operator_CylinderMultiGrid* op, unsigned int numThreads = 0); virtual ~Engine_CylinderMultiGrid(); @@ -53,7 +53,7 @@ protected: boost::barrier *m_stopBarrier; Engine_CylinderMultiGrid_Thread* m_IteratorThread; Engine_CylinderMultiGrid_Thread* m_InnerIteratorThread; - + //extension barrier boost::barrier *m_WaitOnBase; boost::barrier *m_WaitOnChild; diff --git a/FDTD/engine_interface_fdtd.cpp b/FDTD/engine_interface_fdtd.cpp index 19169e0..a01c4e1 100644 --- a/FDTD/engine_interface_fdtd.cpp +++ b/FDTD/engine_interface_fdtd.cpp @@ -42,7 +42,7 @@ double* Engine_Interface_FDTD::GetEField(const unsigned int* pos, double* out) c { default: case NO_INTERPOLATION: - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { delta = m_Op->GetEdgeLength(n,pos,false); if (delta) @@ -52,7 +52,7 @@ double* Engine_Interface_FDTD::GetEField(const unsigned int* pos, double* out) c } break; case NODE_INTERPOLATE: - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { delta = m_Op->GetMeshDelta(n,iPos); out[n] = m_Eng->GetVolt(n,iPos); @@ -74,7 +74,7 @@ double* Engine_Interface_FDTD::GetEField(const unsigned int* pos, double* out) c } break; case CELL_INTERPOLATE: - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { nP = (n+1)%3; nPP = (n+2)%3; @@ -120,7 +120,7 @@ double* Engine_Interface_FDTD::GetHField(const unsigned int* pos, double* out) c out[2] = m_Eng->GetCurr(2,pos) / m_Op->GetEdgeLength(2,pos,true); break; case NODE_INTERPOLATE: - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { nP = (n+1)%3; nPP = (n+2)%3; @@ -141,7 +141,7 @@ double* Engine_Interface_FDTD::GetHField(const unsigned int* pos, double* out) c } break; case CELL_INTERPOLATE: - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { delta = m_Op->GetMeshDelta(n,iPos,true); out[n] = m_Eng->GetCurr(n,iPos); @@ -165,18 +165,18 @@ double* Engine_Interface_FDTD::GetHField(const unsigned int* pos, double* out) c double Engine_Interface_FDTD::CalcVoltageIntegral(const unsigned int* start, const unsigned int* stop) const { double result=0; - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { if (start[n]GetVolt(n,pos[0],pos[1],pos[2]); } else { unsigned int pos[3]={stop[0],stop[1],stop[2]}; - for (;pos[n]GetVolt(n,pos[0],pos[1],pos[2]); } } diff --git a/FDTD/engine_multithread.cpp b/FDTD/engine_multithread.cpp index 05ee0ce..0007955 100644 --- a/FDTD/engine_multithread.cpp +++ b/FDTD/engine_multithread.cpp @@ -18,9 +18,9 @@ //#define ENABLE_DEBUG_TIME #ifdef ENABLE_DEBUG_TIME - #define DEBUG_TIME(x) x; +#define DEBUG_TIME(x) x; #else - #define DEBUG_TIME(x) ; +#define DEBUG_TIME(x) ; #endif @@ -58,10 +58,12 @@ Engine_Multithread::~Engine_Multithread() #ifdef ENABLE_DEBUG_TIME NS_Engine_Multithread::DBG().cout() << "Engine_Multithread::~Engine_Multithread()" << endl; std::map >::iterator it; - for (it=m_timer_list.begin(); it!=m_timer_list.end(); it++) { + for (it=m_timer_list.begin(); it!=m_timer_list.end(); it++) + { NS_Engine_Multithread::DBG().cout() << "*** DEBUG Thread: " << it->first << std::endl; std::vector::iterator it2; - for (it2=it->second.begin(); it2second.end();) { + for (it2=it->second.begin(); it2second.end();) + { NS_Engine_Multithread::DBG().cout() << "after voltage update, before barrier1: " << fixed << setprecision(6) << *(it2++) << std::endl; NS_Engine_Multithread::DBG().cout() << "after barrier1, before barrier2: " << fixed << setprecision(6) << *(it2++) << std::endl; NS_Engine_Multithread::DBG().cout() << "after barrier2, before current update: " << fixed << setprecision(6) << *(it2++) << std::endl; @@ -117,7 +119,7 @@ void Engine_Multithread::Init() m_thread_group.add_thread( t ); } - for (size_t n=0;nSetNumberOfThreads(m_numThreads); } @@ -134,9 +136,12 @@ void Engine_Multithread::Reset() m_stopThreads = true; m_stopBarrier->wait(); // wait for the threads to finish m_thread_group.join_all(); // wait for termination - delete m_IterateBarrier; m_IterateBarrier = 0; - delete m_startBarrier; m_startBarrier = 0; - delete m_stopBarrier; m_stopBarrier = 0; + delete m_IterateBarrier; + m_IterateBarrier = 0; + delete m_startBarrier; + m_startBarrier = 0; + delete m_stopBarrier; + m_stopBarrier = 0; } Engine_SSE_Compressed::Reset(); @@ -158,7 +163,7 @@ bool Engine_Multithread::IterateTS(unsigned int iterTS) void Engine_Multithread::DoPreVoltageUpdates(int threadID) { //execute extensions in reverse order -> highest priority gets access to the voltages last - for (int n=m_Eng_exts.size()-1;n>=0;--n) + for (int n=m_Eng_exts.size()-1; n>=0; --n) { m_Eng_exts.at(n)->DoPreVoltageUpdates(threadID); m_IterateBarrier->wait(); @@ -169,7 +174,7 @@ void Engine_Multithread::DoPreVoltageUpdates(int threadID) void Engine_Multithread::DoPostVoltageUpdates(int threadID) { //execute extensions in normal order -> highest priority gets access to the voltages first - for (size_t n=0;nDoPostVoltageUpdates(threadID); m_IterateBarrier->wait(); @@ -179,7 +184,7 @@ void Engine_Multithread::DoPostVoltageUpdates(int threadID) void Engine_Multithread::Apply2Voltages(int threadID) { //execute extensions in normal order -> highest priority gets access to the voltages first - for (size_t n=0;nApply2Voltages(threadID); m_IterateBarrier->wait(); @@ -189,7 +194,7 @@ void Engine_Multithread::Apply2Voltages(int threadID) void Engine_Multithread::DoPreCurrentUpdates(int threadID) { //execute extensions in reverse order -> highest priority gets access to the currents last - for (int n=m_Eng_exts.size()-1;n>=0;--n) + for (int n=m_Eng_exts.size()-1; n>=0; --n) { m_Eng_exts.at(n)->DoPreCurrentUpdates(threadID); m_IterateBarrier->wait(); @@ -199,7 +204,7 @@ void Engine_Multithread::DoPreCurrentUpdates(int threadID) void Engine_Multithread::DoPostCurrentUpdates(int threadID) { //execute extensions in normal order -> highest priority gets access to the currents first - for (size_t n=0;nDoPostCurrentUpdates(threadID); m_IterateBarrier->wait(); @@ -209,7 +214,7 @@ void Engine_Multithread::DoPostCurrentUpdates(int threadID) void Engine_Multithread::Apply2Current(int threadID) { //execute extensions in normal order -> highest priority gets access to the currents first - for (size_t n=0;nApply2Current(threadID); m_IterateBarrier->wait(); @@ -219,7 +224,8 @@ void Engine_Multithread::Apply2Current(int threadID) // // ************************************************************************************************************************* // -namespace NS_Engine_Multithread { +namespace NS_Engine_Multithread +{ thread::thread( Engine_Multithread* ptr, unsigned int start, unsigned int stop, unsigned int stop_h, unsigned int threadID ) { @@ -236,7 +242,8 @@ void thread::operator()() //DBG().cout() << "Thread " << m_threadID << " (" << boost::this_thread::get_id() << ") started." << endl; - while (!m_enginePtr->m_stopThreads) { + while (!m_enginePtr->m_stopThreads) + { // wait for start //DBG().cout() << "Thread " << m_threadID << " (" << boost::this_thread::get_id() << ") waiting..." << endl; m_enginePtr->m_startBarrier->wait(); @@ -244,7 +251,7 @@ void thread::operator()() DEBUG_TIME( Timer timer1 ); - for (unsigned int iter=0;iterm_iterTS;++iter) + for (unsigned int iter=0; iterm_iterTS; ++iter) { // pre voltage stuff... m_enginePtr->DoPreVoltageUpdates(m_threadID); diff --git a/FDTD/engine_multithread.h b/FDTD/engine_multithread.h index 9662f4d..9e72159 100644 --- a/FDTD/engine_multithread.h +++ b/FDTD/engine_multithread.h @@ -34,34 +34,38 @@ class Engine_Multithread; -namespace NS_Engine_Multithread { +namespace NS_Engine_Multithread +{ - class DBG { // debug - public: - DBG() {} - ~DBG() { std::cout << os.str();} - std::ostringstream& cout() {return os;} - protected: - std::ostringstream os; - }; +class DBG // debug +{ +public: + DBG() {} + ~DBG() { std::cout << os.str();} + std::ostringstream& cout() {return os;} +protected: + std::ostringstream os; +}; - class Timer { //debug - public: - Timer() {gettimeofday(&t1,NULL);} - double elapsed() {gettimeofday(&t2,NULL); return (t2.tv_sec-t1.tv_sec) + (t2.tv_usec-t1.tv_usec)*1e-6;} - protected: - timeval t1,t2; - }; +class Timer //debug +{ +public: + Timer() {gettimeofday(&t1,NULL);} + double elapsed() {gettimeofday(&t2,NULL); return (t2.tv_sec-t1.tv_sec) + (t2.tv_usec-t1.tv_usec)*1e-6;} +protected: + timeval t1,t2; +}; - class thread { - public: - thread( Engine_Multithread* ptr, unsigned int start, unsigned int stop, unsigned int stop_h, unsigned int threadID ); - void operator()(); +class thread +{ +public: + thread( Engine_Multithread* ptr, unsigned int start, unsigned int stop, unsigned int stop_h, unsigned int threadID ); + void operator()(); - protected: - unsigned int m_start, m_stop, m_stop_h, m_threadID; - Engine_Multithread *m_enginePtr; - }; +protected: + unsigned int m_start, m_stop, m_stop_h, m_threadID; + Engine_Multithread *m_enginePtr; +}; } // namespace diff --git a/FDTD/engine_sse.cpp b/FDTD/engine_sse.cpp index 02bcecf..b075a49 100644 --- a/FDTD/engine_sse.cpp +++ b/FDTD/engine_sse.cpp @@ -79,13 +79,13 @@ void Engine_sse::UpdateVoltages(unsigned int startX, unsigned int numX) f4vector temp; pos[0] = startX; - for (unsigned int posX=0;posXf4_vv[0][pos[0]][pos[1]][pos[2]].v; @@ -131,11 +131,11 @@ void Engine_sse::UpdateCurrents(unsigned int startX, unsigned int numX) f4vector temp; pos[0] = startX; - for (unsigned int posX=0;posXf4_ii[0][pos[0]][pos[1]][pos[2]].v; diff --git a/FDTD/engine_sse_compressed.cpp b/FDTD/engine_sse_compressed.cpp index a54bc52..8e83387 100644 --- a/FDTD/engine_sse_compressed.cpp +++ b/FDTD/engine_sse_compressed.cpp @@ -17,7 +17,7 @@ #include "engine_sse_compressed.h" #ifdef __SSE2__ - #include +#include #endif Engine_SSE_Compressed* Engine_SSE_Compressed::New(const Operator_SSE_Compressed* op) @@ -45,13 +45,13 @@ void Engine_SSE_Compressed::UpdateVoltages(unsigned int startX, unsigned int num pos[0] = startX; unsigned int index=0; - for (unsigned int posX=0;posXm_Op_index[pos[0]][pos[1]][pos[2]]; // x-polarization @@ -108,11 +108,11 @@ void Engine_SSE_Compressed::UpdateCurrents(unsigned int startX, unsigned int num pos[0] = startX; unsigned int index; - for (unsigned int posX=0;posXm_Op_index[pos[0]][pos[1]][pos[2]]; // x-pol diff --git a/FDTD/excitation.cpp b/FDTD/excitation.cpp index 4fac237..f228874 100644 --- a/FDTD/excitation.cpp +++ b/FDTD/excitation.cpp @@ -34,7 +34,8 @@ Excitation::Excitation( double timestep ) Curr_dir = 0; Curr_Count = 0; - for (int n=0;n<3;++n) { + for (int n=0; n<3; ++n) + { Volt_index[n] = 0; Curr_index[n] = 0; Volt_Count_Dir[n] = 0; @@ -55,7 +56,8 @@ Excitation::~Excitation() delete[] Curr_delay; delete[] Curr_dir; delete[] Curr_amp; - for (int n=0;n<3;++n) { + for (int n=0; n<3; ++n) + { delete[] Volt_index[n]; delete[] Curr_index[n]; } @@ -64,7 +66,8 @@ Excitation::~Excitation() bool Excitation::setupExcitation( TiXmlElement* Excite, unsigned int maxTS ) { - if (!Excite) { + if (!Excite) + { cerr << "Can't read openEMS excitation settings... " << endl; return false; } @@ -76,28 +79,28 @@ bool Excitation::setupExcitation( TiXmlElement* Excite, unsigned int maxTS ) switch (Excit_Type) { - case 0: - Excite->QueryDoubleAttribute("f0",&f0); - Excite->QueryDoubleAttribute("fc",&fc); - CalcGaussianPulsExcitation(f0,fc,maxTS); - break; - case 1: - Excite->QueryDoubleAttribute("f0",&f0); - CalcSinusExcitation(f0,maxTS); - break; - case 2: - CalcDiracPulsExcitation(); - break; - case 3: - CalcStepExcitation(); - break; - case 10: - Excite->QueryDoubleAttribute("f0",&f0); - CalcCustomExcitation(f0,maxTS,Excite->Attribute("Function")); - break; - default: - cerr << "Excitation::setupExcitation: Unknown excitation type: \"" << Excit_Type<< "\" !!" << endl; - return false; + case 0: + Excite->QueryDoubleAttribute("f0",&f0); + Excite->QueryDoubleAttribute("fc",&fc); + CalcGaussianPulsExcitation(f0,fc,maxTS); + break; + case 1: + Excite->QueryDoubleAttribute("f0",&f0); + CalcSinusExcitation(f0,maxTS); + break; + case 2: + CalcDiracPulsExcitation(); + break; + case 3: + CalcStepExcitation(); + break; + case 10: + Excite->QueryDoubleAttribute("f0",&f0); + CalcCustomExcitation(f0,maxTS,Excite->Attribute("Function")); + break; + default: + cerr << "Excitation::setupExcitation: Unknown excitation type: \"" << Excit_Type<< "\" !!" << endl; + return false; } if (GetNyquistNum() == 0) @@ -113,7 +116,7 @@ unsigned int Excitation::GetMaxExcitationTimestep() const { FDTD_FLOAT maxAmp=0; unsigned int maxStep=0; - for (unsigned int n=1;nmaxAmp) { @@ -141,7 +144,7 @@ void Excitation::CalcGaussianPulsExcitation(double f0, double fc, int nTS) Signal_curr = new FDTD_FLOAT[Length+1]; Signal_volt[0]=0.0; Signal_curr[0]=0.0; - for (unsigned int n=1;n const volt_vIndex[3], vector const& volt_vExcit, - vector const& volt_vDelay, vector const& volt_vDir ) + vector const& volt_vDelay, vector const& volt_vDir ) { Volt_Count = volt_vIndex[0].size(); for (int n=0; n<3; n++) @@ -278,7 +281,7 @@ void Excitation::setupVoltageExcitation( vector const volt_vIndex[ } void Excitation::setupCurrentExcitation( vector const curr_vIndex[3], vector const& curr_vExcit, - vector const& curr_vDelay, vector const& curr_vDir ) + vector const& curr_vDelay, vector const& curr_vDir ) { Curr_Count = curr_vIndex[0].size(); for (int n=0; n<3; n++) @@ -297,7 +300,7 @@ void Excitation::setupCurrentExcitation( vector const curr_vIndex[ // cerr << "Excitation::setupCurrentExcitation(): Number of current excitation points: " << Curr_Count << endl; // if (Curr_Count==0) // cerr << "No H-Field/current excitation found!" << endl; - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) for (unsigned int i=0; i const volt_vIndex[3], vector const& volt_vExcit, - vector const& volt_vDelay, vector const& volt_vDir ); + vector const& volt_vDelay, vector const& volt_vDir ); void setupCurrentExcitation( vector const curr_vIndex[3], vector const& curr_vExcit, - vector const& curr_vDelay, vector const& curr_vDir ); + vector const& curr_vDelay, vector const& curr_vDir ); void SetNyquistNum(unsigned int nyquist) {m_nyquistTS=nyquist;} unsigned int GetNyquistNum() const {return m_nyquistTS;} diff --git a/FDTD/extensions/engine_ext_cylinder.cpp b/FDTD/extensions/engine_ext_cylinder.cpp index e7720c3..f7a7d3c 100644 --- a/FDTD/extensions/engine_ext_cylinder.cpp +++ b/FDTD/extensions/engine_ext_cylinder.cpp @@ -26,7 +26,7 @@ Engine_Ext_Cylinder::Engine_Ext_Cylinder(Operator_Ext_Cylinder* op_ext) : Engine CC_closedAlpha = op_ext->CC_closedAlpha; CC_R0_included = op_ext->CC_R0_included; - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) numLines[n] = op_ext->m_Op->GetOriginalNumLines(n); //this cylindrical extension should be executed first? @@ -41,17 +41,17 @@ void Engine_Ext_Cylinder::Apply2Voltages() { unsigned int pos[3]; pos[0] = 0; - for (pos[2]=0;pos[2]SetVolt(2,0,0,pos[2], m_Eng->GetVolt(2,0,0,pos[2])*cyl_Op->vv_R0[pos[2]]); - for (pos[1]=0;pos[1]SetVolt(2,0,0,pos[2], m_Eng->GetVolt(2,0,0,pos[2]) + cyl_Op->vi_R0[pos[2]] * m_Eng->GetCurr(1,0,pos[1],pos[2]) ); + m_Eng->SetVolt(2,0,0,pos[2], m_Eng->GetVolt(2,0,0,pos[2]) + cyl_Op->vi_R0[pos[2]] * m_Eng->GetCurr(1,0,pos[1],pos[2]) ); } } - for (pos[1]=0;pos[1]SetVolt(1,0,pos[1],pos[2], 0); //no voltage in alpha-direction at r=0 m_Eng->SetVolt(2,0,pos[1],pos[2], m_Eng->GetVolt(2,0,0,pos[2]) ); @@ -63,9 +63,9 @@ void Engine_Ext_Cylinder::Apply2Voltages() unsigned int pos[3]; // copy voltages from last alpha-plane to first unsigned int last_A_Line = numLines[1]-1; - for (pos[0]=0;pos[0]SetVolt(0,pos[0],0,pos[2], m_Eng->GetVolt(0,pos[0],last_A_Line,pos[2]) ); m_Eng->SetVolt(1,pos[0],0,pos[2], m_Eng->GetVolt(1,pos[0],last_A_Line,pos[2]) ); @@ -81,10 +81,10 @@ void Engine_Ext_Cylinder::Apply2Current() //close alpha unsigned int pos[3]; // copy currents from first alpha-plane to last - for (pos[0]=0;pos[0]SetCurr(0,pos[0],last_A_Line,pos[2], m_Eng->GetCurr(0,pos[0],0,pos[2]) ); m_Eng->SetCurr(1,pos[0],last_A_Line,pos[2], m_Eng->GetCurr(1,pos[0],0,pos[2]) ); diff --git a/FDTD/extensions/engine_ext_cylindermultigrid.cpp b/FDTD/extensions/engine_ext_cylindermultigrid.cpp index f271f5c..705b447 100644 --- a/FDTD/extensions/engine_ext_cylindermultigrid.cpp +++ b/FDTD/extensions/engine_ext_cylindermultigrid.cpp @@ -96,7 +96,11 @@ void Engine_Ext_CylinderMultiGrid::SyncVoltages() unsigned int pos[3]; pos[0] = m_Eng_MG->Op_CMG->GetSplitPos()-1; unsigned int pos1_half = 0; - f4vector v_null; v_null.f[0] = 0;v_null.f[1] = 0;v_null.f[2] = 0;v_null.f[3] = 0; + f4vector v_null; + v_null.f[0] = 0; + v_null.f[1] = 0; + v_null.f[2] = 0; + v_null.f[3] = 0; for (pos[1]=0; pos[1]m_curr_ADE_On==true) { curr_ADE[n] = new FDTD_FLOAT[m_Op_Ext_Disp->m_LM_Count]; - for (unsigned int i=0;im_LM_Count;++i) + for (unsigned int i=0; im_LM_Count; ++i) curr_ADE[n][i]=0.0; } else @@ -35,7 +35,7 @@ Engine_Ext_Dispersive::Engine_Ext_Dispersive(Operator_Ext_Dispersive* op_ext_dis if (m_Op_Ext_Disp->m_volt_ADE_On==true) { volt_ADE[n] = new FDTD_FLOAT[m_Op_Ext_Disp->m_LM_Count]; - for (unsigned int i=0;im_LM_Count;++i) + for (unsigned int i=0; im_LM_Count; ++i) volt_ADE[n][i]=0.0; } else @@ -45,7 +45,7 @@ Engine_Ext_Dispersive::Engine_Ext_Dispersive(Operator_Ext_Dispersive* op_ext_dis Engine_Ext_Dispersive::~Engine_Ext_Dispersive() { - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { delete[] curr_ADE[n]; curr_ADE[n] = NULL; @@ -65,7 +65,7 @@ void Engine_Ext_Dispersive::Apply2Voltages() { case Engine::BASIC: { - for (unsigned int i=0;im_LM_Count;++i) + for (unsigned int i=0; im_LM_Count; ++i) { m_Eng->Engine::SetVolt(0,pos[0][i],pos[1][i],pos[2][i], m_Eng->Engine::GetVolt(0,pos[0][i],pos[1][i],pos[2][i]) - volt_ADE[0][i]); m_Eng->Engine::SetVolt(1,pos[0][i],pos[1][i],pos[2][i], m_Eng->Engine::GetVolt(1,pos[0][i],pos[1][i],pos[2][i]) - volt_ADE[1][i]); @@ -76,7 +76,7 @@ void Engine_Ext_Dispersive::Apply2Voltages() case Engine::SSE: { Engine_sse* eng_sse = (Engine_sse*)m_Eng; - for (unsigned int i=0;im_LM_Count;++i) + for (unsigned int i=0; im_LM_Count; ++i) { eng_sse->Engine_sse::SetVolt(0,pos[0][i],pos[1][i],pos[2][i], eng_sse->Engine_sse::GetVolt(0,pos[0][i],pos[1][i],pos[2][i]) - volt_ADE[0][i]); eng_sse->Engine_sse::SetVolt(1,pos[0][i],pos[1][i],pos[2][i], eng_sse->Engine_sse::GetVolt(1,pos[0][i],pos[1][i],pos[2][i]) - volt_ADE[1][i]); @@ -85,7 +85,7 @@ void Engine_Ext_Dispersive::Apply2Voltages() break; } default: - for (unsigned int i=0;im_LM_Count;++i) + for (unsigned int i=0; im_LM_Count; ++i) { m_Eng->SetVolt(0,pos[0][i],pos[1][i],pos[2][i], m_Eng->GetVolt(0,pos[0][i],pos[1][i],pos[2][i]) - volt_ADE[0][i]); m_Eng->SetVolt(1,pos[0][i],pos[1][i],pos[2][i], m_Eng->GetVolt(1,pos[0][i],pos[1][i],pos[2][i]) - volt_ADE[1][i]); @@ -106,7 +106,7 @@ void Engine_Ext_Dispersive::Apply2Current() { case Engine::BASIC: { - for (unsigned int i=0;im_LM_Count;++i) + for (unsigned int i=0; im_LM_Count; ++i) { m_Eng->Engine::SetCurr(0,pos[0][i],pos[1][i],pos[2][i], m_Eng->Engine::GetCurr(0,pos[0][i],pos[1][i],pos[2][i]) - curr_ADE[0][i]); m_Eng->Engine::SetCurr(1,pos[0][i],pos[1][i],pos[2][i], m_Eng->Engine::GetCurr(1,pos[0][i],pos[1][i],pos[2][i]) - curr_ADE[1][i]); @@ -117,7 +117,7 @@ void Engine_Ext_Dispersive::Apply2Current() case Engine::SSE: { Engine_sse* eng_sse = (Engine_sse*)m_Eng; - for (unsigned int i=0;im_LM_Count;++i) + for (unsigned int i=0; im_LM_Count; ++i) { eng_sse->Engine_sse::SetCurr(0,pos[0][i],pos[1][i],pos[2][i], eng_sse->Engine_sse::GetCurr(0,pos[0][i],pos[1][i],pos[2][i]) - curr_ADE[0][i]); eng_sse->Engine_sse::SetCurr(1,pos[0][i],pos[1][i],pos[2][i], eng_sse->Engine_sse::GetCurr(1,pos[0][i],pos[1][i],pos[2][i]) - curr_ADE[1][i]); @@ -126,7 +126,7 @@ void Engine_Ext_Dispersive::Apply2Current() break; } default: - for (unsigned int i=0;im_LM_Count;++i) + for (unsigned int i=0; im_LM_Count; ++i) { m_Eng->SetCurr(0,pos[0][i],pos[1][i],pos[2][i], m_Eng->GetCurr(0,pos[0][i],pos[1][i],pos[2][i]) - curr_ADE[0][i]); m_Eng->SetCurr(1,pos[0][i],pos[1][i],pos[2][i], m_Eng->GetCurr(1,pos[0][i],pos[1][i],pos[2][i]) - curr_ADE[1][i]); diff --git a/FDTD/extensions/engine_ext_lorentzmaterial.cpp b/FDTD/extensions/engine_ext_lorentzmaterial.cpp index 6d21aba..cedfdca 100644 --- a/FDTD/extensions/engine_ext_lorentzmaterial.cpp +++ b/FDTD/extensions/engine_ext_lorentzmaterial.cpp @@ -40,7 +40,7 @@ void Engine_Ext_LorentzMaterial::DoPreVoltageUpdates() { case Engine::BASIC: { - for (unsigned int i=0;im_LM_Count;++i) + for (unsigned int i=0; im_LM_Count; ++i) { volt_ADE[0][i] *= m_Op_Ext_Lor->v_int_ADE[0][i]; volt_ADE[0][i] += m_Op_Ext_Lor->v_ext_ADE[0][i] * m_Eng->Engine::GetVolt(0,pos[0][i],pos[1][i],pos[2][i]); @@ -56,7 +56,7 @@ void Engine_Ext_LorentzMaterial::DoPreVoltageUpdates() case Engine::SSE: { Engine_sse* eng_sse = (Engine_sse*)m_Eng; - for (unsigned int i=0;im_LM_Count;++i) + for (unsigned int i=0; im_LM_Count; ++i) { volt_ADE[0][i] *= m_Op_Ext_Lor->v_int_ADE[0][i]; volt_ADE[0][i] += m_Op_Ext_Lor->v_ext_ADE[0][i] * eng_sse->Engine_sse::GetVolt(0,pos[0][i],pos[1][i],pos[2][i]); @@ -70,7 +70,7 @@ void Engine_Ext_LorentzMaterial::DoPreVoltageUpdates() break; } default: - for (unsigned int i=0;im_LM_Count;++i) + for (unsigned int i=0; im_LM_Count; ++i) { volt_ADE[0][i] *= m_Op_Ext_Lor->v_int_ADE[0][i]; volt_ADE[0][i] += m_Op_Ext_Lor->v_ext_ADE[0][i] * m_Eng->GetVolt(0,pos[0][i],pos[1][i],pos[2][i]); @@ -96,7 +96,7 @@ void Engine_Ext_LorentzMaterial::DoPreCurrentUpdates() { case Engine::BASIC: { - for (unsigned int i=0;im_LM_Count;++i) + for (unsigned int i=0; im_LM_Count; ++i) { curr_ADE[0][i] *= m_Op_Ext_Lor->i_int_ADE[0][i]; curr_ADE[0][i] += m_Op_Ext_Lor->i_ext_ADE[0][i] * m_Eng->Engine::GetCurr(0,pos[0][i],pos[1][i],pos[2][i]); @@ -112,7 +112,7 @@ void Engine_Ext_LorentzMaterial::DoPreCurrentUpdates() case Engine::SSE: { Engine_sse* eng_sse = (Engine_sse*)m_Eng; - for (unsigned int i=0;im_LM_Count;++i) + for (unsigned int i=0; im_LM_Count; ++i) { curr_ADE[0][i] *= m_Op_Ext_Lor->i_int_ADE[0][i]; curr_ADE[0][i] += m_Op_Ext_Lor->i_ext_ADE[0][i] * eng_sse->Engine_sse::GetCurr(0,pos[0][i],pos[1][i],pos[2][i]); @@ -126,7 +126,7 @@ void Engine_Ext_LorentzMaterial::DoPreCurrentUpdates() break; } default: - for (unsigned int i=0;im_LM_Count;++i) + for (unsigned int i=0; im_LM_Count; ++i) { curr_ADE[0][i] *= m_Op_Ext_Lor->i_int_ADE[0][i]; curr_ADE[0][i] += m_Op_Ext_Lor->i_ext_ADE[0][i] * m_Eng->GetCurr(0,pos[0][i],pos[1][i],pos[2][i]); diff --git a/FDTD/extensions/engine_ext_mur_abc.cpp b/FDTD/extensions/engine_ext_mur_abc.cpp index bca8b0d..3fee2dd 100644 --- a/FDTD/extensions/engine_ext_mur_abc.cpp +++ b/FDTD/extensions/engine_ext_mur_abc.cpp @@ -41,7 +41,7 @@ Engine_Ext_Mur_ABC::Engine_Ext_Mur_ABC(Operator_Ext_Mur_ABC* op_ext) : Engine_Ex //find if some excitation is on this mur-abc and find the max length of this excite, so that the abc can start after the excitation is done... int maxDelay=-1; - for (unsigned int n=0;nm_Op->Exc->Volt_Count;++n) + for (unsigned int n=0; nm_Op->Exc->Volt_Count; ++n) { if ( ((m_Op_mur->m_Op->Exc->Volt_dir[n]==m_nyP) || (m_Op_mur->m_Op->Exc->Volt_dir[n]==m_nyPP)) && (m_Op_mur->m_Op->Exc->Volt_index[m_ny][n]==m_LineNr) ) { @@ -75,7 +75,7 @@ void Engine_Ext_Mur_ABC::SetNumberOfThreads(int nrThread) m_numX = AssignJobs2Threads(m_numLines[0],m_NrThreads,false); m_start.resize(m_NrThreads,0); m_start.at(0)=0; - for (size_t n=1;nEngine::GetVolt(m_nyP,pos_shift) - m_Op_mur->m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] * m_Eng->Engine::GetVolt(m_nyP,pos); m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]] = m_Eng->Engine::GetVolt(m_nyPP,pos_shift) - m_Op_mur->m_Mur_Coeff_nyPP[pos[m_nyP]][pos[m_nyPP]] * m_Eng->Engine::GetVolt(m_nyPP,pos); } } - break; + break; } case Engine::SSE: { Engine_sse* eng_sse = (Engine_sse*) m_Eng; - for (pos[m_nyP]=0;pos[m_nyP]Engine_sse::GetVolt(m_nyP,pos_shift) - m_Op_mur->m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] * eng_sse->Engine_sse::GetVolt(m_nyP,pos); m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]] = eng_sse->Engine_sse::GetVolt(m_nyPP,pos_shift) - m_Op_mur->m_Mur_Coeff_nyPP[pos[m_nyP]][pos[m_nyPP]] * eng_sse->Engine_sse::GetVolt(m_nyPP,pos); } } - break; + break; } default: - for (unsigned int lineX=0;lineXGetVolt(m_nyP,pos_shift) - m_Op_mur->m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] * m_Eng->GetVolt(m_nyP,pos); @@ -156,11 +156,11 @@ void Engine_Ext_Mur_ABC::DoPostVoltageUpdates(int threadID) { case Engine::BASIC: { - for (unsigned int lineX=0;lineXm_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] * m_Eng->Engine::GetVolt(m_nyP,pos_shift); @@ -173,11 +173,11 @@ void Engine_Ext_Mur_ABC::DoPostVoltageUpdates(int threadID) case Engine::SSE: { Engine_sse* eng_sse = (Engine_sse*) m_Eng; - for (unsigned int lineX=0;lineXm_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] * eng_sse->Engine_sse::GetVolt(m_nyP,pos_shift); @@ -188,11 +188,11 @@ void Engine_Ext_Mur_ABC::DoPostVoltageUpdates(int threadID) } default: - for (unsigned int lineX=0;lineXm_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] * m_Eng->GetVolt(m_nyP,pos_shift); @@ -217,10 +217,10 @@ void Engine_Ext_Mur_ABC::Apply2Voltages(int threadID) { case Engine::BASIC: { - for (unsigned int lineX=0;lineXEngine::SetVolt(m_nyP,pos, m_volt_nyP[pos[m_nyP]][pos[m_nyPP]]); m_Eng->Engine::SetVolt(m_nyPP,pos, m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]]); @@ -232,10 +232,10 @@ void Engine_Ext_Mur_ABC::Apply2Voltages(int threadID) case Engine::SSE: { Engine_sse* eng_sse = (Engine_sse*) m_Eng; - for (unsigned int lineX=0;lineXEngine_sse::SetVolt(m_nyP,pos, m_volt_nyP[pos[m_nyP]][pos[m_nyPP]]); eng_sse->Engine_sse::SetVolt(m_nyPP,pos, m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]]); @@ -245,10 +245,10 @@ void Engine_Ext_Mur_ABC::Apply2Voltages(int threadID) } default: - for (unsigned int lineX=0;lineXSetVolt(m_nyP,pos, m_volt_nyP[pos[m_nyP]][pos[m_nyPP]]); m_Eng->SetVolt(m_nyPP,pos, m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]]); diff --git a/FDTD/extensions/engine_ext_pml_sf.cpp b/FDTD/extensions/engine_ext_pml_sf.cpp index 47bbdec..28defdf 100644 --- a/FDTD/extensions/engine_ext_pml_sf.cpp +++ b/FDTD/extensions/engine_ext_pml_sf.cpp @@ -50,13 +50,13 @@ void Engine_Ext_PML_SF::UpdateVoltages(unsigned int startX, unsigned int numX) pos[0] = startX; //voltage updates - for (unsigned int posX=0;posXm_numLines[1];++pos[1]) + for (pos[1]=0; pos[1]m_numLines[1]; ++pos[1]) { shift[1]=pos[1]; - for (pos[2]=0;pos[2]m_numLines[2];++pos[2]) + for (pos[2]=0; pos[2]m_numLines[2]; ++pos[2]) { shift[2]=pos[2]; //do the updates here @@ -90,11 +90,11 @@ void Engine_Ext_PML_SF::UpdateCurrents(unsigned int startX, unsigned int numX) { unsigned int pos[3]; pos[0] = startX; - for (unsigned int posX=0;posXm_numLines[1]-1;++pos[1]) + for (pos[1]=0; pos[1]m_numLines[1]-1; ++pos[1]) { - for (pos[2]=0;pos[2]m_numLines[2]-1;++pos[2]) + for (pos[2]=0; pos[2]m_numLines[2]-1; ++pos[2]) { //do the updates here //for x @@ -150,10 +150,10 @@ void Engine_Ext_PML_SF_Plane::Apply2Voltages() // copy currents data from main engine to pml engine (lowest main line to highest pml line) if (m_Op_PML_SF_PL->m_top==false) { - for (pos[m_nyP]=0;pos[m_nyP]m_numLines[m_nyP]-1;++pos[m_nyP]) + for (pos[m_nyP]=0; pos[m_nyP]m_numLines[m_nyP]-1; ++pos[m_nyP]) { pml_pos[m_nyP] = pos[m_nyP]; - for (pos[m_nyPP]=0;pos[m_nyPP]m_numLines[m_nyPP]-1;++pos[m_nyPP]) + for (pos[m_nyPP]=0; pos[m_nyPP]m_numLines[m_nyPP]-1; ++pos[m_nyPP]) { pml_pos[m_nyPP] = pos[m_nyPP]; curr[0][0][pml_pos[0]][pml_pos[1]][pml_pos[2]] = m_Eng->GetCurr(0,pos); @@ -174,10 +174,10 @@ void Engine_Ext_PML_SF_Plane::Apply2Voltages() // copy voltage data from pml engine to main engine (highest pml line to lowest main line) pos[m_ny] = 0; pml_pos[m_ny] = m_Op_PML_SF_PL->m_numLines[m_ny]-1; - for (pos[m_nyP]=0;pos[m_nyP]m_numLines[m_nyP];++pos[m_nyP]) + for (pos[m_nyP]=0; pos[m_nyP]m_numLines[m_nyP]; ++pos[m_nyP]) { pml_pos[m_nyP] = pos[m_nyP]; - for (pos[m_nyPP]=0;pos[m_nyPP]m_numLines[m_nyPP];++pos[m_nyPP]) + for (pos[m_nyPP]=0; pos[m_nyPP]m_numLines[m_nyPP]; ++pos[m_nyPP]) { pml_pos[m_nyPP] = pos[m_nyPP]; m_Eng->SetVolt(0,pos, volt[0][0][pml_pos[0]][pml_pos[1]][pml_pos[2]] + volt[1][0][pml_pos[0]][pml_pos[1]][pml_pos[2]] ); @@ -201,10 +201,10 @@ void Engine_Ext_PML_SF_Plane::Apply2Current() // copy voltage data from main engine to pml engine (highest main line to lowest pml line) if (m_Op_PML_SF_PL->m_top) { - for (pos[m_nyP]=0;pos[m_nyP]m_numLines[m_nyP];++pos[m_nyP]) + for (pos[m_nyP]=0; pos[m_nyP]m_numLines[m_nyP]; ++pos[m_nyP]) { pml_pos[m_nyP] = pos[m_nyP]; - for (pos[m_nyPP]=0;pos[m_nyPP]m_numLines[m_nyPP];++pos[m_nyPP]) + for (pos[m_nyPP]=0; pos[m_nyPP]m_numLines[m_nyPP]; ++pos[m_nyPP]) { pml_pos[m_nyPP] = pos[m_nyPP]; volt[0][0][pml_pos[0]][pml_pos[1]][pml_pos[2]] = m_Eng->GetVolt(0,pos); @@ -223,10 +223,10 @@ void Engine_Ext_PML_SF_Plane::Apply2Current() // this is necessary to catch the voltage excitation on the lowest main voltage line... if (m_Op_PML_SF_PL->m_top==false) { - for (pos[m_nyP]=0;pos[m_nyP]m_numLines[m_nyP]-1;++pos[m_nyP]) + for (pos[m_nyP]=0; pos[m_nyP]m_numLines[m_nyP]-1; ++pos[m_nyP]) { pml_pos[m_nyP] = pos[m_nyP]; - for (pos[m_nyPP]=0;pos[m_nyPP]m_numLines[m_nyPP]-1;++pos[m_nyPP]) + for (pos[m_nyPP]=0; pos[m_nyPP]m_numLines[m_nyPP]-1; ++pos[m_nyPP]) { pml_pos[m_nyPP] = pos[m_nyPP]; volt[0][0][pml_pos[0]][pml_pos[1]][pml_pos[2]] = m_Eng->GetVolt(0,pos); @@ -246,10 +246,10 @@ void Engine_Ext_PML_SF_Plane::Apply2Current() // copy currents data from pml engine to main engine (lowest pml line to highest main line) if (m_Op_PML_SF_PL->m_top) { - for (pos[m_nyP]=0;pos[m_nyP]m_numLines[m_nyP]-1;++pos[m_nyP]) + for (pos[m_nyP]=0; pos[m_nyP]m_numLines[m_nyP]-1; ++pos[m_nyP]) { pml_pos[m_nyP] = pos[m_nyP]; - for (pos[m_nyPP]=0;pos[m_nyPP]m_numLines[m_nyPP]-1;++pos[m_nyPP]) + for (pos[m_nyPP]=0; pos[m_nyPP]m_numLines[m_nyPP]-1; ++pos[m_nyPP]) { pml_pos[m_nyPP] = pos[m_nyPP]; diff --git a/FDTD/extensions/engine_ext_upml.cpp b/FDTD/extensions/engine_ext_upml.cpp index 62d51bb..bbb54fe 100644 --- a/FDTD/extensions/engine_ext_upml.cpp +++ b/FDTD/extensions/engine_ext_upml.cpp @@ -50,7 +50,7 @@ void Engine_Ext_UPML::SetNumberOfThreads(int nrThread) m_numX = AssignJobs2Threads(m_Op_UPML->m_numLines[0],m_NrThreads,false); m_start.resize(m_NrThreads,0); m_start.at(0)=0; - for (size_t n=1;nm_StartPos[0]; - for (loc_pos[1]=0;loc_pos[1]m_numLines[1];++loc_pos[1]) + for (loc_pos[1]=0; loc_pos[1]m_numLines[1]; ++loc_pos[1]) { pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1]; - for (loc_pos[2]=0;loc_pos[2]m_numLines[2];++loc_pos[2]) + for (loc_pos[2]=0; loc_pos[2]m_numLines[2]; ++loc_pos[2]) { pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2]; f_help = m_Op_UPML->vv[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->Engine::GetVolt(0,pos) - - m_Op_UPML->vvfo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->vvfo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]; m_Eng->Engine::SetVolt(0,pos, volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]); volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; f_help = m_Op_UPML->vv[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->Engine::GetVolt(1,pos) - - m_Op_UPML->vvfo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->vvfo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]; m_Eng->Engine::SetVolt(1,pos, volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]); volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; f_help = m_Op_UPML->vv[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->Engine::GetVolt(2,pos) - - m_Op_UPML->vvfo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->vvfo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]; m_Eng->Engine::SetVolt(2,pos, volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]); volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; } } } - break; + break; } case Engine::SSE: { Engine_sse* eng_sse = (Engine_sse*) m_Eng; - for (unsigned int lineX=0;lineXm_StartPos[0]; - for (loc_pos[1]=0;loc_pos[1]m_numLines[1];++loc_pos[1]) + for (loc_pos[1]=0; loc_pos[1]m_numLines[1]; ++loc_pos[1]) { pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1]; - for (loc_pos[2]=0;loc_pos[2]m_numLines[2];++loc_pos[2]) + for (loc_pos[2]=0; loc_pos[2]m_numLines[2]; ++loc_pos[2]) { pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2]; f_help = m_Op_UPML->vv[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * eng_sse->Engine_sse::GetVolt(0,pos) - - m_Op_UPML->vvfo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->vvfo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]; eng_sse->Engine_sse::SetVolt(0,pos, volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]); volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; f_help = m_Op_UPML->vv[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * eng_sse->Engine_sse::GetVolt(1,pos) - - m_Op_UPML->vvfo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->vvfo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]; eng_sse->Engine_sse::SetVolt(1,pos, volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]); volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; f_help = m_Op_UPML->vv[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * eng_sse->Engine_sse::GetVolt(2,pos) - - m_Op_UPML->vvfo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->vvfo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]; eng_sse->Engine_sse::SetVolt(2,pos, volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]); volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; } @@ -135,29 +135,29 @@ void Engine_Ext_UPML::DoPreVoltageUpdates(int threadID) } default: { - for (unsigned int lineX=0;lineXm_StartPos[0]; - for (loc_pos[1]=0;loc_pos[1]m_numLines[1];++loc_pos[1]) + for (loc_pos[1]=0; loc_pos[1]m_numLines[1]; ++loc_pos[1]) { pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1]; - for (loc_pos[2]=0;loc_pos[2]m_numLines[2];++loc_pos[2]) + for (loc_pos[2]=0; loc_pos[2]m_numLines[2]; ++loc_pos[2]) { pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2]; f_help = m_Op_UPML->vv[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->GetVolt(0,pos) - - m_Op_UPML->vvfo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->vvfo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]; m_Eng->SetVolt(0,pos, volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]); volt_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; f_help = m_Op_UPML->vv[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->GetVolt(1,pos) - - m_Op_UPML->vvfo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->vvfo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]; m_Eng->SetVolt(1,pos, volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]); volt_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; f_help = m_Op_UPML->vv[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->GetVolt(2,pos) - - m_Op_UPML->vvfo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->vvfo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]; m_Eng->SetVolt(2,pos, volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]); volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; } @@ -184,14 +184,14 @@ void Engine_Ext_UPML::DoPostVoltageUpdates(int threadID) { case Engine::BASIC: { - for (unsigned int lineX=0;lineXm_StartPos[0]; - for (loc_pos[1]=0;loc_pos[1]m_numLines[1];++loc_pos[1]) + for (loc_pos[1]=0; loc_pos[1]m_numLines[1]; ++loc_pos[1]) { pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1]; - for (loc_pos[2]=0;loc_pos[2]m_numLines[2];++loc_pos[2]) + for (loc_pos[2]=0; loc_pos[2]m_numLines[2]; ++loc_pos[2]) { pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2]; @@ -214,14 +214,14 @@ void Engine_Ext_UPML::DoPostVoltageUpdates(int threadID) case Engine::SSE: { Engine_sse* eng_sse = (Engine_sse*) m_Eng; - for (unsigned int lineX=0;lineXm_StartPos[0]; - for (loc_pos[1]=0;loc_pos[1]m_numLines[1];++loc_pos[1]) + for (loc_pos[1]=0; loc_pos[1]m_numLines[1]; ++loc_pos[1]) { pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1]; - for (loc_pos[2]=0;loc_pos[2]m_numLines[2];++loc_pos[2]) + for (loc_pos[2]=0; loc_pos[2]m_numLines[2]; ++loc_pos[2]) { pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2]; @@ -243,14 +243,14 @@ void Engine_Ext_UPML::DoPostVoltageUpdates(int threadID) } default: { - for (unsigned int lineX=0;lineXm_StartPos[0]; - for (loc_pos[1]=0;loc_pos[1]m_numLines[1];++loc_pos[1]) + for (loc_pos[1]=0; loc_pos[1]m_numLines[1]; ++loc_pos[1]) { pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1]; - for (loc_pos[2]=0;loc_pos[2]m_numLines[2];++loc_pos[2]) + for (loc_pos[2]=0; loc_pos[2]m_numLines[2]; ++loc_pos[2]) { pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2]; @@ -264,7 +264,8 @@ void Engine_Ext_UPML::DoPostVoltageUpdates(int threadID) f_help = volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]; volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = m_Eng->GetVolt(2,pos); - m_Eng->SetVolt(2,pos, f_help + m_Op_UPML->vvfn[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]); } + m_Eng->SetVolt(2,pos, f_help + m_Op_UPML->vvfn[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * volt_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]); + } } } break; @@ -288,29 +289,29 @@ void Engine_Ext_UPML::DoPreCurrentUpdates(int threadID) { case Engine::BASIC: { - for (unsigned int lineX=0;lineXm_StartPos[0]; - for (loc_pos[1]=0;loc_pos[1]m_numLines[1];++loc_pos[1]) + for (loc_pos[1]=0; loc_pos[1]m_numLines[1]; ++loc_pos[1]) { pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1]; - for (loc_pos[2]=0;loc_pos[2]m_numLines[2];++loc_pos[2]) + for (loc_pos[2]=0; loc_pos[2]m_numLines[2]; ++loc_pos[2]) { pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2]; f_help = m_Op_UPML->ii[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->Engine::GetCurr(0,pos) - - m_Op_UPML->iifo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->iifo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]; m_Eng->Engine::SetCurr(0,pos, curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]); curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; f_help = m_Op_UPML->ii[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->Engine::GetCurr(1,pos) - - m_Op_UPML->iifo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->iifo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]; m_Eng->Engine::SetCurr(1,pos, curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]); curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; f_help = m_Op_UPML->ii[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->Engine::GetCurr(2,pos) - - m_Op_UPML->iifo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->iifo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]; m_Eng->Engine::SetCurr(2,pos, curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]); curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; } @@ -321,29 +322,29 @@ void Engine_Ext_UPML::DoPreCurrentUpdates(int threadID) case Engine::SSE: { Engine_sse* eng_sse = (Engine_sse*) m_Eng; - for (unsigned int lineX=0;lineXm_StartPos[0]; - for (loc_pos[1]=0;loc_pos[1]m_numLines[1];++loc_pos[1]) + for (loc_pos[1]=0; loc_pos[1]m_numLines[1]; ++loc_pos[1]) { pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1]; - for (loc_pos[2]=0;loc_pos[2]m_numLines[2];++loc_pos[2]) + for (loc_pos[2]=0; loc_pos[2]m_numLines[2]; ++loc_pos[2]) { pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2]; f_help = m_Op_UPML->ii[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * eng_sse->Engine_sse::GetCurr(0,pos) - - m_Op_UPML->iifo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->iifo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]; eng_sse->Engine_sse::SetCurr(0,pos, curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]); curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; f_help = m_Op_UPML->ii[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * eng_sse->Engine_sse::GetCurr(1,pos) - - m_Op_UPML->iifo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->iifo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]; eng_sse->Engine_sse::SetCurr(1,pos, curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]); curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; f_help = m_Op_UPML->ii[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * eng_sse->Engine_sse::GetCurr(2,pos) - - m_Op_UPML->iifo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->iifo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]; eng_sse->Engine_sse::SetCurr(2,pos, curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]); curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; @@ -354,29 +355,29 @@ void Engine_Ext_UPML::DoPreCurrentUpdates(int threadID) } default: { - for (unsigned int lineX=0;lineXm_StartPos[0]; - for (loc_pos[1]=0;loc_pos[1]m_numLines[1];++loc_pos[1]) + for (loc_pos[1]=0; loc_pos[1]m_numLines[1]; ++loc_pos[1]) { pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1]; - for (loc_pos[2]=0;loc_pos[2]m_numLines[2];++loc_pos[2]) + for (loc_pos[2]=0; loc_pos[2]m_numLines[2]; ++loc_pos[2]) { pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2]; f_help = m_Op_UPML->ii[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->GetCurr(0,pos) - - m_Op_UPML->iifo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->iifo[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]; m_Eng->SetCurr(0,pos, curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]]); curr_flux[0][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; f_help = m_Op_UPML->ii[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->GetCurr(1,pos) - - m_Op_UPML->iifo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->iifo[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]; m_Eng->SetCurr(1,pos, curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]]); curr_flux[1][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; f_help = m_Op_UPML->ii[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * m_Eng->GetCurr(2,pos) - - m_Op_UPML->iifo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]; + - m_Op_UPML->iifo[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]; m_Eng->SetCurr(2,pos, curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]); curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = f_help; } @@ -402,14 +403,14 @@ void Engine_Ext_UPML::DoPostCurrentUpdates(int threadID) { case Engine::BASIC: { - for (unsigned int lineX=0;lineXm_StartPos[0]; - for (loc_pos[1]=0;loc_pos[1]m_numLines[1];++loc_pos[1]) + for (loc_pos[1]=0; loc_pos[1]m_numLines[1]; ++loc_pos[1]) { pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1]; - for (loc_pos[2]=0;loc_pos[2]m_numLines[2];++loc_pos[2]) + for (loc_pos[2]=0; loc_pos[2]m_numLines[2]; ++loc_pos[2]) { pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2]; @@ -432,14 +433,14 @@ void Engine_Ext_UPML::DoPostCurrentUpdates(int threadID) case Engine::SSE: { Engine_sse* eng_sse = (Engine_sse*) m_Eng; - for (unsigned int lineX=0;lineXm_StartPos[0]; - for (loc_pos[1]=0;loc_pos[1]m_numLines[1];++loc_pos[1]) + for (loc_pos[1]=0; loc_pos[1]m_numLines[1]; ++loc_pos[1]) { pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1]; - for (loc_pos[2]=0;loc_pos[2]m_numLines[2];++loc_pos[2]) + for (loc_pos[2]=0; loc_pos[2]m_numLines[2]; ++loc_pos[2]) { pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2]; @@ -461,14 +462,14 @@ void Engine_Ext_UPML::DoPostCurrentUpdates(int threadID) } default: { - for (unsigned int lineX=0;lineXm_StartPos[0]; - for (loc_pos[1]=0;loc_pos[1]m_numLines[1];++loc_pos[1]) + for (loc_pos[1]=0; loc_pos[1]m_numLines[1]; ++loc_pos[1]) { pos[1] = loc_pos[1] + m_Op_UPML->m_StartPos[1]; - for (loc_pos[2]=0;loc_pos[2]m_numLines[2];++loc_pos[2]) + for (loc_pos[2]=0; loc_pos[2]m_numLines[2]; ++loc_pos[2]) { pos[2] = loc_pos[2] + m_Op_UPML->m_StartPos[2]; @@ -482,7 +483,8 @@ void Engine_Ext_UPML::DoPostCurrentUpdates(int threadID) f_help = curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]; curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] = m_Eng->GetCurr(2,pos); - m_Eng->SetCurr(2,pos, f_help + m_Op_UPML->iifn[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]); } + m_Eng->SetCurr(2,pos, f_help + m_Op_UPML->iifn[2][loc_pos[0]][loc_pos[1]][loc_pos[2]] * curr_flux[2][loc_pos[0]][loc_pos[1]][loc_pos[2]]); + } } } break; diff --git a/FDTD/extensions/operator_ext_cylinder.cpp b/FDTD/extensions/operator_ext_cylinder.cpp index 0dff575..307024c 100644 --- a/FDTD/extensions/operator_ext_cylinder.cpp +++ b/FDTD/extensions/operator_ext_cylinder.cpp @@ -32,14 +32,18 @@ Operator_Ext_Cylinder::Operator_Ext_Cylinder(Operator_Cylinder* op) : Operator_E Operator_Ext_Cylinder::~Operator_Ext_Cylinder() { - delete[] vv_R0;vv_R0=NULL; - delete[] vi_R0;vi_R0=NULL; + delete[] vv_R0; + vv_R0=NULL; + delete[] vi_R0; + vi_R0=NULL; } bool Operator_Ext_Cylinder::BuildExtension() { - delete[] vv_R0;vv_R0=NULL; - delete[] vi_R0;vi_R0=NULL; + delete[] vv_R0; + vv_R0=NULL; + delete[] vi_R0; + vi_R0=NULL; //if r=0 is not included -> obviously no special treatment for r=0 //if alpha direction is not closed, PEC-BC at r=0 necessary and already set... @@ -53,11 +57,11 @@ bool Operator_Ext_Cylinder::BuildExtension() double inEC[4]; double dT = m_Op->GetTimestep(); pos[0]=0; - for (pos[2]=0;pos[2]GetOriginalNumLines(2);++pos[2]) + for (pos[2]=0; pos[2]GetOriginalNumLines(2); ++pos[2]) { double C=0; double G=0; - for (pos[1]=0;pos[1]GetOriginalNumLines(1)-1;++pos[1]) + for (pos[1]=0; pos[1]GetOriginalNumLines(1)-1; ++pos[1]) { m_Op_Cyl->Calc_ECPos(2,pos,inEC); C+=inEC[0]*0.5; diff --git a/FDTD/extensions/operator_ext_cylinder.h b/FDTD/extensions/operator_ext_cylinder.h index d65fb89..8c8fb80 100644 --- a/FDTD/extensions/operator_ext_cylinder.h +++ b/FDTD/extensions/operator_ext_cylinder.h @@ -35,7 +35,7 @@ public: virtual Engine_Extension* CreateEngineExtention(); virtual bool IsCylinderCoordsSave() const {return true;} - virtual bool IsCylindricalMultiGridSave(bool child) const {UNUSED(child);return true;} + virtual bool IsCylindricalMultiGridSave(bool child) const {UNUSED(child); return true;} virtual std::string GetExtensionName() const {return std::string("Extension for the Cylinder-Coords Operator");} diff --git a/FDTD/extensions/operator_ext_lorentzmaterial.cpp b/FDTD/extensions/operator_ext_lorentzmaterial.cpp index 836b3aa..1e6475d 100644 --- a/FDTD/extensions/operator_ext_lorentzmaterial.cpp +++ b/FDTD/extensions/operator_ext_lorentzmaterial.cpp @@ -20,7 +20,7 @@ Operator_Ext_LorentzMaterial::Operator_Ext_LorentzMaterial(Operator* op) : Operator_Ext_Dispersive(op) { - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { v_int_ADE[n] = NULL; v_ext_ADE[n] = NULL; @@ -31,7 +31,7 @@ Operator_Ext_LorentzMaterial::Operator_Ext_LorentzMaterial(Operator* op) : Opera Operator_Ext_LorentzMaterial::~Operator_Ext_LorentzMaterial() { - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { delete[] v_int_ADE[n]; v_int_ADE[n] = NULL; @@ -61,16 +61,16 @@ bool Operator_Ext_LorentzMaterial::BuildExtension() vector i_ext[3]; vector v_pos[3]; - for (pos[0]=0;pos[0]MainOp->SetPos(pos[0],pos[1],pos[2]); //calc epsilon lorentz material b_pos_on = false; - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { L_D[n]=0; coord[0] = m_Op->GetDiscLine(0,pos[0]); @@ -91,7 +91,7 @@ bool Operator_Ext_LorentzMaterial::BuildExtension() } } - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { C_D[n]=0; coord[0] = m_Op->GetDiscLine(0,pos[0],true); @@ -114,7 +114,7 @@ bool Operator_Ext_LorentzMaterial::BuildExtension() if (b_pos_on) //this position has active lorentz material { - for (unsigned int n=0;n<3;++n) + for (unsigned int n=0; n<3; ++n) { v_pos[n].push_back(pos[n]); v_int[n].push_back(1); @@ -137,17 +137,17 @@ bool Operator_Ext_LorentzMaterial::BuildExtension() //copy all vectors into the array's m_LM_Count = v_pos[0].size(); - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { m_LM_pos[n] = new unsigned int[m_LM_Count]; - for (unsigned int i=0;iGetDiscLine(m_ny,pos[m_ny]) - delta/2 / m_Op->GetGridDelta(); - for (pos[m_nyP]=0;pos[m_nyP]GetDiscLine(m_nyP,pos[m_nyP]); - for (pos[m_nyPP]=0;pos[m_nyPP]GetDiscLine(m_nyPP,pos[m_nyPP]); CSProperties* prop = m_Op->GetGeometryCSX()->GetPropertyByCoordPriority(coord, CSProperties::MATERIAL, false); diff --git a/FDTD/extensions/operator_ext_pml_sf.cpp b/FDTD/extensions/operator_ext_pml_sf.cpp index 46de18d..41be114 100644 --- a/FDTD/extensions/operator_ext_pml_sf.cpp +++ b/FDTD/extensions/operator_ext_pml_sf.cpp @@ -23,7 +23,7 @@ bool Build_Split_Field_PML(Operator* op, int BC[6], int size[6], string gradFunc) { - for (int n=0;n<6;++n) + for (int n=0; n<6; ++n) { if (BC[n]==3) //split field PML { @@ -61,12 +61,16 @@ Operator_Ext_PML_SF::Operator_Ext_PML_SF(Operator* op) : Operator_Extension(op) m_numLines[1]=0; m_numLines[2]=0; - vv[0] = NULL; vv[1] = NULL; - vi[0] = NULL; vi[1] = NULL; - ii[0] = NULL; ii[1] = NULL; - iv[0] = NULL; iv[1] = NULL; + vv[0] = NULL; + vv[1] = NULL; + vi[0] = NULL; + vi[1] = NULL; + ii[0] = NULL; + ii[1] = NULL; + iv[0] = NULL; + iv[1] = NULL; - for (int n=0;n<6;++n) + for (int n=0; n<6; ++n) m_BC[n]=0; m_GradingFunction = new FunctionParser(); @@ -131,7 +135,7 @@ bool Operator_Ext_PML_SF::SetGradingFunction(string func) m_GradFunc = func; int res = m_GradingFunction->Parse(m_GradFunc.c_str(), "D,dl,W,Z,N"); - if(res < 0) return true; + if (res < 0) return true; cerr << "Operator_Ext_PML_SF::SetGradingFunction: Warning, an error occured parsing the pml grading function (see below) ..." << endl; cerr << func << "\n" << string(res, ' ') << "^\n" << m_GradingFunction->ErrorMsg() << "\n"; @@ -152,13 +156,13 @@ bool Operator_Ext_PML_SF::BuildExtension() double inEC[4]; - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { - for (pos[0]=0;pos[0]0) @@ -334,7 +338,7 @@ void Operator_Ext_PML_SF_Plane::ApplyBC() if (m_top==false) PEC[2*m_ny+1] = 0; - for (int n=0;n<6;++n) + for (int n=0; n<6; ++n) { PMC[n] = (m_BC[n] == 1); if (n/2 == m_ny) @@ -343,15 +347,15 @@ void Operator_Ext_PML_SF_Plane::ApplyBC() //apply BC unsigned int pos[3] = {0,0,0}; - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { int nP = (n+1)%3; int nPP = (n+2)%3; - for (pos[nP]=0;pos[nP]= op->GetOriginalNumLines(n) ) { cerr << "Operator_Ext_UPML::Create_UPML: Warning: Not enough lines in direction: " << n << ", resetting to PEC" << endl; @@ -199,7 +199,7 @@ bool Operator_Ext_UPML::Create_UPML(Operator* op, const int ui_BC[6], const unsi { Operator_Cylinder* op_child = op_cyl_MG->GetInnerOperator(); op_cyl_MG = dynamic_cast(op_child); - for (int n=0;n<2;++n) + for (int n=0; n<2; ++n) { start[n]=0; stop[n]=op_child->GetOriginalNumLines(n)-1; @@ -258,7 +258,7 @@ bool Operator_Ext_UPML::SetGradingFunction(string func) m_GradFunc = func; int res = m_GradingFunction->Parse(m_GradFunc.c_str(), "D,dl,W,Z,N"); - if(res < 0) return true; + if (res < 0) return true; cerr << "Operator_Ext_UPML::SetGradingFunction: Warning, an error occured parsing the pml grading function (see below) ..." << endl; cerr << func << "\n" << string(res, ' ') << "^\n" << m_GradingFunction->ErrorMsg() << "\n"; @@ -269,7 +269,7 @@ void Operator_Ext_UPML::CalcGradingKappa(int ny, unsigned int pos[3], double Zm, { double depth=0; double width=0; - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { if ((pos[n] <= m_Size[2*n]) && (m_BC[2*n]==3)) //lower pml in n-dir { @@ -355,16 +355,16 @@ bool Operator_Ext_UPML::BuildExtension() double eff_Mat[4]; double dT = m_Op->GetTimestep(); - for (loc_pos[0]=0;loc_pos[0]Calc_EffMatPos(0,pos,eff_Mat); CalcGradingKappa(n, pos,__Z0__ ,kappa_v ,kappa_i); @@ -440,6 +440,6 @@ void Operator_Ext_UPML::ShowStat(ostream &ostr) const Operator_Extension::ShowStat(ostr); ostr << " PML range\t\t: " << "[" << m_StartPos[0]<< "," << m_StartPos[1]<< "," << m_StartPos[2]<< "] to [" - << m_StartPos[0]+m_numLines[0]-1 << "," << m_StartPos[1]+m_numLines[1]-1 << "," << m_StartPos[2]+m_numLines[2]-1 << "]" << endl; + << m_StartPos[0]+m_numLines[0]-1 << "," << m_StartPos[1]+m_numLines[1]-1 << "," << m_StartPos[2]+m_numLines[2]-1 << "]" << endl; ostr << " Grading function\t: \"" << m_GradFunc << "\"" << endl; } diff --git a/FDTD/extensions/operator_extension.h b/FDTD/extensions/operator_extension.h index bc0b688..4dc90b6 100644 --- a/FDTD/extensions/operator_extension.h +++ b/FDTD/extensions/operator_extension.h @@ -53,7 +53,7 @@ public: virtual bool IsCylinderCoordsSave() const {return false;} //! The cylindrical multi grid operator will check whether the extension is save to use. Default is false. Derive this method to override. - virtual bool IsCylindricalMultiGridSave(bool child) const {UNUSED(child);return false;} + virtual bool IsCylindricalMultiGridSave(bool child) const {UNUSED(child); return false;} virtual std::string GetExtensionName() const {return std::string("Abstract Operator Extension Base Class");} diff --git a/FDTD/operator.cpp b/FDTD/operator.cpp index d0e08cc..11c7f8f 100644 --- a/FDTD/operator.cpp +++ b/FDTD/operator.cpp @@ -39,7 +39,7 @@ Operator::Operator() : Operator_Base() Operator::~Operator() { - for (size_t n=0;nuiStop[n]) { @@ -315,7 +316,7 @@ void Operator::ShowExtStat() const { if (m_Op_exts.size()==0) return; cout << "-----------------------------------" << endl; - for (size_t n=0;nShowStat(cout); cout << "-----------------------------------" << endl; } @@ -340,7 +341,7 @@ void Operator::DumpOperator2File(string filename) FDTD_FLOAT**** exc = Create_N_3DArray(numLines); if (Exc) { - for (unsigned int n=0;nVolt_Count;++n) + for (unsigned int n=0; nVolt_Count; ++n) exc[Exc->Volt_dir[n]][Exc->Volt_index[0][n]][Exc->Volt_index[1][n]][Exc->Volt_index[2][n]] = Exc->Volt_amp[n]; } @@ -400,9 +401,12 @@ void Operator::DumpPEC2File( string filename ) double scaling = 1; #endif - for (pos[0]=0; pos[0](numLines); unsigned int pos[3]; - for (pos[0]=0;pos[0]GetGrid(); - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { discLines[n] = grid->GetLines(n,discLines[n],numLines[n],true); if (n==1) - if (numLines[n]<3) {cerr << "CartOperator::SetGeometryCSX: you need at least 3 disc-lines in every direction (3D!)!!!" << endl; Reset(); return false;} + if (numLines[n]<3) + { + cerr << "CartOperator::SetGeometryCSX: you need at least 3 disc-lines in every direction (3D!)!!!" << endl; + Reset(); + return false; + } } MainOp = new AdrOp(numLines[0],numLines[1],numLines[2]); MainOp->SetGrid(discLines[0],discLines[1],discLines[2]); - if (grid->GetDeltaUnit()<=0) {cerr << "CartOperator::SetGeometryCSX: grid delta unit must not be <=0 !!!" << endl; Reset(); return false;} + if (grid->GetDeltaUnit()<=0) + { + cerr << "CartOperator::SetGeometryCSX: grid delta unit must not be <=0 !!!" << endl; + Reset(); + return false; + } else gridDelta=grid->GetDeltaUnit(); MainOp->SetGridDelta(1); MainOp->AddCellAdrOp(); @@ -612,13 +626,13 @@ int Operator::CalcECOperator( DebugFlags debugFlags ) unsigned int pos[3]; - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { - for (pos[0]=0;pos[0]BuildExtension(); if (debugFlags & debugMaterial) @@ -657,12 +671,16 @@ int Operator::CalcECOperator( DebugFlags debugFlags ) DumpPEC2File( "PEC_dump.vtk" ); //cleanup - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { - delete[] EC_C[n];EC_C[n]=NULL; - delete[] EC_G[n];EC_G[n]=NULL; - delete[] EC_L[n];EC_L[n]=NULL; - delete[] EC_R[n];EC_R[n]=NULL; + delete[] EC_C[n]; + EC_C[n]=NULL; + delete[] EC_G[n]; + EC_G[n]=NULL; + delete[] EC_L[n]; + EC_L[n]=NULL; + delete[] EC_R[n]; + EC_R[n]=NULL; } return 0; @@ -674,13 +692,13 @@ void Operator::ApplyElectricBC(bool* dirs) return; unsigned int pos[3]; - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { int nP = (n+1)%3; int nPP = (n+2)%3; - for (pos[nP]=0;pos[nP]GetSize()]; EC_L[n] = new double[MainOp->GetSize()]; EC_R[n] = new double[MainOp->GetSize()]; - for (unsigned int i=0;iGetSize();i++) //init all + for (unsigned int i=0; iGetSize(); i++) //init all { EC_C[n][i]=0; EC_G[n][i]=0; @@ -998,17 +1018,21 @@ void Operator::Init_EC() bool Operator::Calc_EC() { - if (CSX==NULL) {cerr << "CartOperator::Calc_EC: CSX not given or invalid!!!" << endl; return false;} + if (CSX==NULL) + { + cerr << "CartOperator::Calc_EC: CSX not given or invalid!!!" << endl; + return false; + } unsigned int ipos; unsigned int pos[3]; double inEC[4]; - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { - for (pos[2]=0;pos[2]SetPos(pos[0],pos[1],pos[2]); @@ -1046,16 +1070,16 @@ double Operator::CalcTimestep_Var1() unsigned int ipos_PM; unsigned int ipos_PPM; MainOp->SetReflection2Cell(); - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { int nP = (n+1)%3; int nPP = (n+2)%3; - for (pos[2]=0;pos[2]SetPos(pos[0],pos[1],pos[2]); ipos_PM = MainOp->Shift(nP,-1); @@ -1082,7 +1106,7 @@ double min(double* val, unsigned int count) if (count==0) return 0.0; double min = val[0]; - for (unsigned int n=1;nSetReflection2Cell(); - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { int nP = (n+1)%3; int nPP = (n+2)%3; - for (pos[2]=0;pos[2]ResetShift(); ipos = MainOp->SetPos(pos[0],pos[1],pos[2]); @@ -1191,24 +1215,24 @@ bool Operator::CalcFieldExcitation() CSProperties* prop=NULL; int priority=0; - for (pos[2]=0;pos[2]GetIndexDelta(2,pos[2])); - for (pos[1]=0;pos[1]GetIndexDelta(1,pos[1])); - for (pos[0]=0;pos[0]GetIndexDelta(0,pos[0])); //electric field excite - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { volt_coord[0] = discLines[0][pos[0]]; volt_coord[1] = discLines[1][pos[1]]; volt_coord[2] = discLines[2][pos[2]]; volt_coord[n]+=delta[n]*0.5; - for (size_t p=0;pToElectrode(); @@ -1239,7 +1263,7 @@ bool Operator::CalcFieldExcitation() } //magnetic field excite - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { if ((pos[0]>=numLines[0]-1) || (pos[1]>=numLines[1]-1) || (pos[2]>=numLines[2]-1)) continue; //skip the last H-Line which is outside the FDTD-domain @@ -1250,7 +1274,7 @@ bool Operator::CalcFieldExcitation() curr_coord[2] = discLines[2][pos[2]]; curr_coord[nP] +=delta[nP]*0.5; curr_coord[nPP] +=delta[nPP]*0.5; - for (size_t p=0;pToElectrode(); @@ -1289,24 +1313,24 @@ bool Operator::CalcFieldExcitation() double p2[3]; double deltaN=0.0; struct Grid_Path path; - for (size_t p=0;pToElectrode(); - for (size_t n=0;nGetQtyPrimitives();++n) + for (size_t n=0; nGetQtyPrimitives(); ++n) { CSPrimitives* prim = prop->GetPrimitive(n); CSPrimCurve* curv = prim->ToCurve(); if (curv) { - for (size_t i=1;iGetNumberOfPoints();++i) + for (size_t i=1; iGetNumberOfPoints(); ++i) { curv->GetPoint(i-1,p1); curv->GetPoint(i,p2); path = FindPath(p1,p2); if (path.dir.size()>0) prim->SetPrimitiveUsed(true); - for (size_t t=0;t vec_prop = CSX->GetPropertyByType(CSProperties::METAL); - for (size_t p=0;pGetQtyPrimitives();++n) + for (size_t n=0; nGetQtyPrimitives(); ++n) { CSPrimitives* prim = prop->GetPrimitive(n); CSPrimCurve* curv = prim->ToCurve(); if (curv) { - for (size_t i=1;iGetNumberOfPoints();++i) + for (size_t i=1; iGetNumberOfPoints(); ++i) { curv->GetPoint(i-1,p1); curv->GetPoint(i,p2); path = FindPath(p1,p2); if (path.dir.size()>0) prim->SetPrimitiveUsed(true); - for (size_t t=0;t2*PI) - {cerr << "Operator_Cylinder::SetGeometryCSX: Alpha Max-Min must not be larger than 2*PI!!!" << endl; Reset(); return false;} + { + cerr << "Operator_Cylinder::SetGeometryCSX: Alpha Max-Min must not be larger than 2*PI!!!" << endl; + Reset(); + return false; + } else { CC_closedAlpha=false; } if (discLines[0][0]<0) - {cerr << "Operator_Cylinder::SetGeometryCSX: r<0 not allowed in Cylinder Coordinates!!!" << endl; Reset(); return false;} + { + cerr << "Operator_Cylinder::SetGeometryCSX: r<0 not allowed in Cylinder Coordinates!!!" << endl; + Reset(); + return false; + } else if (discLines[0][0]==0.0) { cout << "Operator_Cylinder::SetGeometryCSX: r=0 included..." << endl; @@ -208,15 +216,16 @@ void Operator_Cylinder::ApplyElectricBC(bool* dirs) if (dirs==NULL) return; if (CC_closedAlpha) { - dirs[2]=0;dirs[3]=0; //no PEC in alpha directions... + dirs[2]=0; + dirs[3]=0; //no PEC in alpha directions... } if (CC_R0_included) { // E in alpha direction ( aka volt[1][x][y][z] ) is not defined for r==0 --> always zero... unsigned int pos[3] = {0,0,0}; - for (pos[1]=0;pos[1] 1e-10) { @@ -77,7 +77,7 @@ bool Operator_CylinderMultiGrid::SetGeometryCSX(ContinuousStructure* geo) } m_Split_Pos = 0; - for (unsigned int n=0;nClearLines(0); grid->ClearLines(1); - for (unsigned int n=0; nAddDiscLine(0,discLines[0][n]); for (unsigned int n=0; nAddDiscLine(1,discLines[1][n]); diff --git a/FDTD/operator_multithread.cpp b/FDTD/operator_multithread.cpp index d8109d9..95fc3cc 100644 --- a/FDTD/operator_multithread.cpp +++ b/FDTD/operator_multithread.cpp @@ -68,11 +68,15 @@ void Operator_Multithread::Reset() m_thread_group.join_all(); - delete m_CalcEC_Start;m_CalcEC_Start=NULL; - delete m_CalcEC_Stop;m_CalcEC_Stop=NULL; + delete m_CalcEC_Start; + m_CalcEC_Start=NULL; + delete m_CalcEC_Stop; + m_CalcEC_Stop=NULL; - delete m_CalcPEC_Start;m_CalcPEC_Start=NULL; - delete m_CalcPEC_Stop;m_CalcPEC_Stop=NULL; + delete m_CalcPEC_Start; + m_CalcPEC_Start=NULL; + delete m_CalcPEC_Stop; + m_CalcPEC_Stop=NULL; } void Operator_Multithread::CalcStartStopLines(unsigned int &numThreads, vector &start, vector &stop) const @@ -106,11 +110,15 @@ int Operator_Multithread::CalcECOperator( DebugFlags debugFlags ) cout << "Multithreaded operator using " << m_numThreads << " threads." << std::endl; m_thread_group.join_all(); - delete m_CalcEC_Start;m_CalcEC_Start = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller - delete m_CalcEC_Stop;m_CalcEC_Stop = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller + delete m_CalcEC_Start; + m_CalcEC_Start = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller + delete m_CalcEC_Stop; + m_CalcEC_Stop = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller - delete m_CalcPEC_Start;m_CalcPEC_Start = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller - delete m_CalcPEC_Stop;m_CalcPEC_Stop = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller + delete m_CalcPEC_Start; + m_CalcPEC_Start = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller + delete m_CalcPEC_Stop; + m_CalcPEC_Stop = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller for (unsigned int n=0; nSetPos(0,0,0); @@ -136,7 +148,9 @@ bool Operator_Multithread::Calc_EC() bool Operator_Multithread::CalcPEC() { - m_Nr_PEC[0]=0; m_Nr_PEC[1]=0; m_Nr_PEC[2]=0; + m_Nr_PEC[0]=0; + m_Nr_PEC[1]=0; + m_Nr_PEC[2]=0; m_Nr_PEC_thread = new unsigned int[m_numThreads][3]; @@ -144,8 +158,8 @@ bool Operator_Multithread::CalcPEC() m_CalcPEC_Stop->wait(); - for (unsigned int t=0;tnumLines[1];++pos[1]) + for (pos[1]=0; pos[1]numLines[1]; ++pos[1]) { - for (pos[2]=0;pos[2]numLines[2];++pos[2]) + for (pos[2]=0; pos[2]numLines[2]; ++pos[2]) { m_OpPtr->Calc_ECPos(n,pos,inEC); ipos = m_OpPtr->MainOp->GetPos(pos[0],pos[1],pos[2]); @@ -193,7 +207,7 @@ void Operator_Thread::operator()() //************** calculate EC (Calc_EC) ***********************// m_OpPtr->m_CalcPEC_Start->wait(); - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) m_OpPtr->m_Nr_PEC_thread[m_threadID][n] = 0; m_OpPtr->CalcPEC_Range(m_start,m_stop,m_OpPtr->m_Nr_PEC_thread[m_threadID]); diff --git a/FDTD/operator_sse_compressed.cpp b/FDTD/operator_sse_compressed.cpp index 9adeccf..b66f0c9 100644 --- a/FDTD/operator_sse_compressed.cpp +++ b/FDTD/operator_sse_compressed.cpp @@ -120,13 +120,13 @@ void Operator_SSE_Compressed::ShowStat() const INLINE int equal(f4vector v1, f4vector v2) { #if defined(__SSE__) - #if (__GNUC__ == 4) && (__GNUC_MINOR__ < 4) - v4si compare = __builtin_ia32_cmpeqps( v1.v, v2.v ); - return __builtin_ia32_movmskps( (v4sf)compare ) == 0x0f; - #else - v4sf compare = __builtin_ia32_cmpeqps( v1.v, v2.v ); - return __builtin_ia32_movmskps( compare ) == 0x0f; - #endif +#if (__GNUC__ == 4) && (__GNUC_MINOR__ < 4) + v4si compare = __builtin_ia32_cmpeqps( v1.v, v2.v ); + return __builtin_ia32_movmskps( (v4sf)compare ) == 0x0f; +#else + v4sf compare = __builtin_ia32_cmpeqps( v1.v, v2.v ); + return __builtin_ia32_movmskps( compare ) == 0x0f; +#endif #else return ( v1.f[0] == v2.f[0] && diff --git a/main.cpp b/main.cpp index c95cc46..0847409 100644 --- a/main.cpp +++ b/main.cpp @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) if (argc>=3) { - for (int n=2;nDeleteAll(); - delete PA; PA=0; - delete FDTD_Eng; FDTD_Eng=0; - delete FDTD_Op; FDTD_Op=0; + delete PA; + PA=0; + delete FDTD_Eng; + FDTD_Eng=0; + delete FDTD_Op; + FDTD_Op=0; } //! \brief processes a command line argument @@ -203,7 +206,7 @@ bool openEMS::SetupBoundaryConditions(TiXmlElement* BC) string bound_names[] = {"xmin","xmax","ymin","ymax","zmin","zmax"}; - for (int n=0;n<6;++n) + for (int n=0; n<6; ++n) { EC = BC->QueryIntAttribute(bound_names[n].c_str(),&bounds[n]); if (EC==TIXML_SUCCESS) @@ -219,7 +222,7 @@ bool openEMS::SetupBoundaryConditions(TiXmlElement* BC) bounds[n] = 1; else if (s_bc=="MUR") bounds[n] = 2; - else if(strncmp(s_bc.c_str(),"PML_=",4)==0) + else if (strncmp(s_bc.c_str(),"PML_=",4)==0) { bounds[n] = 3; pml_size[n] = atoi(s_bc.c_str()+4); @@ -240,7 +243,7 @@ bool openEMS::SetupBoundaryConditions(TiXmlElement* BC) if (BC->QueryDoubleAttribute("MUR_PhaseVelocity",&mur_v_ph) != TIXML_SUCCESS) mur_v_ph = -1; string mur_v_ph_names[6] = {"MUR_PhaseVelocity_xmin", "MUR_PhaseVelocity_xmax", "MUR_PhaseVelocity_ymin", "MUR_PhaseVelocity_ymax", "MUR_PhaseVelocity_zmin", "MUR_PhaseVelocity_zmax"}; - for (int n=0;n<6;++n) + for (int n=0; n<6; ++n) { if (bounds[n]==2) //Mur-ABC { @@ -340,7 +343,7 @@ int openEMS::SetupFDTD(const char* file) if (CylinderCoords) if (CSX.GetCoordInputType()!=CYLINDRICAL) { - cerr << "openEMS::SetupFDTD: Warning: Coordinate system found in the CSX file is not a cylindrical. Forcing to cylindrical coordinate system!" << endl; + cerr << "openEMS::SetupFDTD: Warning: Coordinate system found in the CSX file is not a cylindrical. Forcing to cylindrical coordinate system!" << endl; CSX.SetCoordInputType(CYLINDRICAL); //tell CSX to use cylinder-coords } @@ -396,7 +399,7 @@ int openEMS::SetupFDTD(const char* file) if (m_debugPEC) debugFlags |= Operator::debugPEC; FDTD_Op->CalcECOperator( debugFlags ); - + unsigned int maxTime_TS = (unsigned int)(maxTime/FDTD_Op->GetTimestep()); if ((maxTime_TS>0) && (maxTime_TS Probes = CSX.GetPropertyByType(CSProperties::PROBEBOX); - for (size_t i=0;iGetPrimitive(0); @@ -438,8 +442,12 @@ int openEMS::SetupFDTD(const char* file) bool acc; double bnd[6] = {0,0,0,0,0,0}; acc = prim->GetBoundBox(bnd,true); - start[0]= bnd[0];start[1]=bnd[2];start[2]=bnd[4]; - stop[0] = bnd[1];stop[1] =bnd[3];stop[2] =bnd[5]; + start[0]= bnd[0]; + start[1]=bnd[2]; + start[2]=bnd[4]; + stop[0] = bnd[1]; + stop[1] =bnd[3]; + stop[2] =bnd[5]; CSPropProbeBox* pb = Probes.at(i)->ToProbeBox(); Processing* proc = NULL; if (pb) @@ -490,7 +498,7 @@ int openEMS::SetupFDTD(const char* file) } vector DumpProps = CSX.GetPropertyByType(CSProperties::DUMPBOX); - for (size_t i=0;iSetEnable(Enable_Dumps); @@ -505,8 +513,12 @@ int openEMS::SetupFDTD(const char* file) bool acc; double bnd[6] = {0,0,0,0,0,0}; acc = prim->GetBoundBox(bnd,true); - start[0]= bnd[0];start[1]=bnd[2];start[2]=bnd[4]; - stop[0] = bnd[1];stop[1] =bnd[3];stop[2] =bnd[5]; + 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(i)->ToDumpBox(); if (db) { @@ -516,7 +528,7 @@ int openEMS::SetupFDTD(const char* file) ProcTD->SetFileType((ProcessFields::FileType)db->GetFileType()); if (CylinderCoords) ProcTD->SetMeshType(Processing::CYLINDRICAL_MESH); - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) ProcTD->SetSubSampling(db->GetSubSampling(n),n); ProcTD->SetFilePattern(db->GetName()); ProcTD->SetFileName(db->GetName()); @@ -587,7 +599,7 @@ void openEMS::RunFDTD() //add all timesteps to end-crit field processing with max excite amplitude unsigned int maxExcite = FDTD_Op->Exc->GetMaxExcitationTimestep(); - for (unsigned int n=0;nExc->Volt_Count;++n) + for (unsigned int n=0; nExc->Volt_Count; ++n) ProcField->AddStep(FDTD_Op->Exc->Volt_delay[n]+maxExcite); double change=1; diff --git a/openems.h b/openems.h index 20e7c07..87736f8 100644 --- a/openems.h +++ b/openems.h @@ -31,7 +31,7 @@ class TiXmlElement; class openEMS { public: - openEMS(); + openEMS(); ~openEMS(); bool parseCommandLineArgument( const char *argv ); diff --git a/tools/AdrOp.cpp b/tools/AdrOp.cpp index 6c2c5fd..18b1c52 100644 --- a/tools/AdrOp.cpp +++ b/tools/AdrOp.cpp @@ -20,7 +20,12 @@ AdrOp::AdrOp(unsigned int muiImax, unsigned int muiJmax, unsigned int muiKmax, unsigned int muiLmax) { //error-handling... - error = new ErrorMsg(9); if (error==NULL) { fprintf(stderr,"Memory allocation failed!! exiting..."); exit(1); } + error = new ErrorMsg(9); + if (error==NULL) + { + fprintf(stderr,"Memory allocation failed!! exiting..."); + exit(1); + } error->SetMsg(1,"Adress Operator: Memory allocation failed!! exiting..."); error->SetMsg(2,"Adress Operator: Invalid Adress requested!! exiting..."); error->SetMsg(3,"Adress Operator: Invalid Position set!! exiting..."); @@ -30,12 +35,12 @@ AdrOp::AdrOp(unsigned int muiImax, unsigned int muiJmax, unsigned int muiKmax, u error->SetMsg(7,"Adress Operator: Cells not added to Adress Operator!! exiting..."); error->SetMsg(8,"Adress Operator: Invalid Node!! exiting..."); error->SetMsg(9,"Adress Operator: Grid invalid!! exiting..."); - + //if (muiImax<0) muiImax=0; //if (muiJmax<0) muiJmax=0; //if (muiKmax<0) muiKmax=0; //if (muiLmax<0) muiLmax=0; - + uiDimension=0; if (muiImax>0) uiDimension++; else exit(-1); @@ -43,7 +48,7 @@ AdrOp::AdrOp(unsigned int muiImax, unsigned int muiJmax, unsigned int muiKmax, u else exit(-2); if (muiKmax>0) uiDimension++; if ( (muiLmax>0) && (muiKmax>0) ) uiDimension++; -// cout << "\n-----Adress Operator created: Dimension: " << uiDimension << "----" <uiDimension; uiSize=origOP->uiSize; uiImax=origOP->uiImax; @@ -78,19 +86,19 @@ AdrOp::AdrOp(AdrOp* origOP) uiJpos=origOP->uiJpos; uiKpos=origOP->uiKpos; uiLpos=origOP->uiLpos; - for (int ii=0;ii<4;++ii) dGrid[ii]=origOP->dGrid[ii]; + for (int ii=0; ii<4; ++ii) dGrid[ii]=origOP->dGrid[ii]; dDeltaUnit=origOP->dDeltaUnit; iIshift=origOP->iIshift; iJshift=origOP->iJshift; iKshift=origOP->iKshift; - for (int ii=0;ii<3;++ii) iCellShift[ii]=origOP->iCellShift[ii]; + for (int ii=0; ii<3; ++ii) iCellShift[ii]=origOP->iCellShift[ii]; i=origOP->i; j=origOP->j; k=origOP->k; l=origOP->l; reflect=origOP->reflect; uiTypeOffset=origOP->uiTypeOffset; - + bPosSet=origOP->bPosSet; bDebug=origOP->bDebug; // return; @@ -100,8 +108,10 @@ AdrOp::AdrOp(AdrOp* origOP) AdrOp::~AdrOp() { // cerr << "\n------Adress Operator deconstructed-----\n" << endl; - delete error; error=NULL; - delete clCellAdr; clCellAdr=NULL; + delete error; + error=NULL; + delete clCellAdr; + clCellAdr=NULL; } unsigned int AdrOp::SetPos(unsigned int muiIpos, unsigned int muiJpos, unsigned int muiKpos, unsigned int muiLpos) @@ -173,16 +183,16 @@ unsigned int AdrOp::GetPos(int muiIrel, int muiJrel, int muiKrel, int /*muiLrel* if (bPosSet==false) error->Error(6); if (reflect) { - #if EXPENSE_LOG==1 - if (muiIrel+(int)uiIpos<0) ADRESSEXPENSE(2,1,0,0,1,0) +#if EXPENSE_LOG==1 + if (muiIrel+(int)uiIpos<0) ADRESSEXPENSE(2,1,0,0,1,0) if (muiIrel+(int)uiIpos>(int)uiImax-1) ADRESSEXPENSE(4,1,0,0,1,0) - if (muiJrel+(int)uiJpos<0) ADRESSEXPENSE(2,1,0,0,1,0) - if (muiJrel+(int)uiJpos>(int)uiJmax-1) ADRESSEXPENSE(4,1,0,0,1,0) - if (muiKrel+(int)uiKpos<0) ADRESSEXPENSE(2,1,0,0,1,0) - if (muiKrel+(int)uiKpos>(int)uiKmax-1) ADRESSEXPENSE(4,1,0,0,1,0) - #endif + if (muiJrel+(int)uiJpos<0) ADRESSEXPENSE(2,1,0,0,1,0) + if (muiJrel+(int)uiJpos>(int)uiJmax-1) ADRESSEXPENSE(4,1,0,0,1,0) + if (muiKrel+(int)uiKpos<0) ADRESSEXPENSE(2,1,0,0,1,0) + if (muiKrel+(int)uiKpos>(int)uiKmax-1) ADRESSEXPENSE(4,1,0,0,1,0) +#endif - if (muiIrel+(int)uiIpos<0) muiIrel=-2*uiIpos-muiIrel-uiTypeOffset; + if (muiIrel+(int)uiIpos<0) muiIrel=-2*uiIpos-muiIrel-uiTypeOffset; if (muiIrel+(int)uiIpos>(int)uiImax-1) muiIrel=2*(uiImax-1-uiIpos)-muiIrel+uiTypeOffset; if (muiJrel+(int)uiJpos<0) muiJrel=-2*uiJpos-muiJrel-uiTypeOffset; if (muiJrel+(int)uiJpos>(int)uiJmax-1) muiJrel=2*(uiJmax-1-uiJpos)-muiJrel+uiTypeOffset; @@ -193,7 +203,7 @@ unsigned int AdrOp::GetPos(int muiIrel, int muiJrel, int muiKrel, int /*muiLrel* { ADRESSEXPENSE(7,1,0,0,0,7) if ( (muiIrel+uiIposError(2); return 0; } @@ -201,7 +211,7 @@ unsigned int AdrOp::GetPos(int muiIrel, int muiJrel, int muiKrel, int /*muiLrel* { ADRESSEXPENSE(9,3,0,0,0,11) if ( (muiIrel+uiIposError(2); return 0; } @@ -217,7 +227,7 @@ unsigned int AdrOp::GetPosFromNode(int ny, unsigned int uiNode) help=help/uiImax; j=help%uiJmax; help=help/uiJmax; - if (uiKmax>0) + if (uiKmax>0) { k=help%uiKmax; help=help/uiKmax; @@ -227,22 +237,22 @@ unsigned int AdrOp::GetPosFromNode(int ny, unsigned int uiNode) ADRESSEXPENSE(0,7,0,0,13,4) switch (ny) { - case 0: + case 0: { return i; break; } - case 1: + case 1: { return j; break; } - case 2: + case 2: { return k; break; } - case 3: + case 3: { return l; break; @@ -253,22 +263,34 @@ unsigned int AdrOp::GetPosFromNode(int ny, unsigned int uiNode) double AdrOp::GetNodeVolume(unsigned int uiNode) { - for (unsigned int n=0;nError(9); + for (unsigned int n=0; nError(9); double dVol=1; unsigned int uiMax[4]={uiImax,uiJmax,uiKmax,uiLmax}; unsigned int uiPos[4]={GetPosFromNode(0,uiNode),GetPosFromNode(1,uiNode),GetPosFromNode(2,uiNode),GetPosFromNode(3,uiNode)}; - for (unsigned int n=0;n0) && (uiPos[n]0) && (uiPos[n]==uiMax[n]-1)) { dVol*=dDeltaUnit*(dGrid[n][uiPos[n]]-dGrid[n][uiPos[n]-1]); ADRESSEXPENSE(3,0,1,2,0,4) } + if ((uiPos[n]>0) && (uiPos[n]0) && (uiPos[n]==uiMax[n]-1)) + { + dVol*=dDeltaUnit*(dGrid[n][uiPos[n]]-dGrid[n][uiPos[n]-1]); + ADRESSEXPENSE(3,0,1,2,0,4) + } } return dVol; } double AdrOp::GetIndexWidth(int ny, int index) { - for (unsigned int n=0;nError(9); + for (unsigned int n=0; nError(9); double width=0; while (ny<0) ny+=uiDimension; ny=ny%uiDimension; @@ -282,7 +304,7 @@ double AdrOp::GetIndexWidth(int ny, int index) double AdrOp::GetIndexCoord(int ny, int index) { - for (unsigned int n=0;nError(9); + for (unsigned int n=0; nError(9); while (ny<0) ny+=uiDimension; ny=ny%uiDimension; unsigned int uiMax[4]={uiImax,uiJmax,uiKmax,uiLmax}; @@ -296,7 +318,7 @@ double AdrOp::GetIndexDelta(int ny, int index) if (index<0) return GetIndexCoord(ny, 0) - GetIndexCoord(ny, 1); unsigned int uiMax[4]={uiImax,uiJmax,uiKmax,uiLmax}; if (index>=(int)uiMax[ny]-1) return GetIndexCoord(ny, (int)uiMax[ny]-2) - GetIndexCoord(ny, (int)uiMax[ny]-1); - return GetIndexCoord(ny, index+1) - GetIndexCoord(ny, index); + return GetIndexCoord(ny, index+1) - GetIndexCoord(ny, index); } @@ -307,21 +329,21 @@ unsigned int AdrOp::Shift(int ny, int step) ny=ny%uiDimension; switch (ny) { - case 0: + case 0: { iIshift=step; // if ((int)uiIpos+step<0) iIshift=-2*uiIpos-iIshift; // else if ((int)uiIpos+step>=(int)uiImax) iIshift=-1*iIshift+2*(uiImax-1-uiIpos); break; } - case 1: + case 1: { iJshift=step; // if ((int)uiJpos+iJshift<0) iJshift=-2*uiJpos-iJshift; // else if ((int)uiJpos+iJshift>=(int)uiJmax) iJshift=-1*iJshift+2*(uiJmax-1-uiJpos); break; } - case 2: + case 2: { iKshift=step; // if ((int)uiKpos+iKshift<0) iKshift=-2*uiKpos-iKshift; @@ -363,18 +385,18 @@ void AdrOp::ResetShift() unsigned int AdrOp::Iterate(int jump) { - if (abs(jump)>=(int)uiImax) error->Error(4); + if (abs(jump)>=(int)uiImax) error->Error(4); i=uiIpos+jump; - if (i>=uiImax) + if (i>=uiImax) { i=i-uiImax; j=uiJpos+1; if (j>=uiJmax) { j=0; - if (uiDimension==3) + if (uiDimension==3) { - k=uiKpos+1; + k=uiKpos+1; if (k>=uiKmax) k=0; uiKpos=k; } @@ -387,7 +409,7 @@ unsigned int AdrOp::Iterate(int jump) { uiIpos=i; return GetPos(); - } + } } unsigned int AdrOp::GetSize() @@ -416,21 +438,22 @@ void AdrOp::SetReflectionOff() AdrOp* AdrOp::AddCellAdrOp() { if (clCellAdr!=NULL) return clCellAdr; - if (uiDimension==3) clCellAdr = new AdrOp(uiImax-1,uiJmax-1,uiKmax-1); - else if (uiDimension==2) clCellAdr = new AdrOp(uiImax-1,uiJmax-1); - else clCellAdr=NULL; - if (clCellAdr!=NULL) - { - clCellAdr->SetPos(0,0,0); - clCellAdr->SetReflection2Cell(); - } - iCellShift[0]=iCellShift[1]=iCellShift[2]=0; + if (uiDimension==3) clCellAdr = new AdrOp(uiImax-1,uiJmax-1,uiKmax-1); + else if (uiDimension==2) clCellAdr = new AdrOp(uiImax-1,uiJmax-1); + else clCellAdr=NULL; + if (clCellAdr!=NULL) + { + clCellAdr->SetPos(0,0,0); + clCellAdr->SetReflection2Cell(); + } + iCellShift[0]=iCellShift[1]=iCellShift[2]=0; return clCellAdr; } AdrOp* AdrOp::DeleteCellAdrOp() { - delete clCellAdr; clCellAdr=NULL; + delete clCellAdr; + clCellAdr=NULL; return NULL; } @@ -459,11 +482,11 @@ unsigned int AdrOp::GetCellPos(bool incShift) { if (bPosSet==false) error->Error(6); if (clCellAdr==NULL) error->Error(7); - #if EXPENSE_LOG==1 - if (incShift) ADRESSEXPENSE(3,0,0,0,0,2) - #endif - if (incShift) return clCellAdr->GetPos(uiIpos+iCellShift[0],uiJpos+iCellShift[1],uiKpos+iCellShift[2]); - else return clCellAdr->GetPos(uiIpos,uiJpos,uiKpos); +#if EXPENSE_LOG==1 + if (incShift) ADRESSEXPENSE(3,0,0,0,0,2) +#endif + if (incShift) return clCellAdr->GetPos(uiIpos+iCellShift[0],uiJpos+iCellShift[1],uiKpos+iCellShift[2]); + else return clCellAdr->GetPos(uiIpos,uiJpos,uiKpos); } unsigned int AdrOp::GetCellPos(int i, int j, int k) @@ -475,14 +498,14 @@ unsigned int AdrOp::GetCellPos(int i, int j, int k) double AdrOp::GetShiftCellVolume(int ny, int step) { - for (unsigned int n=0;nError(9); + for (unsigned int n=0; nError(9); int uiMax[4]={uiImax-1,uiJmax-1,uiKmax-1,uiLmax-1}; while (ny<0) ny+=uiDimension; ny=ny%uiDimension; iCellShift[ny]=step; int uiPos[4]={uiIpos+iCellShift[0],uiJpos+iCellShift[1],uiKpos+iCellShift[2]}; double dVol=1; - for (unsigned int n=0;n0) { @@ -517,7 +540,12 @@ unsigned int deltaAdrOp::GetAdr(int pos) if (uiMax==1) return 0; if (pos<0) pos=pos*-1; else if (pos>(int)uiMax-1) pos=2*(uiMax-1)-pos+1; - if ((pos<0) || (pos>(int)uiMax-1)) {fprintf(stderr," Error exiting... "); getchar(); exit(-1);} + if ((pos<0) || (pos>(int)uiMax-1)) + { + fprintf(stderr," Error exiting... "); + getchar(); + exit(-1); + } return pos; } diff --git a/tools/AdrOp.h b/tools/AdrOp.h index 269866c..683c0c8 100644 --- a/tools/AdrOp.h +++ b/tools/AdrOp.h @@ -34,7 +34,8 @@ using namespace std; -class AdrOp{ +class AdrOp +{ public: ///Constructor, define dimension/size here AdrOp(unsigned int muiImax, unsigned int muiYmax, unsigned int muiKmax=0, unsigned int muiLmax=0); @@ -67,7 +68,7 @@ public: // double GetCellVolume(unsigned int uiCell); unsigned int GetPosFromNode(int ny, unsigned int uiNode); - ///Set a shift in ny direction (e.g. 0 for i-direction) + ///Set a shift in ny direction (e.g. 0 for i-direction) /*!Shift set by this methode will be ignored by methode GetPos*/ unsigned int Shift(int ny, int step); ///Set a checked shift in ny direction (e.g. 0 for i-direction) diff --git a/tools/ErrorMsg.cpp b/tools/ErrorMsg.cpp index 3232ee9..9a1974c 100644 --- a/tools/ErrorMsg.cpp +++ b/tools/ErrorMsg.cpp @@ -23,20 +23,35 @@ ErrorMsg::ErrorMsg(unsigned int NoMessage) { NoMsg=NoMessage; - if (NoMsg>0) Msg = new char*[NoMsg]; if (Msg==NULL) { fprintf(stderr,"Memory allocation failed!! exiting..."); exit(1); } - for (unsigned int i=0;i0) Msg = new char*[NoMsg]; + if (Msg==NULL) + { + fprintf(stderr,"Memory allocation failed!! exiting..."); + exit(1); + } + for (unsigned int i=0; iNoMsg) || (Message==NULL)) ownError(); - Msg[nr-1] = new char[strlen(Message)+1]; if (Msg[nr-1]==NULL) { fprintf(stderr,"Memory allocation failed!! exiting..."); exit(1); } + Msg[nr-1] = new char[strlen(Message)+1]; + if (Msg[nr-1]==NULL) + { + fprintf(stderr,"Memory allocation failed!! exiting..."); + exit(1); + } Msg[nr-1]=strcpy(Msg[nr-1],Message); } diff --git a/tools/ExpenseLog.cpp b/tools/ExpenseLog.cpp index ce9d50d..95a0d4c 100644 --- a/tools/ExpenseLog.cpp +++ b/tools/ExpenseLog.cpp @@ -2,7 +2,7 @@ ExpenseModule::ExpenseModule(const char* moduleName) { - chModuleName=moduleName; + chModuleName=moduleName; uiDoubleAdditions=uiDoubleMultiplications=uiIntAdditions=uiIntMultiplications=uiAssignments=uiBoolOp=0; uiMrdDA=uiMrdDM=uiMrdIA=uiMrdIM=uiMrdAssign=uiMrdBO=0; } @@ -12,23 +12,23 @@ ExpenseModule::~ExpenseModule() {}; void ExpenseModule::Clear() { uiDoubleAdditions=uiDoubleMultiplications=uiIntAdditions=uiIntMultiplications=uiAssignments=uiBoolOp=0; - uiMrdDA=uiMrdDM=uiMrdIA=uiMrdIM=uiMrdAssign=uiMrdBO=0; + uiMrdDA=uiMrdDM=uiMrdIA=uiMrdIM=uiMrdAssign=uiMrdBO=0; } -void ExpenseModule::AddDoubleAdditons(unsigned int number) +void ExpenseModule::AddDoubleAdditons(unsigned int number) { uiDoubleAdditions+=number; - if (uiDoubleAdditions>=MRD) + if (uiDoubleAdditions>=MRD) { uiDoubleAdditions-=MRD; ++uiMrdDA; } } -void ExpenseModule::AddDoubleMultiplications(unsigned int number) +void ExpenseModule::AddDoubleMultiplications(unsigned int number) { uiDoubleMultiplications+=number; - if (uiDoubleMultiplications>=MRD) + if (uiDoubleMultiplications>=MRD) { uiDoubleMultiplications-=MRD; ++uiMrdDM; @@ -38,7 +38,7 @@ void ExpenseModule::AddDoubleMultiplications(unsigned int number) void ExpenseModule::AddIntAdditons(unsigned int number) { uiIntAdditions+=number; - if (uiIntAdditions>=MRD) + if (uiIntAdditions>=MRD) { uiIntAdditions-=MRD; ++uiMrdIA; @@ -48,7 +48,7 @@ void ExpenseModule::AddIntAdditons(unsigned int number) void ExpenseModule::AddIntMultiplications(unsigned int number) { uiIntMultiplications+=number; - if (uiIntMultiplications>=MRD) + if (uiIntMultiplications>=MRD) { uiIntMultiplications-=MRD; ++uiMrdIM; @@ -58,7 +58,7 @@ void ExpenseModule::AddIntMultiplications(unsigned int number) void ExpenseModule::AddAssignments(unsigned int number) { uiAssignments+=number; - if (uiAssignments>=MRD) + if (uiAssignments>=MRD) { uiAssignments-=MRD; ++uiMrdAssign; @@ -68,13 +68,13 @@ void ExpenseModule::AddAssignments(unsigned int number) void ExpenseModule::AddBoolOperations(unsigned int number) { uiBoolOp+=number; - if (uiBoolOp>=MRD) + if (uiBoolOp>=MRD) { uiBoolOp-=MRD; ++uiMrdBO; } } - + void ExpenseModule::AddOperations(unsigned int IntAdd, unsigned int IntMul, unsigned int DoubleAdd, unsigned int DoubleMul, unsigned int Assigns, unsigned int BoolOp) { this->AddIntAdditons(IntAdd); @@ -85,7 +85,7 @@ void ExpenseModule::AddOperations(unsigned int IntAdd, unsigned int IntMul, unsi this->AddBoolOperations(BoolOp); } -void ExpenseModule::PrintfSelf(FILE* file) +void ExpenseModule::PrintfSelf(FILE* file) { fprintf(file,"\n***********\n Module: %s\n Additions:\n Double: %3.0d%9d\tInteger: %3.0d%9d",chModuleName,uiMrdDA,uiDoubleAdditions,uiMrdIA,uiIntAdditions); fprintf(file,"\n\n Multiplications:\n Double: %3.0d%9d\tInteger: %3.0d%9d\n",uiMrdDM,uiDoubleMultiplications,uiMrdIM,uiIntMultiplications); @@ -104,7 +104,11 @@ ExpenseLog::ExpenseLog(void) ExpenseLog::~ExpenseLog(void) { - for (size_t i=0;iuiIntAdditions+(double)vModules.at(i)->uiDoubleAdditions) + 1e9*((double)vModules.at(i)->uiMrdIA+(double)vModules.at(i)->uiMrdIA); totalMul+=((double)vModules.at(i)->uiIntMultiplications+(double)vModules.at(i)->uiDoubleMultiplications) + 1e9*(double)(vModules.at(i)->uiMrdIM+vModules.at(i)->uiMrdIM); @@ -133,9 +137,9 @@ void ExpenseLog::PrintAll(FILE *file) void ExpenseLog::ClearAll() { - for (size_t i=0;iClear(); - } + } } diff --git a/tools/ExpenseLog.h b/tools/ExpenseLog.h index e32af91..f8cc1ba 100644 --- a/tools/ExpenseLog.h +++ b/tools/ExpenseLog.h @@ -40,7 +40,7 @@ ExpenseModule* AdrOpExpense=EL.AddModule("Adress Operator"); class ExpenseModule { -friend class ExpenseLog; + friend class ExpenseLog; public: ExpenseModule(const char* moduleName); ~ExpenseModule(); diff --git a/tools/aligned_allocator.h b/tools/aligned_allocator.h index 80ec3da..efabe7d 100644 --- a/tools/aligned_allocator.h +++ b/tools/aligned_allocator.h @@ -26,17 +26,18 @@ #ifdef WIN32 - #define __MSVCRT_VERSION__ 0x0700 - #include - #define MEMALIGN( array, alignment, size ) !(*array = _aligned_malloc( size, alignment )) - #define FREE( array ) _aligned_free( array ) +#define __MSVCRT_VERSION__ 0x0700 +#include +#define MEMALIGN( array, alignment, size ) !(*array = _aligned_malloc( size, alignment )) +#define FREE( array ) _aligned_free( array ) #else - #define MEMALIGN( array, alignment, size ) posix_memalign( array, alignment, size ) - #define FREE( array ) free( array ) +#define MEMALIGN( array, alignment, size ) posix_memalign( array, alignment, size ) +#define FREE( array ) free( array ) #endif -template class aligned_allocator { +template class aligned_allocator +{ public: // The following will be the same for virtually all allocators. typedef T * pointer; @@ -47,30 +48,36 @@ public: typedef size_t size_type; typedef ptrdiff_t difference_type; - T * address(T& r) const { + T * address(T& r) const + { return &r; } - const T * address(const T& s) const { + const T * address(const T& s) const + { return &s; } - size_t max_size() const { + size_t max_size() const + { // The following has been carefully written to be independent of // the definition of size_t and to avoid signed/unsigned warnings. return (static_cast(0) - static_cast(1)) / sizeof(T); } // The following must be the same for all allocators. - template struct rebind { + template struct rebind + { typedef aligned_allocator other; }; - bool operator!=(const aligned_allocator& other) const { + bool operator!=(const aligned_allocator& other) const + { return !(*this == other); } - void construct(T * const p, const T& t) const { + void construct(T * const p, const T& t) const + { void * const pv = static_cast(p); new (pv) T(t); } @@ -80,7 +87,8 @@ public: // Returns true if and only if storage allocated from *this // can be deallocated from other, and vice versa. // Always returns true for stateless allocators. - bool operator==(const aligned_allocator& other) const { + bool operator==(const aligned_allocator& other) const + { return true; } @@ -92,7 +100,8 @@ public: ~aligned_allocator() { } // The following will be different for each allocator. - T * allocate(const size_t n) const { + T * allocate(const size_t n) const + { // std::cout << "Allocating " << n << (n == 1 ? " object" : "objects") << " of size " << sizeof(T) << "." << std::endl; // The return value of allocate(0) is unspecified. // aligned_allocator returns NULL in order to avoid depending @@ -100,14 +109,16 @@ public: // (the implementation can define malloc(0) to return NULL, // in which case the bad_alloc check below would fire). // All allocators can return NULL in this case. - if (n == 0) { + if (n == 0) + { return NULL; } // All allocators should contain an integer overflow check. // The Standardization Committee recommends that std::length_error // be thrown in the case of integer overflow. - if (n > max_size()) { + if (n > max_size()) + { throw std::length_error("aligned_allocator::allocate() - Integer overflow."); } @@ -119,7 +130,8 @@ public: return static_cast(pv); } - void deallocate(T * const p, const size_t n) const { + void deallocate(T * const p, const size_t n) const + { // std::cout << "Deallocating " << n << (n == 1 ? " object" : "objects") << " of size " << sizeof(T) << "." << std::endl; // aligned_allocator wraps free(). UNUSED(n); @@ -127,7 +139,8 @@ public: } // The following will be the same for all allocators that ignore hints. - template T * allocate(const size_t n, const U * /* const hint */) const { + template T * allocate(const size_t n, const U * /* const hint */) const + { return allocate(n); } @@ -145,15 +158,16 @@ private: // A compiler bug causes it to believe that p->~T() doesn't reference p. #ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable: 4100) // unreferenced formal parameter +#pragma warning(push) +#pragma warning(disable: 4100) // unreferenced formal parameter #endif // The definition of destroy() must be the same for all allocators. -template void aligned_allocator::destroy(T * const p) const { +template void aligned_allocator::destroy(T * const p) const +{ p->~T(); } #ifdef _MSC_VER - #pragma warning(pop) +#pragma warning(pop) #endif diff --git a/tools/array_ops.cpp b/tools/array_ops.cpp index 994dd12..a8ad8fa 100644 --- a/tools/array_ops.cpp +++ b/tools/array_ops.cpp @@ -19,14 +19,14 @@ #include #ifdef WIN32 - #define __MSVCRT_VERSION__ 0x0700 - #include - //(void**)&array, 16, sizeof(typeof(f4vector**))*numLines[0] - #define MEMALIGN( array, alignment, size ) !(*array = _aligned_malloc( size, alignment )) - #define FREE( array ) _aligned_free( array ) +#define __MSVCRT_VERSION__ 0x0700 +#include +//(void**)&array, 16, sizeof(typeof(f4vector**))*numLines[0] +#define MEMALIGN( array, alignment, size ) !(*array = _aligned_malloc( size, alignment )) +#define FREE( array ) _aligned_free( array ) #else - #define MEMALIGN( array, alignment, size ) posix_memalign( array, alignment, size ) - #define FREE( array ) free( array ) +#define MEMALIGN( array, alignment, size ) posix_memalign( array, alignment, size ) +#define FREE( array ) free( array ) #endif void Delete1DArray_v4sf(f4vector* array) @@ -40,9 +40,9 @@ void Delete3DArray_v4sf(f4vector*** array, const unsigned int* numLines) { if (array==NULL) return; unsigned int pos[3]; - for (pos[0]=0;pos[0]( numLines ); } @@ -131,9 +131,9 @@ void Delete3DArray(T*** array, const unsigned int* numLines) { if (!array) return; unsigned int pos[3]; - for (pos[0]=0;pos[0] void Delete_N_3DArray(T**** array, const unsigned int* numLines) { if (!array) return; - for (int n=0;n<3;++n) + for (int n=0; n<3; ++n) { Delete3DArray(array[n],numLines); } @@ -157,14 +157,14 @@ template void Dump_N_3DArray2File(ostream &file, T**** array, const unsigned int* numLines) { unsigned int pos[3]; - for (pos[0]=0;pos[0] AssignJobs2Threads(unsigned int jobs, unsigned int nrT std::vector jpt; //jobs per thread unsigned int ui_jpt = jobs/nrThreads; - for (unsigned int n=0;n0) {