int ProcessFieldsTD::Process() { if (Enabled==false) return -1; if (CheckTimestep()==false) return GetNextInterval(); string filename = m_filename; float**** field = CalcField(); bool success = true; if (m_fileType==VTK_FILETYPE) { m_Vtk_Dump_File->SetTimestep(m_Eng_Interface->GetNumberOfTimesteps()); m_Vtk_Dump_File->ClearAllFields(); m_Vtk_Dump_File->AddVectorField(GetFieldNameByType(m_DumpType),field); success &= m_Vtk_Dump_File->Write(); } else if (m_fileType==HDF5_FILETYPE) { stringstream ss; ss << std::setw( pad_length ) << std::setfill( '0' ) << m_Eng_Interface->GetNumberOfTimesteps(); size_t datasize[]={numLines[0],numLines[1],numLines[2]}; success &= m_HDF5_Dump_File->WriteVectorField(ss.str(), field, datasize); float time[1]={m_Eng_Interface->GetTime(m_dualTime)}; success &= m_HDF5_Dump_File->WriteAtrribute("/FieldData/TD/"+ss.str(),"time",time,1); } else { success = false; cerr << "ProcessFieldsTD::Process: unknown File-Type" << endl; } Delete_N_3DArray<FDTD_FLOAT>(field,numLines); if (success==false) { SetEnable(false); cerr << "ProcessFieldsTD::Process: can't dump to file... disabled! " << endl; } return GetNextInterval(); }
int ProcessFieldsFD::Process() { if (Enabled==false) return -1; if (CheckTimestep()==false) return GetNextInterval(); if ((m_FD_Interval==0) || (m_Eng_Interface->GetNumberOfTimesteps()%m_FD_Interval!=0)) return GetNextInterval(); FDTD_FLOAT**** field_td = CalcField(); std::complex<float>**** field_fd = NULL; double T = m_Eng_Interface->GetTime(m_dualTime); unsigned int pos[3]; for (size_t n = 0; n<m_FD_Samples.size(); ++n) { std::complex<float> exp_jwt_2_dt = std::exp( (std::complex<float>)(-2.0 * _I * M_PI * m_FD_Samples.at(n) * T) ); exp_jwt_2_dt *= 2; // *2 for single-sided spectrum exp_jwt_2_dt *= Op->GetTimestep() * m_FD_Interval; // multiply with timestep-interval field_fd = m_FD_Fields.at(n); for (pos[0]=0; pos[0]<numLines[0]; ++pos[0]) { for (pos[1]=0; pos[1]<numLines[1]; ++pos[1]) { for (pos[2]=0; pos[2]<numLines[2]; ++pos[2]) { field_fd[0][pos[0]][pos[1]][pos[2]] += field_td[0][pos[0]][pos[1]][pos[2]] * exp_jwt_2_dt; field_fd[1][pos[0]][pos[1]][pos[2]] += field_td[1][pos[0]][pos[1]][pos[2]] * exp_jwt_2_dt; field_fd[2][pos[0]][pos[1]][pos[2]] += field_td[2][pos[0]][pos[1]][pos[2]] * exp_jwt_2_dt; } } } } Delete_N_3DArray<FDTD_FLOAT>(field_td,numLines); ++m_FD_SampleCount; return GetNextInterval(); }