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

Non-linear iterations within a physical time step for the advection term #1226

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

itopcuoglu
Copy link
Contributor

No description provided.

@@ -190,11 +190,14 @@ struct AdvectionOp<ICNS, fvm::Godunov>
m_allow_inflow_on_outflow = true;
}

// if state is NPH, then n and n+1 are known, and only
// spatial extrapolation is performed
amrex::Real dt_arg = (fstate == FieldState::NPH) ? 0.0 : dt;
Copy link
Contributor

Choose a reason for hiding this comment

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

let's give this a better name than dt_arg. dt_for_hydro ? dt_local ? dt_adjusted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe dt_extrap as in dt for extrapolation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed this into dt_extrap, as in the dt that is used for extrapolation.

@@ -168,6 +168,10 @@ struct AdvectionOp<
(godunov_scheme == godunov::scheme::WENO_JS)) {
m_allow_inflow_on_outflow = true;
}
// if state is NPH, then n and n+1 are known, and only
// spatial extrapolation is performed
amrex::Real dt_arg = (fstate == FieldState::NPH) ? 0.0 : dt;
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment below about naming

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed this into dt_extrap as well.

@@ -172,6 +174,9 @@ private:
// Prescribe advection velocity
bool m_prescribe_vel = false;

// Advection iterations every timestep
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe something with non_linear_iterations in the name? I am a bit wary of our naming for these things because we often mean different things when we say "nonlinear". I am not sure what the right name is but we need to be clear and make sure we stick with it. I have no problem with long, explicit names: e.g. m_non_linear_advection_iterations. Let's add some documentation too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could go for something like m_outer_loop_iterations. I am going to modify the loops to make this compatible with exawind-driver, and I think that is going to make it clear that these are outer loop iterations

@@ -372,6 +378,10 @@ void incflo::init_physics_and_pde()
if (activate_overset) {
m_sim.activate_overset();
}

// Get number of advection iterations
pp.query("advection_iterations", m_adv_iters);
Copy link
Contributor

Choose a reason for hiding this comment

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

and when we update the naming, make sure the user facing input makes sense within that context as well.


// Get number of advection iterations
pp.query("advection_iterations", m_adv_iters);
m_adv_iters = std::max(1, m_adv_iters);
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to silently do this? Or abort on an invalid value? Or warn that we are doing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got rid of this.

const auto& velstar = vel_star(lev);
auto& veldiff = vel_diff(lev);

for (amrex::MFIter mfi(velocity_new(lev)); mfi.isValid(); ++mfi) {
Copy link
Contributor

Choose a reason for hiding this comment

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

make this a fused mfiter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this possible to do since level_mask is a MultiFab and not a field? Should level_mask be converted into an IntScratchField in order to be accessible by a fused MFIter loop?

Copy link
Contributor

Choose a reason for hiding this comment

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

fused mfiter operate on multifabs. no need for fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I converted this into a fused MFIter.

amr-wind/utilities/console_io.cpp Outdated Show resolved Hide resolved
}
}

amrex::Real rms_ucell = 0.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

use amrex::Array of size spacedim, stuff the norms into there with a component loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been fixed.

rms_vcell += vel_diff(lev).norm2(1);
rms_wcell += vel_diff(lev).norm2(2);
}
amrex::Print() << "Non-linear residual for u velocity " << rms_ucell
Copy link
Contributor

Choose a reason for hiding this comment

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

for loop these, or print as a single line.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also make sure the answer is the same when using MPI and multiple procs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this into printing a single line.

The non-linear solver residuals are the same down to roughly the 5th decimal between 4, 6 and 8 ranks.

@@ -214,4 +215,75 @@ void print_tpls(std::ostream& out)
}
}

void print_nonlinear_residual(
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure this print function belongs here. It feels different than the others. Not sure where to put it yet. I wonder if we can also make it more generic by templating to accept fields. The fields should also have the repo/mesh info so we don't need to pass in sim I think. Maybe this is more of a field utils kinda thing.

@itopcuoglu itopcuoglu marked this pull request as ready for review September 13, 2024 17:51
@mbkuhn
Copy link
Contributor

mbkuhn commented Sep 24, 2024

I don't have anything to add to Marc's remaining comments. This looks really good, I'm impressed with how simply and directly you have managed to set this up.

mbkuhn and others added 21 commits September 30, 2024 13:58
- Calculation of NPH velocity within the non-linear iteration loop
… replaced the indivudal change-in-velocity norms with an Array<amrex::Real, AMREX_SPACEDIM> instance
…rNonLinear(), and moved their functionality into advance() and ApplyPredictor()
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.

4 participants