diff --git a/packages/seacas/applications/exodiff/exoII_read.C b/packages/seacas/applications/exodiff/exoII_read.C index 00fb6981b1..4e57ed0b35 100644 --- a/packages/seacas/applications/exodiff/exoII_read.C +++ b/packages/seacas/applications/exodiff/exoII_read.C @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2023 National Technology & Engineering Solutions +// Copyright(C) 1999-2024 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -54,7 +54,6 @@ template ExoII_Read::~ExoII_Read() delete[] nsets; delete[] ssets; delete[] nodes; - delete[] times; delete[] edge_blocks; delete[] face_blocks; delete[] assemblies; @@ -99,7 +98,7 @@ template std::string ExoII_Read::Close_File() template double ExoII_Read::Time(int time_num) const { SMART_ASSERT(Check_State()); - SMART_ASSERT(time_num > 0 && time_num <= num_times)(time_num)(num_times); + SMART_ASSERT(time_num > 0 && time_num <= Num_Times())(time_num)(Num_Times()); return times[time_num - 1]; } @@ -621,7 +620,7 @@ template std::string ExoII_Read::Load_Nodal_Results(int time_step_num, int var_index) { SMART_ASSERT(Check_State()); - SMART_ASSERT(time_step_num > 0 && time_step_num <= num_times); + SMART_ASSERT(time_step_num > 0 && time_step_num <= Num_Times()); SMART_ASSERT(var_index >= 0 && (unsigned)var_index < nodal_vars.size()); if (!Open()) { @@ -667,8 +666,8 @@ const double *ExoII_Read::Get_Nodal_Results(int t1, int t2, double proporti static std::vector st_results2; SMART_ASSERT(Check_State()); - SMART_ASSERT(t1 > 0 && t1 <= num_times); - SMART_ASSERT(t2 > 0 && t2 <= num_times); + SMART_ASSERT(t1 > 0 && t1 <= Num_Times()); + SMART_ASSERT(t2 > 0 && t2 <= Num_Times()); SMART_ASSERT(var_index >= 0 && (unsigned)var_index < nodal_vars.size()); if (!Open()) { @@ -740,7 +739,7 @@ template const double *ExoII_Read::Get_Nodal_Results(int var template std::string ExoII_Read::Load_Global_Results(int time_step_num) { SMART_ASSERT(Check_State()); - SMART_ASSERT(time_step_num > 0 && time_step_num <= num_times); + SMART_ASSERT(time_step_num > 0 && time_step_num <= Num_Times()); if (!Open()) { return "WARNING: File not open!"; @@ -776,8 +775,8 @@ template std::string ExoII_Read::Load_Global_Results(int t1, int t2, double proportion) { SMART_ASSERT(Check_State()); - SMART_ASSERT(t1 > 0 && t1 <= num_times); - SMART_ASSERT(t2 > 0 && t2 <= num_times); + SMART_ASSERT(t1 > 0 && t1 <= Num_Times()); + SMART_ASSERT(t2 > 0 && t2 <= Num_Times()); if (!Open()) { return "WARNING: File not open!"; @@ -912,10 +911,9 @@ template int ExoII_Read::Check_State() const SMART_ASSERT(!(num_nodes == 0 && nodes)); - SMART_ASSERT(num_times >= 0); - SMART_ASSERT(!(num_times > 0 && !times)); + SMART_ASSERT(Num_Times() >= 0); - SMART_ASSERT(cur_time >= 0 && cur_time <= num_times); + SMART_ASSERT(cur_time >= 0 && cur_time <= Num_Times()); SMART_ASSERT(!(!nodal_vars.empty() && !results)); SMART_ASSERT(!(nodal_vars.empty() && results)); @@ -1306,7 +1304,7 @@ template void ExoII_Read::Get_Init_Data() read_vars(file_id, EX_FACE_BLOCK, "Faceblock", num_face_vars, fb_vars); // Times: - num_times = ex_inquire_int(file_id, EX_INQ_TIME); + int num_times = ex_inquire_int(file_id, EX_INQ_TIME); if (num_times < 0) { Error(fmt::format("Number of time steps came back negative ({})! Aborting...\n", num_times)); } @@ -1319,9 +1317,8 @@ template void ExoII_Read::Get_Init_Data() } if (num_times) { - times = new double[num_times]; - SMART_ASSERT(times != nullptr); - ex_get_all_times(file_id, times); + times.resize(num_times); + ex_get_all_times(file_id, times.data()); if (time_scale != 1.0 || time_offset != 0.0) { for (int i = 0; i < num_times; i++) { times[i] = time_scale * times[i] + time_offset; diff --git a/packages/seacas/applications/exodiff/exoII_read.h b/packages/seacas/applications/exodiff/exoII_read.h index fc423d057d..4e0560acd4 100644 --- a/packages/seacas/applications/exodiff/exoII_read.h +++ b/packages/seacas/applications/exodiff/exoII_read.h @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2023 National Technology & Engineering Solutions +// Copyright(C) 1999-2024 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -68,8 +68,7 @@ template class ExoII_Read size_t Num_Assembly() const { return num_assemblies; } // Times: - - int Num_Times() const { return num_times; } + int Num_Times() const { return (int)times.size(); } double Time(int time_num) const; // Variables: @@ -240,11 +239,10 @@ template class ExoII_Read std::vector eb_vars{}; std::vector fb_vars{}; - int num_times{0}; double time_scale{1.0}; double time_offset{0.0}; - double *times{nullptr}; + std::vector times{}; int cur_time{0}; // Current timestep number of the results (0 means none). double **results{nullptr}; // Array of pointers (to arrays of results data);