2010-03-11 15:47:40 +00:00
/*
* 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 < http : //www.gnu.org/licenses/>.
*/
2010-03-02 13:54:50 +00:00
# ifndef PROCESSFIELDS_H
# define PROCESSFIELDS_H
# include "processing.h"
2010-04-28 09:15:59 +00:00
# include "tools/array_ops.h"
2010-03-02 13:54:50 +00:00
class ProcessFields : public Processing
{
public :
2010-03-15 15:59:37 +00:00
ProcessFields ( Operator * op , Engine * eng ) ;
2010-03-02 13:54:50 +00:00
virtual ~ ProcessFields ( ) ;
2010-04-05 18:22:03 +00:00
enum FileType { VTK_FILETYPE , HDF5_FILETYPE } ;
enum DumpType { E_FIELD_DUMP , H_FIELD_DUMP } ;
enum DumpMode { NO_INTERPOLATION , NODE_INTERPOLATE , CELL_INTERPOLATE } ;
virtual void InitProcess ( ) ;
2010-03-02 13:54:50 +00:00
virtual void DefineStartStopCoord ( double * dstart , double * dstop ) ;
2010-04-07 10:57:45 +00:00
//! Define a field dump sub sampling rate for a given direction (default: dir = -1 means all directions)
virtual void SetSubSampling ( unsigned int subSampleRate , int dir = - 1 ) ;
2010-03-09 20:35:57 +00:00
2010-04-05 18:22:03 +00:00
//! 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
2010-04-19 14:09:41 +00:00
void SetFilePattern ( string fp ) { m_filename = filePattern = fp ; }
2010-03-02 13:54:50 +00:00
2010-04-05 18:22:03 +00:00
//! Set the filename for a hdf5 data group file (HDF5 FileType only) \sa SetFileType
2010-04-19 14:09:41 +00:00
void SetFileName ( string fn ) { m_filename = m_fileName = fn ; }
2010-04-05 18:22:03 +00:00
2010-03-10 11:15:14 +00:00
//! Define the Dump-Mode
2010-04-05 18:22:03 +00:00
void SetDumpMode ( DumpMode mode ) { m_DumpMode = mode ; }
2010-03-02 13:54:50 +00:00
//! This methode will dump all fields in the center of a main cell (dual-node) using 4 E-field and 2 H-fields per direction. (default)
2010-04-05 18:22:03 +00:00
void SetDumpMode2Cell ( ) { m_DumpMode = CELL_INTERPOLATE ; }
2010-03-02 13:54:50 +00:00
//! Set dump type: 0 for E-fields, 1 for H-fields, 2 for D-fields, 3 for B-fields, 4 for J-fields, etc...
2010-04-05 18:22:03 +00:00
void SetDumpType ( DumpType type ) { m_DumpType = type ; }
2010-03-02 13:54:50 +00:00
2010-04-21 12:28:16 +00:00
static bool DumpVectorArray2VTK ( ofstream & file , string name , FDTD_FLOAT const * const * const * const * array , double const * const * discLines , unsigned int const * numLines , unsigned int precision = 12 ) ;
static bool DumpMultiVectorArray2VTK ( ofstream & file , string names [ ] , FDTD_FLOAT const * const * const * const * const * array , unsigned int numFields , double const * const * discLines , unsigned int const * numLines , unsigned int precision = 12 ) ;
static bool DumpScalarArray2VTK ( ofstream & file , string name , FDTD_FLOAT const * const * const * array , double const * const * discLines , unsigned int const * numLines , unsigned int precision = 12 ) ;
static bool DumpMultiScalarArray2VTK ( ofstream & file , string names [ ] , FDTD_FLOAT const * const * const * const * array , unsigned int numFields , double const * const * discLines , unsigned int const * numLines , unsigned int precision = 12 ) ;
2010-03-12 19:39:04 +00:00
2010-04-29 17:26:45 +00:00
static bool DumpVectorArray2HDF5 ( string filename , string name , FDTD_FLOAT const * const * const * const * array , unsigned int const * numLines , float time = 0 ) ;
2010-04-05 18:22:03 +00:00
2010-04-21 12:28:16 +00:00
double CalcTotalEnergy ( ) const ;
2010-03-15 15:59:37 +00:00
2010-04-05 18:22:03 +00:00
void SetFileType ( FileType fileType ) { m_fileType = fileType ; }
2010-03-02 13:54:50 +00:00
// virtual void Process();
protected :
2010-04-21 12:28:16 +00:00
static void WriteVTKHeader ( ofstream & file , double const * const * discLines , unsigned int const * numLines , unsigned int precision = 12 ) ;
static void WriteVTKVectorArray ( ofstream & file , string name , FDTD_FLOAT const * 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 ) ;
2010-03-02 13:54:50 +00:00
2010-04-05 18:22:03 +00:00
static string GetFieldNameByType ( DumpType type ) ;
DumpMode m_DumpMode ;
DumpType m_DumpType ;
2010-03-02 13:54:50 +00:00
string filePattern ;
2010-04-05 18:22:03 +00:00
string m_fileName ;
FileType m_fileType ;
2010-03-02 13:54:50 +00:00
2010-04-07 10:57:45 +00:00
//! field dump sub-sampling
unsigned int subSample [ 3 ] ;
2010-03-09 20:35:57 +00:00
//! dump mesh
unsigned int numLines [ 3 ] ;
double * discLines [ 3 ] ;
//! dual dump mesh
2010-03-02 13:54:50 +00:00
unsigned int numDLines [ 3 ] ;
double * discDLines [ 3 ] ;
} ;
# endif // PROCESSFIELDS_H