ProcessFields now using new VTK_File_IO class for vtk dumps
Todo: - HDF5_File_IO - replace all old vtk dump method usage and remove thempull/1/head
parent
3dc19c1f4d
commit
62acf5f1b3
|
@ -18,6 +18,7 @@
|
|||
#include <iomanip>
|
||||
#include <H5Cpp.h>
|
||||
#include "tools/global.h"
|
||||
#include "tools/vtk_file_io.h"
|
||||
#include "processfields.h"
|
||||
#include "FDTD/engine_interface_fdtd.h"
|
||||
|
||||
|
@ -27,6 +28,7 @@ ProcessFields::ProcessFields(Engine_Interface_Base* eng_if) : Processing(eng_if)
|
|||
// vtk-file is default
|
||||
m_fileType = VTK_FILETYPE;
|
||||
m_SampleType = NONE;
|
||||
m_Dump_File = NULL;
|
||||
SetPrecision(6);
|
||||
m_dualTime = false;
|
||||
|
||||
|
@ -42,6 +44,8 @@ ProcessFields::ProcessFields(Engine_Interface_Base* eng_if) : Processing(eng_if)
|
|||
|
||||
ProcessFields::~ProcessFields()
|
||||
{
|
||||
delete m_Dump_File;
|
||||
m_Dump_File = NULL;
|
||||
for (int n=0; n<3; ++n)
|
||||
{
|
||||
delete[] posLines[n];
|
||||
|
@ -74,6 +78,19 @@ void ProcessFields::InitProcess()
|
|||
if (Enabled==false) return;
|
||||
|
||||
CalcMeshPos();
|
||||
|
||||
if (m_fileType==VTK_FILETYPE)
|
||||
{
|
||||
delete m_Dump_File;
|
||||
m_Dump_File = new VTK_File_IO(m_filename,(int)m_Mesh_Type);
|
||||
|
||||
#ifdef OUTPUT_IN_DRAWINGUNITS
|
||||
double discScaling = 1;
|
||||
#else
|
||||
double discScaling = Op->GetGridDelta();
|
||||
#endif
|
||||
m_Dump_File->SetMeshLines(discLines,numLines,discScaling);
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessFields::SetDumpMode(Engine_Interface_Base::InterpolationType mode)
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#define __VTK_DATA_TYPE__ "double"
|
||||
|
||||
class Base_File_IO;
|
||||
|
||||
class ProcessFields : public Processing
|
||||
{
|
||||
public:
|
||||
|
@ -51,10 +53,6 @@ public:
|
|||
//! Define a field dump optimal resolution for a given direction (default: \a dir = -1 means all directions)
|
||||
virtual void SetOptResolution(double optRes, int dir=-1);
|
||||
|
||||
//! Used file pattern e.g. pattern="tmp/efield_" --> "tmp/efield_000045.vtk" for timestep 45 or "tmp/efield_2.40000e9.vtk" for 2.4GHz E-field dump. (VTK FileType only) \sa SetFileType()
|
||||
void SetFilePattern(string fp) {m_filename=filePattern=fp;}
|
||||
string GetFilePattern() const {return filePattern;}
|
||||
|
||||
//! Set the filename for a hdf5 data group file (HDF5 FileType only) \sa SetFileType()
|
||||
void SetFileName(string fn) {m_filename=fn;}
|
||||
string SetFileName() const {return m_filename;}
|
||||
|
@ -105,9 +103,10 @@ public:
|
|||
|
||||
protected:
|
||||
DumpType m_DumpType;
|
||||
string filePattern;
|
||||
FileType m_fileType;
|
||||
|
||||
Base_File_IO* m_Dump_File;
|
||||
|
||||
enum SampleType {NONE, SUBSAMPLE, OPT_RESOLUTION} m_SampleType;
|
||||
virtual void CalcMeshPos();
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "processfields_fd.h"
|
||||
#include "Common/operator_base.h"
|
||||
#include "tools/vtk_file_io.h"
|
||||
#include <H5Cpp.h>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
@ -49,6 +50,9 @@ void ProcessFieldsFD::InitProcess()
|
|||
//setup the hdf5 file
|
||||
ProcessFields::InitProcess();
|
||||
|
||||
if (m_Dump_File)
|
||||
m_Dump_File->SetHeader(string("openEMS FD Field Dump -- Interpolation: ")+m_Eng_Interface->GetInterpolationTypeString());
|
||||
|
||||
if (m_fileType==HDF5_FILETYPE)
|
||||
{
|
||||
//create hdf5 file & necessary groups
|
||||
|
@ -129,12 +133,6 @@ void ProcessFieldsFD::PostProcess()
|
|||
|
||||
void ProcessFieldsFD::DumpFDData()
|
||||
{
|
||||
#ifdef OUTPUT_IN_DRAWINGUNITS
|
||||
double discLines_scaling = 1;
|
||||
#else
|
||||
double discLines_scaling = Op->GetGridDelta();
|
||||
#endif
|
||||
|
||||
if (m_fileType==VTK_FILETYPE)
|
||||
{
|
||||
unsigned int pos[3];
|
||||
|
@ -164,12 +162,13 @@ void ProcessFieldsFD::DumpFDData()
|
|||
}
|
||||
}
|
||||
stringstream ss;
|
||||
ss << m_filename << fixed << "_f=" << m_FD_Samples.at(n) << "_p=" << std::setw( 3 ) << std::setfill( '0' ) <<(int)(angle * 180 / M_PI) << ".vtk";
|
||||
ofstream file(ss.str().c_str());
|
||||
if (file.is_open()==false)
|
||||
cerr << "ProcessFieldsFD::DumpFDData: can't open file '" << ss.str() << "' 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();
|
||||
ss << m_filename << fixed << "_f=" << m_FD_Samples.at(n) << "_p=" << std::setw( 3 ) << std::setfill( '0' ) <<(int)(angle * 180 / M_PI);
|
||||
|
||||
m_Dump_File->SetFilename(ss.str());
|
||||
m_Dump_File->ClearAllFields();
|
||||
m_Dump_File->AddVectorField(GetFieldNameByType(m_DumpType),field,numLines);
|
||||
if (m_Dump_File->Write()==false)
|
||||
cerr << "ProcessFieldsFD::Process: can't dump to file... abort! " << endl;
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -187,12 +186,12 @@ void ProcessFieldsFD::DumpFDData()
|
|||
}
|
||||
}
|
||||
stringstream ss;
|
||||
ss << m_filename << fixed << "_f=" << m_FD_Samples.at(n) << "_abs" << ".vtk";
|
||||
ofstream file(ss.str().c_str());
|
||||
if (file.is_open()==false)
|
||||
cerr << "ProcessFieldsFD::DumpFDData: can't open file '" << ss.str() << "' 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();
|
||||
ss << m_filename << fixed << "_f=" << m_FD_Samples.at(n) << "_abs";
|
||||
m_Dump_File->SetFilename(ss.str());
|
||||
m_Dump_File->ClearAllFields();
|
||||
m_Dump_File->AddVectorField(GetFieldNameByType(m_DumpType),field,numLines);
|
||||
if (m_Dump_File->Write()==false)
|
||||
cerr << "ProcessFieldsFD::Process: can't dump to file... abort! " << endl;
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -210,12 +209,12 @@ void ProcessFieldsFD::DumpFDData()
|
|||
}
|
||||
}
|
||||
stringstream ss;
|
||||
ss << m_filename << fixed << "_f=" << m_FD_Samples.at(n) << "_arg" << ".vtk";
|
||||
ofstream file(ss.str().c_str());
|
||||
if (file.is_open()==false)
|
||||
cerr << "ProcessFieldsFD::DumpFDData: can't open file '" << ss.str() << "' 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();
|
||||
ss << m_filename << fixed << "_f=" << m_FD_Samples.at(n) << "_arg";
|
||||
m_Dump_File->SetFilename(ss.str());
|
||||
m_Dump_File->ClearAllFields();
|
||||
m_Dump_File->AddVectorField(GetFieldNameByType(m_DumpType),field,numLines);
|
||||
if (m_Dump_File->Write()==false)
|
||||
cerr << "ProcessFieldsFD::Process: can't dump to file... abort! " << endl;
|
||||
}
|
||||
}
|
||||
Delete_N_3DArray(field,numLines);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "processfields_td.h"
|
||||
#include "Common/operator_base.h"
|
||||
#include "tools/vtk_file_io.h"
|
||||
#include <H5Cpp.h>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
@ -37,6 +38,15 @@ void ProcessFieldsTD::InitProcess()
|
|||
|
||||
ProcessFields::InitProcess();
|
||||
|
||||
if (m_Dump_File)
|
||||
m_Dump_File->SetHeader(string("openEMS TD Field Dump -- Interpolation: ")+m_Eng_Interface->GetInterpolationTypeString());
|
||||
|
||||
#ifdef OUTPUT_IN_DRAWINGUNITS
|
||||
double discScaling = 1;
|
||||
#else
|
||||
double discScaling = Op->GetGridDelta();
|
||||
#endif
|
||||
|
||||
if (m_fileType==HDF5_FILETYPE)
|
||||
{
|
||||
//create hdf5 file & necessary groups
|
||||
|
@ -49,11 +59,6 @@ void ProcessFieldsTD::InitProcess()
|
|||
delete file;
|
||||
|
||||
//write mesh information in main root-group
|
||||
#ifdef OUTPUT_IN_DRAWINGUNITS
|
||||
double discScaling = 1;
|
||||
#else
|
||||
double discScaling = Op->GetGridDelta();
|
||||
#endif
|
||||
ProcessFields::WriteMesh2HDF5(m_filename,"/",numLines,discLines,m_Mesh_Type, discScaling);
|
||||
}
|
||||
}
|
||||
|
@ -61,37 +66,19 @@ void ProcessFieldsTD::InitProcess()
|
|||
int ProcessFieldsTD::Process()
|
||||
{
|
||||
if (Enabled==false) return -1;
|
||||
if (filePattern.empty()) return -1;
|
||||
if (CheckTimestep()==false) return GetNextInterval();
|
||||
|
||||
string filename;
|
||||
string filename = m_filename;
|
||||
|
||||
float**** field = CalcField();
|
||||
|
||||
if (m_fileType==VTK_FILETYPE)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << filePattern << std::setw( pad_length ) << std::setfill( '0' ) << m_Eng_Interface->GetNumberOfTimesteps() << ".vtk";
|
||||
filename = ss.str();
|
||||
}
|
||||
else
|
||||
filename = m_filename;
|
||||
|
||||
#ifdef OUTPUT_IN_DRAWINGUNITS
|
||||
double discLines_scaling = 1;
|
||||
#else
|
||||
double discLines_scaling = Op->GetGridDelta();
|
||||
#endif
|
||||
|
||||
FDTD_FLOAT**** field = CalcField();
|
||||
|
||||
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;
|
||||
};
|
||||
DumpVectorArray2VTK(file,GetFieldNameByType(m_DumpType),field,discLines,numLines,m_precision,string("Interpolation: ")+m_Eng_Interface->GetInterpolationTypeString(), m_Mesh_Type, discLines_scaling);
|
||||
file.close();
|
||||
m_Dump_File->SetTimestep(m_Eng_Interface->GetNumberOfTimesteps());
|
||||
m_Dump_File->ClearAllFields();
|
||||
m_Dump_File->AddVectorField(GetFieldNameByType(m_DumpType),field,numLines);
|
||||
if (m_Dump_File->Write()==false)
|
||||
cerr << "ProcessFieldsTD::Process: can't dump to file... abort! " << endl;
|
||||
}
|
||||
else if (m_fileType==HDF5_FILETYPE)
|
||||
{
|
||||
|
|
|
@ -408,7 +408,6 @@ bool openEMS_FDTD_MPI::SetupProcessing()
|
|||
stringstream name_ss;
|
||||
name_ss << "ID" << m_MyID << "_" << ProcField->GetName();
|
||||
ProcField->SetName(name_ss.str());
|
||||
ProcField->SetFilePattern(name_ss.str());
|
||||
ProcField->SetFileName(name_ss.str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -418,7 +418,6 @@ bool openEMS::SetupProcessing()
|
|||
for (int n=0; n<3; ++n)
|
||||
ProcField->SetOptResolution(db->GetOptResolution(n),n);
|
||||
ProcField->SetName(db->GetName());
|
||||
ProcField->SetFilePattern(db->GetName());
|
||||
ProcField->SetFileName(db->GetName());
|
||||
ProcField->DefineStartStopCoord(start,stop);
|
||||
PA->AddProcessing(ProcField);
|
||||
|
|
Loading…
Reference in New Issue