Skip to content

Commit

Permalink
Auto-format code changes (#656)
Browse files Browse the repository at this point in the history
Auto-format code using Clang-Format

Co-authored-by: GitHub Actions <actions@github.com>
  • Loading branch information
github-actions[bot] and actions-user authored Sep 14, 2024
1 parent 7347b7a commit 6c8875d
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 61 deletions.
2 changes: 1 addition & 1 deletion include/micm/solver/backward_euler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

#include <micm/profiler/instrumentation.hpp>
#include <micm/solver/backward_euler_solver_parameters.hpp>
#include <micm/solver/backward_euler_temporary_variables.hpp>
#include <micm/solver/linear_solver.hpp>
#include <micm/solver/solver_result.hpp>
#include <micm/solver/state.hpp>
#include <micm/system/system.hpp>
#include <micm/util/jacobian.hpp>
#include <micm/util/matrix.hpp>
#include <micm/solver/backward_euler_temporary_variables.hpp>

#include <algorithm>
#include <array>
Expand Down
3 changes: 2 additions & 1 deletion include/micm/solver/backward_euler.inl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ namespace micm

bool singular = false;

auto derived_class_temporary_variables = static_cast<BackwardEulerTemporaryVariables<MatrixPolicy>*>(state.temporary_variables_.get());
auto derived_class_temporary_variables =
static_cast<BackwardEulerTemporaryVariables<MatrixPolicy>*>(state.temporary_variables_.get());
auto& Yn = derived_class_temporary_variables->Yn_;
auto& Yn1 = state.variables_; // Yn1 will hold the new solution at the end of the solve
auto& forcing = derived_class_temporary_variables->forcing_;
Expand Down
30 changes: 15 additions & 15 deletions include/micm/solver/backward_euler_temporary_variables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@

#include <micm/solver/temporary_variables.hpp>

namespace micm
namespace micm
{
template<class DenseMatrixPolicy>
class BackwardEulerTemporaryVariables : public TemporaryVariables
{
public:
DenseMatrixPolicy Yn_;
DenseMatrixPolicy forcing_;
public:
DenseMatrixPolicy Yn_;
DenseMatrixPolicy forcing_;

BackwardEulerTemporaryVariables() = default;
BackwardEulerTemporaryVariables(const BackwardEulerTemporaryVariables& other) = default;
BackwardEulerTemporaryVariables(BackwardEulerTemporaryVariables&& other) = default;
BackwardEulerTemporaryVariables& operator=(const BackwardEulerTemporaryVariables& other) = default;
BackwardEulerTemporaryVariables& operator=(BackwardEulerTemporaryVariables&& other) = default;
~BackwardEulerTemporaryVariables() = default;
BackwardEulerTemporaryVariables() = default;
BackwardEulerTemporaryVariables(const BackwardEulerTemporaryVariables& other) = default;
BackwardEulerTemporaryVariables(BackwardEulerTemporaryVariables&& other) = default;
BackwardEulerTemporaryVariables& operator=(const BackwardEulerTemporaryVariables& other) = default;
BackwardEulerTemporaryVariables& operator=(BackwardEulerTemporaryVariables&& other) = default;
~BackwardEulerTemporaryVariables() = default;

BackwardEulerTemporaryVariables(const auto& state_parameters):
Yn_(state_parameters.number_of_grid_cells_, state_parameters.number_of_species_),
BackwardEulerTemporaryVariables(const auto& state_parameters)
: Yn_(state_parameters.number_of_grid_cells_, state_parameters.number_of_species_),
forcing_(state_parameters.number_of_grid_cells_, state_parameters.number_of_species_)
{
}
{
}
};
} // namespace name
} // namespace micm
2 changes: 1 addition & 1 deletion include/micm/solver/rosenbrock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
#include <micm/profiler/instrumentation.hpp>
#include <micm/solver/linear_solver.hpp>
#include <micm/solver/rosenbrock_solver_parameters.hpp>
#include <micm/solver/rosenbrock_temporary_variables.hpp>
#include <micm/solver/solver_result.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 <micm/solver/rosenbrock_temporary_variables.hpp>

#include <algorithm>
#include <cassert>
Expand Down
3 changes: 2 additions & 1 deletion include/micm/solver/rosenbrock.inl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ namespace micm
SolverResult result{};
result.state_ = SolverState::Running;
auto& Y = state.variables_; // Y will hold the new solution at the end of the solve
auto derived_class_temporary_variables = static_cast<RosenbrockTemporaryVariables<MatrixPolicy>*>(state.temporary_variables_.get());
auto derived_class_temporary_variables =
static_cast<RosenbrockTemporaryVariables<MatrixPolicy>*>(state.temporary_variables_.get());
auto& Ynew = derived_class_temporary_variables->Ynew_;
auto& initial_forcing = derived_class_temporary_variables->initial_forcing_;
auto& K = derived_class_temporary_variables->K_;
Expand Down
49 changes: 25 additions & 24 deletions include/micm/solver/rosenbrock_temporary_variables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,35 @@
#pragma once

#include <micm/solver/temporary_variables.hpp>

#include <vector>

namespace micm
{
template<class DenseMatrixPolicy>
class RosenbrockTemporaryVariables : public TemporaryVariables
{
public:
DenseMatrixPolicy Ynew_;
DenseMatrixPolicy initial_forcing_;
std::vector<DenseMatrixPolicy> K_;
DenseMatrixPolicy Yerror_;
template<class DenseMatrixPolicy>
class RosenbrockTemporaryVariables : public TemporaryVariables
{
public:
DenseMatrixPolicy Ynew_;
DenseMatrixPolicy initial_forcing_;
std::vector<DenseMatrixPolicy> K_;
DenseMatrixPolicy Yerror_;

RosenbrockTemporaryVariables() = default;
RosenbrockTemporaryVariables(const RosenbrockTemporaryVariables& other) = default;
RosenbrockTemporaryVariables(RosenbrockTemporaryVariables&& other) = default;
RosenbrockTemporaryVariables& operator=(const RosenbrockTemporaryVariables& other) = default;
RosenbrockTemporaryVariables& operator=(RosenbrockTemporaryVariables&& other) = default;
~RosenbrockTemporaryVariables() = default;
RosenbrockTemporaryVariables() = default;
RosenbrockTemporaryVariables(const RosenbrockTemporaryVariables& other) = default;
RosenbrockTemporaryVariables(RosenbrockTemporaryVariables&& other) = default;
RosenbrockTemporaryVariables& operator=(const RosenbrockTemporaryVariables& other) = default;
RosenbrockTemporaryVariables& operator=(RosenbrockTemporaryVariables&& other) = default;
~RosenbrockTemporaryVariables() = default;

RosenbrockTemporaryVariables(const auto& state_parameters, const auto& solver_parameters):
Ynew_(state_parameters.number_of_grid_cells_, state_parameters.number_of_species_),
initial_forcing_(state_parameters.number_of_grid_cells_, state_parameters.number_of_species_),
Yerror_(state_parameters.number_of_grid_cells_, state_parameters.number_of_species_)
{
K_.reserve(solver_parameters.stages_);
for (std::size_t i = 0; i < solver_parameters.stages_; ++i)
K_.emplace_back(state_parameters.number_of_grid_cells_, state_parameters.number_of_species_);
}
};
RosenbrockTemporaryVariables(const auto& state_parameters, const auto& solver_parameters)
: Ynew_(state_parameters.number_of_grid_cells_, state_parameters.number_of_species_),
initial_forcing_(state_parameters.number_of_grid_cells_, state_parameters.number_of_species_),
Yerror_(state_parameters.number_of_grid_cells_, state_parameters.number_of_species_)
{
K_.reserve(solver_parameters.stages_);
for (std::size_t i = 0; i < solver_parameters.stages_; ++i)
K_.emplace_back(state_parameters.number_of_grid_cells_, state_parameters.number_of_species_);
}
};
} // namespace micm
15 changes: 9 additions & 6 deletions include/micm/solver/solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#pragma once

#include <micm/process/process.hpp>
#include <micm/solver/solver_result.hpp>
#include <micm/solver/backward_euler_temporary_variables.hpp>
#include <micm/solver/rosenbrock_temporary_variables.hpp>
#include <micm/solver/backward_euler.hpp>
#include <micm/solver/backward_euler_temporary_variables.hpp>
#include <micm/solver/rosenbrock.hpp>
#include <micm/solver/rosenbrock_temporary_variables.hpp>
#include <micm/solver/solver_result.hpp>

#include <type_traits>

Expand Down Expand Up @@ -60,7 +60,7 @@ namespace micm

SolverResult Solve(double time_step, StatePolicy& state)
{
return solver_.Solve(time_step, state);
return solver_.Solve(time_step, state);
}

/// @brief Returns the number of grid cells
Expand All @@ -82,15 +82,18 @@ namespace micm
auto state = std::move(StatePolicy(state_parameters_));
if constexpr (std::is_convertible_v<typename SolverPolicy::ParametersType, RosenbrockSolverParameters>)
{
state.temporary_variables_ = std::make_unique<RosenbrockTemporaryVariables<DenseMatrixType>>(state_parameters_, solver_parameters_);
state.temporary_variables_ =
std::make_unique<RosenbrockTemporaryVariables<DenseMatrixType>>(state_parameters_, solver_parameters_);
}
else if constexpr (std::is_same_v<typename SolverPolicy::ParametersType, BackwardEulerSolverParameters>)
{
state.temporary_variables_ = std::make_unique<BackwardEulerTemporaryVariables<DenseMatrixType>>(state_parameters_);
}
else
{
throw std::runtime_error("Solver type not supported! Parameter type: " + std::string(typeid(typename SolverPolicy::ParametersType).name()));
throw std::runtime_error(
"Solver type not supported! Parameter type: " +
std::string(typeid(typename SolverPolicy::ParametersType).name()));
}
return state;
}
Expand Down
2 changes: 1 addition & 1 deletion include/micm/solver/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#pragma once

#include <micm/solver/lu_decomposition.hpp>
#include <micm/solver/temporary_variables.hpp>
#include <micm/system/conditions.hpp>
#include <micm/system/system.hpp>
#include <micm/util/jacobian.hpp>
#include <micm/util/matrix.hpp>
#include <micm/util/sparse_matrix.hpp>
#include <micm/solver/temporary_variables.hpp>

#include <algorithm>
#include <cstddef>
Expand Down
23 changes: 12 additions & 11 deletions include/micm/solver/temporary_variables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@

namespace micm
{
/// @brief This is the base class for temporary variables; currently it is empty and will be expanded by a specific solver later.
class TemporaryVariables
{
public:
TemporaryVariables() = default;
TemporaryVariables(const TemporaryVariables& other) = default;
TemporaryVariables(TemporaryVariables&& other) = default;
TemporaryVariables& operator=(const TemporaryVariables& other) = default;
TemporaryVariables& operator=(TemporaryVariables&& other) = default;
virtual ~TemporaryVariables() = default;
};
/// @brief This is the base class for temporary variables; currently it is empty and will be expanded by a specific solver
/// later.
class TemporaryVariables
{
public:
TemporaryVariables() = default;
TemporaryVariables(const TemporaryVariables& other) = default;
TemporaryVariables(TemporaryVariables&& other) = default;
TemporaryVariables& operator=(const TemporaryVariables& other) = default;
TemporaryVariables& operator=(TemporaryVariables&& other) = default;
virtual ~TemporaryVariables() = default;
};
} // namespace micm

0 comments on commit 6c8875d

Please sign in to comment.