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

Add CCE system equations #1397

Merged
merged 3 commits into from Jul 31, 2019
Merged

Conversation

moxcodes
Copy link
Contributor

@moxcodes moxcodes commented Feb 26, 2019

Proposed changes

This PR adds the Cauchy characteristic extraction system equations, which compute the set of inputs to the hypersurface integration routine, and represent the core of the physics at work here.

The equations I've implemented are complicated and have been adjusted to the computational task from the equations in the literature. If any of the reviewers want to be thorough and check the form of the equations themselves (and not simply trust the forms in the documentation), please just leave a comment to that effect and I will create a repository which contains my notes and Mathematica document to produce these results. I would not recommend any reviewer investing the time needed to verify the form of the equations without those reference materials.

Types of changes:

  • New feature

Component:

  • Code
  • Documentation

Code review checklist

  • The PR passes all checks, including unit tests, clang-tidy and IWYU.
    For instructions on how to perform the CI checks locally refer to the Dev
    guide on the Travis CI
    .
  • The code is documented and the documentation renders correctly. Run
    make doc to generate the documentation locally into BUILD_DIR/docs/html.
    Then open index.html.
  • The code follows the stylistic and code quality guidelines listed in the
    code review guide.

Dependencies

@@ -212,6 +212,32 @@ struct ToPyObject<DataVector, std::nullptr_t> {
}
};

template <>
Copy link
Member

Choose a reason for hiding this comment

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

I'd recommend factoring this commit out since it'll be easier to get in and should have different reviewers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes good sense 👍. I was struggling with whether I should ask @osheamonn for this one because of this change.

@moxcodes moxcodes added dependent Needs a different PR to be merged in first and removed dependent Needs a different PR to be merged in first labels Feb 26, 2019
hrueter
hrueter previously requested changes Mar 4, 2019
Copy link
Contributor

@hrueter hrueter left a comment

Choose a reason for hiding this comment

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

group review by @nilsleiffischer (main), @hrueter
We did not yet review the full PR.

If you think it would be hard to follow the calculation in the documentation please either make the documentation self-contained or add your notes as TeX files to the /docs. They are not yet automatically built when building the documentation. If you think it makes sense to add provide the Mathematica notebooks in the documentation, we propose to publish them in a separate repository. Assign them a DOI and link them from our documentation. (use e.g. zenodo )

docs/References.bib Outdated Show resolved Hide resolved
static std::string name() noexcept { return "Beta"; }
};

/// Bondi parameter \f$J\f$
Copy link
Contributor

Choose a reason for hiding this comment

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

J -> H

What is H actually? We can't find it in the Handmer paper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, apparently notation has diverged for this quantity, and the Handmer paper doesn't discuss the procedure in detail. I'll add more explanatory detail to this comment 👍.

};

/// Bondi parameter \f$J\f$
struct H : db::SimpleTag {
Copy link
Contributor

Choose a reason for hiding this comment

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

We suggest naming these BondiH, BondiJ, ...

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 have a mild preference for keeping the tags brief, due to the effect of expanding the already very long tag lists in Equations.hpp. The names are consistently used in CCE, and anything that accesses these tags outside the CCE module will need to access them by Cce::Tags::H etc, so I think it is sufficiently disambiguated.

Copy link
Member

Choose a reason for hiding this comment

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

I’d still prefer BondiH, BondiJ etc, just to avoid single-letter type names that have the possibility of being hard to search-and-replace. I’d also like the other reviewers @markscheel @nilsdeppe to weigh in here before you make the change.

Copy link
Member

Choose a reason for hiding this comment

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

Yea, I hate single letter things. With tags I don't feel as strongly because they're always prefixed with Tags::, but I still am not a fan of it. Since currently there apparently is a comment "Bondi parameter tags` necessary, @nilsleiffischer's suggestion also removes the need for that comment.

/// A prefix tag representing a quantity that will appear on the right-hand side
/// of an explicitly regular differential equation
template <typename Tag>
struct IntegrandFor : db::PrefixTag, db::SimpleTag {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove For. This is implied by the prefixing.

src/Evolution/Systems/Cce/Tags.hpp Outdated Show resolved Hide resolved
/// represent some of the cached quantities for CCE. Note that the spins are
/// added.
template <typename LhsTag, typename RhsTag>
struct Times : db::PrefixTag, db::SimpleTag {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like being general to spin weighted quantities. So better move to DataStructures/Tags.hpp or DataStructures/SpinWeighted.hpp?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or perhaps wait until this is needed elsewhere?

/// Temporary scalars for particular spin weights.
template <size_t index, int spin>
struct TemporarySpinWeightedScalar : db::SimpleTag {
using type = Scalar<SpinWeighted<ComplexDataVector, spin>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

We propose to add a spinweighted prefix tag to DataStructures/Tags.hpp, that swaps the type of a tensor with a spinweighted type. Then you can use the TempBuffer with the aliases from Datastructures/Variables.hpp.

};

// Additional values which are frequently used in CCE calculations, and
// therefore worth caching
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these go into a detail namespace? Maybe in a separate file?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we've put tags into detail namespaces very often (ever?). My issue with moving these into a detail namespace is that they then won't show up in Doxygen and nobody will be able to find them without reading the code.

template <typename BondiAndSWCacheTagList, typename DerivativeTagList,
typename IntegrandTagList, typename SecondaryTagList,
typename TemporaryTagList>
void evaluate(
Copy link
Member

@nilsvu nilsvu Mar 5, 2019

Choose a reason for hiding this comment

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

As discussed at the call yesterday, a comment of ours for some reason didn't make it into the review. We suggested to make this conform to the existing db::mutate_apply mechanism, see also #1413 (that PR only makes that mechanism easier to use, it works already fine right now). Let's talk in a hangout if anything is unclear.

Copy link
Contributor

@fmahebert fmahebert left a comment

Choose a reason for hiding this comment

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

Review with @markscheel (primary) and @moxcodes. We looked at the Tags.hpp and did a brief overview of the equations. Still more review needed.

@@ -0,0 +1,255 @@
// Distributed under the MIT License. See LICENSE.txt for details.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be two (2) lines

... how did this even get committed?

};

/// Bondi parameter \f$K^2 = 1 + J \bar{J}\f$
struct KSquared : db::SimpleTag {
Copy link
Contributor

Choose a reason for hiding this comment

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

@moxcodes notes to self: check if this is used.

struct Dy : db::PrefixTag, db::SimpleTag {
using type = Scalar<SpinWeighted<ComplexDataVector, Tag::type::type::spin>>;
using tag = Tag;
static const size_t dir = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Please use a clearer name. Suggest: dimension_to_differentiate
  • Perhaps open an issue to add documentation that an assumption is made about the (phi, theta, r) ordering of the CCE coordinates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Issue created and assigned to me.


/// A prefix tag representing the contribution to a differential equation which
/// has a contribution of a nontrivial linear operator in addition to the
/// differential operator
Copy link
Contributor

Choose a reason for hiding this comment

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

For ease of reading, suggest: "A prefix tag representing a linear operator that acts on Tag"

Also include the equation in the documentation (here? elsewhere?), because the tag is specialized to a particular differential equation (note, e.g., the hardcoded spin).


/// A prefix tag representing the contribution to a differential equation which
/// has a contribution of a nontrivial linear operator acting on the conjugate
/// of the quantity being solved for in addition to the differential operator
Copy link
Contributor

Choose a reason for hiding this comment

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

"A prefix tag representing a linear operator that acts on the conjugate of Tag"

};

/// The value \f$\exp(2\beta)\f$, which is used frequently in the Bondi
/// computations.
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop second half of comment, it isn't very illuminating. Same on following tag.


/// The value \f$ J (\bar{Q} - 2 \bar{\eth} \beta ) \f$, which must be computed
/// as an intermediate step to CCE equations.
struct JbarQMinus2EthBeta : db::SimpleTag {
Copy link
Contributor

Choose a reason for hiding this comment

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

Convention so far has been to use tag name Xbar for \bar{X}, so fix doxygen and/or tag name for consistency. Or rename to SadTag.

/// \brief A struct for providing a tmpl::list of integrand tags that need to be
/// computed before integration can proceed for a given Bondi variable tag.
template <typename BondiVariable>
using integrands_to_compute_for_bondi_variable =
Copy link
Contributor

Choose a reason for hiding this comment

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

integrands -> integrand_terms (globally)

};
template <>
struct tags_needed_for_integrand_computation_impl<
Tags::IntegrandFor<Tags::Beta>, TagsCategory::Secondary> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Secondary -> IndependentOfIntegration or similar


template <>
struct tags_needed_for_integrand_computation_impl<
Tags::IntegrandFor<Tags::Beta>, TagsCategory::BondiAndSWCache> {
Copy link
Contributor

Choose a reason for hiding this comment

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

BondiAndSWCache -> TagsToSwshDifferentiate

Copy link
Member

@nilsvu nilsvu left a comment

Choose a reason for hiding this comment

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

I think the move of the implementations into the cpp file worked out great 👍 A few more comments on the overall structure below. Also I think it would be good to "activate" the second reviewer, to get a second opinion and make sure we are converging to a state that will be merged. @markscheel would you review this?

@@ -169,6 +169,37 @@ @book{Hartle2003gravity
url = "https://www.pearson.com/us/higher-education/program/Hartle-Gravity-An-Introduction-to-Einstein-s-General-Relativity/PGM298455.html",
}

@article{Bishop1997ik,
Copy link
Member

Choose a reason for hiding this comment

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

Please sort alphabetically (see guidelines linked at the top of this file)

src/DataStructures/Tags.hpp Show resolved Hide resolved

namespace Cce {
// suppresses doxygen problems with these functions
///\cond
Copy link
Member

Choose a reason for hiding this comment

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

add space /// \cond, also you don't need the explanatory comment, this is done at a lot of places in the code

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 one I felt should have a comment, as dox is usually not rendered for cpp, but there appears to be a small bug in doxygen tackling this file.

// clang-tidy readability-avoid-const-params-in-decls, but the consts must
// stay
static void apply(
const gsl::not_null<SpinWeighted<ComplexDataVector, 0>*> // NOLINT
Copy link
Member

Choose a reason for hiding this comment

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

I think you can remove the consts here, you only need them in the cpp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is not true for this scenario, because the calling interface in this case needs to know that it is passing to a function with const arguments (otherwise it can't rely on the function it calls to not mutate its own const arguments). At any rate, I wanted to avoid the long list of nolint's and it does not compile without the const :P

Copy link
Member

Choose a reason for hiding this comment

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

Modulo a compiler bug this is not how const works. You can safely remove the const on the not_null arguments in the forward declarations, there's no need to NOLINT anything. On the arguments that are references, the const matters. I tested this that it compiles the Cce and Test_Cce libraries clang7 and gcc6. We also do not const the not_null arguments everywhere else in the entire repository and have never had to NOLINT anything. We actually use not_null so we don't have to NOLINT.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fortunately, this also can be reverted to standard use now that the Variables interface has been dropped.

@@ -0,0 +1,195 @@
# Distributed under the MIT License.
Copy link
Member

Choose a reason for hiding this comment

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

As of the guidelines introduced in #1382 please name the Python file the same as the cpp test file, without the Test_ prefix.

src/Evolution/Systems/Cce/Equations.hpp Show resolved Hide resolved
* `apply` function in the specialization of `ComputeBondiIntegrand`.
*/
template <typename IntegrandTag>
struct MutateComputeBondiIntegrand {
Copy link
Member

Choose a reason for hiding this comment

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

name ComputeBondiIntegrand

* - `temporary_cache` : `Temporary`
*/
template <typename IntegrandTag>
struct ComputeBondiIntegrandFromVariables {
Copy link
Member

Choose a reason for hiding this comment

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

I suggest to move this into test helpers. If we end up needing this in the public interface we can always move it back, but it is not clear to me that we do.

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'd still lean towards keeping at as part of the public interface, if only because the CCE/SWSH interfaces are currently working with the design goal of having interfaces which act on clusters of tags with some mathematical and functional commonality, in order to manage the combinatorically large number of values that appear in the calculations and impose some mild hierarchy. It ends up having a nice connection as well to the way the lists of tags are presented in this namespace, where if the tags were all put into a single large list, it would be more difficult to read and maintain.

If there is consensus that the Variables interface should not be included in src, I will move it to the tests.

Another alternative is to make the templates more general still, and permit them to take an arbitrary template, so this code is equally operable for sets of Variables or TaggedTuples.

Copy link
Member

Choose a reason for hiding this comment

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

I'd like to get input from the other reviews on this. My intention here is to not make the interface unnecessarily complex before we know we need that functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, I'm happy to have other input for this one.

My main point is just that while it's conceptually simple to just take a bunch of arguments, it will tend to be a frustrating interface to mechanically use for calling code for the large number of arguments for some of these.

@hrueter @fmahebert @markscheel opinions?

Copy link
Member

Choose a reason for hiding this comment

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

Right, so I think we agree that calling these functions with a list of arguments is conceptually nice and clean, but cumbersome when one has to write it out. That is, however, why we have the struct with the argument_tags typelist, so that you can just hand the struct over to the DataBox and have it sort out the arguments for you. I suggest you look at the GeneralizedHarmonic code and tests for an example. Those are just structs with a plain argument_tags list and an apply function that takes those arguments.

When we discussed this last week you mentioned you are worried about having to call the functions explicitly in tests, which is why I suggested to move this "short-cut" code with the categories and Variables to the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From separate discussion, we concluded that it will be best to move these to the test helpers for this PR as suggested by @nilsleiffischer .

@nilsvu
Copy link
Member

nilsvu commented Mar 8, 2019

Oh @markscheel sorry I didn't realised you already reviewed this as part of the group review posted by @fmahebert

@moxcodes
Copy link
Contributor Author

moxcodes commented Mar 8, 2019

Fixups posted for all points aside from moving the Variables to a test helper. The last point, I'll implement and post separately the chosen solution once the discussion is resolved.
Thanks for the reviews!

@kidder
Copy link
Member

kidder commented Mar 11, 2019

Current status:

Copy link
Member

@nilsvu nilsvu left a comment

Choose a reason for hiding this comment

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

Please squash the fixups and these minor additional changes

@@ -200,6 +190,16 @@ @article{Handmer2014qha
url = "https://doi.org/10.1088/0264-9381/32/2/025008"
}

@book{Hartle2003gravity,
Copy link
Member

Choose a reason for hiding this comment

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

remove the leading whitespace please

* \brief An interface to ComputeBondiIntegrand which is convenient for passing
* around clusters of bondi quantities in `Variables`
* \brief An interface to ComputeBondiIntegrandImpl which is convenient for
* passing around clusters of bondi quantities in `Variables`
Copy link
Member

Choose a reason for hiding this comment

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

Bondi

#ifndef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#endif // __clang__
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if this is the best-practice way to do this, so perhaps another reviewer can confirm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean specifically the #ifndef __clang__ to select compiler? This was the method I was advised to use for a compiler-specific warning in #1145 , though the warning was ultimately removed by other changes, but I'm happy to entertain other methods.

IntegrandTag, TagsCategory::IndependentOfBondiIntegration>>;

template <typename... Args>
static void apply(Args... args) noexcept {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

const & or &&

Copy link
Contributor Author

@moxcodes moxcodes left a comment

Choose a reason for hiding this comment

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

A summary of the conclusions from discussion with @nilsdeppe and @nilsleiffischer for the last few changes to these utilities.

* - `temporary_cache` : `Temporary`
*/
template <typename IntegrandTag>
struct ComputeBondiIntegrandFromVariables {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

From separate discussion, we concluded that it will be best to move these to the test helpers for this PR as suggested by @nilsleiffischer .

* `SpinWeighted<ComplexDataVector, N>`s for each of the Bondi arguments.
*/
template <typename IntegrandTag>
struct ComputeBondiIntegrandImpl;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The convenience impl should instead be a impl function moved in the ComputeBondiIntegrand function.


// - Tags for Linear operator that acts on the conjugate of H
template <>
struct tags_needed_for_integrand_computation_impl<
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These type aliases, for each term, should be a single struct, and the collections of tags should probably be placed in a separate file.

using bondi_integrand_tag = typename decltype(y)::type;
using bondi_integrand_argument_list =
all_arguments_for_integrand<bondi_integrand_tag>;
// check the Variables interface
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once the Variables interface is in a test helpers, this comment should give a few more details as to why we are testing this way (i.e. to allow the test to use the equations without using a databox and without manually specifying each of the functions and each of the numerous arguments for each of those functions).

@moxcodes moxcodes force-pushed the cce_equations branch 2 times, most recently from d6e8f70 to 6e78272 Compare March 20, 2019 20:58
@moxcodes
Copy link
Contributor Author

Fixups posted and rebased. The only remaining fixup commit is the one regarding the discussion about the Variables helper and the accompanying typedefs.

class ComplexDataVector;
///\endcond

/// Contains system-specific tools for Cauchy Characteristic Extraction.
Copy link
Member

Choose a reason for hiding this comment

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

What do you mean with system-specific here? Perhaps just “functionality” for CCE

* Characteristic hypersurface equations.
*
* \details The template argument must be one of the integrand-related prefix
* tags applied to a Bondi quantity for which that integrand is required. The
Copy link
Member

Choose a reason for hiding this comment

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

The template argument is not the prefix tag itself, but a prefixed tag, if I understand correctly

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'll adjust the later part of the sentence to refer to 'prefix tags templated on a Bondi quantity tag' for improved clarity.

Tags::Integrand<Tags::Beta>>,
swsh_derivative_tags_needed_for_integrand<Tags::Integrand<Tags::Beta>>,
integration_independent_tags_needed_for_integrand<
Tags::Integrand<Tags::Beta>>>;
Copy link
Member

Choose a reason for hiding this comment

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

To build these return and argument tags you now refer to the tags lists in the other file. From our discussion the other day I understood we’d go with another strategy, and if I misunderstood then I’d like to suggest it here:

  • Build the tag lists self-contained within the specialization of ComputeBondiIntegrand. You can split it into buffer_tags or similar, possibly private, type lists to retain the categoristation, if you like.
  • Remove the TagsLists.hpp from this PR, but keep the code around on another branch in case you’ll ever need it.
  • Also remove the integrand_terms_to_compute_for_bondi_variable from this PR but keep the code on another branch. It is part of the code that does the computation, in my opinion, so add it in a PR that makes use of it.

Before you make this change, I’d like the other reviewers to confirm @markscheel @nilsdeppe, so that you don’t waste time

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Provided consensus, I'm fine doing the first two. I'd prefer, however, to keep the integrand_terms_to_compute_for_bondi_variable. It's actually used in the test, and without it being present here, I'd just have to reproduce the same set of types in the test either by direct listing inline or via type aliases there.

src/Evolution/Systems/Cce/Tags.hpp Show resolved Hide resolved
static std::string name() noexcept { return "Beta"; }
};

/// Bondi parameter \f$H = \partial_u J\f$. Note: the notation in the literature
Copy link
Member

Choose a reason for hiding this comment

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

\brief and \note

jbar = np.conj(j)
k_squared = (1.0 + j * jbar)
qbar = np.conj(q)
script_av = eth_beta * eth_jbar + ethbar_ethbar_j / 2.0 \
Copy link
Member

Choose a reason for hiding this comment

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

You take this as an argument but then compute it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a temporary buffer, taken by argument to avoid allocation.

Copy link
Member

Choose a reason for hiding this comment

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

but this is in python, so does that actually work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, oops, I failed to note which file this was commenting on. No, it doesn't have any optimization utility in python. I could name the intermediate step something else, but I still need the argument so that the function signature is the same as the C++, and I still want to compute the intermediate step so that the function is reasonably readable.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe there is a way to comment out the name of the argument like there is in C/C++? Or maybe just name that argument something that makes it clear it's not used?

Copy link
Member

Choose a reason for hiding this comment

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

You can use an underscore _ for unused arguments, that's the convention

int assign_to_tag(
const gsl::not_null<Variables<VariablesTagList>*> all_variables,
const Arg arg) noexcept {
get(get<Tag>(*all_variables)).data() = arg;
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need the data()? Looks dangerous :D

Copy link
Contributor Author

@moxcodes moxcodes Mar 21, 2019

Choose a reason for hiding this comment

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

This is a result of the SpinWeighted wrapper. The outer get obtains a SpinWeighted<ComplexDataVector, N>, and the .data() obtains the ComplexDataVector, which can be assigned regardless of the spin-weight. It's not a pointer, which I suspect is why it feels concerning.

template <typename Tag, typename VariablesTagList, typename Arg>
int assign_to_tag(
const gsl::not_null<Variables<VariablesTagList>*> all_variables,
const Arg arg) noexcept {
Copy link
Member

Choose a reason for hiding this comment

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

const ref

// create a variables which will hold everything
Variables<
tmpl::flatten<tmpl::append<ArgumentTagList, tmpl::list<OutputTag>>>>
all_variables{NumberOfGridPoints, std::complex<double>(10, 57)};
Copy link
Member

Choose a reason for hiding this comment

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

You can remove the second argument to construct with NaNs

integrand_for_beta,
const SpinWeighted<ComplexDataVector, 2>& dy_j, // NOLINT
const SpinWeighted<ComplexDataVector, 2>& j, // NOLINT
const SpinWeighted<ComplexDataVector, 0>& one_minus_y // NOLINT
Copy link
Member

Choose a reason for hiding this comment

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

You have to make sure that the apply function actually take the types of the return and argument tags. Since you want to avoid the many gets to bypass the Scalars, you’ll need an apply and apply_impl or similar, I think @nilsdeppe suggested something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, true. I agree this needs to be fixed.

Copy link
Member

Choose a reason for hiding this comment

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

To make sure this works, I think it would be good to add a test that calls db::mutate_apply. This will be made easier with #1413

@moxcodes
Copy link
Contributor Author

moxcodes commented Apr 1, 2019

new fixups posted. I believe all comments have been addressed aside from expanding the single-character bondi tags to BondiH etc. pending input from @markscheel or @fmahebert . I want to request that @nilsdeppe at least reads the new commit for the compile-time Tensor get for not_null pointers, as it alters Tensor.hpp.

@moxcodes
Copy link
Contributor Author

moxcodes commented Apr 2, 2019

squashed in a fix to get gcc to build

@nilsvu
Copy link
Member

nilsvu commented Apr 26, 2019

@moxcodes I'll be on vacation 1st to 11th of May, so unable to review this in that time. As far as I understand this is still waiting on input by @markscheel, @fmahebert and @nilsdeppe though. If you end up moving this PR forward while I'm away, please feel free to replace me with another reviewer.

@nilsdeppe
Copy link
Member

@moxcodes could you please rebase and squash this, then ping me so I know to look at it? Thanks :)

@moxcodes moxcodes force-pushed the cce_equations branch 2 times, most recently from fcf0160 to 7d2e650 Compare May 14, 2019 16:50
@moxcodes
Copy link
Contributor Author

@nilsdeppe I've squashed the previous fixes and rebased. I've added one fixup in which I remove the Variables business. After the refactor of other utilities, I've seen the light and managed to use the rest of the cce tools in ways more consistent with the DataBox models.

moxcodes added a commit to moxcodes/spectre that referenced this pull request May 23, 2019
@nilsdeppe
Copy link
Member

@nilsleiffischer @hrueter please give feedback on whether you're happy with the changes or not.

Copy link
Member

@nilsvu nilsvu left a comment

Choose a reason for hiding this comment

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

I'm quite happy about how this code is structured now :) thanks for your patience!

Only a few minor things:

src/Evolution/Systems/Cce/Tags.hpp Outdated Show resolved Hide resolved
src/Evolution/Systems/Cce/Tags.hpp Outdated Show resolved Hide resolved
src/Evolution/Systems/Cce/Tags.hpp Show resolved Hide resolved
tests/Unit/Evolution/Systems/Cce/Equations.py Outdated Show resolved Hide resolved
tests/Unit/Evolution/Systems/Cce/Equations.py Outdated Show resolved Hide resolved
tests/Unit/Evolution/Systems/Cce/Test_Equations.cpp Outdated Show resolved Hide resolved
tests/Unit/Evolution/Systems/Cce/Test_Equations.cpp Outdated Show resolved Hide resolved
tests/Unit/Evolution/Systems/Cce/Test_Equations.cpp Outdated Show resolved Hide resolved
@moxcodes
Copy link
Contributor Author

@nilsleiffischer @fmahebert I've posted fixups for the last few comments.
Cheers

@fmahebert
Copy link
Contributor

The fixups LGTM

Copy link
Member

@nilsvu nilsvu left a comment

Choose a reason for hiding this comment

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

This looks pretty much done to me. Sorry for not checking the fixups earlier, please rebase on develop and squash. Then, make sure Travis is happy and ping @sxs-collaboration/spectre-core-devs to get this finally merged :)

Copy link
Contributor

@markscheel markscheel left a comment

Choose a reason for hiding this comment

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

All minor documentation changes.

I did not try to check the equations themselves (ugh); that's what the tests are for...

src/DataStructures/Tags.hpp Show resolved Hide resolved
src/Evolution/Systems/Cce/Tags.hpp Outdated Show resolved Hide resolved
src/Evolution/Systems/Cce/Equations.hpp Outdated Show resolved Hide resolved
src/Evolution/Systems/Cce/Equations.hpp Outdated Show resolved Hide resolved
src/Evolution/Systems/Cce/Equations.hpp Outdated Show resolved Hide resolved
src/Evolution/Systems/Cce/Equations.hpp Outdated Show resolved Hide resolved
src/Evolution/Systems/Cce/Equations.hpp Outdated Show resolved Hide resolved
src/Evolution/Systems/Cce/Equations.hpp Outdated Show resolved Hide resolved
src/Evolution/Systems/Cce/Equations.hpp Outdated Show resolved Hide resolved
src/Evolution/Systems/Cce/Equations.hpp Outdated Show resolved Hide resolved
@moxcodes
Copy link
Contributor Author

@markscheel I've posted fixups for all of the suggestions.
Cheers!

@moxcodes
Copy link
Contributor Author

@markscheel Just waiting for the go-ahead before I squash the fixups.
Thanks!

@markscheel
Copy link
Contributor

please squash!

- previously the Tags::SpinWeighted prefix tag and Tensors of spin-weighted
  quantities could not be easily put into a DataBox
- add tags for relevant CCE quantities
- add computation methods for CCE integrands
@moxcodes
Copy link
Contributor Author

squashed (and rebased)
Cheers!

@kidder
Copy link
Member

kidder commented Jul 26, 2019

@hrueter @nilsleiffischer @fmahebert @markscheel this should be ready for final approval. Please only request changes for obvious errors, anything else, just comment and @moxcodes can decide to address them or make an issue.

Copy link
Member

@nilsvu nilsvu left a comment

Choose a reason for hiding this comment

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

@moxcodes What I think is missing for these equations are tests that do not rely on the Python implementation, but work with some honest, hard-coded numbers that were computed externally. This is to make sure the C++ and Python implementation don't have the same bug, which can easily happen when coding them up. This was discussed briefly in this review before. Please consider adding such tests soon, perhaps make an issue for the record.

@@ -909,7 +909,7 @@ struct Subitems<TagList, Tag,

namespace Tags {
template <size_t N, typename T>
struct TempTensor {
struct TempTensor : db::SimpleTag {
Copy link
Member

Choose a reason for hiding this comment

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

@nilsdeppe is this resolved for you?

@moxcodes
Copy link
Contributor Author

@nilsleiffischer This pull request alone doesn't have enough of the CCE infrastructure to have useful comparisons against hand-computed quantities. I agree that those checks are important (some already exist on my own branch), so I've created issue #1641 as a reminder to prioritize those tests once the CCE code is capable of them.

@moxcodes
Copy link
Contributor Author

@sxs-collaboration/spectre-core-devs since @nilsleiffischer was the primary on the 'request changes' from @hrueter , I think this one is actually good to go?

@kidder kidder dismissed hrueter’s stale review July 31, 2019 20:07

@hreuter's comments were addressed and made as part of review led by @nilsleiffischer that @NilsL

@kidder kidder merged commit a36f01e into sxs-collaboration:develop Jul 31, 2019
moxcodes added a commit to moxcodes/spectre that referenced this pull request Aug 23, 2019
moxcodes added a commit to moxcodes/spectre that referenced this pull request Sep 24, 2019
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

7 participants