Skip to content

Commit

Permalink
removed too much old testing code, add some back
Browse files Browse the repository at this point in the history
  • Loading branch information
gardner48 committed Jul 7, 2023
1 parent bef4d6f commit 26f779c
Showing 1 changed file with 50 additions and 45 deletions.
95 changes: 50 additions & 45 deletions test/unit_tests/cvode/CXX_serial/cv_test_resize_history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,63 +299,68 @@ int main(int argc, char* argv[])

std::cout << "\n========== End Step " << i << " ==========\n";

std::cout << "\n========== Start Resize " << i << " ==========\n";
// Update saved history
if (i < 6)
if (resize == 1)
{
hist_size++;
}
else
{
hist_size = 6;
}
std::cout << "\n========== Start Resize " << i << " ==========\n";
// Test 2: Copy and expand the state

for (int j = 5; j > 0; j--)
{
thist[j] = thist[j - 1];
}
thist[0] = tret;
// Update saved history
if (i < 6)
{
hist_size++;
}
else
{
hist_size = 6;
}

for (int j = 5; j > 0; j--)
{
N_VScale(ONE, yhist[j - 1], yhist[j]);
}
N_VScale(ONE, y, yhist[0]);
for (int j = 5; j > 0; j--)
{
thist[j] = thist[j - 1];
}
thist[0] = tret;

// Resize all vectors
for (int j = 0; j < 6; j++)
{
sunrealtype* old_data = N_VGetArrayPointer(yhist[j]);
for (int j = 5; j > 0; j--)
{
N_VScale(ONE, yhist[j - 1], yhist[j]);
}
N_VScale(ONE, y, yhist[0]);

N_Vector new_vec = N_VNew_Serial(i + 1, sunctx);
sunrealtype* new_data = N_VGetArrayPointer(new_vec);
for (int k = 0; k < i + 1; k++)
// Resize all vectors
for (int j = 0; j < 6; j++)
{
new_data[k] = old_data[0];
sunrealtype* old_data = N_VGetArrayPointer(yhist[j]);

N_Vector new_vec = N_VNew_Serial(i + 1, sunctx);
sunrealtype* new_data = N_VGetArrayPointer(new_vec);
for (int k = 0; k < i + 1; k++)
{
new_data[k] = old_data[0];
}
N_VDestroy(yhist[j]);
yhist[j] = new_vec;
}
N_VDestroy(yhist[j]);
yhist[j] = new_vec;
}

N_VDestroy(y);
N_VDestroy(ytmp);
y = N_VNew_Serial(i + 1, sunctx);
ytmp = N_VClone(y);
N_VDestroy(y);
N_VDestroy(ytmp);
y = N_VNew_Serial(i + 1, sunctx);
ytmp = N_VClone(y);

flag = CVodeResizeHistory(cvode_mem, thist, yhist, hist_size, resize_vec);
if (check_flag(flag, "CVodeResizeHistory")) return 1;
flag = CVodeResizeHistory(cvode_mem, thist, yhist, hist_size, resize_vec);
if (check_flag(flag, "CVodeResizeHistory")) return 1;

// "Resize" the nonlinear solver
SUNNonlinSolFree(NLS);
NLS = SUNNonlinSol_FixedPoint(y, 2, sunctx);
if (check_ptr(NLS, "SUNNonlinSol_FixedPoint")) return 1;
// "Resize" the nonlinear solver
SUNNonlinSolFree(NLS);
NLS = SUNNonlinSol_FixedPoint(y, 2, sunctx);
if (check_ptr(NLS, "SUNNonlinSol_FixedPoint")) return 1;

flag = CVodeSetNonlinearSolver(cvode_mem, NLS);
if (check_flag(flag, "CVodeSetNonlinearSolver")) return 1;
flag = CVodeSetNonlinearSolver(cvode_mem, NLS);
if (check_flag(flag, "CVodeSetNonlinearSolver")) return 1;

flag = CVodeSetMaxNonlinIters(cvode_mem, 10);
if (check_flag(flag, "CVodeSetMaxNonlinIters")) return 1;
std::cout << "\n========== End Resize " << i << " ==========\n";
flag = CVodeSetMaxNonlinIters(cvode_mem, 10);
if (check_flag(flag, "CVodeSetMaxNonlinIters")) return 1;
std::cout << "\n========== End Resize " << i << " ==========\n";
}
}
std::cout << std::endl;

Expand Down

0 comments on commit 26f779c

Please sign in to comment.