Skip to content

Commit

Permalink
Addressed some issues in flux handlers and solver handlers (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipFackler committed Mar 5, 2024
1 parent 0d9c7a3 commit 0b7a912
Show file tree
Hide file tree
Showing 24 changed files with 80 additions and 103 deletions.
6 changes: 0 additions & 6 deletions test/core/flux/CustomFitFluxHandlerTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<CustomFitFluxHandler>(opts);
Expand Down Expand Up @@ -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()
12 changes: 0 additions & 12 deletions test/core/flux/W100FitFluxHandlerTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<W100FitFluxHandler>(opts);
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -420,8 +410,6 @@ BOOST_AUTO_TEST_CASE(checkTimeProfileFlux)

// Finalize MPI
MPI_Finalize();

return;
}

BOOST_AUTO_TEST_SUITE_END()
2 changes: 0 additions & 2 deletions test/io/HDF5UtilsTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion xolotl/core/include/xolotl/core/flux/AlloyFitFluxHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AlphaZrFitFluxHandler : public FluxHandler
* \see FluxHandler.h
*/
double
FitFunction(double x)
FitFunction(double x) override
{
return 1.0;
}
Expand Down
2 changes: 1 addition & 1 deletion xolotl/core/include/xolotl/core/flux/FeFitFluxHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions xolotl/core/include/xolotl/core/flux/FluxHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -195,7 +195,7 @@ class FluxHandler : public IFluxHandler
* \see IFluxHandler.h
*/
void
setFluxAmplitude(double flux) override;
setFluxAmplitude(double flux) final;

/**
* \see IFluxHandler.h
Expand Down
2 changes: 1 addition & 1 deletion xolotl/core/include/xolotl/core/flux/FuelFitFluxHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FuelFitFluxHandler : public FluxHandler
* \see FluxHandler.h
*/
double
FitFunction(double x)
FitFunction(double x) override
{
// Constant flux
return 1.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion xolotl/core/include/xolotl/core/flux/W100FitFluxHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion xolotl/core/include/xolotl/core/flux/W110FitFluxHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion xolotl/core/include/xolotl/core/flux/W111FitFluxHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion xolotl/core/include/xolotl/core/flux/W211FitFluxHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 10 additions & 8 deletions xolotl/core/src/flux/FluxHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions xolotl/core/src/temperature/HeatEquationHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions xolotl/core/src/temperature/ProfileHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
22 changes: 11 additions & 11 deletions xolotl/solver/include/xolotl/solver/handler/PetscSolver0DHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -69,7 +69,7 @@ class PetscSolver0DHandler : public PetscSolverHandler
*/
std::vector<
std::vector<std::vector<std::vector<std::pair<IdType, double>>>>>
getConcVector(DM& da, Vec& C);
getConcVector(DM& da, Vec& C) override;

/**
* \see ISolverHandler.h
Expand All @@ -78,25 +78,25 @@ class PetscSolver0DHandler : public PetscSolverHandler
setConcVector(DM& da, Vec& C,
std::vector<
std::vector<std::vector<std::vector<std::pair<IdType, double>>>>>&
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;
}
Expand All @@ -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;
}
Expand All @@ -115,7 +115,7 @@ class PetscSolver0DHandler : public PetscSolverHandler
*/
void
getNetworkTemperature(
std::vector<double>& temperatures, std::vector<double>& depths)
std::vector<double>& temperatures, std::vector<double>& depths) override
{
temperatures = temperature;
depths = std::vector<double>(1, 1.0);
Expand Down
Loading

0 comments on commit 0b7a912

Please sign in to comment.