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
Pass fluxes to elliptic source computers #2553
Pass fluxes to elliptic source computers #2553
Conversation
c87c621
to
2439033
Compare
2439033
to
6cea811
Compare
6cea811
to
f570b71
Compare
I don't understand the sentence "pass fluxes to sources". Things are either fluxes or sources, not both. Are the attempts at analogies between elliptic and conservative systems just bad? In the hyperbolic case you have
where
where |
@nilsdeppe Thanks for looking at this. I think the first-order conservative form still works for elliptic systems. Your variables Note that I can't use |
Okay, thanks for explaining that! I was going to ask about |
@nilsdeppe Yes, I'm definitely planning to remove the compute tag for the sources in favor of a function that directly adds the sources to the -div(fluxes). At that point I might also change the interface for the fluxes and sources implementations to compute everything in one function. I'll see how this works out in the evolution code and then adapt it for the elliptic code :) @kidder could you do the second review? |
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.
Sounds good! Just to be clear: only the volume fluxes are computed alongside the source terms so that user functions don't need to know whether we are using Gauss or GL points.
@@ -71,7 +71,7 @@ struct InitializeFirstOrderOperator { | |||
vars_tag, PrimalVariables, |
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 commit message is incorrect. The systems don't need the fluxes to compute sources, but that having access to the fluxes is an optimization.
src/Elliptic/FirstOrderOperator.hpp
Outdated
using auxiliary_field_tag = | ||
tmpl::type_from<decltype(auxiliary_field_tag_v)>; | ||
get<::Tags::Source<auxiliary_field_tag>>(*sources) = | ||
get<auxiliary_field_tag>(vars); | ||
}); | ||
// Call into the sources computer to set primal field sources and possibly | ||
// adjust auxiliary field sources |
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.
Can you add a comment here as to why the fluxes are being passed? As per our discussion, it is not at all clear that this code is correct without such a clarification.
@@ -120,28 +127,34 @@ auto first_order_fluxes(const Variables<VarsTags>& vars, | |||
* |
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.
add a discussion as to why the sources terms are getting the fluxes
@@ -94,7 +94,9 @@ struct Sources { | |||
using argument_tags = tmpl::list<>; | |||
static void apply( | |||
const gsl::not_null<tnsr::I<DataVector, Dim>*> source_for_displacement, | |||
const tnsr::I<DataVector, Dim>& /*displacement*/) noexcept { | |||
const gsl::not_null<tnsr::ii<DataVector, Dim>*> /*source_for_strain*/, | |||
const tnsr::I<DataVector, Dim>& /*displacement*/, |
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.
aren't the new arguments fluxes? Maybe make that clear in the name?
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 new
source_for_strain
argument is the source for the auxiliary equation (think the equation grad(u) = v that defines the auxiliary variable for a Poisson equation. The auxiliary variable for the elasticity system is the symmetric "strain", i.e. the symmetrized gradient of the displacement vector). The source computers gain this argument to get the opportunity to add non-principal contributions to the gradient (Christoffel-symbol terms) to the auxiliary equation. - The new
stress
argument is indeed the flux related to the displacement vector field. It's the strain contracted with the constitutive relation of the elastic material, and that's called "stress" in elasticity terms. I think in the context of the elasticity equations it makes sense to call it by its name.
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.
Okay, I can't speak to what would be most intuitive for people used to the elasticity literature, so I'll have to take your word for it :)
f570b71
to
4c46932
Compare
@nilsdeppe Fixed the commit message and added docs. Please take a look :) @kidder Could you do the second review? |
@kidder already has a lot of PRs awaiting his review so please try to find someone else. |
Sure! @wthrowe could you do me the honour? :) |
Certainly. This looks good to me. |
Thanks @wthrowe! @nilsdeppe Did you look at the fixup already, or should I keep it around a bit longer? |
// adjust auxiliary field sources | ||
SourcesComputer::apply( | ||
make_not_null(&get<::Tags::Source<PrimalFields>>(*sources))..., | ||
make_not_null(&get<::Tags::Source<AuxiliaryFields>>(*sources))..., |
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 keep saying "instead of the auxiliary fields" but here you pass the aux fields. Please correct 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.
No this passes the sources for the auxiliary fields so terms can be added to them, such as Christoffel symbol terms (see this comment #2553 (comment)). Does that make sense?
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.
Okay, that makes sense.
I still don't understand why you say "instead of" because the code didn't previously pass the aux vars. Why wouldn't you need the aux vars (I realize they weren't passed before)? Is that because technically they are just (roughly) the derivatives of the primal fields? If so, I'm a bit confused that stability and well-posedness aren't adversely affected by never using the aux variables, though explaining that is beyond the scope of a GitHub comment, I think ;)
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.
Previously I didn't pass
(i) the auxiliary sources, because they are "usually" just the auxiliary vars, i.e. when no Christoffel-terms need to be added (e.g. consider the Poisson auxiliary equation -grad(u) + v = 0
where the sources are just v
. Remember the auxiliary equation essentially defines the aux vars, which is why the aux vars are always its sources). The aux sources are set to the aux vars just a few lines above.
(ii) the auxiliary variables, because none of the systems that are currently implemented needs to compute non-trivial sources: Both the Poisson and the (linear) elasticity equations are only sourced by a fixed function f(x).
In the comments I say "instead of" because the sources are a function of the variables (primal and auxiliary), but instead of the aux vars I pass the primal fluxes as an optimization, as we discussed before.
Does this clear things up?
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.
Yes, but I think this lengthy discussion suggests that you should either remove the instead of
or expand on it in both the docs and the git message
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.
Adjusted the commit message and the code comment in the fixup commit, please take a look.
@@ -94,7 +94,9 @@ struct Sources { | |||
using argument_tags = tmpl::list<>; | |||
static void apply( | |||
const gsl::not_null<tnsr::I<DataVector, Dim>*> source_for_displacement, | |||
const tnsr::I<DataVector, Dim>& /*displacement*/) noexcept { | |||
const gsl::not_null<tnsr::ii<DataVector, Dim>*> /*source_for_strain*/, | |||
const tnsr::I<DataVector, Dim>& /*displacement*/, |
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.
Okay, I can't speak to what would be most intuitive for people used to the elasticity literature, so I'll have to take your word for it :)
4c46932
to
7fe91fc
Compare
@nilsdeppe could you check the fixup? I adjusted the commit message and the code comment |
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.
Looks good. Please go ahead and squash!
More involved systems such as XCTS need all variables to compute source terms. We pass the computed volume fluxes to the source computers as an optimization so they don't have to be re-computed.
7fe91fc
to
8ef75ee
Compare
Rebased and squashed. Thanks for your reviews @nilsdeppe and @wthrowe. |
@wthrowe I think this is ready to go when you get the chance |
Proposed changes
More involved systems such as XCTS need all variables to compute source terms.
Upgrade instructions
Elliptic/FirstOrderOperator.hpp
have changed.Types of changes:
Component:
Code review checklist
clang-tidy
.For instructions on how to perform the CI checks locally refer to the Dev
guide on the Travis CI.
make doc
to generate the documentation locally intoBUILD_DIR/docs/html
.Then open
index.html
.code review guide.
Further comments