-
Notifications
You must be signed in to change notification settings - Fork 249
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
[Core] restart save process #2283
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2dcf33b
Initial commit WIP
bd843f6
Merge branch 'master' into core/restart-save-process
philbucher f17dd43
Merge branch 'master' into core/restart-save-process
philbucher 0cf11e8
finished save_restart_process
philbucher 7f7b7a9
minor changes in restart_utility
philbucher a30d707
Adding tests for new functionalities
philbucher 2e80aa8
minor
philbucher f463e4b
fixing paths
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
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
from __future__ import print_function, absolute_import, division #makes KratosMultiphysics backward compatible with python 2.6 and 2.7 | ||
# Importing the Kratos Library | ||
import KratosMultiphysics | ||
|
||
|
||
def Factory(settings, Model): | ||
if(type(settings) != KratosMultiphysics.Parameters): | ||
raise Exception("Expected input shall be a Parameters object, encapsulating a json string") | ||
return SaveRestartProcess(Model, settings["Parameters"]) | ||
|
||
|
||
class SaveRestartProcess(KratosMultiphysics.Process): | ||
|
||
def __init__(self, model, params): | ||
"""This process compares saves restart files | ||
It works both in OpenMP and MPI | ||
see the "default_settings" for available options | ||
""" | ||
## Settings string in json format | ||
default_settings = KratosMultiphysics.Parameters("""{ | ||
"model_part_name" : "", | ||
"echo_level" : 0, | ||
"serializer_trace" : "no_trace", | ||
"restart_save_frequency" : 0.0, | ||
"restart_control_type" : "time", | ||
"save_restart_files_in_folder" : true | ||
}""") | ||
|
||
## Overwrite the default settings with user-provided parameters | ||
params.ValidateAndAssignDefaults(default_settings) | ||
self.params = params | ||
self.model = model | ||
|
||
if self.params["model_part_name"].GetString() == "": | ||
raise Exception('No "model_part_name" was specified!') | ||
|
||
def ExecuteInitialize(self): | ||
model_part = self.model[self.params["model_part_name"].GetString()] | ||
|
||
is_mpi_execution = (model_part.GetCommunicator().TotalProcesses() > 1) | ||
|
||
if is_mpi_execution: | ||
import KratosMultiphysics.TrilinosApplication | ||
from trilinos_restart_utility import TrilinosRestartUtility as Restart | ||
else: | ||
from restart_utility import RestartUtility as Restart | ||
|
||
self.params.AddValue("input_filename", self.params["model_part_name"]) | ||
self.params.RemoveValue("model_part_name") | ||
|
||
self.restart_utility = Restart(model_part, self.params) | ||
|
||
def ExecuteBeforeSolutionLoop(self): | ||
pass | ||
|
||
def ExecuteInitializeSolutionStep(self): | ||
pass | ||
|
||
def ExecuteFinalizeSolutionStep(self): | ||
pass | ||
|
||
def ExecuteBeforeOutputStep(self): | ||
pass | ||
|
||
def IsOutputStep(self): | ||
return self.restart_utility.IsRestartOutputStep() | ||
|
||
def PrintOutput(self): | ||
self.restart_utility.SaveRestart() | ||
|
||
def ExecuteAfterOutputStep(self): | ||
pass | ||
|
||
def ExecuteFinalize(self): | ||
pass | ||
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
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.
Minor suggestion (maybe for a future PR): When I have had to use restart, it was often because I was running on a cluster with some limit on run-time for the cases. In such situations, I would just estimate how many time steps I could run in a single batch, then launch a job for that and ensure that the model part was serialized at the end of the job. I think it would make sense that the process allows this, which could be achieved by having an extra save on
ExecuteFinalize
(maybe only if explicily requested via json?).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.
Sounds fine to me, we can speak tmr abt this