Skip to content

Commit

Permalink
Use CUDA Rosenbrock parameters (#659)
Browse files Browse the repository at this point in the history
* use cuda rosenbrock parameters instead

* use 0 for fill function
  • Loading branch information
sjsprecious authored Sep 16, 2024
1 parent 6c8875d commit 84b4b40
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 27 deletions.
3 changes: 0 additions & 3 deletions include/micm/cuda/solver/cuda_linear_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
#include <micm/solver/linear_solver.hpp>
#include <micm/solver/lu_decomposition.hpp>

#include <chrono>
#include <functional>

namespace micm
{
template<class SparseMatrixPolicy, class LuDecompositionPolicy = CudaLuDecomposition>
Expand Down
3 changes: 0 additions & 3 deletions include/micm/cuda/solver/cuda_lu_decomposition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
#include <micm/cuda/util/cuda_sparse_matrix.hpp>
#include <micm/solver/lu_decomposition.hpp>

#include <chrono>
#include <stdexcept>

namespace micm
{
/// This CudaLuDecomposition class inherits everything from the base class "LuDecomposition"
Expand Down
18 changes: 2 additions & 16 deletions include/micm/cuda/solver/cuda_rosenbrock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,12 @@
#include <micm/cuda/util/cuda_dense_matrix.hpp>
#include <micm/cuda/util/cuda_param.hpp>
#include <micm/cuda/util/cuda_sparse_matrix.hpp>
#include <micm/process/process.hpp>
#include <micm/solver/linear_solver.hpp>
#include <micm/solver/rosenbrock.hpp>
#include <micm/solver/rosenbrock_solver_parameters.hpp>
#include <micm/solver/state.hpp>
#include <micm/system/system.hpp>
#include <micm/util/jacobian.hpp>
#include <micm/util/matrix.hpp>
#include <micm/util/sparse_matrix.hpp>

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstddef>
#include <functional>
#include <string>
#include <vector>

namespace micm
{
struct CudaRosenbrockSolverParameters;

template<class RatesPolicy, class LinearSolverPolicy>
class CudaRosenbrockSolver : public AbstractRosenbrockSolver<
Expand All @@ -41,7 +27,7 @@ namespace micm
CudaRosenbrockSolverParam devstruct_;

/// @brief Solver parameters typename
using ParametersType = RosenbrockSolverParameters;
using ParametersType = CudaRosenbrockSolverParameters;

CudaRosenbrockSolver(const CudaRosenbrockSolver&) = delete;
CudaRosenbrockSolver& operator=(const CudaRosenbrockSolver&) = delete;
Expand Down
8 changes: 4 additions & 4 deletions include/micm/solver/rosenbrock.inl
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ namespace micm
H = std::min(H, std::abs(time_step - present_time));

// compute the initial forcing at the beginning of the current time
initial_forcing.Fill(0.0);
initial_forcing.Fill(0);
rates_.AddForcingTerms(state.rate_constants_, Y, initial_forcing);
stats.function_calls_ += 1;

// compute the negative jacobian at the beginning of the current time
state.jacobian_.Fill(0.0);
state.jacobian_.Fill(0);
rates_.SubtractJacobianTerms(state.rate_constants_, Y, state.jacobian_);
stats.jacobian_updates_ += 1;

Expand Down Expand Up @@ -95,7 +95,7 @@ namespace micm
{
Ynew.Axpy(parameters_.a_[stage_combinations + j], K[j]);
}
K[stage].Fill(0.0);
K[stage].Fill(0);
rates_.AddForcingTerms(state.rate_constants_, Ynew, K[stage]);
stats.function_calls_ += 1;
}
Expand Down Expand Up @@ -256,7 +256,7 @@ namespace micm
break;
H /= 2;
// Reconstruct the Jacobian matrix if a substepping is performed here
state.jacobian_.Fill(0.0);
state.jacobian_.Fill(0);
rates_.SubtractJacobianTerms(state.rate_constants_, number_densities, state.jacobian_);
stats.jacobian_updates_ += 1;
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/cuda/solver/test_cuda_rosenbrock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <micm/cuda/solver/cuda_rosenbrock.cuh>
#include <micm/cuda/solver/cuda_rosenbrock.hpp>
#include <micm/cuda/solver/cuda_solver_builder.hpp>
#include <micm/cuda/solver/cuda_solver_parameters.hpp>
#include <micm/cuda/solver/cuda_solver_builder.hpp>
#include <micm/cuda/util/cuda_dense_matrix.hpp>
#include <micm/cuda/util/cuda_sparse_matrix.hpp>
#include <micm/process/arrhenius_rate_constant.hpp>
Expand Down

0 comments on commit 84b4b40

Please sign in to comment.