From 51ddf3909a860c64fb14a5da822e1c30b5493c56 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 12:16:54 -0600 Subject: [PATCH] Auto-format code changes (#708) Auto-format code using Clang-Format Co-authored-by: GitHub Actions --- include/micm/configure/solver_config.hpp | 17 +++- include/micm/cuda/solver/cuda_rosenbrock.hpp | 10 +- include/micm/cuda/solver/cuda_state.hpp | 7 +- include/micm/jit/solver/jit_rosenbrock.hpp | 9 +- include/micm/solver/backward_euler.hpp | 24 ++--- include/micm/solver/backward_euler.inl | 15 ++- include/micm/solver/rosenbrock.hpp | 22 +++-- include/micm/solver/rosenbrock.inl | 25 +++-- include/micm/solver/solver.hpp | 2 +- include/micm/solver/solver_builder.inl | 6 +- include/micm/solver/state.hpp | 4 +- include/micm/solver/state.inl | 10 +- src/solver/rosenbrock.cu | 24 ++++- test/integration/analytical_policy.hpp | 98 ++++++++++++------- .../analytical_surface_rxn_policy.hpp | 6 +- test/integration/test_chapman_integration.cpp | 8 +- .../unit/cuda/solver/test_cuda_rosenbrock.cpp | 2 +- test/unit/solver/test_backward_euler.cpp | 2 +- .../solver/test_lu_decomposition_policy.hpp | 3 +- test/unit/solver/test_rosenbrock.cpp | 4 +- test/unit/solver/test_solver_builder.cpp | 20 ++-- 21 files changed, 200 insertions(+), 118 deletions(-) diff --git a/include/micm/configure/solver_config.hpp b/include/micm/configure/solver_config.hpp index 498f06f63..de73595a7 100644 --- a/include/micm/configure/solver_config.hpp +++ b/include/micm/configure/solver_config.hpp @@ -102,7 +102,7 @@ namespace micm System system_; std::vector processes_; RosenbrockSolverParameters parameters_; - double relative_tolerance_; + double relative_tolerance_; SolverParameters(const System& system, std::vector&& processes, const RosenbrockSolverParameters&& parameters) : system_(system), @@ -119,10 +119,14 @@ namespace micm relative_tolerance_(0) { } - SolverParameters(System&& system, std::vector&& processes, RosenbrockSolverParameters&& parameters, double relative_tolerance) + SolverParameters( + System&& system, + std::vector&& processes, + RosenbrockSolverParameters&& parameters, + double relative_tolerance) : system_(system), processes_(processes), - parameters_(parameters), + parameters_(parameters), relative_tolerance_(relative_tolerance) { } @@ -284,7 +288,7 @@ namespace micm processes_.clear(); // Parse species object array - ParseSpeciesArray(species_objects); + ParseSpeciesArray(species_objects); // Assign the parsed 'Species' to 'Phase' std::vector species_arr; @@ -970,7 +974,10 @@ namespace micm SolverParameters GetSolverParams() { return SolverParameters( - std::move(System(this->gas_phase_, this->phases_)), std::move(this->processes_), std::move(this->parameters_), this->relative_tolerance_); + std::move(System(this->gas_phase_, this->phases_)), + std::move(this->processes_), + std::move(this->parameters_), + this->relative_tolerance_); } }; } // namespace micm diff --git a/include/micm/cuda/solver/cuda_rosenbrock.hpp b/include/micm/cuda/solver/cuda_rosenbrock.hpp index 451722d5a..73528f2ce 100644 --- a/include/micm/cuda/solver/cuda_rosenbrock.hpp +++ b/include/micm/cuda/solver/cuda_rosenbrock.hpp @@ -112,14 +112,18 @@ namespace micm /// @param errors The computed errors /// @return The scaled norm of the errors template - double NormalizedError(const DenseMatrixPolicy& y_old, const DenseMatrixPolicy& y_new, const DenseMatrixPolicy& errors, auto& state) - const requires(CudaMatrix&& VectorizableDense) + double NormalizedError( + const DenseMatrixPolicy& y_old, + const DenseMatrixPolicy& y_new, + const DenseMatrixPolicy& errors, + auto& state) const + requires(CudaMatrix && VectorizableDense) { return micm::cuda::NormalizedErrorDriver( y_old.AsDeviceParam(), y_new.AsDeviceParam(), errors.AsDeviceParam(), - state.absolute_tolerance_param_, + state.absolute_tolerance_param_, state.relative_tolerance_, this->devstruct_); } diff --git a/include/micm/cuda/solver/cuda_state.hpp b/include/micm/cuda/solver/cuda_state.hpp index 8ffb8da41..eceb76db6 100644 --- a/include/micm/cuda/solver/cuda_state.hpp +++ b/include/micm/cuda/solver/cuda_state.hpp @@ -34,7 +34,9 @@ namespace micm absolute_tolerance_param_.number_of_elements_ = atol.size(); absolute_tolerance_param_.number_of_grid_cells_ = 1; - CHECK_CUDA_ERROR(micm::cuda::MallocVector(absolute_tolerance_param_, absolute_tolerance_param_.number_of_elements_), "cudaMalloc"); + CHECK_CUDA_ERROR( + micm::cuda::MallocVector(absolute_tolerance_param_, absolute_tolerance_param_.number_of_elements_), + "cudaMalloc"); CHECK_CUDA_ERROR(micm::cuda::CopyToDevice(absolute_tolerance_param_, atol), "cudaMemcpyHostToDevice"); }; @@ -61,7 +63,8 @@ namespace micm void SetAbsoluteTolerances(const std::vector& absoluteTolerance) override { State::SetAbsoluteTolerances(absoluteTolerance); - CHECK_CUDA_ERROR(micm::cuda::CopyToDevice(absolute_tolerance_param_, absoluteTolerance), "cudaMemcpyHostToDevice"); + CHECK_CUDA_ERROR( + micm::cuda::CopyToDevice(absolute_tolerance_param_, absoluteTolerance), "cudaMemcpyHostToDevice"); } /// @brief Copy input variables to the device diff --git a/include/micm/jit/solver/jit_rosenbrock.hpp b/include/micm/jit/solver/jit_rosenbrock.hpp index 2d85b8974..600912eec 100644 --- a/include/micm/jit/solver/jit_rosenbrock.hpp +++ b/include/micm/jit/solver/jit_rosenbrock.hpp @@ -68,15 +68,12 @@ namespace micm /// @param linear_solver Linear solver /// @param rates Rates calculator /// @param jacobian Jacobian matrix - JitRosenbrockSolver( - LinearSolverPolicy linear_solver, - RatesPolicy rates, - auto& jacobian, - const size_t number_of_species) + JitRosenbrockSolver(LinearSolverPolicy linear_solver, RatesPolicy rates, auto& jacobian, const size_t number_of_species) : AbstractRosenbrockSolver>( std::move(linear_solver), std::move(rates), - jacobian, number_of_species) + jacobian, + number_of_species) { this->GenerateAlphaMinusJacobian(jacobian); } diff --git a/include/micm/solver/backward_euler.hpp b/include/micm/solver/backward_euler.hpp index 288449137..ccd37ceb6 100644 --- a/include/micm/solver/backward_euler.hpp +++ b/include/micm/solver/backward_euler.hpp @@ -43,11 +43,7 @@ namespace micm /// @param linear_solver Linear solver /// @param rates Rates calculator /// @param jacobian Jacobian matrix - BackwardEuler( - LinearSolverPolicy&& linear_solver, - RatesPolicy&& rates, - auto& jacobian, - const size_t number_of_species) + BackwardEuler(LinearSolverPolicy&& linear_solver, RatesPolicy&& rates, auto& jacobian, const size_t number_of_species) : linear_solver_(std::move(linear_solver)), rates_(std::move(rates)), jacobian_diagonal_elements_(jacobian.DiagonalIndices(0)) @@ -74,14 +70,20 @@ namespace micm /// @return true if the residual is small enough to stop the iteration template static bool IsConverged( - const BackwardEulerSolverParameters& parameters, - const DenseMatrixPolicy& residual, - const DenseMatrixPolicy& Yn1, const std::vector& absolute_tolerance, double relative_tolerance) requires(!VectorizableDense); + const BackwardEulerSolverParameters& parameters, + const DenseMatrixPolicy& residual, + const DenseMatrixPolicy& Yn1, + const std::vector& absolute_tolerance, + double relative_tolerance) + requires(!VectorizableDense); template static bool IsConverged( - const BackwardEulerSolverParameters& parameters, - const DenseMatrixPolicy& residual, - const DenseMatrixPolicy& Yn1, const std::vector& absolute_tolerance, double relative_tolerance) requires(VectorizableDense); + const BackwardEulerSolverParameters& parameters, + const DenseMatrixPolicy& residual, + const DenseMatrixPolicy& Yn1, + const std::vector& absolute_tolerance, + double relative_tolerance) + requires(VectorizableDense); }; } // namespace micm diff --git a/include/micm/solver/backward_euler.inl b/include/micm/solver/backward_euler.inl index 1e7ac42b4..48b4e503e 100644 --- a/include/micm/solver/backward_euler.inl +++ b/include/micm/solver/backward_euler.inl @@ -43,7 +43,10 @@ inline std::error_code make_error_code(MicmBackwardEulerErrc e) namespace micm { template - inline SolverResult BackwardEuler::Solve(double time_step, auto& state, const BackwardEulerSolverParameters& parameters) const + inline SolverResult BackwardEuler::Solve( + double time_step, + auto& state, + const BackwardEulerSolverParameters& parameters) const { // A fully implicit euler implementation is given by the following equation: // y_{n+1} = y_n + H * f(t_{n+1}, y_{n+1}) @@ -195,7 +198,10 @@ namespace micm inline bool BackwardEuler::IsConverged( const BackwardEulerSolverParameters& parameters, const DenseMatrixPolicy& residual, - const DenseMatrixPolicy& Yn1, const std::vector& absolute_tolerance, double relative_tolerance) requires(!VectorizableDense) + const DenseMatrixPolicy& Yn1, + const std::vector& absolute_tolerance, + double relative_tolerance) + requires(!VectorizableDense) { double small = parameters.small_; double rel_tol = relative_tolerance; @@ -221,7 +227,10 @@ namespace micm inline bool BackwardEuler::IsConverged( const BackwardEulerSolverParameters& parameters, const DenseMatrixPolicy& residual, - const DenseMatrixPolicy& Yn1, const std::vector& absolute_tolerance, double relative_tolerance) requires(VectorizableDense) + const DenseMatrixPolicy& Yn1, + const std::vector& absolute_tolerance, + double relative_tolerance) + requires(VectorizableDense) { double small = parameters.small_; double rel_tol = relative_tolerance; diff --git a/include/micm/solver/rosenbrock.hpp b/include/micm/solver/rosenbrock.hpp index 27a6e0e36..8b957b39f 100644 --- a/include/micm/solver/rosenbrock.hpp +++ b/include/micm/solver/rosenbrock.hpp @@ -112,11 +112,19 @@ namespace micm /// @param errors The computed errors /// @return template - double NormalizedError(const DenseMatrixPolicy& y, const DenseMatrixPolicy& y_new, const DenseMatrixPolicy& errors, auto& state) const - requires(!VectorizableDense); + double NormalizedError( + const DenseMatrixPolicy& y, + const DenseMatrixPolicy& y_new, + const DenseMatrixPolicy& errors, + auto& state) const + requires(!VectorizableDense); template - double NormalizedError(const DenseMatrixPolicy& y, const DenseMatrixPolicy& y_new, const DenseMatrixPolicy& errors, auto& state) const - requires(VectorizableDense); + double NormalizedError( + const DenseMatrixPolicy& y, + const DenseMatrixPolicy& y_new, + const DenseMatrixPolicy& errors, + auto& state) const + requires(VectorizableDense); }; // end of Abstract Rosenbrock Solver template @@ -130,11 +138,7 @@ namespace micm /// @param jacobian Jacobian matrix /// /// Note: This constructor is not intended to be used directly. Instead, use the SolverBuilder to create a solver - RosenbrockSolver( - LinearSolverPolicy&& linear_solver, - RatesPolicy&& rates, - auto& jacobian, - const size_t number_of_species) + RosenbrockSolver(LinearSolverPolicy&& linear_solver, RatesPolicy&& rates, auto& jacobian, const size_t number_of_species) : AbstractRosenbrockSolver>( std::move(linear_solver), std::move(rates), diff --git a/include/micm/solver/rosenbrock.inl b/include/micm/solver/rosenbrock.inl index 2960b1d7a..f6d99dab9 100644 --- a/include/micm/solver/rosenbrock.inl +++ b/include/micm/solver/rosenbrock.inl @@ -6,7 +6,8 @@ namespace micm template inline SolverResult AbstractRosenbrockSolver::Solve( double time_step, - auto& state, const RosenbrockSolverParameters& parameters) const noexcept + auto& state, + const RosenbrockSolverParameters& parameters) const noexcept { MICM_PROFILE_FUNCTION(); using MatrixPolicy = decltype(state.variables_); @@ -248,8 +249,9 @@ namespace micm inline double AbstractRosenbrockSolver::NormalizedError( const DenseMatrixPolicy& Y, const DenseMatrixPolicy& Ynew, - const DenseMatrixPolicy& errors, - auto& state) const requires(!VectorizableDense) + const DenseMatrixPolicy& errors, + auto& state) const + requires(!VectorizableDense) { // Solving Ordinary Differential Equations II, page 123 // https://link-springer-com.cuucar.idm.oclc.org/book/10.1007/978-3-642-05221-7 @@ -271,8 +273,7 @@ namespace micm for (std::size_t i = 0; i < N; ++i) { ymax = std::max(std::abs(_y[i]), std::abs(_ynew[i])); - errors_over_scale = - _errors[i] / (atol[i % n_vars] + rtol * ymax); + errors_over_scale = _errors[i] / (atol[i % n_vars] + rtol * ymax); error += errors_over_scale * errors_over_scale; } @@ -286,8 +287,9 @@ namespace micm inline double AbstractRosenbrockSolver::NormalizedError( const DenseMatrixPolicy& Y, const DenseMatrixPolicy& Ynew, - const DenseMatrixPolicy& errors, - auto& state) const requires(VectorizableDense) + const DenseMatrixPolicy& errors, + auto& state) const + requires(VectorizableDense) { // Solving Ordinary Differential Equations II, page 123 // https://link-springer-com.cuucar.idm.oclc.org/book/10.1007/978-3-642-05221-7 @@ -310,9 +312,7 @@ namespace micm // compute the error over the blocks which fit exactly into the L parameter for (std::size_t i = 0; i < whole_blocks; ++i) { - errors_over_scale = - *errors_iter / (atol[(i / L) % n_vars] + - rtol * std::max(std::abs(*y_iter), std::abs(*ynew_iter))); + errors_over_scale = *errors_iter / (atol[(i / L) % n_vars] + rtol * std::max(std::abs(*y_iter), std::abs(*ynew_iter))); error += errors_over_scale * errors_over_scale; ++y_iter; ++ynew_iter; @@ -329,9 +329,8 @@ namespace micm for (std::size_t x = 0; x < remaining_rows; ++x) { const std::size_t idx = y * L + x; - errors_over_scale = errors_iter[idx] / - (atol[y] + - rtol * std::max(std::abs(y_iter[idx]), std::abs(ynew_iter[idx]))); + errors_over_scale = + errors_iter[idx] / (atol[y] + rtol * std::max(std::abs(y_iter[idx]), std::abs(ynew_iter[idx]))); error += errors_over_scale * errors_over_scale; } } diff --git a/include/micm/solver/solver.hpp b/include/micm/solver/solver.hpp index 38e2a5ed4..7b4ce7358 100644 --- a/include/micm/solver/solver.hpp +++ b/include/micm/solver/solver.hpp @@ -90,7 +90,7 @@ namespace micm { return state_parameters_.number_of_rate_constants_; } - + StatePolicy GetState() const { auto state = std::move(StatePolicy(state_parameters_)); diff --git a/include/micm/solver/solver_builder.inl b/include/micm/solver/solver_builder.inl index 5b51d65ef..419610afd 100644 --- a/include/micm/solver/solver_builder.inl +++ b/include/micm/solver/solver_builder.inl @@ -337,7 +337,7 @@ namespace micm } } } - } + } template< class SolverParametersPolicy, @@ -404,7 +404,7 @@ namespace micm } this->UnusedSpeciesCheck(); - + RatesPolicy rates(this->reactions_, species_map); auto nonzero_elements = rates.NonZeroJacobianElements(); auto jacobian = BuildJacobian(nonzero_elements, this->number_of_grid_cells_, number_of_species); @@ -422,7 +422,7 @@ namespace micm .variable_names_ = variable_names, .custom_rate_parameter_labels_ = labels, .nonzero_jacobian_elements_ = nonzero_elements }; - + this->SetAbsoluteTolerances(state_parameters.absolute_tolerance_, species_map); return Solver( diff --git a/include/micm/solver/state.hpp b/include/micm/solver/state.hpp index d9a80bfdd..98947bea9 100644 --- a/include/micm/solver/state.hpp +++ b/include/micm/solver/state.hpp @@ -32,7 +32,7 @@ namespace micm std::vector custom_rate_parameter_labels_{}; std::set> nonzero_jacobian_elements_{}; double relative_tolerance_{ 1e-06 }; - std::vector absolute_tolerance_ {}; + std::vector absolute_tolerance_{}; }; template< @@ -68,7 +68,7 @@ namespace micm double relative_tolerance_; std::vector absolute_tolerance_; - public: + public: /// @brief Default constructor /// Only defined to be used to create default values in types, but a default constructed state is not useable State(); diff --git a/include/micm/solver/state.inl b/include/micm/solver/state.inl index b810f8ac9..8a5235456 100644 --- a/include/micm/solver/state.inl +++ b/include/micm/solver/state.inl @@ -252,14 +252,16 @@ namespace micm for (std::size_t i = 0; i < custom_rate_parameters_.NumRows(); ++i) custom_rate_parameters_[i][param->second] = values[i]; } - + template< class DenseMatrixPolicy, class SparseMatrixPolicy, class LuDecompositionPolicy, class LMatrixPolicy, class UMatrixPolicy> - inline void State::SetRelativeTolerance(double relativeTolerance) + inline void + State::SetRelativeTolerance( + double relativeTolerance) { this->relative_tolerance_ = relativeTolerance; } @@ -270,7 +272,9 @@ namespace micm class LuDecompositionPolicy, class LMatrixPolicy, class UMatrixPolicy> - inline void State::SetAbsoluteTolerances(const std::vector& absoluteTolerance) + inline void + State::SetAbsoluteTolerances( + const std::vector& absoluteTolerance) { this->absolute_tolerance_ = absoluteTolerance; } diff --git a/src/solver/rosenbrock.cu b/src/solver/rosenbrock.cu index 036def798..f6dcc4021 100644 --- a/src/solver/rosenbrock.cu +++ b/src/solver/rosenbrock.cu @@ -323,7 +323,13 @@ namespace micm BLOCK_SIZE, BLOCK_SIZE * sizeof(double), micm::cuda::CudaStreamSingleton::GetInstance().GetCudaStream(0)>>>( - y_old_param, y_new_param, absolute_tolerance_param, relative_tolerance, devstruct, number_of_elements, is_first_call); + y_old_param, + y_new_param, + absolute_tolerance_param, + relative_tolerance, + devstruct, + number_of_elements, + is_first_call); is_first_call = false; while (number_of_blocks > 1) { @@ -337,7 +343,13 @@ namespace micm BLOCK_SIZE, BLOCK_SIZE * sizeof(double), micm::cuda::CudaStreamSingleton::GetInstance().GetCudaStream(0)>>>( - y_old_param, y_new_param, absolute_tolerance_param, relative_tolerance, devstruct, number_of_blocks, is_first_call); + y_old_param, + y_new_param, + absolute_tolerance_param, + relative_tolerance, + devstruct, + number_of_blocks, + is_first_call); break; } NormalizedErrorKernel<<< @@ -345,7 +357,13 @@ namespace micm BLOCK_SIZE, BLOCK_SIZE * sizeof(double), micm::cuda::CudaStreamSingleton::GetInstance().GetCudaStream(0)>>>( - y_old_param, y_new_param, absolute_tolerance_param, relative_tolerance, devstruct, number_of_blocks, is_first_call); + y_old_param, + y_new_param, + absolute_tolerance_param, + relative_tolerance, + devstruct, + number_of_blocks, + is_first_call); number_of_blocks = new_number_of_blocks; } diff --git a/test/integration/analytical_policy.hpp b/test/integration/analytical_policy.hpp index 8ac6b9c7f..87eeed80c 100644 --- a/test/integration/analytical_policy.hpp +++ b/test/integration/analytical_policy.hpp @@ -378,8 +378,10 @@ template void test_analytical_troe( BuilderPolicy builder, double absolute_tolerances = 1e-10, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * A -> B, k1 @@ -444,8 +446,10 @@ template void test_analytical_stiff_troe( BuilderPolicy builder, double absolute_tolerances = 1e-5, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * A1 -> B, k1 @@ -531,8 +535,10 @@ template void test_analytical_photolysis( BuilderPolicy builder, double absolute_tolerances = 2e-6, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * A -> B, k1 @@ -589,8 +595,10 @@ template void test_analytical_stiff_photolysis( BuilderPolicy builder, double absolute_tolerances = 2e-5, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * A1 -> B, k1 @@ -670,8 +678,10 @@ template void test_analytical_ternary_chemical_activation( BuilderPolicy builder, double absolute_tolerances = 1e-08, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * A -> B, k1 @@ -737,8 +747,10 @@ template void test_analytical_stiff_ternary_chemical_activation( BuilderPolicy builder, double absolute_tolerances = 1e-6, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * A1 -> B, k1 @@ -824,8 +836,10 @@ template void test_analytical_tunneling( BuilderPolicy builder, double absolute_tolerances = 1e-8, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * A -> B, k1 @@ -880,8 +894,10 @@ template void test_analytical_stiff_tunneling( BuilderPolicy builder, double absolute_tolerances = 1e-6, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * A1 -> B, k1 @@ -956,8 +972,10 @@ template void test_analytical_arrhenius( BuilderPolicy builder, double absolute_tolerances = 1e-9, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * A -> B, k1 @@ -1011,8 +1029,10 @@ template void test_analytical_stiff_arrhenius( BuilderPolicy builder, double absolute_tolerances = 1e-6, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * A1 -> B, k1 @@ -1088,8 +1108,10 @@ template void test_analytical_branched( BuilderPolicy builder, double absolute_tolerances = 1e-13, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * A -> B, k1 @@ -1171,8 +1193,10 @@ template void test_analytical_stiff_branched( BuilderPolicy builder, double absolute_tolerances = 1e-6, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * A1 -> B, k1 @@ -1280,8 +1304,10 @@ template void test_analytical_robertson( BuilderPolicy builder, double relative_tolerance = 1e-8, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * A -> B, k1 = 0.04 @@ -1427,8 +1453,10 @@ template void test_analytical_oregonator( BuilderPolicy builder, double absolute_tolerance = 1e-8, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * This problem is described in @@ -1605,8 +1633,10 @@ template void test_analytical_hires( BuilderPolicy builder, double absolute_tolerance = 1e-8, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * This problem is described in @@ -1801,8 +1831,10 @@ template void test_analytical_e5( BuilderPolicy builder, double relative_tolerance = 1e-8, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { /* * A1 -> A2 + A3, k1 = 7.89e-10 @@ -1892,7 +1924,7 @@ void test_analytical_e5( atol[4] = 1e-7; atol[5] = 1e-7; state.SetAbsoluteTolerances(atol); - + state.SetCustomRateParameter("r1", 7.89e-10); state.SetCustomRateParameter("r2", 1.13e9); state.SetCustomRateParameter("r3", 1.1e7); diff --git a/test/integration/analytical_surface_rxn_policy.hpp b/test/integration/analytical_surface_rxn_policy.hpp index 3eb1ca8d3..ca6ce0a6d 100644 --- a/test/integration/analytical_surface_rxn_policy.hpp +++ b/test/integration/analytical_surface_rxn_policy.hpp @@ -11,8 +11,10 @@ template void test_analytical_surface_rxn( BuilderPolicy& builder, double tolerance = 1e-8, - std::function prepare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}, - std::function postpare_for_solve = [](typename BuilderPolicy::StatePolicyType& state) {}) + std::function prepare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}, + std::function postpare_for_solve = + [](typename BuilderPolicy::StatePolicyType& state) {}) { // parameters, from CAMP/test/unit_rxn_data/test_rxn_surface.F90 const double mode_GMD = 1.0e-6; // mode geometric mean diameter [m] diff --git a/test/integration/test_chapman_integration.cpp b/test/integration/test_chapman_integration.cpp index 6bd8f0668..a245bb23c 100644 --- a/test/integration/test_chapman_integration.cpp +++ b/test/integration/test_chapman_integration.cpp @@ -32,16 +32,16 @@ TEST(ChapmanIntegration, CanBuildChapmanSystemUsingConfig) // Get solver parameters ('System', the collection of 'Process') micm::SolverParameters solver_params = solverConfig.GetSolverParams(); - auto options = solver_params.parameters_; + auto options = solver_params.parameters_; auto solver = micm::CpuSolverBuilder(options) .SetSystem(solver_params.system_) .SetReactions(solver_params.processes_) - .SetIgnoreUnusedSpecies(true) - .Build(); + .SetIgnoreUnusedSpecies(true) + .Build(); micm::State state = solver.GetState(); - state.SetRelativeTolerance(solver_params.relative_tolerance_); + state.SetRelativeTolerance(solver_params.relative_tolerance_); EXPECT_EQ(state.relative_tolerance_, 1.0e-4); auto& abs_tol = state.absolute_tolerance_; diff --git a/test/unit/cuda/solver/test_cuda_rosenbrock.cpp b/test/unit/cuda/solver/test_cuda_rosenbrock.cpp index 8a0d8035d..2810ccdbf 100644 --- a/test/unit/cuda/solver/test_cuda_rosenbrock.cpp +++ b/test/unit/cuda/solver/test_cuda_rosenbrock.cpp @@ -121,7 +121,7 @@ void testNormalizedErrorConst() auto gpu_builder = GpuBuilder(micm::CudaRosenbrockSolverParameters::ThreeStageRosenbrockParameters()); gpu_builder = getSolver(gpu_builder); auto gpu_solver = gpu_builder.SetNumberOfGridCells(number_of_grid_cells).Build(); - auto state = gpu_solver.GetState(); + auto state = gpu_solver.GetState(); auto& atol = state.absolute_tolerance_; double rtol = state.relative_tolerance_; diff --git a/test/unit/solver/test_backward_euler.cpp b/test/unit/solver/test_backward_euler.cpp index b507b6045..47f82ab76 100644 --- a/test/unit/solver/test_backward_euler.cpp +++ b/test/unit/solver/test_backward_euler.cpp @@ -86,7 +86,7 @@ void CheckIsConverged() residual[3][2] = 1e-1; ASSERT_FALSE(BackwardEuler::IsConverged(parameters, residual, Yn1, absolute_tolerance, relative_tolerance)); absolute_tolerance[2] = 1.0; - ASSERT_TRUE(BackwardEuler::IsConverged(parameters, residual, Yn1, absolute_tolerance, relative_tolerance)); + ASSERT_TRUE(BackwardEuler::IsConverged(parameters, residual, Yn1, absolute_tolerance, relative_tolerance)); } TEST(BackwardEuler, IsConverged) diff --git a/test/unit/solver/test_lu_decomposition_policy.hpp b/test/unit/solver/test_lu_decomposition_policy.hpp index 2741b834d..afea2f18f 100644 --- a/test/unit/solver/test_lu_decomposition_policy.hpp +++ b/test/unit/solver/test_lu_decomposition_policy.hpp @@ -113,7 +113,8 @@ void testDenseMatrix() A[0][2][1] = -2; A[0][2][2] = 8; - LuDecompositionPolicy lud = LuDecompositionPolicy::template Create(A); + LuDecompositionPolicy lud = + LuDecompositionPolicy::template Create(A); auto LU = LuDecompositionPolicy::template GetLUMatrices(A, 0); lud.template Decompose(A, LU.first, LU.second); check_results( diff --git a/test/unit/solver/test_rosenbrock.cpp b/test/unit/solver/test_rosenbrock.cpp index c9f9170b1..c737a8a19 100644 --- a/test/unit/solver/test_rosenbrock.cpp +++ b/test/unit/solver/test_rosenbrock.cpp @@ -16,7 +16,7 @@ template void testNormalizedErrorDiff(SolverBuilderPolicy builder, std::size_t number_of_grid_cells) { builder = getSolver(builder); - auto solver = builder.SetNumberOfGridCells(number_of_grid_cells).Build(); + auto solver = builder.SetNumberOfGridCells(number_of_grid_cells).Build(); auto state = solver.GetState(); const std::vector& atol = state.absolute_tolerance_; double rtol = state.relative_tolerance_; @@ -108,7 +108,7 @@ TEST(RosenbrockSolver, CanSetTolerances) .Build(); auto state = solver.GetState(); auto absolute_tolerances = state.absolute_tolerance_; - EXPECT_EQ(absolute_tolerances.size(), 2); + EXPECT_EQ(absolute_tolerances.size(), 2); EXPECT_EQ(absolute_tolerances[0], 1.0e-07); EXPECT_EQ(absolute_tolerances[1], 1.0e-08); } diff --git a/test/unit/solver/test_solver_builder.cpp b/test/unit/solver/test_solver_builder.cpp index 80fdc148f..b20191c09 100644 --- a/test/unit/solver/test_solver_builder.cpp +++ b/test/unit/solver/test_solver_builder.cpp @@ -109,10 +109,10 @@ TEST(SolverBuilder, CanBuildRosenbrock) TEST(SolverBuilder, CanBuildBackwardEulerOverloadedSolverMethod) { auto solver = micm::CpuSolverBuilder(micm::BackwardEulerSolverParameters{}) - .SetSystem(the_system) - .SetReactions(reactions) - .SetNumberOfGridCells(1) - .Build(); + .SetSystem(the_system) + .SetReactions(reactions) + .SetNumberOfGridCells(1) + .Build(); auto state = solver.GetState(); auto options = micm::BackwardEulerSolverParameters(); auto solve = solver.Solve(5, state, options); @@ -122,7 +122,7 @@ TEST(SolverBuilder, CanBuildBackwardEulerOverloadedSolverMethod) ASSERT_EQ(solve.stats_.jacobian_updates_, 2); ASSERT_EQ(solve.stats_.number_of_steps_, 2); ASSERT_EQ(solve.stats_.solves_, 2); - + options.small_ = 1.0; options.max_number_of_steps_ = 1.0; @@ -139,10 +139,10 @@ TEST(SolverBuilder, CanBuildRosenbrockOverloadedSolveMethod) { auto options = micm::RosenbrockSolverParameters::ThreeStageRosenbrockParameters(); auto solver = micm::CpuSolverBuilder(options) - .SetSystem(the_system) - .SetReactions(reactions) - .SetNumberOfGridCells(1) - .Build(); + .SetSystem(the_system) + .SetReactions(reactions) + .SetNumberOfGridCells(1) + .Build(); auto state = solver.GetState(); state.variables_[0] = { 1.0, 0.0, 0.0 }; @@ -153,7 +153,7 @@ TEST(SolverBuilder, CanBuildRosenbrockOverloadedSolveMethod) ASSERT_EQ(solve.stats_.jacobian_updates_, 10); ASSERT_EQ(solve.stats_.number_of_steps_, 10); ASSERT_EQ(solve.stats_.solves_, 30); - + options.h_min_ = 15.0; options.max_number_of_steps_ = 6.0;