2010-03-11 15:47:40 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2010-03-02 13:54:50 +00:00
|
|
|
#include "processfields_td.h"
|
2010-12-06 08:59:42 +00:00
|
|
|
#include "Common/operator_base.h"
|
2010-03-02 13:54:50 +00:00
|
|
|
#include <iomanip>
|
|
|
|
#include <sstream>
|
|
|
|
#include <string>
|
|
|
|
|
2010-12-07 15:47:23 +00:00
|
|
|
ProcessFieldsTD::ProcessFieldsTD(Engine_Interface_Base* eng_if) : ProcessFields(eng_if)
|
2010-03-02 13:54:50 +00:00
|
|
|
{
|
|
|
|
pad_length = 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcessFieldsTD::~ProcessFieldsTD()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-02 12:51:34 +00:00
|
|
|
int ProcessFieldsTD::Process()
|
2010-03-02 13:54:50 +00:00
|
|
|
{
|
2010-12-02 12:51:34 +00:00
|
|
|
if (Enabled==false) return -1;
|
|
|
|
if (filePattern.empty()) return -1;
|
|
|
|
if (CheckTimestep()==false) return GetNextInterval();
|
2010-07-15 10:58:48 +00:00
|
|
|
|
2010-12-02 12:51:34 +00:00
|
|
|
string filename;
|
2010-04-05 18:22:03 +00:00
|
|
|
|
2010-12-02 12:51:34 +00:00
|
|
|
if (m_fileType==VTK_FILETYPE)
|
2010-03-02 14:37:00 +00:00
|
|
|
{
|
2010-12-02 12:51:34 +00:00
|
|
|
stringstream ss;
|
2010-12-02 13:29:46 +00:00
|
|
|
ss << filePattern << std::setw( pad_length ) << std::setfill( '0' ) << m_Eng_Interface->GetNumberOfTimesteps() << ".vtk";
|
2010-12-02 12:51:34 +00:00
|
|
|
filename = ss.str();
|
2010-03-02 14:37:00 +00:00
|
|
|
}
|
2010-12-02 12:51:34 +00:00
|
|
|
else
|
|
|
|
filename = m_filename;
|
2010-03-09 20:35:57 +00:00
|
|
|
|
2010-07-15 10:58:48 +00:00
|
|
|
#ifdef OUTPUT_IN_DRAWINGUNITS
|
|
|
|
double discLines_scaling = 1;
|
|
|
|
#else
|
|
|
|
double discLines_scaling = Op->GetGridDelta();
|
|
|
|
#endif
|
|
|
|
|
2010-03-16 20:41:17 +00:00
|
|
|
unsigned int pos[3];
|
2010-04-07 10:57:45 +00:00
|
|
|
unsigned int OpPos[3];
|
2010-12-02 12:51:34 +00:00
|
|
|
double out[3];
|
|
|
|
//create array
|
|
|
|
FDTD_FLOAT**** field = Create_N_3DArray<FDTD_FLOAT>(numLines);
|
2010-04-05 18:22:03 +00:00
|
|
|
if (m_DumpType==E_FIELD_DUMP)
|
2010-03-09 20:35:57 +00:00
|
|
|
{
|
2010-12-06 12:04:37 +00:00
|
|
|
for (pos[0]=0; pos[0]<numLines[0]; ++pos[0])
|
2010-03-09 20:35:57 +00:00
|
|
|
{
|
2010-04-07 10:57:45 +00:00
|
|
|
OpPos[0]=start[0]+pos[0]*subSample[0];
|
2010-12-06 12:04:37 +00:00
|
|
|
for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
|
2010-03-09 20:35:57 +00:00
|
|
|
{
|
2010-04-07 10:57:45 +00:00
|
|
|
OpPos[1]=start[1]+pos[1]*subSample[1];
|
2010-12-06 12:04:37 +00:00
|
|
|
for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
|
2010-03-09 20:35:57 +00:00
|
|
|
{
|
2010-04-07 10:57:45 +00:00
|
|
|
OpPos[2]=start[2]+pos[2]*subSample[2];
|
2010-12-02 12:51:34 +00:00
|
|
|
m_Eng_Interface->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];
|
2010-03-09 20:35:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-05 18:22:03 +00:00
|
|
|
if (m_DumpType==H_FIELD_DUMP)
|
2010-03-09 20:35:57 +00:00
|
|
|
{
|
2010-12-06 12:04:37 +00:00
|
|
|
for (pos[0]=0; pos[0]<numLines[0]; ++pos[0])
|
2010-03-09 20:35:57 +00:00
|
|
|
{
|
2010-04-07 10:57:45 +00:00
|
|
|
OpPos[0]=start[0]+pos[0]*subSample[0];
|
2010-12-06 12:04:37 +00:00
|
|
|
for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
|
2010-03-09 20:35:57 +00:00
|
|
|
{
|
2010-04-07 10:57:45 +00:00
|
|
|
OpPos[1]=start[1]+pos[1]*subSample[1];
|
2010-12-06 12:04:37 +00:00
|
|
|
for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
|
2010-03-09 20:35:57 +00:00
|
|
|
{
|
2010-04-07 10:57:45 +00:00
|
|
|
OpPos[2]=start[2]+pos[2]*subSample[2];
|
2010-12-02 12:51:34 +00:00
|
|
|
m_Eng_Interface->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];
|
2010-03-09 20:35:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-05 18:22:03 +00:00
|
|
|
if (m_fileType==VTK_FILETYPE)
|
|
|
|
{
|
2010-12-02 12:51:34 +00:00
|
|
|
ofstream file(filename.c_str());
|
2010-12-06 12:04:37 +00:00
|
|
|
if (file.is_open()==false)
|
|
|
|
{
|
|
|
|
cerr << "ProcessFieldsTD::Process: can't open file '" << filename << "' for writing... abort! " << endl;
|
|
|
|
};
|
2010-12-02 12:51:34 +00:00
|
|
|
DumpVectorArray2VTK(file,GetFieldNameByType(m_DumpType),field,discLines,numLines,m_precision,string("Interpolation: ")+m_Eng_Interface->GetInterpolationTypeString(), m_Mesh_Type, discLines_scaling);
|
|
|
|
file.close();
|
2010-04-05 18:22:03 +00:00
|
|
|
}
|
|
|
|
else if (m_fileType==HDF5_FILETYPE)
|
|
|
|
{
|
2010-12-02 12:51:34 +00:00
|
|
|
stringstream ss;
|
2010-12-02 13:29:46 +00:00
|
|
|
ss << std::setw( pad_length ) << std::setfill( '0' ) << m_Eng_Interface->GetNumberOfTimesteps();
|
|
|
|
DumpVectorArray2HDF5(filename.c_str(),string( ss.str() ),field,numLines,(0.5+m_Eng_Interface->GetNumberOfTimesteps())*Op->GetTimestep());
|
2010-04-05 18:22:03 +00:00
|
|
|
}
|
2010-12-02 12:51:34 +00:00
|
|
|
else
|
|
|
|
cerr << "ProcessFieldsTD::Process: unknown File-Type" << endl;
|
|
|
|
|
|
|
|
Delete_N_3DArray(field,numLines);
|
|
|
|
|
|
|
|
|
2010-03-10 11:15:14 +00:00
|
|
|
return GetNextInterval();
|
2010-03-02 13:54:50 +00:00
|
|
|
}
|