diff --git a/Common/processfields.cpp b/Common/processfields.cpp index 38a7eb4..1346758 100644 --- a/Common/processfields.cpp +++ b/Common/processfields.cpp @@ -460,3 +460,53 @@ bool ProcessFields::DumpVectorArray2HDF5(string filename, string name, FDTD_FLOA dataset.write( hdf5array, H5::PredType::NATIVE_FLOAT ); return true; } + +FDTD_FLOAT**** ProcessFields::CalcField() +{ + unsigned int pos[3]; + unsigned int OpPos[3]; + double out[3]; + //create array + FDTD_FLOAT**** field = Create_N_3DArray(numLines); + if (m_DumpType==E_FIELD_DUMP) + { + for (pos[0]=0; pos[0]GetEField(OpPos,out); + field[0][pos[0]][pos[1]][pos[2]] = out[0]; + field[1][pos[0]][pos[1]][pos[2]] = out[1]; + field[2][pos[0]][pos[1]][pos[2]] = out[2]; + } + } + } + } + + if (m_DumpType==H_FIELD_DUMP) + { + for (pos[0]=0; pos[0]GetHField(OpPos,out); + field[0][pos[0]][pos[1]][pos[2]] = out[0]; + field[1][pos[0]][pos[1]][pos[2]] = out[1]; + field[2][pos[0]][pos[1]][pos[2]] = out[2]; + } + } + } + } + return field; +} + diff --git a/Common/processfields.h b/Common/processfields.h index 914c881..75a750c 100644 --- a/Common/processfields.h +++ b/Common/processfields.h @@ -91,6 +91,9 @@ protected: //! dump mesh unsigned int numLines[3]; double* discLines[3]; + + //! Calculate and return the defined field. Caller has to cleanup the array. + FDTD_FLOAT**** CalcField(); }; #endif // PROCESSFIELDS_H diff --git a/Common/processfields_td.cpp b/Common/processfields_td.cpp index da41136..107afa6 100644 --- a/Common/processfields_td.cpp +++ b/Common/processfields_td.cpp @@ -53,50 +53,7 @@ int ProcessFieldsTD::Process() double discLines_scaling = Op->GetGridDelta(); #endif - unsigned int pos[3]; - unsigned int OpPos[3]; - double out[3]; - //create array - FDTD_FLOAT**** field = Create_N_3DArray(numLines); - if (m_DumpType==E_FIELD_DUMP) - { - for (pos[0]=0; pos[0]GetEField(OpPos,out); - field[0][pos[0]][pos[1]][pos[2]] = out[0]; - field[1][pos[0]][pos[1]][pos[2]] = out[1]; - field[2][pos[0]][pos[1]][pos[2]] = out[2]; - } - } - } - } - - if (m_DumpType==H_FIELD_DUMP) - { - for (pos[0]=0; pos[0]GetHField(OpPos,out); - field[0][pos[0]][pos[1]][pos[2]] = out[0]; - field[1][pos[0]][pos[1]][pos[2]] = out[1]; - field[2][pos[0]][pos[1]][pos[2]] = out[2]; - } - } - } - } + FDTD_FLOAT**** field = CalcField(); if (m_fileType==VTK_FILETYPE) { @@ -119,6 +76,5 @@ int ProcessFieldsTD::Process() Delete_N_3DArray(field,numLines); - return GetNextInterval(); }