Operator: new SnapBox2Mesh + used by CalcLumpedElement
parent
3dcc218b09
commit
2e8e8caa4e
|
@ -69,8 +69,20 @@ public:
|
|||
*/
|
||||
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(const double* coord, unsigned int* uicoord, bool lower=false, bool* inside=NULL) const =0;
|
||||
//! Snap the given coodinates to mesh indices, return box dimension
|
||||
virtual bool SnapToMesh(const double* coord, unsigned int* uicoord, bool dualMesh=false, bool* inside=NULL) const =0;
|
||||
|
||||
//! Snap a given box to the operator mesh, uiStart will be always <= uiStop
|
||||
/*!
|
||||
\param[in] start the box-start coorindate
|
||||
\param[in] stop the box-stopt coorindate
|
||||
\param[out] uiStart the snapped box-start coorindate index
|
||||
\param[out] uiStop the snapped box-stop coorindate index
|
||||
\param[in] dualMesh snap to main or dual mesh (default is main mesh)
|
||||
\param[in] SnapMethod Snapping method, 0=snap to closest line, 1/(2)=snap such that given box is inside (outside) the snapped lines
|
||||
\return returns the box dimension or -1 if box is not inside the simulation domain
|
||||
*/
|
||||
virtual int SnapBox2Mesh(const double* start, const double* stop, unsigned int* uiStart, unsigned int* uiStop, bool dualMesh=false, int SnapMethod=0, bool* bStartIn=NULL, bool* bStopIn=NULL) const =0;
|
||||
|
||||
//! Set the boundary conditions
|
||||
virtual void SetBoundaryCondition(int* BCs) {for (int n=0; n<6; ++n) m_BC[n]=BCs[n];}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include "operator.h"
|
||||
#include "engine.h"
|
||||
#include "extensions/operator_extension.h"
|
||||
|
@ -253,6 +254,69 @@ bool Operator::SnapToMesh(const double* dcoord, unsigned int* uicoord, bool dual
|
|||
return ok;
|
||||
}
|
||||
|
||||
int Operator::SnapBox2Mesh(const double* start, const double* stop, unsigned int* uiStart, unsigned int* uiStop, bool dualMesh, int SnapMethod, bool* bStartIn, bool* bStopIn) const
|
||||
{
|
||||
double l_start[3], l_stop[3];
|
||||
for (int n=0;n<3;++n)
|
||||
{
|
||||
l_start[n] = fmin(start[n],stop[n]);
|
||||
l_stop[n] = fmax(start[n], stop[n]);
|
||||
double min = GetDiscLine(n,0);
|
||||
double max = GetDiscLine(n,GetNumberOfLines(n)-1);
|
||||
if ( ((l_start[n]<min) && (l_stop[n]<min)) || ((l_start[n]>max) && (l_stop[n]>max)) )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
SnapToMesh(l_start, uiStart, dualMesh, bStartIn);
|
||||
SnapToMesh(l_stop, uiStop, dualMesh, bStopIn);
|
||||
int iDim = 0;
|
||||
|
||||
if (SnapMethod==0)
|
||||
{
|
||||
for (int n=0;n<3;++n)
|
||||
if (uiStop[n]>uiStart[n])
|
||||
++iDim;
|
||||
return iDim;
|
||||
}
|
||||
else if (SnapMethod==1)
|
||||
{
|
||||
for (int n=0;n<3;++n)
|
||||
{
|
||||
if (uiStop[n]>uiStart[n])
|
||||
{
|
||||
if ((GetDiscLine( n, uiStart[n], dualMesh ) > l_start[n]) && (uiStart[n]>0))
|
||||
--uiStart[n];
|
||||
if ((GetDiscLine( n, uiStop[n], dualMesh ) < l_stop[n]) && (uiStop[n]<GetNumberOfLines(n)-1))
|
||||
++uiStop[n];
|
||||
}
|
||||
if (uiStop[n]>uiStart[n])
|
||||
++iDim;
|
||||
}
|
||||
return iDim;
|
||||
}
|
||||
else if (SnapMethod==2)
|
||||
{
|
||||
for (int n=0;n<3;++n)
|
||||
{
|
||||
if (uiStop[n]>uiStart[n])
|
||||
{
|
||||
if ((GetDiscLine( n, uiStart[n], dualMesh ) < l_start[n]) && (uiStart[n]<GetNumberOfLines(n)-1))
|
||||
++uiStart[n];
|
||||
if ((GetDiscLine( n, uiStop[n], dualMesh ) > l_stop[n]) && (uiStop[n]>0))
|
||||
--uiStop[n];
|
||||
}
|
||||
if (uiStop[n]>uiStart[n])
|
||||
++iDim;
|
||||
}
|
||||
return iDim;
|
||||
}
|
||||
else
|
||||
cerr << "Operator::SnapBox2Mesh: Unknown snapping method!" << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct Operator::Grid_Path Operator::FindPath(double start[], double stop[])
|
||||
{
|
||||
struct Grid_Path path;
|
||||
|
@ -1205,18 +1269,8 @@ bool Operator::Calc_LumpedElements()
|
|||
unsigned int uiStart[3];
|
||||
unsigned int uiStop[3];
|
||||
// snap to the native coordinate system
|
||||
SnapToMesh(box->GetStartCoord()->GetNativeCoords(),uiStart);
|
||||
SnapToMesh(box->GetStopCoord()->GetNativeCoords(),uiStop);
|
||||
|
||||
for (int n=0;n<3;++n)
|
||||
{
|
||||
if (uiStop[n]<uiStart[n])
|
||||
{
|
||||
unsigned int help = uiStart[n];
|
||||
uiStart[n]=uiStop[n];
|
||||
uiStop[n]=help;
|
||||
}
|
||||
}
|
||||
if (Operator::SnapBox2Mesh(box->GetStartCoord()->GetNativeCoords(), box->GetStopCoord()->GetNativeCoords(), uiStart, uiStop)<=0)
|
||||
return false;
|
||||
|
||||
if (uiStart[ny]==uiStop[ny])
|
||||
{
|
||||
|
|
|
@ -120,8 +120,12 @@ public:
|
|||
|
||||
virtual unsigned int SnapToMeshLine(int ny, double coord, bool &inside, bool dualMesh=false) const;
|
||||
|
||||
//! Snap the given coodinates to mesh indices
|
||||
virtual bool SnapToMesh(const double* coord, unsigned int* uicoord, bool dualMesh=false, bool* inside=NULL) const;
|
||||
|
||||
//! Snap a given box to the FDTD mesh
|
||||
virtual int SnapBox2Mesh(const double* start, const double* stop, unsigned int* uiStart, unsigned int* uiStop, bool dualMesh=false, int SnapMethod=0, bool* bStartIn=NULL, bool* bStopIn=NULL) const;
|
||||
|
||||
virtual void AddExtension(Operator_Extension* op_ext);
|
||||
virtual size_t GetNumberOfExtentions() const {return m_Op_exts.size();}
|
||||
virtual Operator_Extension* GetExtension(size_t index) const {return m_Op_exts.at(index);}
|
||||
|
|
Loading…
Reference in New Issue