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

Average velocity as initial condition #1215

Merged
merged 15 commits into from
Aug 9, 2024

Conversation

mivaia
Copy link
Collaborator

@mivaia mivaia commented Jul 30, 2024

The average velocity profile of an old simulation can now be used as an initial condition to a new simulation. The base mesh needs to stay the same, but auxiliary physics can now be added a posteriori without setting them as true in the initial simulation. The time stepping scheme can also be modified.

Description

The refactored restart mechanism had some problems:

  • The auxiliary physics needed to be set as true while the average velocity profile was calculated. The matrix for the auxiliary physic was therefore assembled and could lead to useless memory and simulation time usage.
  • The user could not choose to add an auxiliary physics to an already calculated average velocity profile if it was not specified in the initial simulation. This is because the restart mechanism would always search for a solution to the auxiliary physic in the checkpoint files even if it was non existent.
  • In my opinion, the location of the "use average velocity profile = true" in the multiphysics subsection was somewhat awkward as the average velocity profile is not really an auxiliary physic.

To solve these problems, the already implemented checkpoint mechanism is used. The simulation solving for the average velocity profile therefore needs to have checkpointing activated as well as the set calculate average velocities set to true (as before). Parameters in the initial condition section have been added as well as some conditions in the read_checkpoint() function.

Conditions like:

  • Do not search for a solution to the auxiliary physics if the average velocity is used as an initial condition.
  • Do search for a solution to the auxiliary physics if the restart is normally used.
  • Use the checkpoint file specified by the user in the appropriate initial condition section and not the simulation control section if the average velocity profile initial condition is used.

Testing

A test using the average velocity profile was modified.

Documentation

Documentation will be added in a subsequent PR if all the modifications are accepted.

Miscellaneous (will be removed when merged)

An initial condition using the VTU files was attempted, but it is way easier to use the already existing checkpoint mechanism. No known function to retrieve the triangulation information from the vtu have been found in deal.II. The read_vtu() function is only oriented towards reading vtu meshes generated with deal.II.

Checklist (will be removed when merged)

See this page for more information about the pull request process.

Code related list:

  • All in-code documentation related to this PR is up to date (Doxygen format)
  • Lethe documentation is up to date
  • The branch is rebased onto master
  • Code is indented with indent-all and .prm files (examples and tests) with prm-indent
  • If parameters are modified, the tests and the documentation of examples are up to date
  • Changelog (CHANGELOG.md) is up to date if the refactor affects the user experience or the codebase

Pull request related list:

  • No other PR is open related to this refactoring
  • Labels are applied
  • There are at least 2 reviewers (or 1 if small feature) excluding the responsible for the merge
  • If this PR closes an issue or is related to a project, it is linked in the "Projects" or "Development" section
  • If any future works is planed, an issue is opened
  • The PR description is cleaned and ready for merge

mivaia added 7 commits July 24, 2024 11:35
…t. ->added initial condition parameter file, erased multiphysics use average velocity profile, modified the read_checkpoint to take into account, set simulation time to 0 and erased precedent pvd info
@mivaia mivaia added Ready for review Refactoring This PR is only refactoring or clean up labels Jul 30, 2024
@mivaia mivaia requested review from blaisb and oguevremont July 30, 2024 18:22
mivaia added 3 commits July 30, 2024 16:15
…was not being solved. Changed some conditions to take this into account
…y as an initial condition has a bdf time stepping scheme
Copy link
Contributor

@blaisb blaisb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a first batch of comments. I think it would be wise to add the documentation within this PR. Good job btw

Testing/Temporary/CTestCostData.txt Outdated Show resolved Hide resolved
Testing/Temporary/LastTest.log Outdated Show resolved Hide resolved
include/core/simulation_control.h Outdated Show resolved Hide resolved
source/solvers/heat_transfer.cc Show resolved Hide resolved
source/solvers/heat_transfer_assemblers.cc Outdated Show resolved Hide resolved
source/solvers/navier_stokes_base.cc Outdated Show resolved Hide resolved
Parameters::InitialConditionType::average_velocity_profile &&
this->simulation_parameters.restart_parameters.restart))
{
// std::cout << "Entering normally" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// std::cout << "Entering normally" << std::endl;

source/solvers/navier_stokes_base.cc Outdated Show resolved Hide resolved
…estart with the initial condition. Scaling bug in average velocity
Copy link
Collaborator

@oguevremont oguevremont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice feature!

source/solvers/cahn_hilliard.cc Show resolved Hide resolved
source/solvers/gls_navier_stokes.cc Outdated Show resolved Hide resolved
source/solvers/navier_stokes_base.cc Outdated Show resolved Hide resolved
@oguevremont
Copy link
Collaborator

So now if I understand correctly, we can run simulation that solve FD only while checkpointing, then run subsequent simulations where auxiliary physics are activated by using the proper type of initial condition?

@mivaia mivaia requested a review from blaisb August 6, 2024 20:38
…have number of initial refinements set to 0. This generates an error message in debug mode. This has not been tested using pointwise meshes.
@blaisb blaisb requested a review from oguevremont August 8, 2024 12:41
Copy link
Contributor

@blaisb blaisb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last comment, but this is very good. There's just this "setting the time" that I am not sure about. Can you explain why you need to have the simulation control start at the new time? :)

Comment on lines +203 to +207
// Fix the current time as final checkpointed time
simulation_control_info[0] = last_checkpointed_time;

// Fix time step to be the last time_step that was used
simulation_control_info[1] = time_steps[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You really want to have the new simulation start at the time the previous one finished? why not restart it from zero? does that really pose a problem? I'm not sure what's the goal her (to me this is not intuitive, because if you set the initial condition, shouldnt the time be at zero still ? )

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only to get end time for the average velocity calculation! The simulation time will be restarted from zero in the second simulation. This is necessary because of the way we calculate the average velocity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)perfect

@blaisb blaisb merged commit d711d1f into master Aug 9, 2024
8 checks passed
@blaisb blaisb deleted the average_velocity_as_initial_condition branch August 9, 2024 13:01
M-Badri pushed a commit to M-Badri/lethe that referenced this pull request Sep 29, 2024
The average velocity profile of an old simulation can now be used as an initial condition to a new simulation. The base mesh needs to stay the same, but auxiliary physics can now be added a posteriori without setting them as true in the initial simulation. The time stepping scheme can also be modified.

Description
The refactored restart mechanism had some problems:

The auxiliary physics needed to be set as true while the average velocity profile was calculated. The matrix for the auxiliary physic was therefore assembled and could lead to useless memory and simulation time usage.
The user could not choose to add an auxiliary physics to an already calculated average velocity profile if it was not specified in the initial simulation. This is because the restart mechanism would always search for a solution to the auxiliary physic in the checkpoint files even if it was non existent.
In my opinion, the location of the "use average velocity profile = true" in the multiphysics subsection was somewhat awkward as the average velocity profile is not really an auxiliary physic.
To solve these problems, the already implemented checkpoint mechanism is used. The simulation solving for the average velocity profile therefore needs to have checkpointing activated as well as the set calculate average velocities set to true (as before). Parameters in the initial condition section have been added as well as some conditions in the read_checkpoint() function.

Conditions like:

Do not search for a solution to the auxiliary physics if the average velocity is used as an initial condition.
Do search for a solution to the auxiliary physics if the restart is normally used.
Use the checkpoint file specified by the user in the appropriate initial condition section and not the simulation control section if the average velocity profile initial condition is used.

Former-commit-id: d711d1f
blaisb pushed a commit that referenced this pull request Sep 30, 2024
The average velocity profile of an old simulation can now be used as an initial condition to a new simulation. The base mesh needs to stay the same, but auxiliary physics can now be added a posteriori without setting them as true in the initial simulation. The time stepping scheme can also be modified.

Description
The refactored restart mechanism had some problems:

The auxiliary physics needed to be set as true while the average velocity profile was calculated. The matrix for the auxiliary physic was therefore assembled and could lead to useless memory and simulation time usage.
The user could not choose to add an auxiliary physics to an already calculated average velocity profile if it was not specified in the initial simulation. This is because the restart mechanism would always search for a solution to the auxiliary physic in the checkpoint files even if it was non existent.
In my opinion, the location of the "use average velocity profile = true" in the multiphysics subsection was somewhat awkward as the average velocity profile is not really an auxiliary physic.
To solve these problems, the already implemented checkpoint mechanism is used. The simulation solving for the average velocity profile therefore needs to have checkpointing activated as well as the set calculate average velocities set to true (as before). Parameters in the initial condition section have been added as well as some conditions in the read_checkpoint() function.

Conditions like:

Do not search for a solution to the auxiliary physics if the average velocity is used as an initial condition.
Do search for a solution to the auxiliary physics if the restart is normally used.
Use the checkpoint file specified by the user in the appropriate initial condition section and not the simulation control section if the average velocity profile initial condition is used.

Former-commit-id: d711d1f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready for review Refactoring This PR is only refactoring or clean up
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants