fix vtk-dump: vector fields consider mesh type

furthermore:
- new argument: --nativeFieldDumps to dump original FDTD field components for debugging purposes
- show global arguments on startup
pull/1/head
Thorsten Liebig 2010-09-17 14:48:32 +02:00
parent 482de93d3d
commit 1e78e5c2d6
5 changed files with 52 additions and 11 deletions

View File

@ -345,23 +345,42 @@ void ProcessFields::WriteVTKCylindricalGridHeader(ofstream &file, double const*
} }
void ProcessFields::WriteVTKVectorArray(ofstream &file, string name, FDTD_FLOAT const* const* const* const* array, unsigned int const* numLines, unsigned int precision) void ProcessFields::WriteVTKVectorArray(ofstream &file, string name, FDTD_FLOAT const* const* const* const* array, double const* const* discLines, unsigned int const* numLines, unsigned int precision, MeshType meshT)
{ {
file << "VECTORS " << name << " float " << endl; file << "VECTORS " << name << " float " << endl;
if (g_settings.NativeFieldDumps())
meshT = CARTESIAN_MESH; //dump field components as they are...
unsigned int pos[3]; unsigned int pos[3];
for (pos[2]=0;pos[2]<numLines[2];++pos[2]) for (pos[2]=0;pos[2]<numLines[2];++pos[2])
{ {
for (pos[1]=0;pos[1]<numLines[1];++pos[1]) for (pos[1]=0;pos[1]<numLines[1];++pos[1])
{ {
double cos_a = cos(discLines[1][pos[1]]); //needed only for CYLINDRICAL_MESH
double sin_a = sin(discLines[1][pos[1]]); //needed only for CYLINDRICAL_MESH
for (pos[0]=0;pos[0]<numLines[0];++pos[0]) for (pos[0]=0;pos[0]<numLines[0];++pos[0])
{ {
switch (meshT)
{
case CARTESIAN_MESH:
UNUSED(discLines); //disclines not needed for the original cartesian mesh
//in x //in x
file << setprecision(precision) << array[0][pos[0]][pos[1]][pos[2]] << " "; file << setprecision(precision) << array[0][pos[0]][pos[1]][pos[2]] << " ";
//in y //in y
file << setprecision(precision) << array[1][pos[0]][pos[1]][pos[2]] << " "; file << setprecision(precision) << array[1][pos[0]][pos[1]][pos[2]] << " ";
//in z //in z
file << setprecision(precision) << array[2][pos[0]][pos[1]][pos[2]] << endl; file << setprecision(precision) << array[2][pos[0]][pos[1]][pos[2]] << endl;
break;
case CYLINDRICAL_MESH:
//in x : F_x = F_r * cos(a) - F_a * sin(a);
file << setprecision(precision) << array[0][pos[0]][pos[1]][pos[2]] * cos_a - array[1][pos[0]][pos[1]][pos[2]] * sin_a << " ";
//in y : F_y = F_r * sin(a) + F_a * cos(a);
file << setprecision(precision) << array[0][pos[0]][pos[1]][pos[2]] * sin_a + array[1][pos[0]][pos[1]][pos[2]] * cos_a << " ";
//in z
file << setprecision(precision) << array[2][pos[0]][pos[1]][pos[2]] << endl;
break;
}
} }
} }
} }
@ -371,7 +390,7 @@ void ProcessFields::WriteVTKVectorArray(ofstream &file, string name, FDTD_FLOAT
bool ProcessFields::DumpVectorArray2VTK(ofstream &file, string name, FDTD_FLOAT const* const* const* const* array, double const* const* discLines, unsigned int const* numLines, unsigned int precision, string header_info, MeshType meshT, double discLines_scaling) bool ProcessFields::DumpVectorArray2VTK(ofstream &file, string name, FDTD_FLOAT const* const* const* const* array, double const* const* discLines, unsigned int const* numLines, unsigned int precision, string header_info, MeshType meshT, double discLines_scaling)
{ {
WriteVTKHeader(file, discLines, numLines, precision, header_info, meshT, discLines_scaling); WriteVTKHeader(file, discLines, numLines, precision, header_info, meshT, discLines_scaling);
WriteVTKVectorArray(file, name, array, numLines, precision); WriteVTKVectorArray(file, name, array, discLines, numLines, precision, meshT);
return true; return true;
} }
@ -380,7 +399,7 @@ bool ProcessFields::DumpMultiVectorArray2VTK(ofstream &file, string names[], FDT
WriteVTKHeader(file, discLines, numLines, precision, header_info, meshT, discLines_scaling); WriteVTKHeader(file, discLines, numLines, precision, header_info, meshT, discLines_scaling);
for (unsigned int n=0;n<numFields;++n) for (unsigned int n=0;n<numFields;++n)
{ {
WriteVTKVectorArray(file, names[n], array[n], numLines, precision); WriteVTKVectorArray(file, names[n], array[n], discLines, numLines, precision, meshT);
file << endl; file << endl;
} }
return true; return true;

View File

@ -61,7 +61,7 @@ public:
//! Write a vtk header to an already open file (cylindrical grid) //! Write a vtk header to an already open file (cylindrical grid)
static void WriteVTKCylindricalGridHeader(ofstream &file, double const* const* discLines, unsigned int const* numLines, unsigned int precision=12, string header_info = string(), double discLines_scaling = 1); static void WriteVTKCylindricalGridHeader(ofstream &file, double const* const* discLines, unsigned int const* numLines, unsigned int precision=12, string header_info = string(), double discLines_scaling = 1);
//! Append a vtk vector array to an already open vtk file, write a header first! \sa WriteVTKHeader() //! Append a vtk vector array to an already open vtk file, write a header first! \sa WriteVTKHeader()
static void WriteVTKVectorArray(ofstream &file, string name, FDTD_FLOAT const* const* const* const* array, unsigned int const* numLines, unsigned int precision=12); static void WriteVTKVectorArray(ofstream &file, string name, FDTD_FLOAT const* const* const* const* array, double const* const* discLines, unsigned int const* numLines, unsigned int precision=12, MeshType meshT = CARTESIAN_MESH);
//! Append a vtk scalar array to an already open vtk file, write a header first! \sa WriteVTKHeader() //! Append a vtk scalar array to an already open vtk file, write a header first! \sa WriteVTKHeader()
static void WriteVTKScalarArray(ofstream &file, string name, FDTD_FLOAT const* const* const* array, unsigned int const* numLines, unsigned int precision=12); static void WriteVTKScalarArray(ofstream &file, string name, FDTD_FLOAT const* const* const* array, unsigned int const* numLines, unsigned int precision=12);

View File

@ -62,6 +62,8 @@ int main(int argc, char *argv[])
cout << "\t\t--engine=multithreaded\t\tengine using compressed operator + sse vector extensions + multithreading" << endl; cout << "\t\t--engine=multithreaded\t\tengine using compressed operator + sse vector extensions + multithreading" << endl;
cout << "\t--numThreads=<n>\tForce use n threads for multithreaded engine (needs: --engine=multithreaded)" << endl; cout << "\t--numThreads=<n>\tForce use n threads for multithreaded engine (needs: --engine=multithreaded)" << endl;
cout << "\t--no-simulation\tonly run preprocessing; do not simulate" << endl; cout << "\t--no-simulation\tonly run preprocessing; do not simulate" << endl;
cout << "\n\t Additional global arguments " << endl;
g_settings.ShowArguments(cout,"\t");
cout << endl; cout << endl;
exit(-1); exit(-1);
} }

View File

@ -27,6 +27,13 @@ Global g_settings;
Global::Global() Global::Global()
{ {
m_showProbeDiscretization = false; m_showProbeDiscretization = false;
m_nativeFieldDumps = false;
}
void Global::ShowArguments(ostream& ostr, string front)
{
ostr << front << "--showProbeDiscretization\tShow probe discretization information" << endl;
ostr << front << "--nativeFieldDumps\tDump all fields using the native field components" << endl;
} }
//! \brief This function initializes the object //! \brief This function initializes the object
@ -41,6 +48,11 @@ bool Global::parseCommandLineArgument( const char *argv )
m_showProbeDiscretization = true; m_showProbeDiscretization = true;
return true; return true;
} }
else if (strcmp(argv,"--nativeFieldDumps")==0)
{
cout << "openEMS - dumping all fields using the native field components" << endl;
m_nativeFieldDumps = true;
return true;
}
return false; return false;
} }

View File

@ -18,6 +18,8 @@
#ifndef GLOBAL_H #ifndef GLOBAL_H
#define GLOBAL_H #define GLOBAL_H
#include <sstream>
class Global class Global
{ {
public: public:
@ -26,8 +28,14 @@ public:
bool showProbeDiscretization() const {return m_showProbeDiscretization;} bool showProbeDiscretization() const {return m_showProbeDiscretization;}
//! Returns true if native field dumps are requested...
bool NativeFieldDumps() const {return m_nativeFieldDumps;}
void ShowArguments(std::ostream& ostr, std::string front=std::string());
protected: protected:
bool m_showProbeDiscretization; bool m_showProbeDiscretization;
bool m_nativeFieldDumps;
}; };
extern Global g_settings; extern Global g_settings;