FluidityProject / fluidity

Fluidity
http://fluidity-project.org
Other
365 stars 115 forks source link

VTK state output out of sync with mesh adaptivity #304

Closed gnikit closed 2 years ago

gnikit commented 3 years ago

I was wondering if anyone knows what is the benefit of outputting our VTK files in the next timestep iteration (i.e. at the top of the timestep loop) instead of outputting at the very end of a timestep right before the last exit condition (Fluids.F90:792). Writing our VTK files in that order when adapting the mesh results into the solution from the current_time solve being output onto the newly adapted mesh on which we have not yet performed a solve. Moreover, this setup for adaptivity, assuming that we output at each timestep, results into the last and second to last VTK outputs being on the same mesh which is not technically right.

In addition, the first VTK dump I believe should be moved to be just before adapt_state_first_timestep so as we ouput the input mesh on the zeroth timestep -> we then adapt it -> solve on it -> output timestep 1 mesh-> adapt mesh for next timestep -> top of the loop ->...

This can be seen for example in test: adaptivity_preprocessing where the last 2 timesteps have the same mesh even though we have gone and adapted (I have also turned on adapt at first timestep).

image

With the suggested changes (i have turned on adapt at first timestep for this) our VTK dumps would look like this

image

gnikit commented 3 years ago

I realise that a potential complication/side effect of this is that certain fields that are yet to be inserted into state like Time are not present in the 0th VTU dump. I guess 2 things can be done about this:

  1. Leave that as is.
  2. Move things around in Fluids.F90 so that the adapt_at_first_timestep happens after all the fields have been imported and initialised from the options file into state.