Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/c_ggrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,23 @@ void c_ggrid::interpolate( nec_float x, nec_float y, nec_complex *f1,
{
static const int nda[3] = {11,17,9}, ndpa[3] = {110, 85, 72};

bool recalculate = true;
/* A point below the cached region origin carries no valid index, so it
forces the coefficients to be rebuilt. */
bool jump = false;

if( (x >= m_ip_xs) && (y >= m_ip_ys) ) {
if( (x < m_ip_xs) || (y < m_ip_ys) ) {
jump = true;
} else {
m_ip_ix = static_cast<int>((x - m_ip_xs) / m_ip_dx) + 1;
m_ip_iy = static_cast<int>((y - m_ip_ys) / m_ip_dy) + 1;
} else {
/* if point lies in same 4 by 4 point region */
/* as previous point, old values are reused. */
if ( ((m_ip_ix >= m_ip_ixeg) && (m_ip_iy >= m_ip_iyeg)) &&
((std::abs(m_ip_ix - m_ip_ixs) < 2) && (std::abs(m_ip_iy - m_ip_iys) < 2)) )
recalculate = false;
}

/* if point lies in same 4 by 4 point region */
/* as previous point, old values are reused. */
bool recalculate = jump ||
(m_ip_ix < m_ip_ixeg) || (m_ip_iy < m_ip_iyeg) ||
(std::abs(m_ip_ix - m_ip_ixs) >= 2) || (std::abs(m_ip_iy - m_ip_iys) >= 2);

if (true == recalculate) {
/* determine correct grid and grid region */
int igr;
Expand Down
14 changes: 7 additions & 7 deletions src/nec_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2975,7 +2975,7 @@ void nec_context::efld( nec_float xi, nec_float yi, nec_float zi, nec_float ai,
rhox= sabj* zij- salpr* yij;
rhoy= salpr* xij- cabj* zij;
rhoz= cabj* yij- sabj* xij;
rh = norm(rhox, rhoy, rhoz); // rhox* rhox+ rhoy* rhoy+ rhoz* rhoz;
rh = norm2(rhox, rhoy, rhoz);

if ( rh <= 1.e-10) {
xo= xi- ai* ysn;
Expand Down Expand Up @@ -5638,7 +5638,7 @@ void nec_context::rom2( nec_float a, nec_float b, complex_array& sum, nec_float
WRITE(3,18)
STOP
*/
int nts = 4, nx = 1;
int nts = 4, nx = 1, nma = 65536;
const int n = 9;
nec_float rx = 1e-4;
nec_float dz = 0.0;
Expand Down Expand Up @@ -5666,7 +5666,7 @@ void nec_context::rom2( nec_float a, nec_float b, complex_array& sum, nec_float
complex_array t01(9), t10(9), t20(9), t11(9);

/*! tolerance for hitting upper limit */
const nec_float ep = _s/(1.0e4 * m_geometry->n_plus_m());
const nec_float ep = _s/(1.0e4 * nma);

/*! upper limit */
const nec_float zend = ze - ep;
Expand Down Expand Up @@ -5846,7 +5846,7 @@ C
GO TO 5
*/
nt=0;
if ( ns >= m_geometry->n_plus_m() )
if ( ns >= nma )
{
nec_error_mode em(m_output);
m_output.string("ROM2 -- STEP SIZE LIMITED AT Z = ");
Expand Down Expand Up @@ -5894,7 +5894,7 @@ void nec_context::rom2( nec_float a, nec_float b, complex_array& sum, nec_float

bool recalculate_fields = true;

int nts = 4, nx = 1, n = 9;
int nts = 4, nx = 1, n = 9, nma = 65536;

/*! subinterval size */
nec_float dz=0.0;
Expand All @@ -5918,7 +5918,7 @@ void nec_context::rom2( nec_float a, nec_float b, complex_array& sum, nec_float
}

/*! tolerance for hitting upper limit */
const nec_float ep = _s/(1.0e4 * m_geometry->n_plus_m());
const nec_float ep = _s/(1.0e4 * nma);

/*! upper limit */
const nec_float zend = ze - ep;
Expand Down Expand Up @@ -6015,7 +6015,7 @@ void nec_context::rom2( nec_float a, nec_float b, complex_array& sum, nec_float
if ( tr > rx)
{
nt=0;
if ( ns <= m_geometry->n_plus_m() )
if ( ns <= nma )
{
// halve step size
ns = ns*2;
Expand Down
Loading