/* * Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "processing.h" Processing::Processing(Operator* op, Engine* eng) { Op=op; Eng=eng; Enabled = true; m_PS_pos = 0; SetPrecision(12); ProcessInterval=0; } Processing::~Processing() { file.close(); } void Processing::Reset() { m_PS_pos=0; } bool Processing::CheckTimestep() { if (m_ProcessSteps.size()>m_PS_pos) { if (m_ProcessSteps.at(m_PS_pos)==Eng->GetNumberOfTimesteps()) { ++m_PS_pos; return true; } } if (ProcessInterval) { if (Eng->GetNumberOfTimesteps()%ProcessInterval==0) return true; } return false; } int Processing::GetNextInterval() const { if (Enabled==false) return -1; unsigned int next=-1; if (m_ProcessSteps.size()>m_PS_pos) { next = m_ProcessSteps.at(m_PS_pos)-Eng->GetNumberOfTimesteps(); } if (ProcessInterval==0) return next; unsigned int next_Interval = ProcessInterval - Eng->GetNumberOfTimesteps()%ProcessInterval; if (next_Interval steps) { for (size_t n=0;nSnapToMesh(dstart,start)==false) cerr << "Processing::DefineStartStopCoord: Warning: Snapped line outside field domain!!" << endl; if (Op->SnapToMesh(dstop,stop)==false) cerr << "Processing::DefineStartStopCoord: Warning: Snapped line outside field domain!!" << endl; } double Processing::CalcLineIntegral(unsigned int* start, unsigned int* stop, int field) { double result=0; FDTD_FLOAT**** array; if (field==0) array=Eng->GetVoltages(); else if (field==1) array=Eng->GetCurrents(); else return 0.0; for (int n=0;n<3;++n) { if (start[n]GetDiscLine(i,start[i],dualMesh),Op->GetDiscLine(i,stop[i],dualMesh)); s2[i] = max(Op->GetDiscLine(i,start[i],dualMesh),Op->GetDiscLine(i,stop[i],dualMesh)); } // fix degenerate box/plane -> line (paraview display problem) if (((s1[0] == s2[0]) && (s1[1] == s2[1])) || ((s1[0] == s2[0]) && (s1[2] == s2[2])) || ((s1[2] == s2[2]) && (s1[1] == s2[1]))) { // line are not displayed correctly -> enlarge for (int i=0; i<3; i++) { double delta = min( Op->GetMeshDelta( i, start,dualMesh ), Op->GetMeshDelta( i, stop,dualMesh ) ) / Op->GetGridDelta() / 4.0; s1[i] -= delta; s2[i] += delta; } } file << "# vtk DataFile Version 2.0" << endl; file << "" << endl; file << "ASCII" << endl; file << "DATASET POLYDATA" << endl; file << "POINTS 8 float" << endl; file << s1[0] << " " << s1[1] << " " << s1[2] << endl; file << s2[0] << " " << s1[1] << " " << s1[2] << endl; file << s2[0] << " " << s2[1] << " " << s1[2] << endl; file << s1[0] << " " << s2[1] << " " << s1[2] << endl; file << s1[0] << " " << s1[1] << " " << s2[2] << endl; file << s2[0] << " " << s1[1] << " " << s2[2] << endl; file << s2[0] << " " << s2[1] << " " << s2[2] << endl; file << s1[0] << " " << s2[1] << " " << s2[2] << endl; file << "POLYGONS 6 30" << endl; file << "4 0 1 2 3" << endl; file << "4 4 5 6 7" << endl; file << "4 7 6 2 3" << endl; file << "4 4 5 1 0" << endl; file << "4 0 4 7 3" << endl; file << "4 5 6 2 1" << endl; file.close(); } void ProcessingArray::AddProcessing(Processing* proc) { ProcessArray.push_back(proc); } void ProcessingArray::Reset() { for (size_t i=0;iReset(); } } void ProcessingArray::DeleteAll() { for (size_t i=0;iProcess(); if ((step>0) && (stepDumpBox2File( vtkfilenameprefix ); }