-
Notifications
You must be signed in to change notification settings - Fork 29
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
#368 modify iterate method to allow timestep control #387
Open
acse-ej321
wants to merge
9
commits into
master
Choose a base branch
from
single-timestep-368
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ee59b43
#368 split iterator functionality between api wrapper and generator f…
acse-ej321 946d290
Merge branch 'master' into single-timestep-368
acse-ej321 006ec9c
#368 minor linting corrections
acse-ej321 4149176
Merge branch 'single-timestep-368' of https://github.com/thetisprojec…
acse-ej321 6ed32cc
added call to in demo_2d_tracer demo for test coverage
acse-ej321 3d732b7
minor spelling corrections
acse-ej321 95d08b2
minor linting edits
acse-ej321 47954d0
minor linting edits
acse-ej321 c1bc11b
minor linting edits
acse-ej321 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 | ||||
---|---|---|---|---|---|---|
|
@@ -947,15 +947,52 @@ def iterate(self, update_forcings=None, | |||||
""" | ||||||
Runs the simulation | ||||||
|
||||||
Wrapper for function for `create_iterator` generator and automatically | ||||||
iterates over the time loop until time ``options.simulation_end_time`` is reached. | ||||||
Exports fields to disk on ``options.simulation_export_time`` intervals. | ||||||
|
||||||
:kwarg update_forcings: User-defined function that takes simulation | ||||||
time as an argument and updates time-dependent boundary conditions | ||||||
(if any). | ||||||
:kwarg export_func: User-defined function (with no arguments) that will | ||||||
be called on every export. | ||||||
""" | ||||||
for _ in self.create_iterator(update_forcings=update_forcings, | ||||||
export_func=export_func): | ||||||
pass | ||||||
|
||||||
@PETSc.Log.EventDecorator("thetis.FlowSolver2d.create_iterator") | ||||||
def create_iterator(self, update_forcings=None, | ||||||
export_func=None): | ||||||
""" | ||||||
Creates a generator to iterate through the simulation and return access | ||||||
to time advancing function when time control is handled eternally. | ||||||
|
||||||
Iterates over the time loop until time ``options.simulation_end_time`` is reached. | ||||||
Exports fields to disk on ``options.simulation_export_time`` intervals. | ||||||
|
||||||
For example: | ||||||
|
||||||
.. code-block:: python | ||||||
|
||||||
for t in solver_obj.generator(): | ||||||
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.
Suggested change
|
||||||
# user code | ||||||
|
||||||
or, to get per time-step control: | ||||||
|
||||||
.. code-block:: python | ||||||
|
||||||
thetis_timestepper = solver_obj.generator() | ||||||
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.
Suggested change
|
||||||
while t_Thetis<t_end and .... : | ||||||
t_Thetis = next(thetis_timestepper) | ||||||
|
||||||
:kwarg update_forcings: User-defined function that takes simulation | ||||||
time as an argument and updates time-dependent boundary conditions | ||||||
(if any). | ||||||
:kwarg export_func: User-defined function (with no arguments) that will | ||||||
be called on every export. | ||||||
""" | ||||||
|
||||||
if not self._initialized: | ||||||
self.initialize() | ||||||
|
||||||
|
@@ -1042,6 +1079,9 @@ def iterate(self, update_forcings=None, | |||||
|
||||||
while self.simulation_time <= self.options.simulation_end_time - t_epsilon: | ||||||
self.timestepper.advance(self.simulation_time, update_forcings) | ||||||
|
||||||
# returns internal simulation time | ||||||
yield self.simulation_time | ||||||
|
||||||
# Move to next time step | ||||||
self.iteration += 1 | ||||||
|
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.
Typo: