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

adding mass to bulk velocity #783

Merged
merged 3 commits into from
Dec 2, 2023
Merged

Conversation

nicolasaunai
Copy link
Member

@nicolasaunai nicolasaunai commented Nov 21, 2023

#782

Summary by CodeRabbit

  • New Features

    • Added a search functionality to the app.
  • Bug Fixes

    • Corrected the initialization of the ionMassDensity field to ensure proper data handling.
  • Refactor

    • Streamlined resource management and ghost refinement framework to integrate new mass density field.
    • Updated various functions to accommodate new mass density calculations and data structures.
  • Documentation

    • Clarified the purpose and impact of new features and enhancements in the release notes for end-users.

Copy link

coderabbitai bot commented Nov 21, 2023

Warning

Rate Limit Exceeded

@nicolasaunai has exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 22 minutes and 6 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 501fb3b and 3a002f6.

Walkthrough

The changes across the codebase involve the introduction of mass density calculations for ion populations, with adjustments to accommodate different masses within populations. A new Float type alias is added, and various functions and classes are updated to handle mass density data. Tests are modified to reflect these changes, and some build configurations are adjusted. Additionally, there are updates to ensure the use of std::size_t for non-negative values and some refactoring for better type consistency.

Changes

File(s) Summary
src/core/data/ions/ions.hpp Added Float type alias, massDensity_ field, computeMassDensity() function, and logic to handle different population masses.
tests/core/numerics/ion_updater/test_updater.cpp Added ionMassDensity field to IonsBuffers struct and updated constructors and setBuffers function.
src/amr/messengers/.../hybrid_hybrid_messenger_strategy.hpp Integrated new massDensityOldUser_ resource and related functions for managing mass density data.
src/amr/messengers/hybrid_messenger_info.hpp Added modelIonMassDensity member variable.
src/amr/physical_models/hybrid_model.hpp Included new modelIonMassDensity field in hybridInfo structure.
tests/simulator/test_restarts.py Updated test cases with new functions and dictionary entries for velocity and mass, and adjusted parameters.
.github/workflows/cmake_ubuntu.yml Modified CMake build configuration to enable development mode.
pyphare/pyphare/pharein/__init__.py Updated functions to check for non-negative values and raise errors if negative.
res/cmake/def.cmake Adjusted CMake flags based on the compiler and added flags in devMode.
src/core/data/particles/particle_packer.hpp Changed Particle object initialization to uniform initialization syntax.
src/core/utilities/types.hpp Added overloads for float_equals and allowed custom predicate functions for all, any, and none.
src/python3/CMakeLists.txt Updated compile options and added preprocessor definitions for cpp_dbg target.
tests/amr/.../test_messengers.cpp, tests/amr/models/test_models.cpp, tests/amr/resources_manager/test_resources_manager.cpp, tests/amr/tagging/test_tagging.cpp, tests/core/data/electrons/test_electrons.cpp, tests/core/data/ions/test_ions.cpp, tests/diagnostic/test_diagnostics.hpp, tests/initializer/test_initializer.cpp Changed type from int to std::size_t for nbrPopulations and other related variables.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

@nicolasaunai nicolasaunai force-pushed the bulkvelpop branch 3 times, most recently from 4906a2d to 9b4195e Compare November 22, 2023 14:47
@nicolasaunai nicolasaunai force-pushed the bulkvelpop branch 3 times, most recently from 49e37b1 to e262158 Compare November 22, 2023 20:22
@nicolasaunai nicolasaunai marked this pull request as ready for review November 22, 2023 20:28
if (!sameMasses_)
computeMassDensity();
auto const& density = (sameMasses_) ? rho_ : massDensity_;

bulkVelocity_.zero();
auto& vx = bulkVelocity_.getComponent(Component::X);
Copy link
Member Author

@nicolasaunai nicolasaunai Nov 22, 2023

Choose a reason for hiding this comment

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

not sure why I can't do

auto& [vx, vy, vz] = bulkVelocity_();

@nicolasaunai nicolasaunai changed the title wip adding mass to bulk velocity adding mass to bulk velocity Nov 22, 2023
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 4

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 43c40cc and 1540ea6.
Files selected for processing (2)
  • src/core/data/ions/ions.hpp (7 hunks)
  • tests/core/numerics/ion_updater/test_updater.cpp (5 hunks)
Additional comments: 9
src/core/data/ions/ions.hpp (7)
  • 28-34: The new type alias Float is introduced to standardize the floating-point type used across the codebase. This is a good practice for maintainability and consistency.

  • 49-54: The constructor now checks if all ion populations have the same mass and sets the sameMasses_ flag accordingly. Ensure that the allSameMass_() function is correctly implemented and that this logic does not introduce any side effects.

  • 106-127: The computeMassDensity() function is added to calculate the mass density of ions. It is important to ensure that the massDensity_ field is properly initialized before this function is called to avoid null pointer dereferences or undefined behavior.

  • 130-172: The computeBulkVelocity() function has been updated to account for different population masses. The use of sameMasses_ to optimize the computation when all populations have the same mass is a good performance consideration. However, ensure that the massDensity_ field is correctly computed before it is used in this function.

  • 180-187: The isUsable() function has been updated to not check massDensity_ as it is for internal use only. This is a reasonable decision, but it is important to ensure that massDensity_ is always in a valid state when it is used internally.

  • 221-226: The getFieldNamesAndQuantities() function now includes "massDensity" in the list of field names and quantities. This change aligns with the new functionality to compute mass density.

  • 233-242: The setBuffer() function has been updated to handle the new "massDensity" buffer. It is crucial to ensure that the buffer names used throughout the codebase are consistent with these changes.

tests/core/numerics/ion_updater/test_updater.cpp (2)
  • 342-347: The copy constructor for IonsBuffers should ensure that the copyData method is called for all member fields. It seems that copyData is not called for protonFx, protonFy, protonFz, alphaFx, alphaFy, alphaFz, Vx, Vy, and Vz. Ensure that these fields are also copied if necessary.

  • 372-378: In the setBuffers method, the buffer for ionMassDensity is set with the identifier "massDensity". This is correct and consistent with the proposed changes to the initialization of ionMassDensity. Ensure that all other parts of the code that reference this buffer are updated accordingly.

src/core/data/ions/ions.hpp Outdated Show resolved Hide resolved
tests/core/numerics/ion_updater/test_updater.cpp Outdated Show resolved Hide resolved
tests/core/numerics/ion_updater/test_updater.cpp Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 43c40cc and da37b36.
Files selected for processing (2)
  • src/core/data/ions/ions.hpp (7 hunks)
  • tests/core/numerics/ion_updater/test_updater.cpp (5 hunks)
Additional comments: 10
tests/core/numerics/ion_updater/test_updater.cpp (3)
  • 259-266: The constructor of IonsBuffers initializes the ionMassDensity field. Ensure that the initialization of this field is consistent with the rest of the codebase and that the ionMassDensity field is being used as intended.

  • 307-314: The copy constructor of IonsBuffers should ensure that the ionMassDensity field is copied correctly. Verify that the copy constructor is being used appropriately and that the ionMassDensity field is handled correctly in all cases where IonsBuffers is copied.

  • 372-378: The setBuffers function of IonsBuffers sets the buffer for the ionMassDensity field. Ensure that the buffer is being set correctly and that the ionMassDensity field is being used as intended in the rest of the codebase.

src/core/data/ions/ions.hpp (7)
  • 28-34: The introduction of the Float type alias within the core namespace is a good practice for code clarity and potential changes to floating-point precision. Ensure that all floating-point types in the codebase are updated to use this alias for consistency.

  • 49-53: The constructor now checks if all ion populations have the same mass and sets the sameMasses_ flag accordingly. Ensure that this flag is correctly used throughout the codebase to optimize calculations when applicable.

  • 106-127: The new computeMassDensity() function correctly computes the mass density of ion populations. Ensure that this function is called before any code that requires the mass density value.

  • 130-171: The computeBulkVelocity() function has been updated to account for different population masses. Ensure that the mass density is computed before calling this function when sameMasses_ is false. Also, verify that the bulkVelocity_ is correctly used in subsequent calculations.

  • 180-187: The comment on lines 183-184 indicates that massDensity_ is for internal use only and is not checked by isUsable(). Ensure that this does not lead to any unintended side effects when massDensity_ is required elsewhere in the code.

  • 221-225: The getFieldNamesAndQuantities() function now includes "massDensity" in the returned properties. Verify that all consumers of this function can handle the new "massDensity" field.

  • 233-242: The setBuffer() function has been updated to handle the "massDensity" buffer. Ensure that the buffer is correctly initialized and used wherever necessary.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between da37b36 and e27d836.
Files selected for processing (5)
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (9 hunks)
  • src/amr/messengers/hybrid_messenger_info.hpp (1 hunks)
  • src/amr/physical_models/hybrid_model.hpp (1 hunks)
  • src/core/data/ions/ions.hpp (7 hunks)
  • tests/simulator/test_restarts.py (3 hunks)
Files skipped from review due to trivial changes (1)
  • src/amr/messengers/hybrid_messenger_info.hpp
Additional comments: 17
src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (7)
  • 121-126: The registration of resources such as Jold_, NiOldUser_, massDensityOldUser_, and ViOld_ is done correctly according to the summary. However, it's important to ensure that these resources are properly managed elsewhere in the codebase, especially during deallocation to prevent memory leaks.

  • 142-147: The allocation of resources for Jold_, NiOldUser_, massDensityOldUser_, and ViOld_ is consistent with the registration. It is crucial to verify that the allocateTime parameter is being used correctly and that the allocated resources are being freed appropriately to avoid memory leaks.

  • 188-194: The registration of massDensityGhostsRefiners_ is consistent with the summary, which indicates the integration of mass density calculations into the ghost node refinement framework. Ensure that the registration of massDensityGhostsRefiners_ is accompanied by the necessary logic to handle the new massDensityOldUser_ resource in other parts of the code.

  • 429-434: The filling of ghost nodes for massDensity is implemented as described in the summary. It is important to ensure that the afterPushTime parameter is being used correctly and that the filling process does not introduce inconsistencies in the simulation data.

  • 546-565: The prepareStep method correctly copies the current state of J, Vi, Ni, and massDensity to their respective "old" versions for use in time interpolation. It is essential to verify that the currentTime parameter is being used correctly and that the copied data is consistent with the simulation's state at that time.

  • 681-690: The registration of time refiners for massDensity is consistent with the summary. Ensure that the fieldRefineOp_ and fieldTimeOp_ operators are correctly implemented to handle the new massDensityOldUser_ resource.

  • 1002-1010: The initialization of Jold_, ViOld_, NiOldUser_, and massDensityOldUser_ is consistent with the summary. It is important to verify that the massDensityOld_ pointer is being managed correctly to prevent potential null pointer dereferences or memory leaks.

src/amr/physical_models/hybrid_model.hpp (1)
  • 149-155: The addition of modelIonMassDensity to hybridInfo is consistent with the summary provided. This change will require that any code using hybridInfo is updated to handle the new modelIonMassDensity field.
src/core/data/ions/ions.hpp (7)
  • 28-34: The addition of the Float type alias is a good practice for maintaining consistency in floating-point precision across the codebase.

  • 49-54: The constructor now checks if all populations have the same mass and sets the sameMasses_ flag accordingly. Ensure that this logic is consistent with the intended behavior of the simulation when populations are added or removed dynamically.

  • 60-95: The density() and massDensity() functions have been added to provide access to the density and mass density data. The error handling for unusable data is consistent and throws an exception, which is good practice.

  • 115-137: The computeMassDensity() function correctly computes the mass density by summing the product of population density and mass. The use of std::transform with a lambda for the accumulation is efficient and clear.

  • 142-182: The computeBulkVelocity() function has been updated to account for varying population masses. The conditional logic based on the sameMasses_ flag is clear and should work as intended. However, ensure that the computeMassDensity() function is called at the appropriate times if populations are added or removed dynamically.

  • 190-197: The isUsable() function has been updated to not check massDensity_ as it is for internal use only. This is a reasonable decision if massDensity_ is indeed not meant to be accessed externally.

  • 232-253: The getFieldNamesAndQuantities() and setBuffer() functions have been updated to handle the new massDensity field. The error handling for invalid buffer names is consistent with the rest of the codebase.

tests/simulator/test_restarts.py (2)
  • 23-25: The comment on line 23 suggests that the dims list might be updated in the future to include more dimensions. Ensure that the permute function and any related code are prepared to handle multiple dimensions when this change occurs.

  • 188-197: The permute function is called with expected_num_levels=1 and expected_num_levels=2, but the comment in the change summary indicates that expected_num_levels was updated from 3 to 1 and from 2 to 1. Verify that the test cases are correctly reflecting the intended levels of refinement for the tests.

tests/simulator/test_restarts.py Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between e27d836 and 6343132.
Files selected for processing (1)
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (9 hunks)
Additional comments: 9
src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (9)
  • 121-126: The registration of massDensityOldUser_ is correct and consistent with the summary.

  • 142-147: The allocation of massDensityOldUser_ is correct and consistent with the summary.

  • 188-194: The registration of massDensityGhostsRefiners_ is correct and consistent with the summary.

  • 429-435: The filling of massDensityGhostsRefiners_ in fillIonMomentGhosts is correct and consistent with the summary.

  • 546-565: The prepareStep method correctly sets the time and copies data for massDensityOldUser_, which is consistent with the summary.

  • 641-646: The postSynchronize method correctly fills the massDensityGhostsRefiners_, which is consistent with the summary.

  • 681-690: The registration of massDensityGhostsRefiners_ in registerGhostComms_ is correct and consistent with the summary.

  • 1055-1061: The GhostRefinerPool for massDensityGhostsRefiners_ is correctly declared and initialized, which is consistent with the summary.

  • 1002-1011: The declaration and initialization of massDensityOldUser_ are correct and consistent with the summary.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 6343132 and 8c01361.
Files selected for processing (3)
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (9 hunks)
  • src/core/data/ions/ions.hpp (7 hunks)
  • tests/simulator/test_restarts.py (9 hunks)
Additional comments: 21
src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (7)
  • 121-126: The registration of resources such as Jold_, NiOldUser_, massDensityOldUser_, and ViOld_ is done correctly in the constructor. However, it is important to ensure that these resources are also properly unregistered when they are no longer needed to avoid memory leaks.

  • 142-147: The allocation of resources within the allocate method is correct. It is important to ensure that the allocated resources are deallocated appropriately when they are no longer in use.

  • 188-194: The registration of the massDensityGhostsRefiners_ is done correctly. It is important to verify that the corresponding de-registration logic is implemented when the level is unregistered or the object is destroyed.

  • 431-433: The commented-out line // massDensityGhostsRefiners_.fill(level.getLevelNumber(), afterPushTime); suggests that there was an intention to fill the mass density ghosts, but it is currently not being done. If this is intentional, the commented code should be removed to avoid confusion. If it is an oversight, the code should be uncommented and verified to work as expected.

  • 546-565: The prepareStep method correctly copies the data from the current state to the old state buffers (Jold_, NiOldUser_, massDensityOldUser_, ViOld_). Ensure that the copied data is used appropriately in subsequent calculations and that the buffers are updated at the correct times to maintain consistency.

  • 681-690: The registration of the massDensityGhostsRefiners_ and velGhostsRefiners_ is done correctly. It is important to verify that the corresponding de-registration logic is implemented when the level is unregistered or the object is destroyed.

  • 1002-1010: The fields NiOld_ and massDensityOld_ are raw pointers that are being wrapped in FieldUser objects (NiOldUser_, massDensityOldUser_). It is crucial to ensure that the memory management for these pointers is handled correctly to prevent memory leaks or dangling pointers.

src/core/data/ions/ions.hpp (6)
  • 28-34: The introduction of the Float type alias is a good practice for maintaining consistency in floating-point precision across the codebase.

  • 49-53: The constructor now initializes the sameMasses_ flag by calling allSameMass_(). Ensure that this flag is correctly updated if populations are dynamically created or modified during the simulation, as indicated in the comment on lines 304-307.

  • 59-94: The density() and massDensity() functions have been updated to throw exceptions if the data is not usable. This is a good practice for error handling, but ensure that these exceptions are caught and handled properly wherever these functions are called.

  • 114-135: The computeMassDensity() function correctly computes the mass density by summing the product of population density and mass. Ensure that the mass density field is initialized before this function is called.

  • 189-196: The isUsable() function does not check massDensity_ because it is for internal use only. Ensure that massDensity_ is always in a valid state when used internally, as it is not checked for usability.

  • 230-253: The getFieldNamesAndQuantities() and setBuffer() functions have been updated to handle the massDensity field. Ensure that the massDensity field is correctly managed in the resource management framework.

tests/simulator/test_restarts.py (8)
  • 21-26: The permute function has been updated to include a space after the comma in the dims assignment. This is a minor style change and does not affect the functionality of the code.

  • 63-68: A new function vxalpha has been added to calculate the velocity in the x-direction for alpha particles. This function is consistent with the existing velocity functions and follows the same pattern.

  • 77-84: The vvvalpha dictionary has been introduced to store velocity functions for alpha particles. This dictionary is correctly structured and follows the same pattern as the vvv dictionary for protons.

  • 95-104: The alpha dictionary within the MaxwellianFluidModel function has been modified to include the vvvalpha dictionary. This change correctly integrates the new velocity functions for alpha particles into the model.

  • 171-187: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [171-203]

Assertions and error handling have been added within the count_levels_and_patches function. The error handling for the domain particles comparison is appropriate, and the use of np.testing.assert_equal for array comparisons is correct.

  • 211-220: The parameters passed to the permute function in the test cases have been adjusted. The changes are consistent with the updated permute function and reflect the correct expected number of levels for the tests.

  • 249-252: The restart_idx and restart_time are set correctly, and the timestamps list is constructed properly to include the restart time and the final time step.

  • 261-266: The setup for the first simulation is correct, and the use of dump_all_diags to output diagnostics is appropriate. The simulator is run and then reset, which is the expected behavior.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 8c01361 and f7b4129.
Files selected for processing (1)
  • src/core/data/ions/ions.hpp (7 hunks)
Additional comments: 6
src/core/data/ions/ions.hpp (6)
  • 28-34: The introduction of the Float type alias is a good practice for maintaining consistency in the representation of floating-point numbers across the codebase. Ensure that all floating-point types in the Ions class and related classes are updated to use this alias.

  • 49-53: The constructor now initializes the sameMasses_ member by calling allSameMass_(). Ensure that this change does not introduce any side effects in the simulation where ion populations are dynamically added or removed after the Ions object is constructed.

  • 59-94: The density() and massDensity() functions have been implemented to throw exceptions when the data is not usable. This is a good practice for error handling, but ensure that these exceptions are caught and handled properly wherever these functions are called.

  • 114-135: The computeMassDensity() function correctly computes the mass density by summing the product of population density and mass. Ensure that the mass of each population is correctly initialized before this function is called to avoid incorrect calculations.

  • 189-196: The isUsable() function does not check the massDensity_ field because it is for internal use only. This is acceptable, but ensure that the massDensity_ field is always in a valid state when used internally.

  • 231-253: The getFieldNamesAndQuantities() and setBuffer() functions have been updated to handle the massDensity buffer. Ensure that all buffer names used throughout the codebase are consistent with these changes.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between f7b4129 and c63eae3.
Files selected for processing (2)
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (1 hunks)
  • src/core/data/ions/ions.hpp (7 hunks)
Files skipped from review due to trivial changes (1)
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp
Additional comments: 6
src/core/data/ions/ions.hpp (6)
  • 28-34: The introduction of the type alias Float is a good practice for maintainability and readability, especially if there's a possibility of changing the underlying type in the future. However, ensure that this alias is consistently used throughout the codebase where applicable.

  • 49-53: The constructor now initializes the sameMasses_ flag by calling the allSameMass_() function. Ensure that this flag is correctly updated if populations are dynamically created or modified during the simulation, as mentioned in the comment on lines 287-288.

  • 59-75: The density() function now throws a runtime error if the density data is not usable. This is a good practice for error handling, but ensure that there are appropriate try-catch blocks where this function is called to handle the exception properly.

  • 96-117: The computeMassDensity() function has been added to compute the mass density of ion populations. It uses a lambda function to multiply the population density by the population mass. This is a correct and efficient way to perform this operation. However, ensure that massDensity_ is properly initialized before this function is called to prevent undefined behavior.

  • 171-178: The comment on lines 174-175 mentions that massDensity_ is not checked in isUsable because it is for internal use only. This is a reasonable decision, but it's important to ensure that massDensity_ is always in a valid state when used internally to avoid any potential issues.

  • 212-235: The getFieldNamesAndQuantities() and setBuffer() functions have been updated to handle the massDensity buffer. This is consistent with the changes made to include mass density in the simulation. Ensure that these functions are tested thoroughly to prevent any issues with buffer management.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between ab52821 and 499763e.
Files selected for processing (4)
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (1 hunks)
  • src/core/data/ions/ions.hpp (7 hunks)
  • tests/core/numerics/ion_updater/test_updater.cpp (5 hunks)
  • tests/simulator/test_restarts.py (9 hunks)
Files skipped from review due to trivial changes (1)
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp
Additional comments: 20
src/core/data/ions/ions.hpp (7)
  • 28-34: The addition of the type alias Float and the related changes in the Ions class are consistent with the summary provided. This change will help maintain consistency in the type used for floating-point operations throughout the class.

  • 49-53: The constructor now initializes the sameMasses_ member variable by calling the allSameMass_() function. This is a logical addition to optimize the bulk velocity computation when all ion populations have the same mass.

  • 59-75: The density() function now throws a runtime error if the density data is not usable. This is a good practice for error handling, ensuring that the function fails fast and provides a clear error message if the preconditions are not met.

  • 83-84: The addition of the massDensityName() function aligns with the summary, providing a consistent way to refer to the mass density field across the codebase.

  • 96-117: The computeMassDensity() function has been added to compute the mass density of ion populations. This function is consistent with the summary and uses a lambda expression to apply the mass of each population to its density, summing the results to obtain the mass density.

  • 171-178: The comment on lines 174-175 provides clarity on why massDensity_ is not checked in isUsable(). This is a good practice for maintainability, as it explains the reasoning behind the implementation choices.

  • 213-235: The getFieldNamesAndQuantities() and setBuffer() functions have been updated to handle the new massDensity field. This change is consistent with the summary and ensures that the new field is integrated into the existing framework for resource management.

tests/core/numerics/ion_updater/test_updater.cpp (5)
  • 227-233: The type alias ParticleInitializerFactory is declared but not used in the provided code. If it is not used elsewhere, consider removing it to avoid unused code declarations.

  • 259-266: The ionMassDensity field is initialized with the same HybridQuantity::Scalar::rho as ionDensity, protonDensity, and alphaDensity. This could be an error if ionMassDensity is supposed to represent a different physical quantity and should have a different initialization size. Please verify that the initialization size for ionMassDensity is correct and that it should indeed be the same as for density fields.

  • 307-314: The copy constructor for IonsBuffers initializes ionMassDensity with the same HybridQuantity::Scalar::rho as the other density fields. As with the default constructor, verify that this is the intended behavior and that ionMassDensity should not have a different initialization size.

  • 342-347: The copyData method is used to copy the contents of the fields from the source IonsBuffers. Ensure that the source buffers have been properly initialized before this copy operation to prevent copying uninitialized or invalid data.

  • 372-378: The setBuffers method sets the massDensity buffer for the ions object. Verify that the massDensity field is expected to be used in the same way as the other fields and that the corresponding buffer is properly allocated and initialized before being set.

tests/simulator/test_restarts.py (8)
  • 21-26: The permute function has been updated with corrected indentation for the dims list assignment. This change is purely stylistic and does not affect the functionality of the code.

  • 63-68: A new function vxalpha has been added to calculate the velocity in the x-direction for alpha particles. This function is consistent with the summary of changes and is correctly implemented.

  • 74-84: A new dictionary vvvalpha has been introduced to store velocity functions for alpha particles. This dictionary is consistent with the summary of changes and is correctly implemented.

  • 98-104: The mass value for alpha particles has been changed from 4 to 4.0. This change ensures that the mass is explicitly a floating-point number, which is a good practice for clarity and to avoid potential type-related issues in calculations.

  • 171-187: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [171-203]

Assertions and error handling have been added to the count_levels_and_patches function. This is a good practice as it ensures the integrity of the data being compared in the diagnostics. The error messages provide additional context which can be helpful for debugging.

  • 211-220: The max_nbr_levels value has been changed from 3 to 1 in the simInput dictionary. This change is consistent with the summary of changes and is correctly implemented.

  • 249-252: The timestamps list has been adjusted to use the restart_time variable. This change is consistent with the summary of changes and is correctly implemented.

  • 264-264: A line registering a directory for cleanup has been commented out. This could potentially lead to directories not being cleaned up after tests, which may cause issues with disk space or test isolation. It's important to verify whether this change was intentional and if there are alternative cleanup mechanisms in place.

src/core/data/ions/ions.hpp Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 3

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 501fb3b and 27feacc.
Files selected for processing (4)
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (1 hunks)
  • src/core/data/ions/ions.hpp (7 hunks)
  • tests/core/numerics/ion_updater/test_updater.cpp (5 hunks)
  • tests/simulator/test_restarts.py (8 hunks)
Files skipped from review due to trivial changes (1)
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp
Additional comments: 15
src/core/data/ions/ions.hpp (6)
  • 31-31: The introduction of the Float type alias is a good practice for maintainability and flexibility in case the underlying type needs to change in the future.

  • 52-52: The sameMasses_ variable is correctly initialized in the constructor to optimize bulk velocity calculations when all ion populations have the same mass.

  • 102-117: The computeMassDensity method is correctly implemented to calculate the mass density of ion populations, taking into account the mass of each population.

  • 123-163: The computeBulkVelocity method is updated to handle different population masses, with an optimization for the case when all populations have the same mass.

  • 84-84: The massDensityName method is a good addition for consistency and maintainability, providing a centralized place to change the name of the mass density field if needed.

  • 221-235: The setBuffer method is correctly updated to handle the mass density buffer, with appropriate error handling for invalid buffer names.

tests/core/numerics/ion_updater/test_updater.cpp (3)
  • 227-233: The addition of the ionMassDensity field to the IonsBuffers struct is correctly implemented with proper initialization and copying of data.

  • 372-378: The setBuffers function in the IonsBuffers struct has been correctly updated to include the massDensity buffer.

  • 259-266: Verify that the allocation size for ionMassDensity is intended to be the same as for number density fields (ionDensity, protonDensity, alphaDensity), as they all use HybridQuantity::Scalar::rho.

tests/simulator/test_restarts.py (6)
  • 21-26: The permute function now includes expected_num_levels to parameterize test cases with the expected number of levels after simulation restarts.

  • 63-64: The vxalpha function has been added to calculate the x-direction velocity for alpha particles.

  • 77-84: The vvvalpha dictionary has been introduced to store velocity functions for alpha particles, which is a new feature to handle different particle types.

  • 98-98: The mass value for alpha particles has been updated from an integer to a float for consistency in numerical representation.

  • 211-220: The test case parameters max_nbr_levels and expected_num_levels have been adjusted to reflect changes in the simulation's expected behavior after restarts.

  • 249-251: The restart_time and timestamps are set up for testing the simulation's restart functionality, ensuring that the simulation can continue from a specific point in time.

Comment on lines 227 to 233
using ParticleInitializerFactory = typename PHARETypes::ParticleInitializerFactory;

Field ionDensity;
Field ionMassDensity;
Field protonDensity;
Field alphaDensity;
Field protonFx;
Copy link

Choose a reason for hiding this comment

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

Note: This review was outside the patches, and no patch overlapping with it was found. Original lines [27-27]

There is a typo in the ElectromagBuffers constructor: the Ey and Ez fields are incorrectly initialized with the string "EM_E_x". They should be initialized with "EM_E_y" and "EM_E_z" respectively.

-        , Ey{"EM_E_x", HybridQuantity::Scalar::Ey, layout.allocSize(HybridQuantity::Scalar::Ey)}
-        , Ez{"EM_E_x", HybridQuantity::Scalar::Ez, layout.allocSize(HybridQuantity::Scalar::Ez)}
+        , Ey{"EM_E_y", HybridQuantity::Scalar::Ey, layout.allocSize(HybridQuantity::Scalar::Ey)}
+        , Ez{"EM_E_z", HybridQuantity::Scalar::Ez, layout.allocSize(HybridQuantity::Scalar::Ez)}

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 3

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 501fb3b and 3abf8c5.
Files selected for processing (4)
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (1 hunks)
  • src/core/data/ions/ions.hpp (7 hunks)
  • tests/core/numerics/ion_updater/test_updater.cpp (5 hunks)
  • tests/simulator/test_restarts.py (7 hunks)
Files skipped from review due to trivial changes (1)
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp
Additional comments: 13
src/core/data/ions/ions.hpp (4)
  • 31-31: The introduction of the Float type alias enhances type consistency and readability.

  • 84-84: The massDensityName function correctly provides the name for the mass density field.

  • 102-117: The computeMassDensity function is correctly implemented to zero the massDensity_ field and compute the mass density.

  • 221-235: The setBuffer function is correctly implemented to handle the assignment of the rho_ and massDensity_ fields based on the buffer name.

tests/core/numerics/ion_updater/test_updater.cpp (3)
  • 227-233: The addition of the ionMassDensity field to the IonsBuffers struct and its initialization in the constructor align with the summary of changes.

  • 307-314: The update to the IonsBuffers copy constructor to include the ionMassDensity field is consistent with the summary.

  • 372-378: The modification to the setBuffers function to handle the ionMassDensity buffer is in line with the summary.

tests/simulator/test_restarts.py (6)
  • 21-26: Verify that the test is intended to run only in one dimension as the dims list is hardcoded to [1].

  • 63-64: The addition of vxalpha function for alpha particles' x-velocity calculation looks good.

  • 77-83: The introduction of vvvalpha dictionary to store alpha particles' velocity functions is correctly implemented.

  • 97-103: The update to the alpha dictionary in the MaxwellianFluidModel to include vvvalpha is correctly done.

  • 171-187: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [174-203]

The assertions and error handling within the check_diags method, which likely includes the functionality of the mentioned count_levels_and_patches function, are correctly implemented.

  • 248-251: The adjustment to the timestamps list in the test_restarts function to use the restart_time variable is correct and improves code readability.

src/core/data/ions/ions.hpp Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 3

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 3abf8c5 and c3a1b10.
Files selected for processing (16)
  • .github/workflows/cmake_ubuntu.yml (1 hunks)
  • pyphare/pyphare/pharein/init.py (2 hunks)
  • res/cmake/def.cmake (2 hunks)
  • src/core/data/ions/ions.hpp (7 hunks)
  • src/core/data/particles/particle_packer.hpp (1 hunks)
  • src/core/utilities/types.hpp (1 hunks)
  • src/python3/CMakeLists.txt (3 hunks)
  • tests/amr/messengers/test_messengers.cpp (1 hunks)
  • tests/amr/models/test_models.cpp (1 hunks)
  • tests/amr/resources_manager/test_resources_manager.cpp (1 hunks)
  • tests/amr/tagging/test_tagging.cpp (1 hunks)
  • tests/core/data/electrons/test_electrons.cpp (1 hunks)
  • tests/core/data/ions/test_ions.cpp (1 hunks)
  • tests/core/numerics/ion_updater/test_updater.cpp (6 hunks)
  • tests/diagnostic/test_diagnostics.hpp (1 hunks)
  • tests/initializer/test_initializer.cpp (1 hunks)
Files skipped from review due to trivial changes (4)
  • tests/amr/tagging/test_tagging.cpp
  • tests/core/data/electrons/test_electrons.cpp
  • tests/core/data/ions/test_ions.cpp
  • tests/diagnostic/test_diagnostics.hpp
Additional comments: 27
.github/workflows/cmake_ubuntu.yml (1)
  • 83-83: The addition of -DdevMode=ON enables development mode. Verify that this mode does not introduce any side effects that could affect the production build or the behavior of the software in a production environment.
pyphare/pyphare/pharein/__init__.py (2)
  • 102-106: The changes to add_size_t function correctly ensure that only non-negative values are accepted, which aligns with the expected type size_t. Good error handling with the RuntimeError.

  • 198-200: The check for negative population numbers before calling add_size_t is a good practice to ensure data integrity.

res/cmake/def.cmake (2)
  • 11-11: The PHARE_WERROR_FLAGS variable is being set with the contents of PHARE_FLAGS. Verify if this is the intended behavior, as it could unintentionally include flags that are not related to warnings or errors.

  • 38-38: The addition of the -Wuninitialized flag to the _Werr variable is consistent with the summary and is a good practice to catch potential issues with uninitialized variables.

src/core/data/ions/ions.hpp (5)
  • 28-34: The introduction of the Float type alias is a good practice for maintaining type consistency across the codebase.

  • 40-50: The constructor properly initializes the sameMasses_ member variable, which is a good practice for setting the initial state of the object.

  • 56-72: The error handling in the density() functions is appropriate, throwing exceptions when the data is not usable.

  • 99-115: The use of a lambda in the computeMassDensity() function for inline operations is efficient and maintains readability.

  • 266-270: The use of a custom tolerance in the allSameMass_() function for floating-point comparison is a good practice to handle numerical precision issues.

src/core/data/particles/particle_packer.hpp (1)
  • 29-33: The change to use uniform initialization syntax in the empty function is a good practice as it ensures value-initialization of the particle object, which can prevent potential issues with uninitialized data.
src/core/utilities/types.hpp (2)
  • 329-346: The addition of the Fn template parameter to the all, any, and none functions is a good enhancement for flexibility, allowing custom predicate functions to be used.

  • 348-355: The addition of overloads for float_equals for both float and double types with default precision thresholds is a good enhancement for floating-point comparisons.

src/python3/CMakeLists.txt (3)
  • 4-10: The changes to the cpp target's compile options to use ${PHARE_WERROR_FLAGS} and the setting of the library output directory are consistent and appear correct.

  • 15-21: The cpp_dbg target has been correctly configured with additional preprocessor definitions for debugging purposes. Ensure that these new definitions are well-documented and that their impact is understood across the codebase.

  • 26-32: The cpp_etc target's changes mirror those of the cpp target, using ${PHARE_WERROR_FLAGS} and setting the library output directory. This maintains consistency across different build targets.

tests/amr/messengers/test_messengers.cpp (1)
  • 168-168: The change from int to std::size_t for dict["ions"]["nbrPopulations"] is consistent with the summary and improves type safety for representing sizes and counts.
tests/amr/models/test_models.cpp (1)
  • 54-54: The change from int to std::size_t for dict["ions"]["nbrPopulations"] is consistent with the summary and ensures type safety for size-related values.
tests/amr/resources_manager/test_resources_manager.cpp (1)
  • 50-50: The change from int to std::size_t for "nbrPopulations" is consistent with the summary and improves type safety for size-related variables. Ensure that all parts of the code that interact with "nbrPopulations" are compatible with this change.
tests/core/numerics/ion_updater/test_updater.cpp (6)
  • 77-77: The change from int to std::size_t for nbrPopulations is consistent with the summary and is a good practice for representing sizes.

  • 229-232: The addition of ionMassDensity to IonsBuffers struct is consistent with the summary and is necessary for the new mass density calculations.

  • 374-375: The update to the setBuffers function in IonsBuffers to set the buffer for massDensity aligns with the new field addition and is necessary for the mass density calculations.

  • 259-263: The constructor of IonsBuffers has been updated to initialize the new ionMassDensity field, which is consistent with the addition of the new field and necessary for proper initialization.

  • 307-311: The copy constructor of IonsBuffers has been updated to handle the new ionMassDensity field, ensuring that the mass density data is correctly copied when creating a new instance from an existing one.

  • 343-344: The copyData method is called for the new ionMassDensity field in the copy constructor of IonsBuffers, which is necessary to ensure the data is correctly copied.

tests/initializer/test_initializer.cpp (2)
  • 71-77: The change from a reference to a non-reference variable for pop0ParticleInitializer is not mentioned in the summary. Verify if this change is intentional and consider the implications on memory usage and performance, as a non-reference variable may involve a copy of the initializer object.

  • 71-77: The use of InitFunction<1> for pop0density aligns with the type consistency improvements mentioned in the summary. Ensure that all related code is updated to work with the templated type.

pyphare/pyphare/pharein/__init__.py Show resolved Hide resolved
src/core/data/ions/ions.hpp Show resolved Hide resolved
src/core/data/ions/ions.hpp Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between c3a1b10 and b24c4d8.
Files selected for processing (3)
  • src/initializer/python_data_provider.hpp (2 hunks)
  • src/python3/cpp_simulator.hpp (1 hunks)
  • src/python3/pybind_def.hpp (1 hunks)
Files skipped from review due to trivial changes (2)
  • src/python3/cpp_simulator.hpp
  • src/python3/pybind_def.hpp
Additional comments: 2
src/initializer/python_data_provider.hpp (2)
  • 1-3: The removal of the comment block is a non-functional change and seems to be a cleanup task.

  • 14-15: The change in the #undef directive from HAVE_UNISTD_HPP to HAVE_UNISTD_H aligns with standard header file naming conventions.

@nicolasaunai nicolasaunai merged commit 61b1ade into PHAREHUB:master Dec 2, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants