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