Skip to content

Commit

Permalink
Simplify algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacarniato committed Oct 31, 2023
1 parent d6a85f9 commit 2f09798
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
10 changes: 10 additions & 0 deletions libs/MeshKernel/src/CurvilinearGrid/CurvilinearGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,16 @@ CurvilinearGrid::ComputeBlockFromCornerPoints(const CurvilinearGridNodeIndices&
throw ConstraintError("Invalid index: first index - {{{}, {}}}, second index - {{{}, {}}}", lowerLeft.m_m, lowerLeft.m_n, upperRight.m_m, upperRight.m_n);
}

if (lowerLeft.m_m >= m_numM || lowerLeft.m_n >= m_numN)
{
throw ConstraintError("Invalid index: first index {{{}, {}}} not in mesh limits {{{}, {}}}", lowerLeft.m_m, lowerLeft.m_n, m_numM, m_numN);
}

if (upperRight.m_m >= m_numM || upperRight.m_n >= m_numN)
{
throw ConstraintError("Invalid index: second index {{{}, {}}} not in mesh limits {{{}, {}}}", upperRight.m_m, upperRight.m_n, m_numM, m_numN);
}

return {lowerLeft, upperRight};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,11 @@ meshkernel::CurvilinearGridDeleteInterior::CurvilinearGridDeleteInterior(Curvili

void meshkernel::CurvilinearGridDeleteInterior::Compute()
{
const UInt lowerLimitI = m_lowerLeft.m_n;
const UInt upperLimitI = m_upperRight.m_n;

if (m_lowerLeft.m_m >= m_grid.m_numM || m_lowerLeft.m_n >= m_grid.m_numN)
{
throw ConstraintError("Invalid index: first index {{{}, {}}} not in mesh limits {{{}, {}}}", m_lowerLeft.m_m, m_lowerLeft.m_n, m_grid.m_numM, m_grid.m_numN);
}

if (m_upperRight.m_m >= m_grid.m_numM || m_upperRight.m_n >= m_grid.m_numN)
{
throw ConstraintError("Invalid index: second index {{{}, {}}} not in mesh limits {{{}, {}}}", m_upperRight.m_m, m_upperRight.m_n, m_grid.m_numM, m_grid.m_numN);
}

UInt lowerLimitI = m_lowerLeft.m_n;
UInt upperLimitI = m_upperRight.m_n;

UInt lowerLimitJ = m_lowerLeft.m_m;
UInt upperLimitJ = m_upperRight.m_m;
const UInt lowerLimitJ = m_lowerLeft.m_m;
const UInt upperLimitJ = m_upperRight.m_m;

for (UInt n = lowerLimitI + 1; n < upperLimitI; ++n)
{
Expand Down

0 comments on commit 2f09798

Please sign in to comment.