From 0b7a91237b2ecbf28612c4692c82f414e4afd1e1 Mon Sep 17 00:00:00 2001 From: Philip Fackler Date: Tue, 5 Mar 2024 15:44:39 -0500 Subject: [PATCH] Addressed some issues in flux handlers and solver handlers (#179) --- test/core/flux/CustomFitFluxHandlerTester.cpp | 6 ----- test/core/flux/W100FitFluxHandlerTester.cpp | 12 ---------- test/io/HDF5UtilsTester.cpp | 2 -- .../xolotl/core/flux/AlloyFitFluxHandler.h | 2 +- .../xolotl/core/flux/AlphaZrFitFluxHandler.h | 2 +- .../xolotl/core/flux/FeFitFluxHandler.h | 2 +- .../include/xolotl/core/flux/FluxHandler.h | 4 ++-- .../xolotl/core/flux/FuelFitFluxHandler.h | 2 +- .../xolotl/core/flux/PulsedFitFluxHandler.h | 2 +- .../xolotl/core/flux/W100FitFluxHandler.h | 2 +- .../xolotl/core/flux/W110FitFluxHandler.h | 2 +- .../xolotl/core/flux/W111FitFluxHandler.h | 2 +- .../xolotl/core/flux/W211FitFluxHandler.h | 2 +- xolotl/core/src/flux/FluxHandler.cpp | 18 ++++++++------- .../src/temperature/HeatEquationHandler.cpp | 4 ++-- .../core/src/temperature/ProfileHandler.cpp | 4 ++-- .../solver/handler/PetscSolver0DHandler.h | 22 +++++++++---------- .../solver/handler/PetscSolver1DHandler.h | 22 +++++++++---------- .../solver/handler/PetscSolver2DHandler.h | 22 +++++++++---------- .../solver/handler/PetscSolver3DHandler.h | 22 +++++++++---------- xolotl/solver/src/Solver.cpp | 2 +- .../src/handler/PetscSolver0DHandler.cpp | 8 ------- .../src/handler/PetscSolver1DHandler.cpp | 12 +++++----- .../util/include/xolotl/util/IStepSequence.h | 5 +++++ 24 files changed, 80 insertions(+), 103 deletions(-) diff --git a/test/core/flux/CustomFitFluxHandlerTester.cpp b/test/core/flux/CustomFitFluxHandlerTester.cpp index de90fbf39..47bf028db 100644 --- a/test/core/flux/CustomFitFluxHandlerTester.cpp +++ b/test/core/flux/CustomFitFluxHandlerTester.cpp @@ -126,8 +126,6 @@ BOOST_AUTO_TEST_CASE(checkComputeIncidentFlux) BOOST_REQUIRE_CLOSE(newConcentration(1, 46), 0.0, 0.01); BOOST_REQUIRE_CLOSE(newConcentration(2, 0), 3.60006e-06, 0.01); BOOST_REQUIRE_CLOSE(newConcentration(2, 16), 0.0398406, 0.01); - - return; } BOOST_AUTO_TEST_CASE(checkFluence) @@ -189,8 +187,6 @@ BOOST_AUTO_TEST_CASE(checkFluence) NetworkType::AmountType maxD = opts.getMaxD(); NetworkType::AmountType maxT = opts.getMaxT(); NetworkType network({maxHe, maxD, maxT, maxV, maxI}, grid.size(), opts); - // Get its size - const int dof = network.getDOF(); // Create the W100 flux handler auto testFitFlux = make_shared(opts); @@ -219,8 +215,6 @@ BOOST_AUTO_TEST_CASE(checkFluence) BOOST_REQUIRE_EQUAL(fluence[0], f[0]); BOOST_REQUIRE_EQUAL(fluence[1], f[1]); BOOST_REQUIRE_EQUAL(fluence[2], f[2]); - - return; } BOOST_AUTO_TEST_SUITE_END() diff --git a/test/core/flux/W100FitFluxHandlerTester.cpp b/test/core/flux/W100FitFluxHandlerTester.cpp index 632e34e3f..cecd7309d 100644 --- a/test/core/flux/W100FitFluxHandlerTester.cpp +++ b/test/core/flux/W100FitFluxHandlerTester.cpp @@ -95,8 +95,6 @@ BOOST_AUTO_TEST_CASE(checkComputeIncidentFlux) BOOST_REQUIRE_CLOSE(newConcentration(1, 0), 0.444777, 0.01); BOOST_REQUIRE_CLOSE(newConcentration(2, 0), 0.247638, 0.01); BOOST_REQUIRE_CLOSE(newConcentration(3, 0), 0.10758, 0.01); - - return; } BOOST_AUTO_TEST_CASE(checkComputeIncidentFluxNoGrid) @@ -156,8 +154,6 @@ BOOST_AUTO_TEST_CASE(checkComputeIncidentFluxNoGrid) auto newConcentration = create_mirror_view_and_copy(Kokkos::HostSpace{}, updatedConcOffset); BOOST_REQUIRE_CLOSE(newConcentration[0], 1.0, 0.01); - - return; } BOOST_AUTO_TEST_CASE(checkFluence) @@ -193,8 +189,6 @@ BOOST_AUTO_TEST_CASE(checkFluence) NetworkType::AmountType maxD = opts.getMaxD(); NetworkType::AmountType maxT = opts.getMaxT(); NetworkType network({maxHe, maxD, maxT, maxV, maxI}, grid.size(), opts); - // Get its size - const int dof = network.getDOF(); // Create the W100 flux handler auto testFitFlux = make_shared(opts); @@ -213,8 +207,6 @@ BOOST_AUTO_TEST_CASE(checkFluence) // Check that the fluence is not 0.0 anymore fluence = testFitFlux->getFluence(); BOOST_REQUIRE_EQUAL(fluence[0], 1.0e-8); - - return; } BOOST_AUTO_TEST_CASE(checkFluxAmplitude) @@ -289,8 +281,6 @@ BOOST_AUTO_TEST_CASE(checkFluxAmplitude) BOOST_REQUIRE_CLOSE(newConcentration(1, 0), 1.111943, 0.01); BOOST_REQUIRE_CLOSE(newConcentration(2, 0), 0.619095, 0.01); BOOST_REQUIRE_CLOSE(newConcentration(3, 0), 0.268961, 0.01); - - return; } BOOST_AUTO_TEST_CASE(checkTimeProfileFlux) @@ -420,8 +410,6 @@ BOOST_AUTO_TEST_CASE(checkTimeProfileFlux) // Finalize MPI MPI_Finalize(); - - return; } BOOST_AUTO_TEST_SUITE_END() diff --git a/test/io/HDF5UtilsTester.cpp b/test/io/HDF5UtilsTester.cpp index 1c714f60c..340c00bea 100644 --- a/test/io/HDF5UtilsTester.cpp +++ b/test/io/HDF5UtilsTester.cpp @@ -84,8 +84,6 @@ BOOST_AUTO_TEST_CASE(checkIO) NetworkType::AmountType maxD = opts.getMaxD(); NetworkType::AmountType maxT = opts.getMaxT(); NetworkType network({maxHe, maxD, maxT, maxV, maxI}, grid.size(), opts); - // Get the size of the network - int networkSize = network.getNumClusters(); // Set the time step number int timeStep = 0; diff --git a/xolotl/core/include/xolotl/core/flux/AlloyFitFluxHandler.h b/xolotl/core/include/xolotl/core/flux/AlloyFitFluxHandler.h index 27f6f6814..9614c5aaf 100644 --- a/xolotl/core/include/xolotl/core/flux/AlloyFitFluxHandler.h +++ b/xolotl/core/include/xolotl/core/flux/AlloyFitFluxHandler.h @@ -28,7 +28,7 @@ class AlloyFitFluxHandler : public FluxHandler * \see FluxHandler.h */ double - FitFunction(double x) + FitFunction(double x) override { // Not actually used return 1.0; diff --git a/xolotl/core/include/xolotl/core/flux/AlphaZrFitFluxHandler.h b/xolotl/core/include/xolotl/core/flux/AlphaZrFitFluxHandler.h index 95a50700c..299ff3424 100644 --- a/xolotl/core/include/xolotl/core/flux/AlphaZrFitFluxHandler.h +++ b/xolotl/core/include/xolotl/core/flux/AlphaZrFitFluxHandler.h @@ -23,7 +23,7 @@ class AlphaZrFitFluxHandler : public FluxHandler * \see FluxHandler.h */ double - FitFunction(double x) + FitFunction(double x) override { return 1.0; } diff --git a/xolotl/core/include/xolotl/core/flux/FeFitFluxHandler.h b/xolotl/core/include/xolotl/core/flux/FeFitFluxHandler.h index a003d153b..a4eff429a 100644 --- a/xolotl/core/include/xolotl/core/flux/FeFitFluxHandler.h +++ b/xolotl/core/include/xolotl/core/flux/FeFitFluxHandler.h @@ -22,7 +22,7 @@ class FeFitFluxHandler : public FluxHandler * \see FluxHandler.h */ double - FitFunction(double x) + FitFunction(double x) override { // Not actually used return 0.0; diff --git a/xolotl/core/include/xolotl/core/flux/FluxHandler.h b/xolotl/core/include/xolotl/core/flux/FluxHandler.h index c54d40d86..dca793c49 100644 --- a/xolotl/core/include/xolotl/core/flux/FluxHandler.h +++ b/xolotl/core/include/xolotl/core/flux/FluxHandler.h @@ -157,7 +157,7 @@ class FluxHandler : public IFluxHandler * \see IFluxHandler.h */ void - initializeTimeProfile(const std::string& fileName) override; + initializeTimeProfile(const std::string& fileName) final; /** * \see IFluxHandler.h @@ -195,7 +195,7 @@ class FluxHandler : public IFluxHandler * \see IFluxHandler.h */ void - setFluxAmplitude(double flux) override; + setFluxAmplitude(double flux) final; /** * \see IFluxHandler.h diff --git a/xolotl/core/include/xolotl/core/flux/FuelFitFluxHandler.h b/xolotl/core/include/xolotl/core/flux/FuelFitFluxHandler.h index d71dd5513..f80bf3a6d 100644 --- a/xolotl/core/include/xolotl/core/flux/FuelFitFluxHandler.h +++ b/xolotl/core/include/xolotl/core/flux/FuelFitFluxHandler.h @@ -23,7 +23,7 @@ class FuelFitFluxHandler : public FluxHandler * \see FluxHandler.h */ double - FitFunction(double x) + FitFunction(double x) override { // Constant flux return 1.0; diff --git a/xolotl/core/include/xolotl/core/flux/PulsedFitFluxHandler.h b/xolotl/core/include/xolotl/core/flux/PulsedFitFluxHandler.h index 9e883b27d..6189795e4 100644 --- a/xolotl/core/include/xolotl/core/flux/PulsedFitFluxHandler.h +++ b/xolotl/core/include/xolotl/core/flux/PulsedFitFluxHandler.h @@ -39,7 +39,7 @@ class PulsedFitFluxHandler : public FluxHandler * \see FluxHandler.h */ double - FitFunction(double x) + FitFunction(double x) override { // Compute the polynomial fit double value = exp(-pow((x - mu) / (sqrt(2.0) * sigma), 2.0)); diff --git a/xolotl/core/include/xolotl/core/flux/W100FitFluxHandler.h b/xolotl/core/include/xolotl/core/flux/W100FitFluxHandler.h index b34820c9b..1d6516c67 100644 --- a/xolotl/core/include/xolotl/core/flux/W100FitFluxHandler.h +++ b/xolotl/core/include/xolotl/core/flux/W100FitFluxHandler.h @@ -22,7 +22,7 @@ class W100FitFluxHandler : public PSIFluxHandler * \see FluxHandler.h */ double - FitFunction(double x) + FitFunction(double x) override { // Value at which the flux goes to 0 double x1 = 10.0; diff --git a/xolotl/core/include/xolotl/core/flux/W110FitFluxHandler.h b/xolotl/core/include/xolotl/core/flux/W110FitFluxHandler.h index 066cedc0d..c1be0db93 100644 --- a/xolotl/core/include/xolotl/core/flux/W110FitFluxHandler.h +++ b/xolotl/core/include/xolotl/core/flux/W110FitFluxHandler.h @@ -22,7 +22,7 @@ class W110FitFluxHandler : public PSIFluxHandler * \see FluxHandler.h */ double - FitFunction(double x) + FitFunction(double x) override { // Value at which the flux goes to 0 double x1 = 10.0; diff --git a/xolotl/core/include/xolotl/core/flux/W111FitFluxHandler.h b/xolotl/core/include/xolotl/core/flux/W111FitFluxHandler.h index de8fa8c9f..53be51008 100644 --- a/xolotl/core/include/xolotl/core/flux/W111FitFluxHandler.h +++ b/xolotl/core/include/xolotl/core/flux/W111FitFluxHandler.h @@ -22,7 +22,7 @@ class W111FitFluxHandler : public PSIFluxHandler * \see FluxHandler.h */ double - FitFunction(double x) + FitFunction(double x) override { // Value at which the flux goes to 0 double x1 = 10.0; diff --git a/xolotl/core/include/xolotl/core/flux/W211FitFluxHandler.h b/xolotl/core/include/xolotl/core/flux/W211FitFluxHandler.h index 9190d0026..cf64e83a1 100644 --- a/xolotl/core/include/xolotl/core/flux/W211FitFluxHandler.h +++ b/xolotl/core/include/xolotl/core/flux/W211FitFluxHandler.h @@ -22,7 +22,7 @@ class W211FitFluxHandler : public PSIFluxHandler * \see FluxHandler.h */ double - FitFunction(double x) + FitFunction(double x) override { // Value at which the flux goes to 0 double x1 = 10.0; diff --git a/xolotl/core/src/flux/FluxHandler.cpp b/xolotl/core/src/flux/FluxHandler.cpp index 627f694d9..45869a31a 100644 --- a/xolotl/core/src/flux/FluxHandler.cpp +++ b/xolotl/core/src/flux/FluxHandler.cpp @@ -172,12 +172,14 @@ FluxHandler::getProfileAmplitude(double currentTime) const double f = 0.0; // If the time is smaller than or equal than the first stored time - if (currentTime <= time[0]) - return f = amplitudes[0]; + if (currentTime <= time[0]) { + return amplitudes[0]; + } // If the time is larger or equal to the last stored time - if (currentTime >= time[time.size() - 1]) - return f = amplitudes[time.size() - 1]; + if (currentTime >= time[time.size() - 1]) { + return amplitudes[time.size() - 1]; + } // Else loop to determine the interval the time falls in // i.e. time[k] < time < time[k + 1] @@ -235,8 +237,8 @@ FluxHandler::incrementFluence(double dt) if (reductionFactors.size() > 0) { if (fluence.size() == 1) { // Add entries - for (auto factor : reductionFactors) - fluence.push_back(0.0); + std::fill_n( + std::back_inserter(fluence), reductionFactors.size(), 0.0); } // Update entries @@ -255,8 +257,8 @@ FluxHandler::computeFluence(double time) if (reductionFactors.size() > 0) { if (fluence.size() == 1) { // Add entries - for (auto factor : reductionFactors) - fluence.push_back(0.0); + std::fill_n( + std::back_inserter(fluence), reductionFactors.size(), 0.0); } // Update entries diff --git a/xolotl/core/src/temperature/HeatEquationHandler.cpp b/xolotl/core/src/temperature/HeatEquationHandler.cpp index d2344080a..00e50763a 100644 --- a/xolotl/core/src/temperature/HeatEquationHandler.cpp +++ b/xolotl/core/src/temperature/HeatEquationHandler.cpp @@ -500,11 +500,11 @@ HeatEquationHandler::getHeatFlux(double currentTime) double f = 0.0; // If the time is smaller than or equal than the first stored time if (currentTime <= time[0]) - return f = flux[0]; + return flux[0]; // If the time is larger or equal to the last stored time if (currentTime >= time[time.size() - 1]) - return f = flux[time.size() - 1]; + return flux[time.size() - 1]; // Else loop to determine the interval the time falls in // i.e. time[k] < time < time[k + 1] diff --git a/xolotl/core/src/temperature/ProfileHandler.cpp b/xolotl/core/src/temperature/ProfileHandler.cpp index e19439da5..6833647c7 100644 --- a/xolotl/core/src/temperature/ProfileHandler.cpp +++ b/xolotl/core/src/temperature/ProfileHandler.cpp @@ -68,11 +68,11 @@ ProfileHandler::getTemperature( // If the time is smaller than or equal than the first stored time if (currentTime <= time[0]) - return f = temp[0]; + return temp[0]; // If the time is larger or equal to the last stored time if (currentTime >= time[time.size() - 1]) - return f = temp[time.size() - 1]; + return temp[time.size() - 1]; // Else loop to determine the interval the time falls in // i.e. time[k] < time < time[k + 1] diff --git a/xolotl/solver/include/xolotl/solver/handler/PetscSolver0DHandler.h b/xolotl/solver/include/xolotl/solver/handler/PetscSolver0DHandler.h index 7bdb9ea78..7cba3981f 100644 --- a/xolotl/solver/include/xolotl/solver/handler/PetscSolver0DHandler.h +++ b/xolotl/solver/include/xolotl/solver/handler/PetscSolver0DHandler.h @@ -40,25 +40,25 @@ class PetscSolver0DHandler : public PetscSolverHandler * \see ISolverHandler.h */ void - createSolverContext(DM& da); + createSolverContext(DM& da) override; /** * \see ISolverHandler.h */ void - initializeSolverContext(DM& da, Mat& J); + initializeSolverContext(DM& da, Mat& J) override; /** * \see ISolverHandler.h */ void - initializeConcentration(DM& da, Vec& C, DM& oldDA, Vec& oldC); + initializeConcentration(DM& da, Vec& C, DM& oldDA, Vec& oldC) override; /** * \see ISolverHandler.h */ void - initGBLocation(DM& da, Vec& C) + initGBLocation(DM& da, Vec& C) override { // Doesn't do anything in 0D return; @@ -69,7 +69,7 @@ class PetscSolver0DHandler : public PetscSolverHandler */ std::vector< std::vector>>>> - getConcVector(DM& da, Vec& C); + getConcVector(DM& da, Vec& C) override; /** * \see ISolverHandler.h @@ -78,25 +78,25 @@ class PetscSolver0DHandler : public PetscSolverHandler setConcVector(DM& da, Vec& C, std::vector< std::vector>>>>& - concVector); + concVector) override; /** * \see ISolverHandler.h */ void - updateConcentration(TS& ts, Vec& localC, Vec& F, PetscReal ftime); + updateConcentration(TS& ts, Vec& localC, Vec& F, PetscReal ftime) override; /** * \see ISolverHandler.h */ void - computeJacobian(TS& ts, Vec& localC, Mat& J, PetscReal ftime); + computeJacobian(TS& ts, Vec& localC, Mat& J, PetscReal ftime) override; /** * \see ISolverHandler.h */ IdType - getSurfacePosition(IdType j = badId, IdType k = badId) const + getSurfacePosition(IdType j = badId, IdType k = badId) const override { return 0; } @@ -105,7 +105,7 @@ class PetscSolver0DHandler : public PetscSolverHandler * \see ISolverHandler.h */ void - setSurfacePosition(IdType pos, IdType j = badId, IdType k = badId) + setSurfacePosition(IdType pos, IdType j = badId, IdType k = badId) override { return; } @@ -115,7 +115,7 @@ class PetscSolver0DHandler : public PetscSolverHandler */ void getNetworkTemperature( - std::vector& temperatures, std::vector& depths) + std::vector& temperatures, std::vector& depths) override { temperatures = temperature; depths = std::vector(1, 1.0); diff --git a/xolotl/solver/include/xolotl/solver/handler/PetscSolver1DHandler.h b/xolotl/solver/include/xolotl/solver/handler/PetscSolver1DHandler.h index cfe736c90..aaf1cf1b0 100644 --- a/xolotl/solver/include/xolotl/solver/handler/PetscSolver1DHandler.h +++ b/xolotl/solver/include/xolotl/solver/handler/PetscSolver1DHandler.h @@ -40,32 +40,32 @@ class PetscSolver1DHandler : public PetscSolverHandler * \see ISolverHandler.h */ void - createSolverContext(DM& da); + createSolverContext(DM& da) override; /** * \see ISolverHandler.h */ void - initializeSolverContext(DM& da, Mat& J); + initializeSolverContext(DM& da, Mat& J) override; /** * \see ISolverHandler.h */ void - initializeConcentration(DM& da, Vec& C, DM& oldDA, Vec& oldC); + initializeConcentration(DM& da, Vec& C, DM& oldDA, Vec& oldC) override; /** * \see ISolverHandler.h */ void - initGBLocation(DM& da, Vec& C); + initGBLocation(DM& da, Vec& C) override; /** * \see ISolverHandler.h */ std::vector< std::vector>>>> - getConcVector(DM& da, Vec& C); + getConcVector(DM& da, Vec& C) override; /** * \see ISolverHandler.h @@ -74,25 +74,25 @@ class PetscSolver1DHandler : public PetscSolverHandler setConcVector(DM& da, Vec& C, std::vector< std::vector>>>>& - concVector); + concVector) override; /** * \see ISolverHandler.h */ void - updateConcentration(TS& ts, Vec& localC, Vec& F, PetscReal ftime); + updateConcentration(TS& ts, Vec& localC, Vec& F, PetscReal ftime) override; /** * \see ISolverHandler.h */ void - computeJacobian(TS& ts, Vec& localC, Mat& J, PetscReal ftime); + computeJacobian(TS& ts, Vec& localC, Mat& J, PetscReal ftime) override; /** * \see ISolverHandler.h */ IdType - getSurfacePosition(IdType j = badId, IdType k = badId) const + getSurfacePosition(IdType j = badId, IdType k = badId) const override { return 0; } @@ -101,7 +101,7 @@ class PetscSolver1DHandler : public PetscSolverHandler * \see ISolverHandler.h */ void - setSurfacePosition(IdType pos, IdType j = badId, IdType k = badId) + setSurfacePosition(IdType pos, IdType j = badId, IdType k = badId) override { return; } @@ -111,7 +111,7 @@ class PetscSolver1DHandler : public PetscSolverHandler */ void getNetworkTemperature( - std::vector& temperatures, std::vector& depths) + std::vector& temperatures, std::vector& depths) override { temperatures = interpolateTemperature(); for (auto i = 0; i < temperatures.size(); i++) { diff --git a/xolotl/solver/include/xolotl/solver/handler/PetscSolver2DHandler.h b/xolotl/solver/include/xolotl/solver/handler/PetscSolver2DHandler.h index a6845f831..4009b33f0 100644 --- a/xolotl/solver/include/xolotl/solver/handler/PetscSolver2DHandler.h +++ b/xolotl/solver/include/xolotl/solver/handler/PetscSolver2DHandler.h @@ -44,32 +44,32 @@ class PetscSolver2DHandler : public PetscSolverHandler * \see ISolverHandler.h */ void - createSolverContext(DM& da); + createSolverContext(DM& da) override; /** * \see ISolverHandler.h */ void - initializeSolverContext(DM& da, Mat& J); + initializeSolverContext(DM& da, Mat& J) override; /** * \see ISolverHandler.h */ void - initializeConcentration(DM& da, Vec& C, DM& oldDA, Vec& oldC); + initializeConcentration(DM& da, Vec& C, DM& oldDA, Vec& oldC) override; /** * \see ISolverHandler.h */ void - initGBLocation(DM& da, Vec& C); + initGBLocation(DM& da, Vec& C) override; /** * \see ISolverHandler.h */ std::vector< std::vector>>>> - getConcVector(DM& da, Vec& C); + getConcVector(DM& da, Vec& C) override; /** * \see ISolverHandler.h @@ -78,25 +78,25 @@ class PetscSolver2DHandler : public PetscSolverHandler setConcVector(DM& da, Vec& C, std::vector< std::vector>>>>& - concVector); + concVector) override; /** * \see ISolverHandler.h */ void - updateConcentration(TS& ts, Vec& localC, Vec& F, PetscReal ftime); + updateConcentration(TS& ts, Vec& localC, Vec& F, PetscReal ftime) override; /** * \see ISolverHandler.h */ void - computeJacobian(TS& ts, Vec& localC, Mat& J, PetscReal ftime); + computeJacobian(TS& ts, Vec& localC, Mat& J, PetscReal ftime) override; /** * \see ISolverHandler.h */ IdType - getSurfacePosition(IdType j = badId, IdType k = badId) const + getSurfacePosition(IdType j = badId, IdType k = badId) const override { return surfacePosition[j]; } @@ -105,7 +105,7 @@ class PetscSolver2DHandler : public PetscSolverHandler * \see ISolverHandler.h */ void - setSurfacePosition(IdType pos, IdType j = badId, IdType k = badId) + setSurfacePosition(IdType pos, IdType j = badId, IdType k = badId) override { surfacePosition[j] = pos; @@ -117,7 +117,7 @@ class PetscSolver2DHandler : public PetscSolverHandler */ void getNetworkTemperature( - std::vector& temperatures, std::vector& depths) + std::vector& temperatures, std::vector& depths) override { temperatures = temperature; for (auto i = 0; i < temperature.size(); i++) { diff --git a/xolotl/solver/include/xolotl/solver/handler/PetscSolver3DHandler.h b/xolotl/solver/include/xolotl/solver/handler/PetscSolver3DHandler.h index 9cebdbd28..9d46544f1 100644 --- a/xolotl/solver/include/xolotl/solver/handler/PetscSolver3DHandler.h +++ b/xolotl/solver/include/xolotl/solver/handler/PetscSolver3DHandler.h @@ -44,33 +44,33 @@ class PetscSolver3DHandler : public PetscSolverHandler * \see ISolverHandler.h */ void - createSolverContext(DM& da); + createSolverContext(DM& da) override; /** * \see ISolverHandler.h */ void - initializeSolverContext(DM& da, Mat& J); + initializeSolverContext(DM& da, Mat& J) override; /** * Initialize the concentration solution vector. * \see ISolverHandler.h */ void - initializeConcentration(DM& da, Vec& C, DM& oldDA, Vec& oldC); + initializeConcentration(DM& da, Vec& C, DM& oldDA, Vec& oldC) override; /** * \see ISolverHandler.h */ void - initGBLocation(DM& da, Vec& C); + initGBLocation(DM& da, Vec& C) override; /** * \see ISolverHandler.h */ std::vector< std::vector>>>> - getConcVector(DM& da, Vec& C); + getConcVector(DM& da, Vec& C) override; /** * \see ISolverHandler.h @@ -79,25 +79,25 @@ class PetscSolver3DHandler : public PetscSolverHandler setConcVector(DM& da, Vec& C, std::vector< std::vector>>>>& - concVector); + concVector) override; /** * \see ISolverHandler.h */ void - updateConcentration(TS& ts, Vec& localC, Vec& F, PetscReal ftime); + updateConcentration(TS& ts, Vec& localC, Vec& F, PetscReal ftime) override; /** * \see ISolverHandler.h */ void - computeJacobian(TS& ts, Vec& localC, Mat& J, PetscReal ftime); + computeJacobian(TS& ts, Vec& localC, Mat& J, PetscReal ftime) override; /** * \see ISolverHandler.h */ IdType - getSurfacePosition(IdType j = badId, IdType k = badId) const + getSurfacePosition(IdType j = badId, IdType k = badId) const override { return surfacePosition[j][k]; } @@ -106,7 +106,7 @@ class PetscSolver3DHandler : public PetscSolverHandler * \see ISolverHandler.h */ void - setSurfacePosition(IdType pos, IdType j = badId, IdType k = badId) + setSurfacePosition(IdType pos, IdType j = badId, IdType k = badId) override { surfacePosition[j][k] = pos; @@ -118,7 +118,7 @@ class PetscSolver3DHandler : public PetscSolverHandler */ void getNetworkTemperature( - std::vector& temperatures, std::vector& depths) + std::vector& temperatures, std::vector& depths) override { temperatures = temperature; for (auto i = 0; i < temperature.size(); i++) { diff --git a/xolotl/solver/src/Solver.cpp b/xolotl/solver/src/Solver.cpp index c69328f7e..3a742f4cc 100644 --- a/xolotl/solver/src/Solver.cpp +++ b/xolotl/solver/src/Solver.cpp @@ -37,7 +37,7 @@ Solver::Solver( Solver::Solver(const std::shared_ptr& _solverHandler) : optionsString(""), solverHandler(_solverHandler), - perfHandler(solverHandler->getPerfHandler()) + perfHandler(_solverHandler->getPerfHandler()) { } diff --git a/xolotl/solver/src/handler/PetscSolver0DHandler.cpp b/xolotl/solver/src/handler/PetscSolver0DHandler.cpp index 813bf0941..3ed2ee5f0 100644 --- a/xolotl/solver/src/handler/PetscSolver0DHandler.cpp +++ b/xolotl/solver/src/handler/PetscSolver0DHandler.cpp @@ -271,10 +271,6 @@ PetscSolver0DHandler::updateConcentration( auto concOffset = subview(concs, 0, Kokkos::ALL).view(); auto updatedConcOffset = subview(updatedConcs, 0, Kokkos::ALL).view(); - // Degrees of freedom is the total number of clusters in the network + - // moments - const auto dof = network.getDOF(); - // Get the temperature from the temperature handler temperatureHandler->setTemperature(concOffset); double temp = temperatureHandler->getTemperature(gridPosition, ftime); @@ -315,10 +311,6 @@ PetscSolver0DHandler::computeJacobian( PetscOffsetView concs; PetscCallVoid(DMDAVecGetKokkosOffsetViewDOF(da, localC, &concs)); - // Degrees of freedom is the total number of clusters in the network + - // moments - const auto dof = network.getDOF(); - // Set the grid position plsm::SpaceVector gridPosition{0.0, 0.0, 0.0}; diff --git a/xolotl/solver/src/handler/PetscSolver1DHandler.cpp b/xolotl/solver/src/handler/PetscSolver1DHandler.cpp index 6c90694c8..3ff815641 100644 --- a/xolotl/solver/src/handler/PetscSolver1DHandler.cpp +++ b/xolotl/solver/src/handler/PetscSolver1DHandler.cpp @@ -415,6 +415,7 @@ PetscSolver1DHandler::initializeConcentration( // Check the distance if (distance > right - 1.0e-4) { // Create the arrays to receive the data + std::vector leftConcVec, rightConcVec; PetscScalar *rightConc, *leftConc; // Check where all the needed data is located @@ -451,7 +452,8 @@ PetscSolver1DHandler::initializeConcentration( // Receive the data on the new proc if (procId == totalProcs[2]) { // Receive the data - leftConc = new PetscScalar[dof + 1]; + leftConcVec.resize(dof + 1); + leftConc = leftConcVec.data(); MPI_Recv(leftConc, dof + 1, MPI_DOUBLE, totalProcs[0], 2, MPI_COMM_WORLD, MPI_STATUS_IGNORE); @@ -475,7 +477,8 @@ PetscSolver1DHandler::initializeConcentration( // Receive the data on the new proc if (procId == totalProcs[2]) { // Receive the data - rightConc = new PetscScalar[dof + 1]; + rightConcVec.resize(dof + 1); + rightConc = rightConcVec.data(); MPI_Recv(rightConc, dof + 1, MPI_DOUBLE, totalProcs[1], 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE); @@ -494,11 +497,6 @@ PetscSolver1DHandler::initializeConcentration( newConc[k] = leftConc[k] + (rightConc[k] - leftConc[k]) * xFactor; } - - if (totalProcs[2] != totalProcs[0]) - delete leftConc; - if (totalProcs[2] != totalProcs[1]) - delete rightConc; } break; diff --git a/xolotl/util/include/xolotl/util/IStepSequence.h b/xolotl/util/include/xolotl/util/IStepSequence.h index e7b83bf21..cda0f222e 100644 --- a/xolotl/util/include/xolotl/util/IStepSequence.h +++ b/xolotl/util/include/xolotl/util/IStepSequence.h @@ -9,6 +9,11 @@ namespace util class IStepSequence { public: + virtual + ~IStepSequence() + { + } + virtual void start() = 0;