operator: removed redundant methods using integer positions

pull/1/head
Thorsten Liebig 2010-09-17 14:51:07 +02:00
parent 1e78e5c2d6
commit 060b93d089
4 changed files with 26 additions and 48 deletions

View File

@ -116,13 +116,7 @@ string Operator::GetDirName(int ny) const
double Operator::GetMeshDelta(int n, const unsigned int* pos, bool dualMesh) const
{
if ((n<0) || (n>2)) return 0.0;
int i_pos[] = {pos[0],pos[1],pos[2]};
return GetMeshDelta(n,i_pos,dualMesh);
}
double Operator::GetMeshDelta(int n, const int* pos, bool dualMesh) const
{
if ((n<0) || (n>2)) return 0.0;
if (pos[n]>=numLines[n]) return 0.0;
if (dualMesh==false)
return fabs(MainOp->GetIndexDelta(n,pos[n]))*gridDelta;
else
@ -130,21 +124,16 @@ double Operator::GetMeshDelta(int n, const int* pos, bool dualMesh) const
}
double Operator::GetDiscLine(int n, unsigned int pos, bool dualMesh) const
{
return GetDiscLine(n,(int)pos,dualMesh);
}
double Operator::GetDiscLine(int n, int pos, bool dualMesh) const
{
if ((n<0) || (n>2)) return 0.0;
if ((pos<0) || (pos>=(int)numLines[n])) return 0.0;
if (pos>=numLines[n]) return 0.0;
if (dualMesh==false)
return discLines[n][pos];
else
return (discLines[n][pos] + 0.5*fabs(MainOp->GetIndexDelta(n,pos)));
}
double Operator::GetNodeArea(int ny, const int pos[3], bool dualMesh) const
double Operator::GetNodeArea(int ny, const unsigned int pos[3], bool dualMesh) const
{
int nyP = (ny+1)%3;
int nyPP = (ny+2)%3;
@ -738,7 +727,7 @@ bool Operator::Calc_EffMatPos(int ny, const unsigned int* pos, double* EffMat) c
shiftCoord[n] = coord[n]+delta*0.5;
shiftCoord[nP] = coord[nP]+deltaP*0.25;
shiftCoord[nPP] = coord[nPP]+deltaPP*0.25;
A_n = GetNodeArea(ny,loc_pos,true);
A_n = GetNodeArea(ny,(unsigned int*)loc_pos,true);
// {
// cerr << ny << " " << pos[0] << " " << pos[1] << " " << pos[2] << ": " << A_n << endl;
// exit(0);
@ -763,7 +752,7 @@ bool Operator::Calc_EffMatPos(int ny, const unsigned int* pos, double* EffMat) c
shiftCoord[nPP] = coord[nPP]+deltaPP*0.25;
--loc_pos[nP];
A_n = GetNodeArea(ny,loc_pos,true);
A_n = GetNodeArea(ny,(unsigned int*)loc_pos,true);
// cerr << A_n << endl;
prop = CSX->GetPropertyByCoordPriority(shiftCoord,CSProperties::MATERIAL);
if (prop)
@ -785,7 +774,7 @@ bool Operator::Calc_EffMatPos(int ny, const unsigned int* pos, double* EffMat) c
shiftCoord[nPP] = coord[nPP]-deltaPP_M*0.25;
++loc_pos[nP];
--loc_pos[nPP];
A_n = GetNodeArea(ny,loc_pos,true);
A_n = GetNodeArea(ny,(unsigned int*)loc_pos,true);
prop = CSX->GetPropertyByCoordPriority(shiftCoord,CSProperties::MATERIAL);
if (prop)
{
@ -805,7 +794,7 @@ bool Operator::Calc_EffMatPos(int ny, const unsigned int* pos, double* EffMat) c
shiftCoord[nP] = coord[nP]-deltaP_M*0.25;
shiftCoord[nPP] = coord[nPP]-deltaPP_M*0.25;
--loc_pos[nP];
A_n = GetNodeArea(ny,loc_pos,true);
A_n = GetNodeArea(ny,(unsigned int*)loc_pos,true);
prop = CSX->GetPropertyByCoordPriority(shiftCoord,CSProperties::MATERIAL);
if (prop)
{
@ -831,7 +820,7 @@ bool Operator::Calc_EffMatPos(int ny, const unsigned int* pos, double* EffMat) c
shiftCoord[nP] = coord[nP]+deltaP*0.5;
shiftCoord[nPP] = coord[nPP]+deltaPP*0.5;
--loc_pos[n];
double delta_ny = GetNodeWidth(n,loc_pos,true);
double delta_ny = GetNodeWidth(n,(unsigned int*)loc_pos,true);
prop = CSX->GetPropertyByCoordPriority(shiftCoord,CSProperties::MATERIAL);
if (prop)
{
@ -854,7 +843,7 @@ bool Operator::Calc_EffMatPos(int ny, const unsigned int* pos, double* EffMat) c
shiftCoord[nP] = coord[nP]+deltaP*0.5;
shiftCoord[nPP] = coord[nPP]+deltaPP*0.5;
++loc_pos[n];
delta_ny = GetNodeWidth(n,loc_pos,true);
delta_ny = GetNodeWidth(n,(unsigned int*)loc_pos,true);
prop = CSX->GetPropertyByCoordPriority(shiftCoord,CSProperties::MATERIAL);
if (prop)
{

View File

@ -86,38 +86,26 @@ public:
virtual double GetGridDelta() const {return gridDelta;}
//! Get the mesh delta times the grid delta for a 3D position (unit is meter)
virtual double GetMeshDelta(int n, const int* pos, bool dualMesh=false) const;
//! 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;
//! Get the disc line in \a n direction (in drawing units)
virtual double GetDiscLine(int n, int pos, bool dualMesh=false) const;
//! Get the disc line in \a n direction (in drawing units)
virtual double GetDiscLine(int n, unsigned int pos, bool dualMesh=false) const;
//! 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 {return GetNodeWidth(ny,(const int*)pos,dualMesh);}
//! Get the node width for a given direction \a n and a given mesh position \a pos
virtual double GetNodeWidth(int ny, const int pos[3], bool dualMesh = false) const {return GetMeshDelta(ny,pos,!dualMesh);}
virtual double GetNodeWidth(int ny, const unsigned int pos[3], bool dualMesh = false) const {return GetMeshDelta(ny,pos,!dualMesh);}
//! 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 {return GetNodeArea(ny,(const int*)pos,dualMesh);}
//! Get the node area for a given direction \a n and a given mesh position \a pos
virtual double GetNodeArea(int ny, const int pos[3], bool dualMesh = false) const;
virtual double GetNodeArea(int ny, const unsigned int pos[3], bool dualMesh = false) const;
//! Get the length of an FDTD edge (unit is meter).
virtual double GetEdgeLength(int ny, const unsigned int pos[3], bool dualMesh = false) const {return GetEdgeLength(ny,(const int*)pos,dualMesh);}
//! Get the length of an FDTD edge (unit is meter).
virtual double GetEdgeLength(int ny, const int pos[3], bool dualMesh = false) const {return GetMeshDelta(ny,pos,dualMesh);}
virtual double GetEdgeLength(int ny, const unsigned int pos[3], bool dualMesh = false) const {return GetMeshDelta(ny,pos,dualMesh);}
//! 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 {return GetEdgeArea(ny,(const int*)pos,dualMesh);}
//! Get the area around an edge for a given direction \a n and a given mesh posisition \a pos \sa GetEdgeArea
virtual double GetEdgeArea(int ny, const int pos[3], bool dualMesh = false) const {return GetNodeArea(ny,(const int*)pos,dualMesh);};
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);

View File

@ -74,7 +74,7 @@ string Operator_Cylinder::GetDirName(int ny) const
return "";
}
double Operator_Cylinder::GetMeshDelta(int n, const int* pos, bool dualMesh) const
double Operator_Cylinder::GetMeshDelta(int n, const unsigned int* pos, bool dualMesh) const
{
double delta = Operator_Multithread::GetMeshDelta(n,pos,dualMesh);
if (delta==0) return delta;
@ -85,9 +85,10 @@ double Operator_Cylinder::GetMeshDelta(int n, const int* pos, bool dualMesh) con
return delta;
}
double Operator_Cylinder::GetNodeWidth(int ny, const int pos[3], bool dualMesh) const
double Operator_Cylinder::GetNodeWidth(int ny, const unsigned int pos[3], bool dualMesh) const
{
if ((ny<0) || (ny>2)) return 0.0;
if (pos[ny]>=numLines[ny]) return 0.0;
double width = 0;
if (dualMesh)
width = fabs(MainOp->GetIndexDelta(ny,pos[ny]))*gridDelta;
@ -99,8 +100,10 @@ double Operator_Cylinder::GetNodeWidth(int ny, const int pos[3], bool dualMesh)
}
double Operator_Cylinder::GetNodeArea(int ny, const int pos[3], bool dualMesh) const
double Operator_Cylinder::GetNodeArea(int ny, const unsigned int pos[3], bool dualMesh) const
{
if (pos[ny]>=numLines[ny]) return 0.0;
if (pos[0]>=numLines[0]) return 0.0;
if (ny==2)
{
double da = Operator_Multithread::GetMeshDelta(1,pos,dualMesh)/gridDelta;
@ -130,7 +133,7 @@ double Operator_Cylinder::GetNodeArea(int ny, const int pos[3], bool dualMesh) c
return Operator_Multithread::GetNodeArea(ny,pos,dualMesh);
}
double Operator_Cylinder::GetEdgeLength(int ny, const int pos[3], bool dualMesh) const
double Operator_Cylinder::GetEdgeLength(int ny, const unsigned int pos[3], bool dualMesh) const
{
double length = Operator_Multithread::GetMeshDelta(ny,pos,dualMesh);
if (ny!=1)
@ -138,7 +141,7 @@ double Operator_Cylinder::GetEdgeLength(int ny, const int pos[3], bool dualMesh)
return length * GetDiscLine(0,pos[0],dualMesh);
}
double Operator_Cylinder::GetEdgeArea(int ny, const int pos[3], bool dualMesh) const
double Operator_Cylinder::GetEdgeArea(int ny, const unsigned int pos[3], bool dualMesh) const
{
if (ny!=0)
return GetNodeArea(ny,pos,dualMesh);

View File

@ -43,25 +43,23 @@ public:
virtual string GetDirName(int ny) const;
//! Get the mesh delta times the grid delta for a 3D position, including radius corrected alpha-mesh width
virtual double GetMeshDelta(int n, const int* pos, bool dualMesh=false) const;
virtual double GetMeshDelta(int n, const unsigned int* pos, bool dualMesh=false) const;
//! Get the node width for a given direction \a n and a given mesh posisition \a pos
virtual double GetNodeWidth(int ny, const int pos[3], bool dualMesh = false) const;
virtual double GetNodeWidth(int ny, const unsigned int pos[3], bool dualMesh = false) const;
//! Get the node area for a given direction \a n and a given mesh posisition \a pos
virtual double GetNodeArea(int ny, const unsigned int pos[3], bool dualMesh = false) const {return GetNodeArea(ny,(const int*)pos,dualMesh);}
//! Get the node area for a given direction \a n and a given mesh posisition \a pos
virtual double GetNodeArea(int n, const int* pos, bool dualMesh=false) const;
virtual double GetNodeArea(int n, const unsigned int* pos, bool dualMesh=false) const;
//! Get the length of an FDTD edge.
virtual double GetEdgeLength(int ny, const int pos[3], bool dualMesh = false) const;
virtual double GetEdgeLength(int ny, const unsigned int pos[3], bool dualMesh = false) const;
//! 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 int pos[3], bool dualMesh = false) const;
virtual double GetEdgeArea(int ny, const unsigned int pos[3], bool dualMesh = false) const;
bool GetClosedAlpha() const {return CC_closedAlpha;}
bool GetR0Included() const {return CC_R0_included;}