-
Notifications
You must be signed in to change notification settings - Fork 5
Matter: Port Matter classes (with unit tests) #94
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
base: develop
Are you sure you want to change the base?
Conversation
This PR modifies the following files which are ignored by .lint-ignore:
Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
This PR modifies the following files which are ignored by .lint-ignore:
Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
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.
Thanks for this PR Juliana.
It looks pretty good but I have some comments. I know there are a fair few of them but I think most of them should be easy to resolve and the more complicated ones I will try and look at myself.
For the GRChombo HDF5 files you have generated for the tests, where is the code you used to create them? I couldn't find a relevant branch in the GRChombo repo.
I don't think the Tests/MatterWeyl4Test/GRChomboEMTensorTest.h5
file is needed/used so could you remove it as well?
Would you also be able to fix the commit history by applying the fixup
s?
Source/Matter/EMTensor.hpp
Outdated
/// 3 components for the momentum density: m_11, m_22, m_33 | ||
/// 6 components for the stress energy tensor (symmetric): s_11, s_12 etc. | ||
static inline const amrex::Vector<std::string> extra_var_names = { | ||
"m_11, m_22, m_33, s_11, s_12, s_13, s_22, s_23, s_33"}; |
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. We have always used Si and Sij but here that naming might be confusing. We could use J instead, so then it would be J1,J2,J3, S11, S12 etc. Maybe let's leave this for the naming tidy up as it would be best to be consistent throughout the code.
Source/Matter/EMTensor.impl.hpp
Outdated
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 would be good. I always found the passing of intervals in the constructor a bit ugly and confusing.
Source/Matter/MatterConstraints.hpp
Outdated
class [[deprecated("Use new MatterConstraints class in " | ||
"NewMatterConstraints.hpp")]] MatterConstraints | ||
: public Constraints | ||
template <class matter_t> class MatterConstraints : public Constraints |
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.
Maybe it is nicer for this to be called ConstraintsWithMatter, and similarly CCZ4RHSWithMatter, Weyl4WithMatter etc but we can do this in the tidy up if it is controversial. The advantage is that the files don't then all start with Matter, which is a bit annoying for tab complete. I also find it more readable.
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 would be fine with this change so long as it is done consistently. We might as well do it now given this whole PR is about matter.
5e527e5
to
2b7a3ce
Compare
This PR modifies the following files which are ignored by .lint-ignore:
Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
1c36aac
to
a44ef5d
Compare
This PR modifies the following files which are ignored by .lint-ignore:
Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
1 similar comment
This PR modifies the following files which are ignored by .lint-ignore:
Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
50c4e2b
to
dcf4ae8
Compare
This PR modifies the following files which are ignored by .lint-ignore:
Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
This PR modifies the following files which are ignored by .lint-ignore:
Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
Hi all - I think I have addressed everyone's comments now (and the lint checks have finally passed). Could you please review this PR again and double check that you are happy with everything? Main changes are:
|
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.
Thanks for making the changes, Juliana. Just a couple more minor changes.
Source/Matter/EMTensor.hpp
Outdated
static inline const amrex::Vector<std::string> extra_var_names = { | ||
"Sij_11, Sij_22, Sij_33, Sij_11, Sij_12, Sij_13, Sij_22, Sij_23, " | ||
"Sij_33"}; |
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 we've agreed on the following names.
static inline const amrex::Vector<std::string> extra_var_names = { | |
"Sij_11, Sij_22, Sij_33, Sij_11, Sij_12, Sij_13, Sij_22, Sij_23, " | |
"Sij_33"}; | |
static inline const amrex::Vector<std::string> extra_var_names = { | |
"j_1, j_2, j_3, S_11, S_12, S_13, S_22, S_23, S_33"}; |
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.
Based on this comment:
We should make sure our var names are consistent with the
emtensor_t
struct.
I thought we had decided to make them consistent with the existing names without matter? If you prefer the j's, I can open a pull request to change them both?
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.
Let's just change it to my suggestion in the emtensor_t
struct in this PR.
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 change the emtensor_t
struct in CCZ4Geometry.hpp to
template <class data_t> struct emtensor_t
{
Tensor<2, data_t> S; //!< S_ij = T_ij
Tensor<1, data_t> j; //!< j_i = T_ia_n^a
data_t trS; //!< trS = S^i_i
data_t rho; //!< rho = T_ab n^a n^b
};
and modify where this struct appears accordingly?
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 opened a new PR for this (#117) because CCZ4Geometry.hpp
wasn't part of this original PR. I will change in this PR once that has been accepted and merged.
da3ee70
to
47a3a61
Compare
This PR modifies the following files which are ignored by .lint-ignore:
Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
47a3a61
to
20562ea
Compare
Hi @mirenradia - I believe I have addressed all your comments now. Can you please take another look at this PR? Thanks! |
This will also modify the current implementation of Weyl4::set_up and Weyl4::calculate_mf to be inline (so header can be included with MatterWeyl4 without multiple definitions). It also changes the private members of Weyl4 to be protected, so that MatterWeyl4 can access the derivatives and epsilon3_U_LL and EB fields calculated by Weyl4.
This test will check the calculation of Ham and Mom against a previously calculated set in GRChombo. It will also change the private class members of Constraints to protected and inline the Constraints::set_up and Constraints::calculate_mf so they can be inherited by the matter versions.
Previously, the HDF5 files were written in serial so the CI runs with MPI would fail. Also added MatterWeyl4::set_up and MatterWeyl4::compute_mf functions.
- Calculate MatterWeyl4 and EMTensor by adding these to derive_lst using new MultiFab version of looping over the calculate function - Add set_up function to MatterWeyl4 to set up derive_lst - Add default constructor to ScalarField class
There were some leftover GRChombo characteristics in the calls to Cell in the compute function so I've cleaned these up in this commit. I also fixed a bug where I had mixed up the rhs as Vars and the rhs as an Array4.
This commit adds: - a set_up function to add the energy density, momemtum density and spatial stress-energy tensor as components of derive_lst - compute_mf a wrapper to the compute function which is called by AMReX whenever a derived variable needs to be calculated.
This commit will: - introduce a set_up function that adds "Weyl4_Re" and "Weyl4_Im" to the derive_lst for matter classes. - wrap the compute function inside compute_mf which is called by AMReX whenever the derived variable are needed.
This commit will: - introduce a set_up function for adding "Ham", "Mom1", "Mom2", and "Mom3" (or alternatively "Ham" and "Mom" normalized) to the derive_lst - introduce a compute_mf wrapper that will calculate the above whenever required by AMReX.
This commit will: - Call compute_mf to calculate derived varables - Refactor the HDF5 output to be consistent with the other unit tests (and update the relevent HDF5 files).
This commit will: - Pull out the test for rho from the MatterWeyl4 unit test into its own test case - Test the outputted values of rho calculated by EMTensor against values calculated by GRChombo - Test the outputted values of chi calculated by ChiRelaxation against values calculated by GRChombo - Add the GRChombo .h5 files for comparison - Add these two new test cases to the list in TestCases.hpp
This commit will: - Add an #if statement around HDF5 parts so they are not compiled if USE_HDF5=FALSE - Also, fix Lint errors
This commit will: - fix the bug in GRChombo with the gauge calculation in MatterCCZ4
This commit will: - Add the definition of phi and Pi to the common header file - Refactor the tests to use these definitions. I noticed that the BSSN Matter test and the chi relaxation test were using different initial conditions from the other so I had to update the HDF5 file outputs as well.
This commit will also: - Rename G_newton to G_Newton in the BSSN Matter test
This commit will: - Switch ordering of naming convention, so MatterCCZ4RHS becomes CCZ4RHSWithMatter, MatterConstraints becomes ConstraintsWithMatter, MatterWeyl4 becomes Weyl4WithMatter Matter: Remove matter object from constructor I forgot to remove the matter object in the constructor for CCZ4RHSWithMatter!
There is now a separate branch for the ChiRelaxation class
This will update the naming convention of emtensor_t: - The trace of the spatial stress energy tensor is now trS - The spatial stress energy tensor itself is now S - The momentum vector is now j
20562ea
to
8c30fcb
Compare
This PR modifies the following files which are ignored by .lint-ignore:
Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted. |
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 am happy with this PR, I made two minor suggestions for you to consider @julianakwan but I don't feel strongly about them, so whatever you think! Let's get this merged and do the tidy up!
/// This class adds the matter terms to the RHS of the gauge equation | ||
/// for the moving puncture gauge | ||
|
||
class MovingPunctureGaugeWithMatter : public MovingPunctureGauge |
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.
In the original code, we just added this function into the MovingPunctureGauge class, and didn't inherit to a matter version... I can see it is a bit inconsistent with the structure of the CCZ4/CCZ4Matter classes, but it means fewer files and I don't think it should cause issues, or am I missing something?
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 did this because I thought it was tidier to have everything to do with matter in the Source/Matter
directory. It doesn't cause any issues otherwise, it was just an issue of consistency so non-matter people can freely ignore the matter stuff if they choose to :)
@@ -107,7 +109,8 @@ template <class potential_t> | |||
template <class data_t, template <typename> class vars_t, | |||
template <typename> class diff2_vars_t, | |||
template <typename> class rhs_vars_t> | |||
void ScalarField<potential_t>::matter_rhs_excl_potential( | |||
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void | |||
ScalarField<potential_t>::matter_rhs_excl_potential( |
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 know that I did this - separating out the rhs and emtensor with and without potential - but now I can't remember why! I think it was to enable doing complex fields, but now we do that without any inheritance from the real fields, which is tidier. This just adds another long function definition that doesn't do much in the body of the function and that makes the code messier. Maybe we should just combine them?
This PR completes my port of the
Matter
classes and closes #10 . It includes:MatterCCZ4
ScalarField
andDefaultPotential
classesWeyl4_Re
andWeyl4_Im
for aMatter
classMatter
classesNewMatterConstraints
to justMatterConstraints
.Matter
directory from the list of ignored files in.lint_ignore