From 14aa47b3c5f4eb1dc2bd3be47050aaf916b9c7f3 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Tue, 28 Dec 2010 11:15:08 +0100 Subject: [PATCH] use new CSXCAD optimal resolution dump options --- Common/processfields.cpp | 48 ++++++++++++++++++++++++++++++++++++++++ Common/processfields.h | 8 ++++++- openems.cpp | 3 +++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/Common/processfields.cpp b/Common/processfields.cpp index 50b887f..938249c 100644 --- a/Common/processfields.cpp +++ b/Common/processfields.cpp @@ -29,6 +29,9 @@ ProcessFields::ProcessFields(Engine_Interface_Base* eng_if) : Processing(eng_if) subSample[0]=1; subSample[1]=1; subSample[2]=1; + optResolution[0]=0; + optResolution[1]=0; + optResolution[2]=0; m_SampleType = NONE; SetPrecision(6); m_dualTime = false; @@ -137,6 +140,19 @@ void ProcessFields::SetSubSampling(unsigned int subSampleRate, int dir) m_SampleType = SUBSAMPLE; } +void ProcessFields::SetOptResolution(double optRes, int dir) +{ + if (dir>2) return; + if (dir<0) + { + optResolution[0]=optRes; + optResolution[1]=optRes; + optResolution[2]=optRes; + } + else optResolution[dir]=optRes; + m_SampleType = OPT_RESOLUTION; +} + void ProcessFields::CalcMeshPos() { if ((m_SampleType==SUBSAMPLE) || (m_SampleType==NONE)) @@ -162,6 +178,38 @@ void ProcessFields::CalcMeshPos() } } } + if ((m_SampleType==OPT_RESOLUTION)) + { + vector tmp_pos; + double oldPos=0; + for (int n=0; n<3; ++n) + { + // construct new discLines + tmp_pos.clear(); + tmp_pos.push_back(start[n]); + oldPos=Op->GetDiscLine(n,start[n],m_dualMesh); + for (unsigned int i=start[n]+1; i<=stop[n]-1; ++i) + { + if ( (Op->GetDiscLine(n,i+1,m_dualMesh)-oldPos) >= optResolution[n]) + { + tmp_pos.push_back(i); + oldPos=Op->GetDiscLine(n,i,m_dualMesh); + } + } + if (start[n]!=stop[n]) + tmp_pos.push_back(stop[n]); + numLines[n] = tmp_pos.size(); + delete[] discLines[n]; + discLines[n] = new double[numLines[n]]; + delete[] posLines[n]; + posLines[n] = new unsigned int[numLines[n]]; + for (unsigned int i=0; iGetDiscLine(n,tmp_pos.at(i),m_dualMesh); + } + } + } } void ProcessFields::WriteVTKHeader(ofstream &file, double const* const* discLines, unsigned int const* numLines, unsigned int precision, string header_info, MeshType meshT, double discLines_scaling) diff --git a/Common/processfields.h b/Common/processfields.h index ecd5afa..fb7f767 100644 --- a/Common/processfields.h +++ b/Common/processfields.h @@ -39,6 +39,9 @@ public: //! Define a field dump sub sampling rate for a given direction (default: \a dir = -1 means all directions) virtual void SetSubSampling(unsigned int subSampleRate, int dir=-1); + //! 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); + //! 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;} @@ -91,12 +94,15 @@ protected: string filePattern; FileType m_fileType; - enum SampleType {NONE, SUBSAMPLE} m_SampleType; + enum SampleType {NONE, SUBSAMPLE, OPT_RESOLUTION} m_SampleType; virtual void CalcMeshPos(); //! field dump sub-sampling (if enabled) unsigned int subSample[3]; + //! field dump optimal resolution (if enabled) + double optResolution[3]; + //! dump mesh information unsigned int numLines[3]; //number of lines to dump unsigned int* posLines[3]; //grid positions to dump diff --git a/openems.cpp b/openems.cpp index 6925fd9..60944c1 100644 --- a/openems.cpp +++ b/openems.cpp @@ -555,6 +555,9 @@ int openEMS::SetupFDTD(const char* file) if (db->GetSubSampling()) for (int n=0; n<3; ++n) ProcField->SetSubSampling(db->GetSubSampling(n),n); + if (db->GetOptResolution()) + for (int n=0; n<3; ++n) + ProcField->SetOptResolution(db->GetOptResolution(n),n); ProcField->SetFilePattern(db->GetName()); ProcField->SetFileName(db->GetName()); ProcField->DefineStartStopCoord(start,stop);