processing: new type name and header dump in integral processing

- new type name for each processing class (used in some file descriptions)
- new integral name in ProcessIntegral for every result row --> used in file header

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
This commit is contained in:
Thorsten Liebig 2011-01-18 10:34:13 +01:00
parent c0c66518c1
commit dff20e51cd
16 changed files with 134 additions and 3 deletions

View File

@ -29,6 +29,17 @@ ProcessEField::~ProcessEField()
FlushData(); FlushData();
} }
string ProcessEField::GetIntegralName(int row) const
{
if (row==0)
return "Ex/(V/m)";
if (row==1)
return "Ey/(V/m)";
if (row==2)
return "Ez/(V/m)";
return "unknown";
}
void ProcessEField::InitProcess() void ProcessEField::InitProcess()
{ {
OpenFile(m_Name); OpenFile(m_Name);

View File

@ -32,6 +32,10 @@ public:
ProcessEField(Engine_Interface_Base* eng_if, Engine* eng); ProcessEField(Engine_Interface_Base* eng_if, Engine* eng);
virtual ~ProcessEField(); virtual ~ProcessEField();
virtual string GetProcessingName() const {return "electric field probe";}
virtual string GetIntegralName(int row) const;
virtual void InitProcess(); virtual void InitProcess();
virtual void FlushData(); virtual void FlushData();
void Dump_FD_Data(vector<double_complex> value[3], double factor, string filename); void Dump_FD_Data(vector<double_complex> value[3], double factor, string filename);

View File

@ -27,6 +27,17 @@ ProcessHField::~ProcessHField()
{ {
} }
string ProcessHField::GetIntegralName(int row) const
{
if (row==0)
return "Hx/(A/m)";
if (row==1)
return "Hy/(A/m)";
if (row==2)
return "Hz/(A/m)";
return "unknown";
}
void ProcessHField::InitProcess() void ProcessHField::InitProcess()
{ {
OpenFile(m_Name); OpenFile(m_Name);

View File

@ -31,6 +31,10 @@ public:
ProcessHField(Engine_Interface_Base* eng_if, Engine* eng); ProcessHField(Engine_Interface_Base* eng_if, Engine* eng);
virtual ~ProcessHField(); virtual ~ProcessHField();
virtual string GetProcessingName() const {return "magnetic field probe";}
virtual string GetIntegralName(int row) const;
virtual void InitProcess(); virtual void InitProcess();
void DefineStartStopCoord(double* dstart, double* dstop); void DefineStartStopCoord(double* dstart, double* dstop);
virtual int Process(); virtual int Process();

View File

@ -28,6 +28,13 @@ ProcessCurrent::~ProcessCurrent()
{ {
} }
string ProcessCurrent::GetIntegralName(int row) const
{
if (row==0)
return "current";
return "unknown";
}
double ProcessCurrent::CalcIntegral() double ProcessCurrent::CalcIntegral()
{ {
FDTD_FLOAT current=0; FDTD_FLOAT current=0;

View File

@ -26,6 +26,10 @@ public:
ProcessCurrent(Engine_Interface_Base* eng_if); ProcessCurrent(Engine_Interface_Base* eng_if);
virtual ~ProcessCurrent(); virtual ~ProcessCurrent();
virtual string GetProcessingName() const {return "current integration";}
virtual string GetIntegralName(int row) const;
//! Integrate currents flowing through an area //! Integrate currents flowing through an area
virtual double CalcIntegral(); virtual double CalcIntegral();

View File

@ -39,6 +39,8 @@ public:
*/ */
enum DumpType { E_FIELD_DUMP, H_FIELD_DUMP, J_FIELD_DUMP, ROTH_FIELD_DUMP}; enum DumpType { E_FIELD_DUMP, H_FIELD_DUMP, J_FIELD_DUMP, ROTH_FIELD_DUMP};
virtual string GetProcessingName() const {return "common field processing";}
virtual void InitProcess(); virtual void InitProcess();
virtual void DefineStartStopCoord(double* dstart, double* dstop); virtual void DefineStartStopCoord(double* dstart, double* dstop);

View File

@ -26,6 +26,8 @@ public:
ProcessFieldsFD(Engine_Interface_Base* eng_if); ProcessFieldsFD(Engine_Interface_Base* eng_if);
virtual ~ProcessFieldsFD(); virtual ~ProcessFieldsFD();
virtual string GetProcessingName() const {return "frequency domain field dump";}
virtual void InitProcess(); virtual void InitProcess();
virtual int Process(); virtual int Process();

View File

@ -26,6 +26,8 @@ public:
ProcessFieldsTD(Engine_Interface_Base* eng_if); ProcessFieldsTD(Engine_Interface_Base* eng_if);
virtual ~ProcessFieldsTD(); virtual ~ProcessFieldsTD();
virtual string GetProcessingName() const {return "time domain field dump";}
virtual void InitProcess(); virtual void InitProcess();
virtual int Process(); virtual int Process();

View File

@ -40,7 +40,6 @@ using namespace std;
class Processing class Processing
{ {
public: public:
Processing(Engine_Interface_Base* eng_if);
virtual ~Processing(); virtual ~Processing();
enum MeshType { CARTESIAN_MESH, CYLINDRICAL_MESH}; enum MeshType { CARTESIAN_MESH, CYLINDRICAL_MESH};
@ -50,6 +49,9 @@ public:
virtual void SetName(string val) {m_Name=val;} virtual void SetName(string val) {m_Name=val;}
//! Get the name for this processing, will be used in file description.
virtual string GetProcessingName() const = 0;
virtual void InitProcess() {}; virtual void InitProcess() {};
virtual void Reset(); virtual void Reset();
@ -101,6 +103,7 @@ public:
virtual void SetDualTime(bool val) {m_dualTime=val;} virtual void SetDualTime(bool val) {m_dualTime=val;}
protected: protected:
Processing(Engine_Interface_Base* eng_if);
Engine_Interface_Base* m_Eng_Interface; Engine_Interface_Base* m_Eng_Interface;
const Operator_Base* Op; const Operator_Base* Op;
MeshType m_Mesh_Type; MeshType m_Mesh_Type;

View File

@ -16,6 +16,7 @@
*/ */
#include "processintegral.h" #include "processintegral.h"
#include "Common/operator_base.h"
#include "time.h" #include "time.h"
#include <iomanip> #include <iomanip>
@ -44,6 +45,25 @@ void ProcessIntegral::InitProcess()
m_filename = m_Name; m_filename = m_Name;
OpenFile(m_filename); OpenFile(m_filename);
//write header
time_t rawTime;
time(&rawTime);
file << "% time-domain " << GetProcessingName() << " by openEMS " << GIT_VERSION << " @" << ctime(&rawTime);
file << "% start-coordinates: ("
<< Op->GetDiscLine(0,start[0])*Op->GetGridDelta() << ","
<< Op->GetDiscLine(1,start[1])*Op->GetGridDelta() << ","
<< Op->GetDiscLine(2,start[2])*Op->GetGridDelta() << ") m -> [" << start[0] << "," << start[1] << "," << start[2] << "]" << endl;
file << "% stop-coordinates: ("
<< Op->GetDiscLine(0,stop[0])*Op->GetGridDelta() << ","
<< Op->GetDiscLine(1,stop[1])*Op->GetGridDelta() << ","
<< Op->GetDiscLine(2,stop[2])*Op->GetGridDelta() << ") m -> [" << stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl;
file << "% t/s";
for (int n=0;n<GetNumberOfIntegrals();++n)
{
file << "\t" << GetIntegralName(n);
}
file << endl;
for (int i=0;i<GetNumberOfIntegrals();++i) for (int i=0;i<GetNumberOfIntegrals();++i)
{ {
for (size_t n=0; n<m_FD_Samples.size(); ++n) for (size_t n=0; n<m_FD_Samples.size(); ++n)
@ -68,12 +88,28 @@ void ProcessIntegral::Dump_FD_Data(double factor, string filename)
file.open( filename.c_str() ); file.open( filename.c_str() );
if (!file.is_open()) if (!file.is_open())
cerr << "ProcessIntegral::Dump_FD_Data: Error: Can't open file: " << filename << endl; cerr << "ProcessIntegral::Dump_FD_Data: Error: Can't open file: " << filename << endl;
//write header
time_t rawTime; time_t rawTime;
time(&rawTime); time(&rawTime);
file << "%dump by openEMS @" << ctime(&rawTime) << "%frequency"; file << "% frequency-domain " << GetProcessingName() << " by openEMS " << GIT_VERSION << " @" << ctime(&rawTime);
file << "% start-coordinates: ("
<< Op->GetDiscLine(0,start[0])*Op->GetGridDelta() << ","
<< Op->GetDiscLine(1,start[1])*Op->GetGridDelta() << ","
<< Op->GetDiscLine(2,start[2])*Op->GetGridDelta() << ") m -> [" << start[0] << "," << start[1] << "," << start[2] << "]" << endl;
file << "% stop-coordinates: ("
<< Op->GetDiscLine(0,stop[0])*Op->GetGridDelta() << ","
<< Op->GetDiscLine(1,stop[1])*Op->GetGridDelta() << ","
<< Op->GetDiscLine(2,stop[2])*Op->GetGridDelta() << ") m -> [" << stop[0] << "," << stop[1] << "," << stop[2] << "]" << endl;
file << "% f/Hz";
for (int n=0;n<GetNumberOfIntegrals();++n)
{
file << "\t" << GetIntegralName(n) << "\t";
}
file << endl << "%";
for (int i = 0; i < GetNumberOfIntegrals();++i) for (int i = 0; i < GetNumberOfIntegrals();++i)
file << "\treal\timag"; file << "\treal\timag";
file << "\n"; file << endl;
for (size_t n=0; n<m_FD_Samples.size(); ++n) for (size_t n=0; n<m_FD_Samples.size(); ++n)
{ {

View File

@ -31,6 +31,8 @@ public:
virtual void InitProcess(); virtual void InitProcess();
virtual string GetProcessingName() const = 0;
//! Flush FD data to disk //! Flush FD data to disk
virtual void FlushData(); virtual void FlushData();
@ -41,6 +43,9 @@ public:
*/ */
virtual double* CalcMultipleIntegrals(); virtual double* CalcMultipleIntegrals();
//! Get the name of the integral for the given row. The names will be used in the file header.
virtual string GetIntegralName(int row) const = 0;
//! Number of calculated results produced by this integral processing. \sa CalcMultipleIntegrals //! Number of calculated results produced by this integral processing. \sa CalcMultipleIntegrals
virtual int GetNumberOfIntegrals() const {return 1;} virtual int GetNumberOfIntegrals() const {return 1;}

View File

@ -41,6 +41,31 @@ ProcessModeMatch::~ProcessModeMatch()
Reset(); Reset();
} }
string ProcessModeMatch::GetIntegralName(int row) const
{
if (row==0)
{
if (m_ModeFieldType==0)
return "voltage";
if (m_ModeFieldType==1)
return "current";
}
if (row==1)
{
return "mode_purity";
}
return "unknown";
}
string ProcessModeMatch::GetProcessingName() const
{
if (m_ModeFieldType==0)
return "voltage mode matching";
if (m_ModeFieldType==1)
return "current mode matching";
return "unknown mode matching";
}
void ProcessModeMatch::InitProcess() void ProcessModeMatch::InitProcess()
{ {
if (!Enabled) return; if (!Enabled) return;

View File

@ -33,6 +33,10 @@ public:
ProcessModeMatch(Engine_Interface_Base* eng_if); ProcessModeMatch(Engine_Interface_Base* eng_if);
virtual ~ProcessModeMatch(); virtual ~ProcessModeMatch();
virtual string GetProcessingName() const;
virtual string GetIntegralName(int row) const;
virtual void InitProcess(); virtual void InitProcess();
virtual void Reset(); virtual void Reset();

View File

@ -26,6 +26,13 @@ ProcessVoltage::~ProcessVoltage()
{ {
} }
string ProcessVoltage::GetIntegralName(int row) const
{
if (row==0)
return "voltage";
return "unknown";
}
double ProcessVoltage::CalcIntegral() double ProcessVoltage::CalcIntegral()
{ {
//integrate voltages from start to stop on a line //integrate voltages from start to stop on a line

View File

@ -27,6 +27,10 @@ public:
ProcessVoltage(Engine_Interface_Base* eng_if); ProcessVoltage(Engine_Interface_Base* eng_if);
virtual ~ProcessVoltage(); virtual ~ProcessVoltage();
virtual string GetProcessingName() const {return "voltage integration";}
virtual string GetIntegralName(int row) const;
virtual double CalcIntegral(); virtual double CalcIntegral();
protected: protected: