-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
162 euler option #197
Closed
Closed
162 euler option #197
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a0da3c9
Added MICM::CreateBackwardEuler and MICM::CreateBackwardEulerStandard…
dwfncar 8cf0a04
Added BackwardEuler and BackwardEulerStandard solver types.
dwfncar 8cf94f4
Added MICMSolver types BackwardEuler and BackwardEulerStandardOrder.
dwfncar f9239bb
Added MICM::CreateBackwardEuler.
dwfncar d99b8df
Added MICM::CreateBackwardEuler.
dwfncar d5b8206
Merge branch 'main' into 162-euler-option
dwfncar 8be7180
Start on test for BackwardEulerStandardOrder.
dwfncar 993d7af
Test set up for BackwardEulerStandardOrder.
dwfncar a5765f4
Start on CreateBackwardEulerStandardOrder.
dwfncar 05ca29b
Merge branch 'main' into 162-euler-option
dwfncar 2e96ee9
Merged main.
dwfncar f7de2ef
Fixed micm::CreateBackwardEuler.
dwfncar 715ccc2
Added MICM::CreateBackwardEulerStandardOrder.
dwfncar 0cd931d
Start on unit test SolveUsingVectorOrderedBackwardEuler.
dwfncar 4ac136e
Updated micm.cpp for Backward Euler.
dwfncar 6e89178
Added unit test check on number of user defined rates for Backward Eu…
dwfncar 0a18361
Set custom rate parameters in Backward Euler C API unit tests.
dwfncar 6ac37a4
Added Backward Euler options to MicmSolve.
dwfncar d4d4ed1
Added MicmSolve to Backward Euler unit tests.
dwfncar c82938b
Added MicmSolve to Backward Euler unit tests.
dwfncar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,8 +39,10 @@ namespace musica | |
/// @brief Types of MICM solver | ||
enum MICMSolver | ||
{ | ||
Rosenbrock = 1, // Vector-ordered Rosenbrock solver | ||
RosenbrockStandardOrder, // Standard-ordered Rosenbrock solver | ||
Rosenbrock = 1, // Vector-ordered Rosenbrock solver | ||
BackwardEuler, // Vector-ordered BackwardEuler solver | ||
RosenbrockStandardOrder, // Standard-ordered Rosenbrock solver | ||
BackwardEulerStandardOrder, // Standard-ordered BackwardEuler solver | ||
}; | ||
|
||
struct SolverResultStats | ||
|
@@ -140,11 +142,21 @@ namespace musica | |
/// @param error Error struct to indicate success or failure | ||
void CreateRosenbrock(const std::string &config_path, Error *error); | ||
|
||
/// @brief Create a BackwardEuler solver of vector-ordered matrix type by reading and parsing configuration file | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have the same thoughts on the ordering of the functions related to the above comments. |
||
/// @param config_path Path to configuration file or directory containing configuration file | ||
/// @param error Error struct to indicate success or failure | ||
void CreateBackwardEuler(const std::string &config_path, Error *error); | ||
|
||
/// @brief Create a Rosenbrock solver of standard-ordered matrix type by reading and parsing configuration file | ||
/// @param config_path Path to configuration file or directory containing configuration file | ||
/// @param error Error struct to indicate success or failure | ||
void CreateRosenbrockStandardOrder(const std::string &config_path, Error *error); | ||
|
||
/// @brief Create a BackwardEuler solver of standard-ordered matrix type by reading and parsing configuration file | ||
/// @param config_path Path to configuration file or directory containing configuration file | ||
/// @param error Error struct to indicate success or failure | ||
void CreateBackwardEulerStandardOrder(const std::string &config_path, Error *error); | ||
|
||
/// @brief Solve the system | ||
/// @param solver Pointer to solver | ||
/// @param time_step Time [s] to advance the state by | ||
|
@@ -210,24 +222,36 @@ namespace musica | |
public: | ||
MICMSolver solver_type_; | ||
|
||
/// @brief Vector-ordered Rosenbrock solver type | ||
/// @brief Vector-ordered Rosenbrock and BackwardEuler solver types | ||
using DenseMatrixVector = micm::VectorMatrix<double, MICM_VECTOR_MATRIX_SIZE>; | ||
using SparseMatrixVector = micm::SparseMatrix<double, micm::SparseMatrixVectorOrdering<MICM_VECTOR_MATRIX_SIZE>>; | ||
|
||
using RosenbrockVectorType = typename micm::RosenbrockSolverParameters:: | ||
template SolverType<micm::ProcessSet, micm::LinearSolver<SparseMatrixVector, micm::LuDecomposition>>; | ||
using Rosenbrock = micm::Solver<RosenbrockVectorType, micm::State<DenseMatrixVector, SparseMatrixVector>>; | ||
using VectorState = micm::State<DenseMatrixVector, SparseMatrixVector>; | ||
std::unique_ptr<Rosenbrock> rosenbrock_; | ||
|
||
/// @brief Standard-ordered Rosenbrock solver type | ||
using BackwardEulerVectorType = typename micm::BackwardEulerSolverParameters:: | ||
template SolverType<micm::ProcessSet, micm::LinearSolver<SparseMatrixVector, micm::LuDecomposition>>; | ||
using BackwardEuler = micm::Solver<BackwardEulerVectorType, micm::State<DenseMatrixVector, SparseMatrixVector>>; | ||
std::unique_ptr<BackwardEuler> backward_euler_; | ||
|
||
/// @brief Standard-ordered Rosenbrock and BackwardEuler solver types | ||
using DenseMatrixStandard = micm::Matrix<double>; | ||
using SparseMatrixStandard = micm::SparseMatrix<double, micm::SparseMatrixStandardOrdering>; | ||
|
||
using RosenbrockStandardType = typename micm::RosenbrockSolverParameters:: | ||
template SolverType<micm::ProcessSet, micm::LinearSolver<SparseMatrixStandard, micm::LuDecomposition>>; | ||
using RosenbrockStandard = micm::Solver<RosenbrockStandardType, micm::State<DenseMatrixStandard, SparseMatrixStandard>>; | ||
using StandardState = micm::State<DenseMatrixStandard, SparseMatrixStandard>; | ||
std::unique_ptr<RosenbrockStandard> rosenbrock_standard_; | ||
|
||
using BackwardEulerStandardType = typename micm::BackwardEulerSolverParameters:: | ||
template SolverType<micm::ProcessSet, micm::LinearSolver<SparseMatrixStandard, micm::LuDecomposition>>; | ||
using BackwardEulerStandard = micm::Solver<BackwardEulerStandardType, micm::State<DenseMatrixStandard, SparseMatrixStandard>>; | ||
std::unique_ptr<BackwardEulerStandard> backward_euler_standard_; | ||
|
||
private: | ||
int num_grid_cells_; | ||
std::unique_ptr<micm::SolverParameters> solver_parameters_; | ||
|
@@ -294,4 +318,4 @@ namespace musica | |
*error = ToError(MUSICA_ERROR_CATEGORY, MUSICA_ERROR_CODE_SPECIES_NOT_FOUND, msg.c_str()); | ||
return T(); | ||
} | ||
} // namespace musica | ||
} // namespace musica |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change of the enum order will fail the fortran micm APIs. I guess the ordering based on the matrix type is fine as it is because we only have two types of solver, but if we think about adding more solvers, it'd probably be easier for maintainers to order them based on the solver type, then the enum value doesn't have to change every time we add a new solver. Also for the users, if a new release has to change the ordering, it could be confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it will better to order by solver type / matrix type ... will also rearrange source with this ordering.