From 610f4e62da076d7002c97921a7b7cda1046ce05d Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Wed, 2 Jun 2010 14:18:25 +0200 Subject: [PATCH] processfields: allow different mesh types for vtk dump, e.g. cylindrical mesh dump --- FDTD/processfields.cpp | 52 ++++++++++++++++++++++++++++++++------- FDTD/processfields.h | 19 +++++++++----- FDTD/processfields_td.cpp | 12 ++++----- openems.cpp | 2 ++ 4 files changed, 64 insertions(+), 21 deletions(-) diff --git a/FDTD/processfields.cpp b/FDTD/processfields.cpp index cd01c6a..3115fe5 100644 --- a/FDTD/processfields.cpp +++ b/FDTD/processfields.cpp @@ -26,6 +26,7 @@ ProcessFields::ProcessFields(Operator* op, Engine* eng) : Processing(op, eng) m_DumpType = E_FIELD_DUMP; // vtk-file is default m_fileType = VTK_FILETYPE; + m_Mesh_Type = CARTESIAN_MESH; SetSubSampling(1); SetPrecision(6); @@ -254,7 +255,17 @@ void ProcessFields::SetSubSampling(unsigned int subSampleRate, int dir) else subSample[dir]=subSampleRate; } -void ProcessFields::WriteVTKHeader(ofstream &file, double const* const* discLines, unsigned int const* numLines, unsigned int precision, string header_info) +void ProcessFields::WriteVTKHeader(ofstream &file, double const* const* discLines, unsigned int const* numLines, unsigned int precision, string header_info, MeshType meshT) +{ + if (meshT==CARTESIAN_MESH) + WriteVTKCartesianGridHeader(file, discLines, numLines, precision, header_info); + else if (meshT==CYLINDRICAL_MESH) + WriteVTKCylindricalGridHeader(file, discLines, numLines, precision, header_info); + else + cerr << "ProcessFields::WriteVTKHeader: Warning: unknown mesh type, skipping header -> file will be invalid..." << endl; +} + +void ProcessFields::WriteVTKCartesianGridHeader(ofstream &file, double const* const* discLines, unsigned int const* numLines, unsigned int precision, string header_info) { file << "# vtk DataFile Version 2.0" << endl; file << "Rectilinear Grid openEMS_ProcessFields"; @@ -279,6 +290,29 @@ void ProcessFields::WriteVTKHeader(ofstream &file, double const* const* discLine file << "POINT_DATA " << numLines[0]*numLines[1]*numLines[2] << endl; } +void ProcessFields::WriteVTKCylindricalGridHeader(ofstream &file, double const* const* discLines, unsigned int const* numLines, unsigned int precision, string header_info) +{ + file << "# vtk DataFile Version 3.0" << endl; + file << "Structured Grid from openEMS_ProcessFields"; + if (!header_info.empty()) + file << " " << header_info; + file << endl; + file << "ASCII" << endl; + file << "DATASET STRUCTURED_GRID " << endl; + file << "DIMENSIONS " << numLines[0] << " " << numLines[1] << " " << numLines[2] << endl; + file << "POINTS " << numLines[0]*numLines[1]*numLines[2] << " float" << endl; + for (unsigned int k=0;kSetDumpType((ProcessFields::DumpType)db->GetDumpType()); ProcTD->SetDumpMode((ProcessFields::DumpMode)db->GetDumpMode()); ProcTD->SetFileType((ProcessFields::FileType)db->GetFileType()); + if (CylinderCoords) + ProcTD->SetMeshType(ProcessFields::CYLINDRICAL_MESH); for (int n=0;n<3;++n) ProcTD->SetSubSampling(db->GetSubSampling(n),n); ProcTD->SetFilePattern(db->GetName());