-
-
Notifications
You must be signed in to change notification settings - Fork 4
Add dumux-customised checkpointing feature #58
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d2c0dc8
add customised checkpointing feature
Fujikawas ac66781
formatting
Fujikawas 8ee41ff
remove redundent check
Fujikawas 2f7500b
small refactor
Fujikawas 0c78329
clear the test case
Fujikawas f247093
simplify status check
Fujikawas d930c0c
remove advanceTimeStep
Fujikawas 43fdc63
remove handling of TimeLoop
Fujikawas 830fec5
add change to changelog
Fujikawas fe21e50
get rid of the time step parameter
Fujikawas e3f903d
remove old functions for checkpointing
Fujikawas 27380de
add timeloop reset
Fujikawas 145bea2
formatting
Fujikawas 2202c9a
remove redundant includes
Fujikawas 60acb45
Add dt to checkpointing
IshaanDesai 90c818b
Add relevant methods to the mocked TimeLoop class
IshaanDesai 40f6e26
improve test
Fujikawas 70c3c68
formatting
Fujikawas 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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include "solverstate.hh" |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| #ifndef SOLVERSTATE_HH | ||
| #define SOLVERSTATE_HH | ||
|
|
||
| #include <precice/precice.hpp> | ||
|
|
||
| /*! | ||
| * @brief Namespace of dumux-precice | ||
| * | ||
| */ | ||
| namespace Dumux::Precice | ||
| { | ||
| struct SolverStateBase { | ||
| virtual ~SolverStateBase() = default; | ||
| virtual void writeState() = 0; | ||
| virtual void readState() = 0; | ||
| }; | ||
| /*! | ||
| * @brief A class to store and provide the state of the solver while checkpointing, one SolutionVector object is supported. | ||
| */ | ||
| template<class SolutionVector> | ||
| class SolverStateOnly : public SolverStateBase | ||
| { | ||
| private: | ||
| SolutionVector *x_; | ||
| SolutionVector xCheckpoint_; | ||
|
|
||
| public: | ||
| SolverStateOnly(SolutionVector &x) : x_(&x), xCheckpoint_(*x_) {} | ||
|
|
||
| void writeState() override { xCheckpoint_ = *x_; } | ||
|
|
||
| void readState() override { *x_ = xCheckpoint_; } | ||
| }; | ||
| /*! | ||
| * @brief A class to store and provide the state of the solver while checkpointing, one SolutionVector object is supported. | ||
| */ | ||
| template<class SolutionVector, class GridVariables> | ||
| class SolverStateGridVar : public SolverStateBase | ||
| { | ||
| private: | ||
| SolutionVector *x_; | ||
| SolutionVector xCheckpoint_; | ||
| GridVariables *gv_; | ||
|
|
||
| public: | ||
| SolverStateGridVar(SolutionVector &x, GridVariables &gv) | ||
| : x_(&x), xCheckpoint_(*x_), gv_(&gv) | ||
| { | ||
| } | ||
|
|
||
| void writeState() override { xCheckpoint_ = *x_; } | ||
|
|
||
| void readState() override | ||
| { | ||
| *x_ = xCheckpoint_; | ||
| gv_->update(*x_); | ||
| } | ||
| }; | ||
| /*! | ||
| * @brief A class to store and provide the state of the solver while checkpointing, one SolutionVector object is supported. | ||
| */ | ||
| template<class SolutionVector, class GridVariables, class TimeLoop> | ||
| class SolverStateGridVarTimeLoop : public SolverStateBase | ||
| { | ||
| private: | ||
| SolutionVector *x_; | ||
| SolutionVector xCheckpoint_; | ||
| GridVariables *gv_; | ||
| TimeLoop *tl_; | ||
Fujikawas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| double timeCheckpoint_ = 0.0; | ||
| double dtCheckpoint_ = 0.0; | ||
| long timeStepCheckpoint_ = 0; | ||
|
|
||
| public: | ||
| SolverStateGridVarTimeLoop(SolutionVector &x, | ||
| GridVariables &gv, | ||
| TimeLoop &tl) | ||
| : x_(&x), xCheckpoint_(*x_), gv_(&gv), tl_(&tl) | ||
| { | ||
| } | ||
|
|
||
| void writeState() override | ||
| { | ||
| xCheckpoint_ = *x_; | ||
| timeCheckpoint_ = tl_->time(); | ||
| timeStepCheckpoint_ = tl_->timeStepIndex(); | ||
| dtCheckpoint_ = tl_->timeStepSize(); | ||
| } | ||
|
|
||
| void readState() override | ||
| { | ||
| *x_ = xCheckpoint_; | ||
| gv_->update(*x_); | ||
| tl_->setTime(timeCheckpoint_, timeStepCheckpoint_); | ||
| tl_->setTimeStepSize(dtCheckpoint_); | ||
| } | ||
| }; | ||
| } // namespace Dumux::Precice | ||
| #endif | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| add_subdirectory(ff-pm) | ||
| add_subdirectory(dummysolver) | ||
| add_subdirectory(singleCheckpointTest) |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.