-
Notifications
You must be signed in to change notification settings - Fork 189
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
Add IMEX SolveImplicitSector mutator #5653
Add IMEX SolveImplicitSector mutator #5653
Conversation
0e38ae4
to
adbe671
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Thanks for all your hard work on the IMEX code! I have a few suggestions/comments/questions. Please feel free to rebase and squash directly since I don't think any of them are major.
src/Evolution/Imex/Tags/Mode.hpp
Outdated
|
||
namespace imex { | ||
namespace OptionTags { | ||
struct ImexMode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to add Doxygen comments for the tags, mostly for discoverability?
src/Evolution/Imex/Tags/Mode.hpp
Outdated
struct ImexMode { | ||
static constexpr Options::String help{"IMEX implementation to use"}; | ||
using type = ::imex::Mode; | ||
using group = evolution::OptionTags::Group; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be useful to add an Imex
subgroup into Evolution
to group the options together? [later in a separate PR is totally fine if you think it's a good idea!]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, and renamed some tags both to avoid duplicating the group name and for consistency.
|
||
namespace imex { | ||
namespace OptionTags { | ||
struct ImexImplicitSolveTolerance { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same doxygen question
using attempt_tags = tmpl::transform<typename ImplicitSector::solve_attempts, | ||
get_tags_from_evolution<tmpl::_1>>; | ||
using evolution_data_tags = | ||
tmpl::push_front<attempt_tags, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible tmpl::append
here to combine the two lists? If not, maybe a comment why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed a thing and added some comments to try to make this clearer. Not sure if it's enough.
// Only allocated if used. | ||
Matrix semi_implicit_jacobian{}; | ||
|
||
bool had_failure = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would find reading the code easier if this was solve_succeeded
or something like that. not had_failure
I think is success
and I would find it easier to read
if (solve_succeeded) {
return;
}
return inhomogeneous_terms_; | ||
} | ||
|
||
bool do_solve() const { return implicit_weight_ != 0.0; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the function name makes me think it does some computation. Maybe rename to something like solved_needed
?
: solve_box_(db::create<simple_tags, compute_tags>()), | ||
implicit_equation_(&implicit_equation) { | ||
static_assert(std::is_same_v<PassedEvolutionData, const EvolutionData&>, | ||
"ImplicitSolver was passed a temporary."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you expand this error message? I'm not sure what I should do if I were to get this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should stop passing a temporary. I've added a brief explanation of why.
}; | ||
|
||
template <typename ImplicitSector, typename SolveAttempt> | ||
class ImplicitSolver { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would some overview documentation be useful here? Not necessarily for doxygen, but to get a quick overview of what the different functions do and why? Maybe also for ImplicitEquation
?
struct ReadOnly : Tag, ::db::ComputeTag { | ||
using base = Tag; | ||
using argument_tags = tmpl::list<ReadOnlySource<Tag>>; | ||
static void function(gsl::not_null<typename ReadOnly::type*> dest, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const gsl::not_null
?
}; | ||
// End stuff only used for DataBox handling | ||
|
||
// [initial_guess] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want this initial_guess
to be around the AnalyticSolution
or the InitialGuess
class below? Right now I think it's around the AnalyticSolution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intentional. They are both valid "initial_guess" structs (the example chooses between them with a tmpl::conditional_t
), but this one does a reasonable calculation while InitialGuess
just does some nonsensical modifications to the data.
adbe671
to
95395bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now dependent on (and includes the commits from) #5657.
using attempt_tags = tmpl::transform<typename ImplicitSector::solve_attempts, | ||
get_tags_from_evolution<tmpl::_1>>; | ||
using evolution_data_tags = | ||
tmpl::push_front<attempt_tags, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed a thing and added some comments to try to make this clearer. Not sure if it's enough.
: solve_box_(db::create<simple_tags, compute_tags>()), | ||
implicit_equation_(&implicit_equation) { | ||
static_assert(std::is_same_v<PassedEvolutionData, const EvolutionData&>, | ||
"ImplicitSolver was passed a temporary."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should stop passing a temporary. I've added a brief explanation of why.
break; | ||
} | ||
case Mode::SemiImplicit: { | ||
auto correction_array = solver(initial_guess); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There weren't supposed to be any after the first point, but you're right that I missed one in the LAPACK wrapper, so I fixed that.
I've made the types of some variables and temporaries explicitly arrays, so it should be clear that there are no allocations in them.
}; | ||
// End stuff only used for DataBox handling | ||
|
||
// [initial_guess] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intentional. They are both valid "initial_guess" structs (the example chooses between them with a tmpl::conditional_t
), but this one does a reasonable calculation while InitialGuess
just does some nonsensical modifications to the data.
src/Evolution/Imex/Tags/Mode.hpp
Outdated
struct ImexMode { | ||
static constexpr Options::String help{"IMEX implementation to use"}; | ||
using type = ::imex::Mode; | ||
using group = evolution::OptionTags::Group; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, and renamed some tags both to avoid duplicating the group name and for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, please go ahead and squash!
95395bc
to
da76af4
Compare
@nilsdeppe I think this is ready to go. |
This is the actual solver for the IMEX code. The remaining stuff to submit is mostly actions and other similar wrappers.
Proposed changes
Upgrade instructions
Code review checklist
make doc
to generate the documentation locally intoBUILD_DIR/docs/html
.Then open
index.html
.code review guide.
bugfix
ornew feature
if appropriate.Further comments