define dump precision
parent
4db42917bb
commit
b4bc990b0f
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "processcurrent.h"
|
#include "processcurrent.h"
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
ProcessCurrent::ProcessCurrent(Operator* op, Engine* eng) : Processing(op, eng)
|
ProcessCurrent::ProcessCurrent(Operator* op, Engine* eng) : Processing(op, eng)
|
||||||
{
|
{
|
||||||
|
@ -97,6 +98,6 @@ int ProcessCurrent::Process()
|
||||||
// cerr << "ts: " << Eng->numTS << " i: " << current << endl;
|
// cerr << "ts: " << Eng->numTS << " i: " << current << endl;
|
||||||
v_current.push_back(current);
|
v_current.push_back(current);
|
||||||
//current is sampled half a timestep later then the voltages
|
//current is sampled half a timestep later then the voltages
|
||||||
file << (0.5 + (double)Eng->GetNumberOfTimesteps())*Op->GetTimestep() << "\t" << current << endl;
|
file << setprecision(m_precision) << (0.5 + (double)Eng->GetNumberOfTimesteps())*Op->GetTimestep() << "\t" << current << endl;
|
||||||
return GetNextInterval();
|
return GetNextInterval();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "processfields.h"
|
#include "processfields.h"
|
||||||
|
|
||||||
|
#include <iomanip>
|
||||||
#include "H5Cpp.h"
|
#include "H5Cpp.h"
|
||||||
|
|
||||||
ProcessFields::ProcessFields(Operator* op, Engine* eng) : Processing(op, eng)
|
ProcessFields::ProcessFields(Operator* op, Engine* eng) : Processing(op, eng)
|
||||||
|
@ -26,6 +27,7 @@ ProcessFields::ProcessFields(Operator* op, Engine* eng) : Processing(op, eng)
|
||||||
// vtk-file is default
|
// vtk-file is default
|
||||||
m_fileType = VTK_FILETYPE;
|
m_fileType = VTK_FILETYPE;
|
||||||
SetSubSampling(1);
|
SetSubSampling(1);
|
||||||
|
SetPrecision(6);
|
||||||
|
|
||||||
for (int n=0;n<3;++n)
|
for (int n=0;n<3;++n)
|
||||||
{
|
{
|
||||||
|
@ -203,7 +205,7 @@ void ProcessFields::SetSubSampling(unsigned int subSampleRate, int dir)
|
||||||
else subSample[dir]=subSampleRate;
|
else subSample[dir]=subSampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessFields::WriteVTKHeader(ofstream &file, double** discLines, unsigned int* numLines)
|
void ProcessFields::WriteVTKHeader(ofstream &file, double** discLines, unsigned int* numLines, unsigned int precision)
|
||||||
{
|
{
|
||||||
file << "# vtk DataFile Version 2.0" << endl;
|
file << "# vtk DataFile Version 2.0" << endl;
|
||||||
file << "Rectilinear Grid openEMS_ProcessFields" << endl;
|
file << "Rectilinear Grid openEMS_ProcessFields" << endl;
|
||||||
|
@ -212,20 +214,20 @@ void ProcessFields::WriteVTKHeader(ofstream &file, double** discLines, unsigned
|
||||||
file << "DIMENSIONS " << numLines[0] << " " << numLines[1] << " " << numLines[2] << endl;
|
file << "DIMENSIONS " << numLines[0] << " " << numLines[1] << " " << numLines[2] << endl;
|
||||||
file << "X_COORDINATES " << numLines[0] << " float" << endl;
|
file << "X_COORDINATES " << numLines[0] << " float" << endl;
|
||||||
for (unsigned int i=0;i<numLines[0];++i)
|
for (unsigned int i=0;i<numLines[0];++i)
|
||||||
file << discLines[0][i] << " ";
|
file << setprecision(precision) << discLines[0][i] << " ";
|
||||||
file << endl;
|
file << endl;
|
||||||
file << "Y_COORDINATES " << numLines[1] << " float" << endl;
|
file << "Y_COORDINATES " << numLines[1] << " float" << endl;
|
||||||
for (unsigned int i=0;i<numLines[1];++i)
|
for (unsigned int i=0;i<numLines[1];++i)
|
||||||
file << discLines[1][i] << " ";
|
file << setprecision(precision) << discLines[1][i] << " ";
|
||||||
file << endl;
|
file << endl;
|
||||||
file << "Z_COORDINATES " << numLines[2] << " float" << endl;
|
file << "Z_COORDINATES " << numLines[2] << " float" << endl;
|
||||||
for (unsigned int i=0;i<numLines[2];++i)
|
for (unsigned int i=0;i<numLines[2];++i)
|
||||||
file << discLines[2][i] << " ";
|
file << setprecision(precision) << discLines[2][i] << " ";
|
||||||
file << endl << endl;
|
file << endl << endl;
|
||||||
file << "POINT_DATA " << numLines[0]*numLines[1]*numLines[2] << endl;
|
file << "POINT_DATA " << numLines[0]*numLines[1]*numLines[2] << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessFields::WriteVTKVectorArray(ofstream &file, string name, FDTD_FLOAT**** array, unsigned int* numLines)
|
void ProcessFields::WriteVTKVectorArray(ofstream &file, string name, FDTD_FLOAT**** array, unsigned int* numLines, unsigned int precision)
|
||||||
{
|
{
|
||||||
file << "VECTORS " << name << " float " << endl;
|
file << "VECTORS " << name << " float " << endl;
|
||||||
|
|
||||||
|
@ -237,36 +239,36 @@ void ProcessFields::WriteVTKVectorArray(ofstream &file, string name, FDTD_FLOAT*
|
||||||
for (pos[0]=0;pos[0]<numLines[0];++pos[0])
|
for (pos[0]=0;pos[0]<numLines[0];++pos[0])
|
||||||
{
|
{
|
||||||
//in x
|
//in x
|
||||||
file << array[0][pos[0]][pos[1]][pos[2]] << " ";
|
file << setprecision(precision) << array[0][pos[0]][pos[1]][pos[2]] << " ";
|
||||||
//in y
|
//in y
|
||||||
file << array[1][pos[0]][pos[1]][pos[2]] << " ";
|
file << setprecision(precision) << array[1][pos[0]][pos[1]][pos[2]] << " ";
|
||||||
//in z
|
//in z
|
||||||
file << array[2][pos[0]][pos[1]][pos[2]] << endl;
|
file << setprecision(precision) << array[2][pos[0]][pos[1]][pos[2]] << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ProcessFields::DumpVectorArray2VTK(ofstream &file, string name, FDTD_FLOAT**** array, double** discLines, unsigned int* numLines)
|
bool ProcessFields::DumpVectorArray2VTK(ofstream &file, string name, FDTD_FLOAT**** array, double** discLines, unsigned int* numLines, unsigned int precision)
|
||||||
{
|
{
|
||||||
WriteVTKHeader(file, discLines, numLines);
|
WriteVTKHeader(file, discLines, numLines, precision);
|
||||||
WriteVTKVectorArray(file, name, array, numLines);
|
WriteVTKVectorArray(file, name, array, numLines, precision);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProcessFields::DumpMultiVectorArray2VTK(ofstream &file, string names[], FDTD_FLOAT**** array[], unsigned int numFields, double** discLines, unsigned int* numLines)
|
bool ProcessFields::DumpMultiVectorArray2VTK(ofstream &file, string names[], FDTD_FLOAT**** array[], unsigned int numFields, double** discLines, unsigned int* numLines, unsigned int precision)
|
||||||
{
|
{
|
||||||
WriteVTKHeader(file, discLines, numLines);
|
WriteVTKHeader(file, discLines, numLines, precision);
|
||||||
for (unsigned int n=0;n<numFields;++n)
|
for (unsigned int n=0;n<numFields;++n)
|
||||||
{
|
{
|
||||||
WriteVTKVectorArray(file, names[n], array[n], numLines);
|
WriteVTKVectorArray(file, names[n], array[n], numLines, precision);
|
||||||
file << endl;
|
file << endl;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessFields::WriteVTKScalarArray(ofstream &file, string name, FDTD_FLOAT*** array, unsigned int* numLines)
|
void ProcessFields::WriteVTKScalarArray(ofstream &file, string name, FDTD_FLOAT*** array, unsigned int* numLines, unsigned int precision)
|
||||||
{
|
{
|
||||||
file << "SCALARS " << name << " float " << 1 << endl;
|
file << "SCALARS " << name << " float " << 1 << endl;
|
||||||
file << "LOOKUP_TABLE default" << endl;
|
file << "LOOKUP_TABLE default" << endl;
|
||||||
|
@ -287,19 +289,19 @@ void ProcessFields::WriteVTKScalarArray(ofstream &file, string name, FDTD_FLOAT*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProcessFields::DumpScalarArray2VTK(ofstream &file, string name, FDTD_FLOAT*** array, double** discLines, unsigned int* numLines)
|
bool ProcessFields::DumpScalarArray2VTK(ofstream &file, string name, FDTD_FLOAT*** array, double** discLines, unsigned int* numLines, unsigned int precision)
|
||||||
{
|
{
|
||||||
WriteVTKHeader(file, discLines, numLines);
|
WriteVTKHeader(file, discLines, numLines, precision);
|
||||||
WriteVTKScalarArray(file, name, array, numLines);
|
WriteVTKScalarArray(file, name, array, numLines, precision);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProcessFields::DumpMultiScalarArray2VTK(ofstream &file, string names[], FDTD_FLOAT*** array[], unsigned int numFields, double** discLines, unsigned int* numLines)
|
bool ProcessFields::DumpMultiScalarArray2VTK(ofstream &file, string names[], FDTD_FLOAT*** array[], unsigned int numFields, double** discLines, unsigned int* numLines, unsigned int precision)
|
||||||
{
|
{
|
||||||
WriteVTKHeader(file, discLines, numLines);
|
WriteVTKHeader(file, discLines, numLines);
|
||||||
for (unsigned int n=0;n<numFields;++n)
|
for (unsigned int n=0;n<numFields;++n)
|
||||||
{
|
{
|
||||||
WriteVTKScalarArray(file, names[n], array[n], numLines);
|
WriteVTKScalarArray(file, names[n], array[n], numLines, precision);
|
||||||
file << endl;
|
file << endl;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -52,10 +52,10 @@ public:
|
||||||
//! Set dump type: 0 for E-fields, 1 for H-fields, 2 for D-fields, 3 for B-fields, 4 for J-fields, etc...
|
//! Set dump type: 0 for E-fields, 1 for H-fields, 2 for D-fields, 3 for B-fields, 4 for J-fields, etc...
|
||||||
void SetDumpType(DumpType type) {m_DumpType=type;}
|
void SetDumpType(DumpType type) {m_DumpType=type;}
|
||||||
|
|
||||||
static bool DumpVectorArray2VTK(ofstream &file, string name, FDTD_FLOAT**** array, double** discLines, unsigned int* numLines);
|
static bool DumpVectorArray2VTK(ofstream &file, string name, FDTD_FLOAT**** array, double** discLines, unsigned int* numLines, unsigned int precision=12);
|
||||||
static bool DumpMultiVectorArray2VTK(ofstream &file, string names[], FDTD_FLOAT**** array[], unsigned int numFields, double** discLines, unsigned int* numLines);
|
static bool DumpMultiVectorArray2VTK(ofstream &file, string names[], FDTD_FLOAT**** array[], unsigned int numFields, double** discLines, unsigned int* numLines, unsigned int precision=12);
|
||||||
static bool DumpScalarArray2VTK(ofstream &file, string name, FDTD_FLOAT*** array, double** discLines, unsigned int* numLines);
|
static bool DumpScalarArray2VTK(ofstream &file, string name, FDTD_FLOAT*** array, double** discLines, unsigned int* numLines, unsigned int precision=12);
|
||||||
static bool DumpMultiScalarArray2VTK(ofstream &file, string names[], FDTD_FLOAT*** array[], unsigned int numFields, double** discLines, unsigned int* numLines);
|
static bool DumpMultiScalarArray2VTK(ofstream &file, string names[], FDTD_FLOAT*** array[], unsigned int numFields, double** discLines, unsigned int* numLines, unsigned int precision=12);
|
||||||
|
|
||||||
static bool DumpVectorArray2HDF5(string filename, string name, FDTD_FLOAT**** array, unsigned int* numLines);
|
static bool DumpVectorArray2HDF5(string filename, string name, FDTD_FLOAT**** array, unsigned int* numLines);
|
||||||
|
|
||||||
|
@ -65,9 +65,9 @@ public:
|
||||||
|
|
||||||
// virtual void Process();
|
// virtual void Process();
|
||||||
protected:
|
protected:
|
||||||
static void WriteVTKHeader(ofstream &file, double** discLines, unsigned int* numLines);
|
static void WriteVTKHeader(ofstream &file, double** discLines, unsigned int* numLines, unsigned int precision=12);
|
||||||
static void WriteVTKVectorArray(ofstream &file, string name, FDTD_FLOAT**** array, unsigned int* numLines);
|
static void WriteVTKVectorArray(ofstream &file, string name, FDTD_FLOAT**** array, unsigned int* numLines, unsigned int precision=12);
|
||||||
static void WriteVTKScalarArray(ofstream &file, string name, FDTD_FLOAT*** array, unsigned int* numLines);
|
static void WriteVTKScalarArray(ofstream &file, string name, FDTD_FLOAT*** array, unsigned int* numLines, unsigned int precision=12);
|
||||||
|
|
||||||
static string GetFieldNameByType(DumpType type);
|
static string GetFieldNameByType(DumpType type);
|
||||||
DumpMode m_DumpMode;
|
DumpMode m_DumpMode;
|
||||||
|
|
|
@ -71,7 +71,7 @@ void ProcessFieldsTD::DumpCellInterpol(string filename)
|
||||||
{
|
{
|
||||||
ofstream file(filename.c_str());
|
ofstream file(filename.c_str());
|
||||||
if (file.is_open()==false) { cerr << "ProcessFieldsTD::Process: can't open file '" << filename << "' for writing... abort! " << endl;};
|
if (file.is_open()==false) { cerr << "ProcessFieldsTD::Process: can't open file '" << filename << "' for writing... abort! " << endl;};
|
||||||
DumpVectorArray2VTK(file,string("E-Field"),E_T,discDLines,numDLines);
|
DumpVectorArray2VTK(file,string("E-Field"),E_T,discDLines,numDLines,m_precision);
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
else if (m_fileType==HDF5_FILETYPE)
|
else if (m_fileType==HDF5_FILETYPE)
|
||||||
|
@ -123,7 +123,7 @@ void ProcessFieldsTD::DumpCellInterpol(string filename)
|
||||||
{
|
{
|
||||||
ofstream file(filename.c_str());
|
ofstream file(filename.c_str());
|
||||||
if (file.is_open()==false) { cerr << "ProcessFieldsTD::Process: can't open file '" << filename << "' for writing... abort! " << endl;};
|
if (file.is_open()==false) { cerr << "ProcessFieldsTD::Process: can't open file '" << filename << "' for writing... abort! " << endl;};
|
||||||
DumpVectorArray2VTK(file,string("H-Field"),H_T,discDLines,numDLines);
|
DumpVectorArray2VTK(file,string("H-Field"),H_T,discDLines,numDLines,m_precision);
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
else if (m_fileType==HDF5_FILETYPE)
|
else if (m_fileType==HDF5_FILETYPE)
|
||||||
|
@ -173,7 +173,7 @@ void ProcessFieldsTD::DumpNoInterpol(string filename)
|
||||||
{
|
{
|
||||||
ofstream file(filename.c_str());
|
ofstream file(filename.c_str());
|
||||||
if (file.is_open()==false) { cerr << "ProcessFieldsTD::Process: can't open file '" << filename << "' for writing... abort! " << endl;};
|
if (file.is_open()==false) { cerr << "ProcessFieldsTD::Process: can't open file '" << filename << "' for writing... abort! " << endl;};
|
||||||
DumpVectorArray2VTK(file,string("E-Field"),E_T,discLines,numLines);
|
DumpVectorArray2VTK(file,string("E-Field"),E_T,discLines,numLines,m_precision);
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
else if (m_fileType==HDF5_FILETYPE)
|
else if (m_fileType==HDF5_FILETYPE)
|
||||||
|
@ -216,7 +216,7 @@ void ProcessFieldsTD::DumpNoInterpol(string filename)
|
||||||
{
|
{
|
||||||
ofstream file(filename.c_str());
|
ofstream file(filename.c_str());
|
||||||
if (file.is_open()==false) { cerr << "ProcessFieldsTD::Process: can't open file '" << filename << "' for writing... abort! " << endl;};
|
if (file.is_open()==false) { cerr << "ProcessFieldsTD::Process: can't open file '" << filename << "' for writing... abort! " << endl;};
|
||||||
DumpVectorArray2VTK(file,string("H-Field"),H_T,discLines,numLines);
|
DumpVectorArray2VTK(file,string("H-Field"),H_T,discLines,numLines,m_precision);
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
else if (m_fileType==HDF5_FILETYPE)
|
else if (m_fileType==HDF5_FILETYPE)
|
||||||
|
|
|
@ -23,6 +23,7 @@ Processing::Processing(Operator* op, Engine* eng)
|
||||||
Eng=eng;
|
Eng=eng;
|
||||||
Enabled = true;
|
Enabled = true;
|
||||||
m_PS_pos = 0;
|
m_PS_pos = 0;
|
||||||
|
SetPrecision(12);
|
||||||
ProcessInterval=0;
|
ProcessInterval=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,13 @@ public:
|
||||||
//! If Disabled Process() will do nothing...
|
//! If Disabled Process() will do nothing...
|
||||||
virtual bool GetEnable() const {return Enabled;}
|
virtual bool GetEnable() const {return Enabled;}
|
||||||
|
|
||||||
|
//! Set the dump precision
|
||||||
|
void SetPrecision(unsigned int val) {m_precision = val;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Operator* Op;
|
Operator* Op;
|
||||||
Engine* Eng;
|
Engine* Eng;
|
||||||
|
unsigned int m_precision;
|
||||||
|
|
||||||
bool Enabled;
|
bool Enabled;
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "processvoltage.h"
|
#include "processvoltage.h"
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
ProcessVoltage::ProcessVoltage(Operator* op, Engine* eng) : Processing(op, eng)
|
ProcessVoltage::ProcessVoltage(Operator* op, Engine* eng) : Processing(op, eng)
|
||||||
{
|
{
|
||||||
|
@ -45,6 +46,6 @@ int ProcessVoltage::Process()
|
||||||
FDTD_FLOAT voltage=CalcLineIntegral(start,stop,0);
|
FDTD_FLOAT voltage=CalcLineIntegral(start,stop,0);
|
||||||
// cerr << voltage << endl;
|
// cerr << voltage << endl;
|
||||||
voltages.push_back(voltage);
|
voltages.push_back(voltage);
|
||||||
file << (double)Eng->GetNumberOfTimesteps()*Op->GetTimestep() << "\t" << voltage << endl;
|
file << setprecision(m_precision) << (double)Eng->GetNumberOfTimesteps()*Op->GetTimestep() << "\t" << voltage << endl;
|
||||||
return GetNextInterval();
|
return GetNextInterval();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue