real abstract base classes for common operator and engine-interface

pull/1/head
Thorsten Liebig 2010-12-07 14:47:22 +01:00
parent 3dc8c2df1c
commit 57ead21ccc
5 changed files with 27 additions and 24 deletions

View File

@ -40,21 +40,21 @@ public:
InterpolationType GetInterpolationType() {return m_InterpolType;}
//! Get the (interpolated) electric field at \p pos. \sa SetInterpolationType
virtual double* GetEField(const unsigned int* pos, double* out) const {UNUSED(pos); return out;}
virtual double* GetEField(const unsigned int* pos, double* out) const =0;
//! Get the (interpolated) magnetic field at \p pos. \sa SetInterpolationType
virtual double* GetHField(const unsigned int* pos, double* out) const {UNUSED(pos); return out;}
virtual double* GetHField(const unsigned int* pos, double* out) const =0;
//! Calculate the electric field integral along a given line
virtual double CalcVoltageIntegral(const unsigned int* start, const unsigned int* stop) const {UNUSED(start); UNUSED(stop); return 0.0;}
virtual double CalcVoltageIntegral(const unsigned int* start, const unsigned int* stop) const =0;
//! Convert the interpolation type into a string.
static std::string GetInterpolationNameByType(InterpolationType mode);
//! Get the current simulation time
virtual double GetTime(bool dualTime=false) const {UNUSED(dualTime); return 0.0;}
virtual double GetTime(bool dualTime=false) const =0;
//! Get the current number of timesteps
virtual unsigned int GetNumberOfTimesteps() const {return 0;}
virtual unsigned int GetNumberOfTimesteps() const =0;
protected:
Engine_Interface_Base();

View File

@ -22,51 +22,52 @@
#include "Common/processing.h"
#include "string"
//! Abstract base-class for a common operator
class Operator_Base
{
public:
//! Get the timestep used by this operator
double GetTimestep() const {return dT;};
virtual double GetTimestep() const {return dT;};
//! Get the number of cells or nodes defined by this operator
virtual double GetNumberCells() const {return 0;}
virtual double GetNumberCells() const =0;
//! Get the number of timesteps satisfying the nyquist condition (may depend on the excitation)
unsigned int GetNumberOfNyquistTimesteps() const {return 0;}
virtual unsigned int GetNumberOfNyquistTimesteps() const =0;
//! Returns the number of lines as needed for post-processing etc. (for the engine, use GetOriginalNumLines())
virtual unsigned int GetNumberOfLines(int ny) const {return numLines[ny];}
virtual unsigned int GetNumberOfLines(int ny) const =0;
//! Get the name for the given direction: 0 -> x, 1 -> y, 2 -> z
virtual std::string GetDirName(int ny) const;
//! Get the grid drawing unit in m
virtual double GetGridDelta() const {return 0;}
virtual double GetGridDelta() const =0;
//! Get the mesh delta times the grid delta for a 3D position (unit is meter)
virtual double GetMeshDelta(int n, const unsigned int* pos, bool dualMesh=false) const {UNUSED(n); UNUSED(pos); UNUSED(dualMesh); return 0.0;}
virtual double GetMeshDelta(int n, const unsigned int* pos, bool dualMesh=false) const =0;
//! Get the disc line in \a n direction (in drawing units)
virtual double GetDiscLine(int n, unsigned int pos, bool dualMesh=false) const {UNUSED(n); UNUSED(pos); UNUSED(dualMesh); return 0.0;}
virtual double GetDiscLine(int n, unsigned int pos, bool dualMesh=false) const =0;
//! Get the node width for a given direction \a n and a given mesh position \a pos
virtual double GetNodeWidth(int ny, const unsigned int pos[3], bool dualMesh = false) const {UNUSED(ny); UNUSED(pos); UNUSED(dualMesh); return 0.0;}
virtual double GetNodeWidth(int ny, const unsigned int pos[3], bool dualMesh = false) const =0;
//! Get the node area for a given direction \a n and a given mesh position \a pos
virtual double GetNodeArea(int ny, const unsigned int pos[3], bool dualMesh = false) const {UNUSED(ny); UNUSED(pos); UNUSED(dualMesh); return 0.0;}
virtual double GetNodeArea(int ny, const unsigned int pos[3], bool dualMesh = false) const =0;
//! Get the length of an FDTD edge (unit is meter).
virtual double GetEdgeLength(int ny, const unsigned int pos[3], bool dualMesh = false) const {UNUSED(ny); UNUSED(pos); UNUSED(dualMesh); return 0.0;}
virtual double GetEdgeLength(int ny, const unsigned int pos[3], bool dualMesh = false) const =0;
//! Get the area around an edge for a given direction \a n and a given mesh posisition \a pos
/*!
This will return the area around an edge with a given direction, measured at the middle of the edge.
In a cartesian mesh this is equal to the NodeArea, may be different in other coordinate systems.
*/
virtual double GetEdgeArea(int ny, const unsigned int pos[3], bool dualMesh = false) const {UNUSED(ny); UNUSED(pos); UNUSED(dualMesh); return 0.0;}
virtual double GetEdgeArea(int ny, const unsigned int pos[3], bool dualMesh = false) const =0;
//! Snap the given coodinates to mesh indices
virtual bool SnapToMesh(double* coord, unsigned int* uicoord, bool lower=false, bool* inside=NULL) {UNUSED(coord); UNUSED(uicoord); UNUSED(lower); UNUSED(inside); return false;};
virtual bool SnapToMesh(const double* coord, unsigned int* uicoord, bool lower=false, bool* inside=NULL) const =0;
//! Set the boundary conditions
virtual void SetBoundaryCondition(int* BCs) {for (int n=0; n<6; ++n) m_BC[n]=BCs[n];}

View File

@ -1,6 +1,6 @@
readme for openEMS/Commen
readme for openEMS/Common
- This folder contains all classes common for all numerical solver included in openEMS (currently only FDTD)
- This folder contains all classes common for all numerical solver included in openEMS (currently only EC-FDTD)
- Operator-Base class
- Engine-Interface classes
- Commen processing classes
- Common processing classes

View File

@ -124,7 +124,7 @@ double Operator::GetNodeArea(int ny, const unsigned int pos[3], bool dualMesh) c
return GetNodeWidth(nyP,pos,dualMesh) * GetNodeWidth(nyPP,pos,dualMesh);
}
bool Operator::SnapToMesh(double* dcoord, unsigned int* uicoord, bool lower, bool* inside)
bool Operator::SnapToMesh(const double* dcoord, unsigned int* uicoord, bool lower, bool* inside) const
{
bool ok=true;
unsigned int numLines[3];

View File

@ -28,7 +28,7 @@ class Operator_Extension;
class Engine;
class TiXmlElement;
//! Abstract base-class for the FDTD-operator
//! Basic FDTD-operator
class Operator : public Operator_Base
{
friend class Engine;
@ -82,7 +82,9 @@ public:
bool GetTimestepValid() const {return !m_InvaildTimestep;}
virtual double GetNumberCells() const;
unsigned int GetNumberOfNyquistTimesteps() const {return Exc->GetNyquistNum();}
virtual unsigned int GetNumberOfNyquistTimesteps() const {return Exc->GetNyquistNum();}
virtual unsigned int GetNumberOfLines(int ny) const {return numLines[ny];}
//! Returns the number of lines as needed for the engine etc. (for post-processing etc, use GetNumLines())
virtual unsigned int GetOriginalNumLines(int ny) const {return numLines[ny];}
@ -113,7 +115,7 @@ public:
*/
virtual double GetEdgeArea(int ny, const unsigned int pos[3], bool dualMesh = false) const {return GetNodeArea(ny,pos,dualMesh);}
virtual bool SnapToMesh(double* coord, unsigned int* uicoord, bool lower=false, bool* inside=NULL);
virtual bool SnapToMesh(const double* coord, unsigned int* uicoord, bool lower=false, bool* inside=NULL) const;
virtual void AddExtension(Operator_Extension* op_ext);
virtual size_t GetNumberOfExtentions() const {return m_Op_exts.size();}