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

Low storage runge kutta #259

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

jocelynpoon
Copy link

Draft PR for the low storage RK method code

//int k = q_hat +1;

double sum_delta = 0;
double atol = 0.1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets include atol and rtol as parameters

int k = q_hat +1;
// double error = 0.0;
//double w = 0.0;
double beta_controller[3] = {0.70, -0.40, 0};
Copy link
Collaborator

Choose a reason for hiding this comment

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

The same for beta as well.

Copy link
Collaborator

@cpethrick cpethrick left a comment

Choose a reason for hiding this comment

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

This is great work! I'm glad to see it coming together so well. I've left some preliminary comments to work through while the PR is still in draft. As you clean up your code, it is also good to remove commented lines, though I know those are sometimes necessary while you're still developing it!


// Compute the unsteady quantities, write to the dealii table, and output to file
flow_solver_case->compute_unsteady_data_and_write_to_table(ode_solver, dg, unsteady_data_table);
// update next time step
if(flow_solver_param.adaptive_time_step == true) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add another parameter which controls whether you use the error-adaptive time stepping? Then this structure would change to

if (CFL adaptive timestep)
    next_time_step = flow_solver_case->get_adaptive_time_step(dg)
else if (error adaptive time step)
    next_time_step = ode_solver->err_time_step(time_step,false);
else
    next_time_step = flow_solver_case->get_constant_time_step(dg);

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the best place for that parameter would be in the flow solver section.

}

template <int dim, typename real, int n_rk_stages, typename MeshType>
void LowStorageRungeKuttaODESolver<dim,real,n_rk_stages, MeshType>::step_in_time (real dt, const bool pseudotime)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
void LowStorageRungeKuttaODESolver<dim,real,n_rk_stages, MeshType>::step_in_time (real dt, const bool pseudotime)
void LowStorageRungeKuttaODESolver<dim,real,n_rk_stages, MeshType>::step_in_time (real dt, const bool /*pseudotime*/)

This way you don't have to call (void) pseudotime.

dealii::LinearAlgebra::distributed::Vector<double> storage_register_1;
storage_register_1.reinit(this->solution_update);
storage_register_1 = this->dg->solution;
dealii::LinearAlgebra::distributed::Vector<double> storage_register_3 = storage_register_1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you move the initialization of these vectors to allocate_ode_system()?

In order to do that, you would need to make all of the storage registers member variables of the LowStorageRungeKuttaODESolver, then just do the allocation steps in allocate_ode_system().

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just be careful to reinitialize the vectors if that needs to be done!

for (int i = 1; i < n_rk_stages +1; i++ ){
// storage_register_2 = storage_register_2 + delta[i-1] * storage_register_1;
storage_register_2.add(this->butcher_tableau->get_delta(i-1) , storage_register_1);
this->dg->solution = rhs;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this might be possible to do without the extra vector rhs, and instead using storage_register_1. I haven't gone through the loop in detail, but maybe you could check that.

}
this->dg->solution = storage_register_1;

double global_size = dealii::Utilities::MPI::sum(storage_register_1.local_size(), this->mpi_communicator);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This would probably be better to do in allocate_ode_system and storing as a member variable. Summing over all of the cores is often quite slow, especially as you increase the number of parallel processes.

/** This is initialized for any RK method, but solution-sized vectors are
* only initialized if there is an implicit solve
*/
JFNKSolver<dim,real,MeshType> solver;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this can be removed since we will never have implicit for this type of low-storage algorithm. You can remove it from the header here and also from line 13 of the cpp file.

namespace PHiLiP {
namespace ODE {

#if PHILIP_DIM==1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you also add references to the paper and github repo to this class?

@@ -7,6 +7,18 @@ void LinearSolverParam::declare_parameters (dealii::ParameterHandler &prm)
{
prm.enter_subsection("linear solver");
{
prm.declare_entry("atol", "0.001",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could these be moved to the ode_solver parameters section rather than this one? I think they would be more relevant there.

" dirk_3_im"),
" dirk_3_im | "
" RK3_2_5F_3SStarPlus | "
" RK4_3_5_3SStar "),
"Runge-kutta method to use. Methods with _ex are explicit, and with _im are implicit."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add another line to this description indicating that 2SStarPlus and 3SStar are low-storage RK methods.

@@ -61,12 +62,15 @@ class ODESolverParam
euler_ex, ///Forward Euler
euler_im, ///Implicit Euler
dirk_2_im, ///Second-order diagonally-implicit RK
dirk_3_im ///Third-order diagonally-implicit RK
dirk_3_im, ///Third-order diagonally-implicit RK
RK4_3_5_3SStar,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add short comments with the main properties - include order, number of stages, FSAL, and other pertinent information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants