Skip to content
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

Allow single timestep control over Thetis run #368

Open
stephankramer opened this issue Jun 10, 2024 · 1 comment
Open

Allow single timestep control over Thetis run #368

stephankramer opened this issue Jun 10, 2024 · 1 comment
Assignees

Comments

@stephankramer
Copy link
Contributor

stephankramer commented Jun 10, 2024

This issue has come up coupling Thetis to a goal-based mesh-adaptivity framework goalie but would equally be important coupling Thetis to other models via a coupling framework: Thetis only provides per timestep control via callbacks, which keeps Thetis in charge of runtime, and does not cater for an external framework to request a single timestep to be performed.

Two potential implementations that I can think of:

  1. Simply separate the timestep code into a separate (user callable) method
  2. Use a generator approach.
    So change the current code
   def iterate(self, ...):
       <prep-stuff>
       while t<t_end:
           <timestep-code>

to either 1:

   def advance(self):
        <timestep-code>

   def prep-stuff(self):
       <prep_stuff>

   def iterate(self, ...):
      self.prep_stuff()
       while t<t_end:
          self.advance()

or 2:

   def iterate(self, ...):
        for t in self.generator(...):
             pass

   def generator(self, ...):
       <prep-stuff>
       while t<t_end:
          <timestep-code>
          yield t

where in both cases the user can use solver_obj.iterate() in exactly the same way as before.

To get per time-step control, in case 1, the user (coupling framework) would have to do three things

    solver_obj.prep_stuff()
    while t<t_end:  # i.e. repeat the timestep logic
        solver_obj.advance()
        # user code

whereas in case 2, that would simply be:

   for t in solver_obj.generator():
        # user code

or if there's some further logic, or other looping requirements:

   thetis_timestepper = solver_obj.generator()
   while t_Thetis<t_end and .... :
      t_Thetis = thetis_timestepper.next()

So at the moment I'm inclined to go for option 2.

@thangel
Copy link
Contributor

thangel commented Jun 10, 2024

The work of @fragkouan should be useful here - sometimes a few iteration have to take place between coupling
https://github.com/fragkouan/thetis_wci/blob/138b2204c8fa3aea4ddda383168d17b0384146ee/thetis/solver2d.py#L1063

@acse-ej321 acse-ej321 self-assigned this Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants