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

hierarchy views #787

Closed
wants to merge 4 commits into from
Closed

hierarchy views #787

wants to merge 4 commits into from

Conversation

PhilipDeegan
Copy link
Member

@PhilipDeegan PhilipDeegan commented Nov 30, 2023

for #778

Summary by CodeRabbit

  • Refactor

    • Transitioned from using Field to Grid across various components, enhancing the data structure and processing efficiency.
  • Bug Fixes

    • Fixed a typo in the build configuration comments.
  • New Features

    • Implemented a new Grid class with advanced capabilities and integrated it into the system.
    • Added a function to compute the average of two grids.
  • Documentation

    • Updated comments and documentation to reflect the shift from Field to Grid.
  • Tests

    • Revised and added tests to cover the new Grid functionality and ensure compatibility.

Copy link

coderabbitai bot commented Nov 30, 2023

Walkthrough

The codebase has undergone a major refactoring, transitioning from the Field class to a new Grid class. This change impacts a wide range of files, including core data structures, AMR (Adaptive Mesh Refinement) components, and tests. The Grid class is now a central element in the code, affecting how data is handled and operations are performed. This shift necessitates updates to include directives, type aliases, function signatures, and member functions across various modules.

Changes

Files Summary of Changes
res/cmake/dep.cmake, res/cmake/test.cmake Corrected typos and updated directory names in CMake configuration.
src/core/data/grid/grid.hpp, tests/core/data/grid/test_grid.hpp Introduced grid_base.hpp, defined Grid class template and average function.
src/core/data/field/..., src/core/data/vecfield/..., src/core/..., src/diagnostic/..., src/phare_core.hpp, src/simulator/... Updated to use Grid class, modified include statements, type aliases, and function signatures.
src/amr/..., src/amr/messengers/..., src/amr/multiphysics_integrator.hpp, src/amr/physical_models/..., src/amr/resources_manager/..., src/amr/solvers/..., src/amr/tagging/... Updated AMR-related files to use Grid, modified class templates, function signatures, and include statements.
tests/amr/data/field/..., tests/amr/models/..., tests/amr/resources_manager/..., tests/amr/tagging/..., tests/core/data/electrons/..., tests/core/data/field/..., tests/core/data/grid/..., tests/core/data/gridlayout/..., tests/core/data/ion_population/..., tests/core/data/ions/..., tests/core/data/vecfield/..., tests/core/numerics/... Updated tests to use Grid, modified include statements, type aliases, and test cases.
src/amr/solvers/solver_ppc.hpp Added new include directive, member variable, virtual function, modified function signatures and implementations, and added a debug log function.

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

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: 28

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 501fb3b and 90077cb.
Files selected for processing (57)
  • res/cmake/dep.cmake (1 hunks)
  • res/cmake/test.cmake (1 hunks)
  • src/amr/data/field/field_data.hpp (2 hunks)
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (3 hunks)
  • src/amr/multiphysics_integrator.hpp (5 hunks)
  • src/amr/physical_models/hybrid_model.hpp (2 hunks)
  • src/amr/resources_manager/field_resource.hpp (1 hunks)
  • src/amr/resources_manager/resources_manager.hpp (1 hunks)
  • src/amr/solvers/solver.hpp (5 hunks)
  • src/amr/solvers/solver_mhd.hpp (2 hunks)
  • src/amr/solvers/solver_ppc.hpp (8 hunks)
  • src/amr/solvers/solver_ppc_model_view.hpp (1 hunks)
  • src/amr/tagging/default_hybrid_tagger_strategy.hpp (1 hunks)
  • src/amr/tagging/hybrid_tagger.hpp (1 hunks)
  • src/core/data/electrons/electrons.hpp (9 hunks)
  • src/core/data/field/field.hpp (1 hunks)
  • src/core/data/grid/grid.hpp (1 hunks)
  • src/core/data/grid/gridlayout.hpp (6 hunks)
  • src/core/data/ions/ion_population/ion_population.hpp (1 hunks)
  • src/core/data/ions/ions.hpp (2 hunks)
  • src/core/data/ndarray/ndarray_vector.hpp (5 hunks)
  • src/core/data/vecfield/vecfield.hpp (4 hunks)
  • src/core/models/hybrid_state.hpp (1 hunks)
  • src/core/numerics/ampere/ampere.hpp (1 hunks)
  • src/core/numerics/faraday/faraday.hpp (1 hunks)
  • src/core/numerics/ohm/ohm.hpp (1 hunks)
  • src/core/utilities/box/box.hpp (1 hunks)
  • src/core/utilities/types.hpp (2 hunks)
  • src/diagnostic/detail/types/fluid.hpp (1 hunks)
  • src/phare_core.hpp (3 hunks)
  • src/simulator/phare_types.hpp (1 hunks)
  • tests/amr/data/field/coarsening/test_linear_coarsen.hpp (3 hunks)
  • tests/amr/data/field/copy_pack/field_data_test_param.hpp (2 hunks)
  • tests/amr/data/field/geometry/test_field_geometry.cpp (2 hunks)
  • tests/amr/data/field/refine/test_field_refine.cpp (1 hunks)
  • tests/amr/data/field/refine/test_field_refinement_on_hierarchy.cpp (2 hunks)
  • tests/amr/data/field/refine/test_field_refinement_on_hierarchy.hpp (1 hunks)
  • tests/amr/data/field/time_interpolate/test_field_data_time_interpolate.cpp (2 hunks)
  • tests/amr/data/field/variable/test_field_variable.cpp (2 hunks)
  • tests/amr/models/test_models.cpp (1 hunks)
  • tests/amr/resources_manager/CMakeLists.txt (1 hunks)
  • tests/amr/resources_manager/test_resources_manager.cpp (2 hunks)
  • tests/amr/resources_manager/test_resources_manager_basic_hierarchy.hpp (1 hunks)
  • tests/amr/tagging/test_tagging.cpp (1 hunks)
  • tests/core/data/electrons/test_electrons.cpp (9 hunks)
  • tests/core/data/field/test_field.hpp (2 hunks)
  • tests/core/data/grid/CMakeLists.txt (1 hunks)
  • tests/core/data/grid/test_grid.cpp (9 hunks)
  • tests/core/data/grid/test_grid.hpp (1 hunks)
  • tests/core/data/gridlayout/gridlayout_base_params.hpp (1 hunks)
  • tests/core/data/gridlayout/gridlayout_deriv.hpp (4 hunks)
  • tests/core/data/gridlayout/gridlayout_laplacian.hpp (4 hunks)
  • tests/core/data/ion_population/test_ion_population.cpp (1 hunks)
  • tests/core/data/ions/test_ions.cpp (2 hunks)
  • tests/core/data/vecfield/test_main.cpp (5 hunks)
  • tests/core/numerics/ampere/test_main.cpp (6 hunks)
  • tests/core/numerics/faraday/test_main.cpp (6 hunks)
Files not processed due to max files limit (4)
  • tests/core/numerics/interpolator/test_main.cpp
  • tests/core/numerics/ion_updater/test_updater.cpp
  • tests/core/numerics/ohm/test_main.cpp
  • tests/simulator/test_restarts.py
Files skipped from review due to trivial changes (9)
  • res/cmake/dep.cmake
  • src/amr/tagging/default_hybrid_tagger_strategy.hpp
  • src/core/data/ions/ion_population/ion_population.hpp
  • src/core/data/ions/ions.hpp
  • src/core/utilities/box/box.hpp
  • tests/amr/resources_manager/CMakeLists.txt
  • tests/core/data/grid/CMakeLists.txt
  • tests/core/data/gridlayout/gridlayout_deriv.hpp
  • tests/core/data/ion_population/test_ion_population.cpp
Additional comments: 169
res/cmake/test.cmake (1)
  • 8-14: The summary mentions that "tests/core/data/field" has been replaced with "tests/core/data/grid", but the hunk does not show the removal of "tests/core/data/field". Please verify if the summary is accurate or if the removal was omitted.
src/amr/data/field/field_data.hpp (2)
  • 89-91: The assertion ensures that field.vector() is not empty before attempting to populate it from the restart database. Verify that the size check is indeed intended to be non-zero and not a specific expected size. Additionally, confirm that the size of the array being read from the database matches the size of field.vector() to prevent buffer overflows or underflows.

  • 314-314: The use of auto* in the getPointer method simplifies the code and ensures that the correct pointer type is returned even if the type of field changes. This change is consistent with modern C++ practices.

src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (3)
  • 49-88: The changes to the FieldUser struct to use GridT and the addition of the copyData method are consistent with the summary and appear to be correctly implemented.

  • 95-125: The changes to the HybridHybridMessengerStrategy class to use GridT instead of FieldT are consistent with the summary and appear to be correctly implemented.

  • 1005-1009: The changes to the NiOldUser_ member to use FieldUser<GridT> are consistent with the summary and appear to be correctly implemented.

src/amr/multiphysics_integrator.hpp (5)
  • 344-351: The logic to either push a new model view or update an existing one based on the levelNumber is correctly implemented.

  • 365-374: The loop to register levels with the messenger and create model views for each level is correctly implemented.

  • 498-502: The advanceLevel method call has been correctly updated to include getModelView_(iLevel) as an additional argument.

  • 579-579: The new member variable model_views_ has been correctly added to the class.

  • 807-807: The new private method getModelView_ has been correctly added to retrieve the model view based on the level.

src/amr/physical_models/hybrid_model.hpp (4)
  • 4-7: The addition of #include "core/data/grid/grid.hpp" aligns with the refactoring to use Grid types.

  • 37-38: The introduction of the grid_type alias is consistent with the refactoring to use Grid types.

  • 45-45: The relocation of model_name is consistent with the summary and does not affect functionality.

  • 33-41: The changes to type definitions such as gridlayout_type, electromag_type, vecfield_type, field_type, grid_type, and resources_manager_type are consistent with the refactoring to use Grid types.

src/amr/resources_manager/field_resource.hpp (1)
  • 19-19: The internal_type_ptr still uses ResourcesUser::field_type. Please verify if this is intentional or if it should also be updated to ResourcesUser::grid_type to maintain consistency with the other type changes.
src/amr/resources_manager/resources_manager.hpp (2)
  • 574-574: The ResourcesUser parameter is commented out, which contradicts the summary stating that it is now used in the method. Please verify if the parameter should be uncommented or if the summary needs to be updated.

  • 575-575: The use of const for the allocateTime parameter is a good practice to ensure it is not modified within the method.

src/amr/solvers/solver.hpp (6)
  • 19-25: The ISolverModelView class has been added as an interface, which currently only includes a virtual destructor. Ensure that the implementation of this interface in derived classes is planned and that it will be utilized effectively in the codebase.

  • 47-49: The addition of type aliases patch_t, level_t, and hierarchy_t in the ISolver class is a good practice for code readability and maintainability, as it abstracts the underlying types and makes future changes easier.

  • 89-93: The advanceLevel method now includes an additional parameter ISolverModelView& view. Ensure that all implementations of this method are updated accordingly and that the view parameter is being used effectively within the method's logic.

  • 103-104: The allocate method now uses the type alias patch_t instead of the specific SAMRAI::hier::Patch type. This change increases the flexibility of the code by decoupling it from a specific implementation and should be reflected in all derived classes and usages.

  • 112-113: The new virtual method make_view has been added to create a view for the solver model. Ensure that the implementations of this method in derived classes provide meaningful and correct views of the solver model, and that these views are utilized where necessary.

  • 116-117: The constructor of ISolver is now protected, which is a good practice as it prevents direct instantiation of the interface and ensures that only derived classes can be instantiated. The constructor initializes solverName, which is a clean way to set up the name for each solver instance.

src/amr/solvers/solver_mhd.hpp (1)
  • 38-60: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [14-59]

The changes to the SolverMHD class, including the addition of type aliases and modifications to function signatures, align with the summary and appear to be correctly implemented.

src/amr/solvers/solver_ppc.hpp (4)
  • 49-49: The addition of the type alias HybridModelView_t is confirmed and aligns with the summary.

  • 97-99: The new function make_view is added as described in the summary and correctly returns a HybridModelView_t object.

  • 106-124: The methods predictor1_, predictor2_, corrector_, average_, and moveIons_ now correctly take an additional parameter HybridModelView_t& view as mentioned in the summary.

  • 93-95: The function signature for advanceLevel has been updated to include the new parameter ISolverModelView& view as described in the summary.

src/amr/solvers/solver_ppc_model_view.hpp (2)
  • 38-40: The use of dynamic_cast in the regrid function could lead to a std::bad_cast exception if the cast is not valid. It's important to ensure that the function is only called with compatible types or to handle the potential exception.

  • 94-102: The assert statements in the iterator's dereference operators are used to ensure the validity of the current state. While this is good for debugging, it's important to note that asserts are not usually present in release builds, so they should not be relied upon for program logic.

src/amr/tagging/hybrid_tagger.hpp (2)
  • 90-93: The summary states that the second int* argument has been removed from the NdArrayView template arguments, but the code still shows two template arguments being used. Please verify if the summary is accurate or if the code needs to be updated to reflect the intended changes.

  • 94-96: The code within the if constexpr block is specific to 2D cases. If the application is intended to support 1D or 3D as well, corresponding code blocks should be added to handle those dimensions.

src/core/data/electrons/electrons.hpp (12)
  • 139-139: The summary states that ions_ was changed from a reference to an object, but the code still shows it as a reference. Please verify this discrepancy.

  • 140-141: The summary states that J_ and Ve_ were changed from references to objects, but the code still shows them as references. Please verify this discrepancy.

  • 157-160: The change to the constructor of IsothermalElectronPressureClosure to take Ions const& ions is consistent with the summary.

  • 169-171: The addition of NO_DISCARD to isUsable and isSettable in IsothermalElectronPressureClosure is consistent with the summary.

  • 235-235: The summary states that ions_ was changed from a reference to an object, but the code still shows it as a reference. Please verify this discrepancy.

  • 236-236: The change of Te_ from a constant reference to a constant in IsothermalElectronPressureClosure is consistent with the summary.

  • 237-237: The summary states that Pe_ was changed from a pointer to an object, but the code still shows it as a pointer. Please verify this discrepancy.

  • 252-254: The change to the constructor of ElectronMomentModel to take Ions& ions is consistent with the summary.

  • 304-304: The summary indicates a change in fluxComput_ from FluxComputer to FluxComputer, which seems to be an error as it suggests no actual change.

  • 305-305: The change of pressureClosure_ from IsothermalElectronPressureClosure<FluxComputer> to IsothermalElectronPressureClosure<Ions> in ElectronMomentModel is consistent with the summary.

  • 323-324: The addition of copy constructor and deletion of move constructor in Electrons is consistent with the summary.

  • 7-10: The summary indicates significant refactoring related to Grid and Field types, but the provided hunks do not cover all these changes. Please ensure that all related changes are consistent throughout the codebase.

src/core/data/field/field.hpp (6)
  • 14-14: The namespace change from PHARE to PHARE::core is correctly applied.

  • 25-25: The using statement for Super is correctly added to alias NdArrayImpl.

  • 31-38: The constructor has been correctly updated to take a std::array for dimensions.

  • 45-46: The name and physicalQuantity methods have been correctly updated to return references.

  • 48-48: The copyData method should be made private according to the summary, but it is still public in the code.

- public:
-    void copyData(Field const& source) { Super::fill_from(source); }
+ private:
+    void copyData(Field const& source) { Super::fill_from(source); }
  • 58-68: The new average function has been correctly added to the code.
src/core/data/grid/gridlayout.hpp (7)
  • 325-332: The summary of changes mentions Field_t replacing NdArrayImpl, but the pull request summary discusses a transition from Field to Grid types. Please verify the consistency between the summaries and the actual changes in the code.

  • 328-332: The change to physicalStartIndex to accept a Field_t type is consistent with the summary and seems correct.

  • 370-374: The change to physicalEndIndex to accept a Field_t type is consistent with the summary and seems correct.

  • 408-412: The change to ghostStartIndex to accept a Field_t type and use the [[maybe_unused]] attribute for the parameters is consistent with the summary and seems correct.

  • 450-453: The change to ghostEndIndex to accept a Field_t type is consistent with the summary and seems correct.

  • 467-473: The change to fieldNodeCoordinates to accept a Field_t type is consistent with the summary and seems correct.

  • 961-965: The change to fieldCentering to accept a Field_t type is consistent with the summary and seems correct.

src/core/data/ndarray/ndarray_vector.hpp (6)
  • 197-197: The summary indicates that the 'zero' member function was removed from 'NdArrayVector', but it is actually present in 'NdArrayView'. Please verify if this is an oversight in the summary or the code.

  • 147-150: The use of 'std::decay_t' in the constructor ensures that cv-qualifiers and references are removed from the type, which is a good practice for type compatibility.

  • 184-189: The 'fill_from' function correctly checks for size compatibility before copying data, which ensures data integrity when copying from another 'NdArrayView'.

  • 197-197: The addition of the 'zero' function is a useful feature that allows for resetting the data in the 'NdArrayView' to zero.

  • 191-195: The addition of 'begin' and 'end' functions provides iterator functionality to 'NdArrayView', aligning with standard practices for container-like structures.

  • 200-200: The change of the 'ptr_' member variable type to 'pointer_type' is consistent with the removal of the 'Pointer' template parameter and the refactoring described in the summary.

src/core/data/vecfield/vecfield.hpp (9)
  • 30-30: The summary states that the static constexpr member dimension has been removed, but the hunk shows it being added. Please verify this discrepancy.

  • 33-33: The summary indicates that the field_type alias has been removed from the class definition, but the hunk shows it being defined. Please verify this discrepancy.

  • 37-37: The change from a deleted to a default copy constructor is consistent with the summary and is a valid change.

  • 40-40: The change from a deleted to a default move assignment operator is consistent with the summary and is a valid change.

  • 66-71: The modification of the return type of getFieldNamesAndQuantities to resources_properties is consistent with the summary and is a valid change.

  • 127-130: The use of auto for the return type of the getComponent member function is consistent with the summary and is a valid change.

  • 144-147: The use of auto for the return type of the getComponent member function is consistent with the summary and is a valid change.

  • 36-36: The deletion of the default constructor is not mentioned in the summary. Please verify if this change is intentional.

  • 39-39: The deletion of the copy assignment operator is not mentioned in the summary. Please verify if this change is intentional.

src/core/models/hybrid_state.hpp (3)
  • 75-83: The addition of J to the return tuple of getCompileTimeResourcesUserList may require updates to the code where this function is used. Verify that all usages of this function have been updated to handle the additional tuple element.

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

The summary of the pull request mentions a transition from Field to Grid types, but this file does not show any changes related to that refactoring. Ensure that the changes in this file are consistent with the overall refactoring effort described in the pull request summary.

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

The summary does not mention the addition of the VecField J member to the HybridState class, which is present in the hunk. This should be included in the summary to accurately reflect the changes made to the code.

src/core/numerics/ohm/ohm.hpp (3)
  • 54-62: The summary states that the return value of fn is used to update the layout_ member, but the code shows that fn is called with state as an argument, and the result is destructured to obtain layout and other variables. The summary should be updated to accurately reflect the code's behavior.

  • 65-66: The member variables eta_ and nu_ are correctly defined as constants, which is good practice for values that should not change after construction.

  • 50-67: > Note: This review was outside the patches, and no patch overlapping with it was found. Original lines [9-11]

The Ohm class correctly inherits from LayoutHolder<GridLayout>, which is consistent with the design of handling layout information.

src/core/utilities/types.hpp (4)
  • 72-76: The addition of type_list struct with a nested type alias Tuple is correctly implemented and follows the conventions of the file.

  • 330-346: The modifications to the all, any, and none functions to accept an additional template parameter Fn with a default value of decltype(to_bool) are correctly implemented and enhance the flexibility of these functions.

  • 351-453: The introduction of the Apply struct, apply_N functions, and the for_N_R_mode enum class is correctly implemented and provides a useful mechanism for applying functions to a sequence of integers with different return modes.

  • 381-453: The addition of the for_N functions and the functions for working with named tuples is correctly implemented and follows the conventions of the file.

src/diagnostic/detail/types/fluid.hpp (1)
  • 191-195: The change to use field.data() instead of &(*field.begin()) is a good practice as it avoids potential dereferencing of an invalid iterator and makes the code more readable. Ensure that write_data_set_flat is designed to handle the case where data() returns a pointer to an empty container without dereferencing it.
src/phare_core.hpp (6)
  • 38-39: The summary states that Array_t was replaced with Grid_t, but Array_t is still being used within the definition of Grid_t. Please verify if this is intentional or if the summary needs to be updated.

  • 41-41: The addition of ArrayView_t aligns with the summary and seems correctly defined.

  • 42-43: The modifications to VecField_t and Field_t to use Grid_t and ArrayView_t respectively are consistent with the summary and appear to be correctly implemented.

  • 5-5: The inclusion of grid.hpp is noted and seems appropriate for the changes described in the summary.

  • 50-51: The type aliases ParticleArray_t and ParticleSoA_t are present and seem to be correctly defined.

  • 53-55: The type aliases MaxwellianParticleInitializer_t, IonPopulation_t, Ions_t, and Electrons_t are present and seem to be correctly defined.

src/simulator/phare_types.hpp (1)
  • 18-24: The addition of Grid_t to the PHARE_Types struct aligns with the refactoring described in the pull request summary. Ensure that all relevant parts of the codebase are updated to use Grid_t where appropriate.
tests/amr/data/field/coarsening/test_linear_coarsen.hpp (10)
  • 5-8: The addition of #include "core/data/grid/grid.hpp" is consistent with the summary and necessary for the changes made in the file.

  • 55-60: The replacement of Field with Grid in the EMData struct is consistent with the summary and reflects the refactoring to use the new Grid type.

  • 91-97: The replacement of Field with Grid in the FieldCoarsenTestData struct is consistent with the summary and reflects the refactoring to use the new Grid type.

  • 91-91: The change in the absError constant value is not mentioned in the summary, but it seems to be a minor change and may not require explicit documentation.

  • 91-91: The absError constant within the FieldCoarsenOperatorTest struct is not mentioned in the summary, but it seems to be a minor change and may not require explicit documentation.

  • 91-91: The changes to the TYPED_TEST and TYPED_TEST_SUITE macros are not mentioned in the summary, but they seem to be minor and may not require explicit documentation.

  • 91-91: The changes to the createParam function template are not mentioned in the summary, but they seem to be minor and may not require explicit documentation.

  • 91-91: The changes to the load function template are not mentioned in the summary, but they seem to be minor and may not require explicit documentation.

  • 91-91: The changes to the coarsen function template are not mentioned in the summary, but they seem to be minor and may not require explicit documentation.

  • 91-91: The changes to the check lambda function within the TYPED_TEST are not mentioned in the summary, but they seem to be minor and may not require explicit documentation.

tests/amr/data/field/copy_pack/field_data_test_param.hpp (3)
  • 281-281: The change from Field to Grid in the type alias Field1D aligns with the refactoring described in the pull request summary.

  • 22-22: The inclusion of core/data/grid/grid.hpp is consistent with the changes described in the pull request summary.

  • 15-25: The changes in the includes and type alias are part of a larger refactoring effort and do not introduce unnecessary complexity, aligning with the user's preference for minimal and efficient code.

tests/amr/data/field/geometry/test_field_geometry.cpp (3)
  • 10-15: The addition of the include statement for "core/data/grid/grid.hpp" and the modification of Field1D to use Grid are consistent with the summary and pull request description. Ensure that the rest of the codebase is updated to reflect these changes where Field1D is used.

  • 35-35: The Field1D type alias has been correctly updated to use Grid instead of Field, aligning with the refactoring goal. Ensure that the usage of Field1D is consistent with this change throughout the codebase.

  • 37-37: The FieldGeometryParam struct template parameters appear to be compatible with the new Field1D type alias. Confirm that the GridLayoutT and FieldImpl parameters are used correctly in all instances where FieldGeometryParam is instantiated.

tests/amr/data/field/refine/test_field_refine.cpp (1)
  • 78-84: The type alias FieldT has been correctly updated to use Grid instead of Field. Ensure that all usages of FieldT throughout the codebase are updated to work with the Grid type if they were previously expecting a Field type.
tests/amr/data/field/refine/test_field_refinement_on_hierarchy.cpp (2)
  • 20-23: The change from Field to Grid type is correctly reflected in the type alias FieldND. This aligns with the summary and the broader refactoring effort described in the pull request.

  • 51-53: The change from Field to Grid type is correctly reflected in the type alias FieldND within the TYPED_TEST body. This is consistent with the changes in the rest of the file and the broader refactoring effort.

tests/amr/data/field/refine/test_field_refinement_on_hierarchy.hpp (2)
  • 9-9: The addition of the include statement for "core/data/grid/grid.hpp" aligns with the refactoring changes described in the pull request summary, ensuring that the necessary Grid type definitions are available in this file.

  • 6-12: No further action is required for this hunk as the rest of the code remains unchanged and the new include does not seem to introduce any conflicts or issues.

tests/amr/data/field/time_interpolate/test_field_data_time_interpolate.cpp (2)
  • 12-18: The import statement has been correctly updated to reflect the transition from Field to Grid.

  • 48-54: The type alias FieldND has been correctly updated to Grid<NdArrayVector<dim>, HybridQuantity::Scalar> to align with the refactoring from Field to Grid.

tests/amr/data/field/variable/test_field_variable.cpp (2)
  • 8-15: The inclusion of "core/data/grid/grid.hpp" and the use of Grid in the type alias FieldVar are consistent with the summary's description of the refactoring from Field to Grid.

  • 51-53: The update of the type alias FieldVar to use Grid instead of Field is in line with the refactoring described in the summary.

tests/amr/models/test_models.cpp (1)
  • 35-49: The summary states that definitions for VecField1D, GridImplYee1D, ParticleArray1D, and GridYee1D were removed, but the hunk shows that these types are still present and have been updated. Please verify the accuracy of the summary.
tests/amr/resources_manager/test_resources_manager.cpp (3)
  • 5-11: The summary mentions the inclusion of "core/data/grid/grid.hpp" on line 3, but it is actually included on line 8. Please verify the correct line number for the inclusion.

  • 35-48: The type aliases have been updated as described in the summary, and they appear to be correctly defined.

  • 50-50: The function createInitDict is well-defined and does not appear in the summary, which is acceptable as it may not be considered a key change.

tests/amr/resources_manager/test_resources_manager_basic_hierarchy.hpp (3)
  • 31-42: The constructor correctly initializes member variables using the input file data.

  • 47-79: The init method correctly creates and configures a SAMRAI::hier::Box object and uses it to create a new patch level in the hierarchy.

  • 31-39: The summary should specify that the BasicHierarchy class constructor initializes inputDatabase, dimension, patchHierarchyDatabase, gridGeometry, and hierarchy member variables using data parsed from the input file.

tests/amr/tagging/test_tagging.cpp (1)
  • 161-165: The change from Field_t to Grid_t in the type alias Field is consistent with the overall refactoring described in the pull request summary. Ensure that all usages of the Field alias within the TestTagger struct and related test cases are updated to work with the new Grid_t type.
tests/core/data/electrons/test_electrons.cpp (9)
  • 5-8: The addition of grid.hpp and the changes in type definitions align with the refactoring to use Grid types.

  • 130-131: The new type aliases GridND and VecFieldND are correctly defined and used.

  • 143-154: The global variables Jx, Jy, Jz, J, Nibuffer, NiProtons, Fxi, Fyi, Fzi, Vex, Vey, Vez, Vix, Viy, Viz, Pe, and pack are correctly declared with the new GridND type.

  • 138-198: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [186-213]

The constructor has been modified to initialize the new GridND variables and VecFieldND J with appropriate types and values.

  • 227-232: The lambda function used to fill the grid data is consistent with the refactoring and is a generic operation that should work as intended.

  • 250-255: The lambda function for filling the grid data in the 2D case is correctly implemented.

  • 280-285: The lambda function for filling the grid data in the 3D case is correctly implemented.

  • 457-470: The test case ThatElectronsVelocityEqualIonVelocityMinusJ is correctly using the GridYee type to project the current density onto the velocity grid.

  • 593-595: The main function for running all tests is correctly implemented.

tests/core/data/field/test_field.hpp (4)
  • 4-14: The summary indicates changes to the function template test at line 19, but the hunk provided starts at line 4 and does not include line 19. Please verify the accuracy of the summary or the hunk provided.

  • 173-193: The summary indicates changes to the type of field1 at line 31, but the hunk provided does not include line 31. Please verify the accuracy of the summary or the hunk provided.

  • 173-193: The summary indicates changes to another test function template at line 47, but the hunk provided does not include line 47. Please verify the accuracy of the summary or the hunk provided.

  • 173-193: The pull request summary mentions a significant refactoring from Field to Grid types, but the hunk still shows the use of Field type in the function signatures. Please verify the accuracy of the pull request summary or the hunk provided.

tests/core/data/gridlayout/gridlayout_base_params.hpp (4)
  • 13-13: The summary indicates that #include "gridlayout_utilities.hpp" was removed, but it is still present in the code.

  • 22-22: The summary states that the using Grid_t alias was added at line 10, but it is actually at line 22.

  • 32-32: The change of the field type to std::shared_ptr<Grid_t> aligns with the refactoring to use Grid types and is correctly implemented.

  • 35-38: The change in the makeIt_ function signature to use Grid_t is consistent with the refactoring efforts and is correctly implemented.

tests/core/data/gridlayout/gridlayout_laplacian.hpp (5)
  • 2-8: The update of the include statement from Field to Grid is consistent with the summary and the overall refactoring effort.

  • 25-30: The change from Field to Grid for the Jx, Jy, and Jz variables in the 1D Laplacian class is consistent with the summary and the overall refactoring effort.

  • 47-52: The change from Field to Grid for the Jx, Jy, and Jz variables in the 2D Laplacian class is consistent with the summary and the overall refactoring effort.

  • 69-74: The change from Field to Grid for the Jx, Jy, and Jz variables in the 3D Laplacian class is consistent with the summary and the overall refactoring effort.

  • 25-33: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [2-77]

The changes in the file are part of a larger refactoring effort and do not introduce unnecessary complexity or inefficiency, aligning with the user's preference for minimal and efficient code.

tests/core/data/ions/test_ions.cpp (2)
  • 9-15: The changes made to the includes and type definitions are consistent with the summary and the broader refactoring effort described in the pull request. No issues found.

  • 34-41: The updates to the type aliases Grid1D and VecField1D align with the refactoring goals outlined in the pull request. The code is clear and maintainable.

tests/core/data/vecfield/test_main.cpp (8)
  • 3-6: The summary states that #include "core/data/grid/grid.hpp" was added at line 3, but it is actually included at line 6 in the hunk.

  • 27-44: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [26-30]

The summary states that the type of vf2 was changed at line 26, but the hunk shows the change at line 30.

  • 28-28: The summary mentions a change from NdArrayVector to NdArrayView at line 28, but there is no such change in the provided hunk.

  • 30-39: The summary states that a new template alias VecField_t was added at lines 30-33, but it is actually defined at lines 38-39 in the hunk.

  • 92-112: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [88-109]

The summary states that Field was replaced with Grid for various variables at lines 88-101, but the hunk shows these changes at lines 92-109.

  • 103-109: The summary states that VecField<NdArrayVector<dim>, HybridQuantity> was replaced with VecField_t<dim> for B1D_, B2D_, and B3D_ at lines 103-106, but the hunk shows these changes at lines 107-109.

  • 303-312: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [299-324]

The summary states that the type of various variables was changed at lines 299-315, but the hunk shows these changes at lines 306-312 and 318-324.

  • 92-112: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [3-324]

The changes in the hunk are consistent with the larger refactoring effort to use Grid and VecField_t types as described in the pull request summary.

tests/core/numerics/ampere/test_main.cpp (6)
  • 5-8: The inclusion of "core/data/grid/grid.hpp" aligns with the summary stating that the grid module has been added.

  • 35-39: The refactoring of physicalStartIndex and physicalEndIndex methods in GridLayoutMock1D to take FieldMock and Direction as arguments is consistent with the summary.

  • 72-72: The addition of the template alias Grid_t is consistent with the summary and is a good use of type aliasing for code clarity and maintainability.

  • 128-143: The changes in Ampere1DTest to use the Grid_t type for fields and VecField for vectors, as well as the addition of dim and interp_order static variables, are consistent with the summary and improve type consistency and readability.

  • 170-185: The changes in Ampere2DTest to use the Grid_t type for fields and VecField for vectors, as well as the addition of dim and interp_order static variables, are consistent with the summary and improve type consistency and readability.

  • 212-228: The changes in Ampere3DTest to use the Grid_t type for fields and VecField for vectors, as well as the addition of dim and interp_order static variables, are consistent with the summary and improve type consistency and readability.

tests/core/numerics/faraday/test_main.cpp (7)
  • 29-55: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [29-68]

The summary states that [[maybe_unused]] attributes were removed from physicalStartIndex and physicalEndIndex methods, but the hunks do not show any such attributes being removed. Please verify if the summary is accurate or if the changes were not included in the hunks.

  • 5-11: The change from including "core/data/field/field.hpp" to "core/data/grid/grid.hpp" aligns with the refactoring towards using Grid types.

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

The update to use FieldMock<dimension> in the GridLayoutMock structs is consistent with the refactoring towards more specific type usage.

  • 136-158: The update to use Grid_t and VecField<Grid_t, HybridQuantity> in the Faraday1DTest class is consistent with the refactoring towards using Grid types.

  • 191-213: The update to use Grid_t and VecField<Grid_t, HybridQuantity> in the Faraday2DTest class is consistent with the refactoring towards using Grid types.

  • 246-269: The update to use Grid_t and VecField<Grid_t, HybridQuantity> in the Faraday3DTest class is consistent with the refactoring towards using Grid types.

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

The test classes Faraday1DTest, Faraday2DTest, and Faraday3DTest are structured to separate concerns for each dimensionality, which is a good practice for clarity and maintainability in unit testing. This aligns with the user's preference for efficient code, as it makes the tests easier to understand and maintain.

tests/core/data/grid/test_grid.hpp Outdated Show resolved Hide resolved
Comment on lines +32 to +36
Grid() = delete;
Grid(Grid const& source) = delete;
Grid(Grid&& source) = default;
Grid& operator=(Grid&& source) = delete;
Grid& operator=(Grid const& source) = delete;
Copy link

Choose a reason for hiding this comment

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

The class Grid has a defaulted move constructor but a deleted move assignment operator. It's generally expected that if a class supports move semantics, it should define both the move constructor and move assignment operator to ensure consistency.

-    Grid& operator=(Grid&& source)      = delete;
+    Grid& operator=(Grid&& source)      = default;

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
Grid() = delete;
Grid(Grid const& source) = delete;
Grid(Grid&& source) = default;
Grid& operator=(Grid&& source) = delete;
Grid& operator=(Grid const& source) = delete;
Grid() = delete;
Grid(Grid const& source) = delete;
Grid(Grid&& source) = default;
Grid& operator=(Grid&& source) = default;
Grid& operator=(Grid const& source) = delete;

Comment on lines +86 to +90
std::transform(std::begin(f1), std::end(f1), std::begin(f2), std::begin(avg),
std::plus<double>());

std::transform(std::begin(avg), std::end(avg), std::begin(avg),
[](double x) { return x * 0.5; });
Copy link

Choose a reason for hiding this comment

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

The average function assumes that the Grid will always be working with double types. This may not be the case, and the function should be templated to work with the value_type of the Grid.

-    std::transform(std::begin(f1), std::end(f1), std::begin(f2), std::begin(avg),
-                   std::plus<double>());
+    std::transform(std::begin(f1), std::end(f1), std::begin(f2), std::begin(avg),
+                   std::plus<typename Grid<NdArrayImpl, PhysicalQuantity>::value_type>());

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
std::transform(std::begin(f1), std::end(f1), std::begin(f2), std::begin(avg),
std::plus<double>());
std::transform(std::begin(avg), std::end(avg), std::begin(avg),
[](double x) { return x * 0.5; });
std::transform(std::begin(f1), std::end(f1), std::begin(f2), std::begin(avg),
std::plus<typename Grid<NdArrayImpl, PhysicalQuantity>::value_type>());
std::transform(std::begin(avg), std::end(avg), std::begin(avg),
[](double x) { return x * 0.5; });

The average function does not check if the sizes of the input Grid objects are the same before performing the operation. This could lead to undefined behavior if the Grid objects have different sizes.

auto operator&() const { return &field_; }

private:
std::string name_{"No Name"};
Copy link

Choose a reason for hiding this comment

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

The Grid class initializes the name_ member with a default value of "No Name". It would be better to enforce the name to be provided during construction to avoid objects without meaningful names.

Comment on lines +64 to +65
assert(Super::size() == that.size());
std::copy(that.data(), that.data() + Super::size(), Super::data());
Copy link

Choose a reason for hiding this comment

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

The copyData method uses assert to check the size of the Grid objects. This check will not be performed in release builds where asserts may be disabled, potentially leading to undefined behavior.

Comment on lines +56 to +58
auto const& [layout, B, E, Bnew] = fn(state);
this->layout_ = &layout;
(*this)(B, E, Bnew, dt);
Copy link

Choose a reason for hiding this comment

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

The layout_ member variable is being set inside a loop, which could lead to incorrect behavior if the states collection contains different layouts. Verify that all states are expected to have the same layout or refactor the code to handle different layouts appropriately.

this->layout_ = &layout;
(*this)(B, E, Bnew, dt);
}
}

private:
double dt_;
Copy link

Choose a reason for hiding this comment

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

The dt_ member variable is used in the BxEq_, ByEq_, and BzEq_ functions but is not set in the new operator() function. Ensure that dt_ is properly initialized before these functions are called.

{
EXPECT_EQ(std::string("test"), this->f.name());
}



TYPED_TEST(GenericField1D, physiscalQuantity)
TYPED_TEST(GenericGrid1D, physiscalQuantity)
Copy link

@coderabbitai coderabbitai bot Nov 30, 2023

Choose a reason for hiding this comment

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

There is a typo in the test case name physiscalQuantity. It should be corrected to physicalQuantity for clarity and correctness.

- TYPED_TEST(GenericGrid1D, physiscalQuantity)
+ TYPED_TEST(GenericGrid1D, physicalQuantity)

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
TYPED_TEST(GenericGrid1D, physiscalQuantity)
TYPED_TEST(GenericGrid1D, physicalQuantity)

Copy link
Member Author

Choose a reason for hiding this comment

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

good bot

Copy link

Choose a reason for hiding this comment

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

@PhilipDeegan Thank you! 😊

(\_/)
( •_•)
/>❤️

tests/core/data/grid/test_grid.cpp Outdated Show resolved Hide resolved
tests/core/data/grid/test_grid.cpp Outdated Show resolved Hide resolved
for (auto& state : states)
{
auto const& [layout, B, E, Bnew] = fn(state);
this->layout_ = &layout;

Check warning

Code scanning / CodeQL

Local variable address stored in non-local memory

A stack address ([source](1)) may be assigned to a non-local variable.
Comment on lines +384 to +398
/* // how to use
for_N<2>([](auto ic) {
constexpr auto i = ic();
// ...
});
*/

Check notice

Code scanning / CodeQL

Commented-out code

This comment appears to contain commented-out code.
for (auto& state : states)
{
auto const& [layout, B, J] = fn(state);
this->layout_ = &layout;

Check warning

Code scanning / CodeQL

Local variable address stored in non-local memory

A stack address ([source](1)) may be assigned to a non-local variable.
for (auto& state : states)
{
auto const& [layout, n, Ve, Pe, B, J, Enew] = fn(state);
this->layout_ = &layout;

Check warning

Code scanning / CodeQL

Local variable address stored in non-local memory

A stack address ([source](1)) may be assigned to a non-local variable.
template<typename... Args>
auto static _J(Args&... args)
{
auto const& [Jx, Jy, Jz] = std::forward_as_tuple(args...);

Check notice

Code scanning / CodeQL

Unused local variable

Variable (unnamed local variable) is not used.
template<typename... Args>
auto static _ions(Args&... args)
{
auto const& [Fxi, Fyi, Fzi, Nibuffer, NiProtons, Vix, Viy, Viz, pack]

Check notice

Code scanning / CodeQL

Unused local variable

Variable (unnamed local variable) is not used.
src/core/utilities/types.hpp Dismissed Show dismissed Hide dismissed
template<typename... Args>
auto static _J(Args&... args)
{
auto const& [Jx, Jy, Jz] = std::forward_as_tuple(args...);

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable (unnamed local variable) is not used.
template<typename... Args>
auto static _ions(Args&... args)
{
auto const& [Fxi, Fyi, Fzi, Nibuffer, NiProtons, Vix, Viy, Viz, pack]

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable (unnamed local variable) is not used.
for (auto& state : states)
{
auto const& [layout, B, J] = fn(state);
this->layout_ = &layout;

Check warning

Code scanning / CodeQL

Local variable address stored in non-local memory Warning

A stack address (
source
) may be assigned to a non-local variable.
for (auto& state : states)
{
auto const& [layout, B, E, Bnew] = fn(state);
this->layout_ = &layout;

Check warning

Code scanning / CodeQL

Local variable address stored in non-local memory Warning

A stack address (
source
) may be assigned to a non-local variable.
for (auto& state : states)
{
auto const& [layout, n, Ve, Pe, B, J, Enew] = fn(state);
this->layout_ = &layout;

Check warning

Code scanning / CodeQL

Local variable address stored in non-local memory Warning

A stack address (
source
) may be assigned to a non-local variable.
@PhilipDeegan PhilipDeegan force-pushed the views branch 2 times, most recently from 72f4841 to 2fd735c Compare November 30, 2023 14:51
@PhilipDeegan
Copy link
Member Author

closes #778

if (static_cast<std::size_t>(levelNumber) == model_views_.size())
model_views_.push_back(solver.make_view(*level, model));
else
model_views_[levelNumber] = solver.make_view(*level, model);
Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't super sure of the point of the level descriptor system here so I didn't use it.

That might very well be an issue for future usage with varying solvers between levels, tbc

field -> grid

more

more

more
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: 22

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 2ae567b and e14b580.
Files selected for processing (57)
  • res/cmake/dep.cmake (1 hunks)
  • res/cmake/test.cmake (1 hunks)
  • src/amr/data/field/field_data.hpp (2 hunks)
  • src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (3 hunks)
  • src/amr/multiphysics_integrator.hpp (5 hunks)
  • src/amr/physical_models/hybrid_model.hpp (2 hunks)
  • src/amr/resources_manager/field_resource.hpp (1 hunks)
  • src/amr/resources_manager/resources_manager.hpp (2 hunks)
  • src/amr/solvers/solver.hpp (5 hunks)
  • src/amr/solvers/solver_mhd.hpp (2 hunks)
  • src/amr/solvers/solver_ppc.hpp (6 hunks)
  • src/amr/solvers/solver_ppc_model_view.hpp (1 hunks)
  • src/amr/tagging/default_hybrid_tagger_strategy.hpp (1 hunks)
  • src/amr/tagging/hybrid_tagger.hpp (1 hunks)
  • src/core/data/electrons/electrons.hpp (9 hunks)
  • src/core/data/field/field.hpp (1 hunks)
  • src/core/data/grid/grid.hpp (1 hunks)
  • src/core/data/grid/gridlayout.hpp (6 hunks)
  • src/core/data/ions/ion_population/ion_population.hpp (4 hunks)
  • src/core/data/ions/ions.hpp (2 hunks)
  • src/core/data/ndarray/ndarray_vector.hpp (5 hunks)
  • src/core/data/vecfield/vecfield.hpp (4 hunks)
  • src/core/models/hybrid_state.hpp (1 hunks)
  • src/core/numerics/ampere/ampere.hpp (1 hunks)
  • src/core/numerics/faraday/faraday.hpp (1 hunks)
  • src/core/numerics/ohm/ohm.hpp (1 hunks)
  • src/core/utilities/box/box.hpp (1 hunks)
  • src/core/utilities/types.hpp (3 hunks)
  • src/diagnostic/detail/types/fluid.hpp (1 hunks)
  • src/phare_core.hpp (3 hunks)
  • src/simulator/phare_types.hpp (1 hunks)
  • tests/amr/data/field/coarsening/test_linear_coarsen.hpp (3 hunks)
  • tests/amr/data/field/copy_pack/field_data_test_param.hpp (2 hunks)
  • tests/amr/data/field/geometry/test_field_geometry.cpp (2 hunks)
  • tests/amr/data/field/refine/test_field_refine.cpp (1 hunks)
  • tests/amr/data/field/refine/test_field_refinement_on_hierarchy.cpp (2 hunks)
  • tests/amr/data/field/refine/test_field_refinement_on_hierarchy.hpp (1 hunks)
  • tests/amr/data/field/time_interpolate/test_field_data_time_interpolate.cpp (2 hunks)
  • tests/amr/data/field/variable/test_field_variable.cpp (2 hunks)
  • tests/amr/models/test_models.cpp (1 hunks)
  • tests/amr/resources_manager/CMakeLists.txt (1 hunks)
  • tests/amr/resources_manager/input_config.h (1 hunks)
  • tests/amr/resources_manager/test_resources_manager.cpp (2 hunks)
  • tests/amr/resources_manager/test_resources_manager_basic_hierarchy.hpp (1 hunks)
  • tests/amr/tagging/test_tagging.cpp (1 hunks)
  • tests/core/data/electrons/test_electrons.cpp (10 hunks)
  • tests/core/data/field/test_field.hpp (2 hunks)
  • tests/core/data/grid/CMakeLists.txt (1 hunks)
  • tests/core/data/grid/test_grid.cpp (9 hunks)
  • tests/core/data/gridlayout/gridlayout_base_params.hpp (1 hunks)
  • tests/core/data/gridlayout/gridlayout_deriv.hpp (4 hunks)
  • tests/core/data/gridlayout/gridlayout_laplacian.hpp (4 hunks)
  • tests/core/data/ion_population/test_ion_population.cpp (1 hunks)
  • tests/core/data/ions/test_ions.cpp (2 hunks)
  • tests/core/data/vecfield/test_main.cpp (5 hunks)
  • tests/core/numerics/ampere/test_main.cpp (6 hunks)
  • tests/core/numerics/faraday/test_main.cpp (6 hunks)
Files not processed due to max files limit (4)
  • tests/core/numerics/interpolator/test_main.cpp
  • tests/core/numerics/ion_updater/test_updater.cpp
  • tests/core/numerics/ohm/test_main.cpp
  • tests/functional/harris/harris_2d_2.py
Files skipped from review due to trivial changes (4)
  • res/cmake/dep.cmake
  • src/amr/resources_manager/resources_manager.hpp
  • tests/amr/resources_manager/input_config.h
  • tests/core/data/grid/CMakeLists.txt
Additional comments: 166
res/cmake/test.cmake (1)
  • 10-14: The addition of tests/core/data/grid and related test directories is consistent with the PR's objective of transitioning to a Grid-based system. Ensure that any obsolete test directories, such as tests/core/data/field, are removed if they are no longer relevant to avoid maintaining dead code, in line with the user's preference for minimal and efficient code.
src/amr/data/field/field_data.hpp (2)
  • 86-91: The changes in the getFromRestart method to use getDoubleArray instead of getVector and the addition of an assertion to check the vector size are good for ensuring data integrity and avoiding potential issues with empty vectors.

  • 314-314: The change in the return type of the getPointer method from FieldImpl* to auto* is consistent with modern C++ practices and should maintain the same functionality while allowing for automatic type deduction.

src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (3)
  • 49-88: The changes to the FieldUser struct, including the use of GridT instead of FieldT and the addition of a nested type field_type, are consistent with the PR objectives and the generated summaries. The copyData method's use of a template parameter That instead of FieldT const& is also in line with the refactoring.

  • 95-125: The updates to the HybridHybridMessengerStrategy class, including the use of GridT instead of FieldT in type aliases and member types, align with the PR objectives and the generated summaries. The changes to the BaseRefineOp, FieldTimeInterp, and BaseCoarsenOp types to use GridT are also consistent with the transition to a grid-based system.

  • 1006-1010: The FieldUser instance NiOldUser_ has been correctly updated to use GridT instead of FieldT, and the NiOld_ member has been changed from FieldT* to field_type*, which is consistent with the refactoring effort described in the PR objectives and the generated summaries.

src/amr/multiphysics_integrator.hpp (5)
  • 344-351: The logic for updating or pushing new model views in initializeLevelData is correct. However, it's important to ensure that the size of model_views_ is always in sync with the number of levels. If the number of levels can change dynamically, additional logic may be needed to handle resizing of model_views_.

  • 365-374: The logic for registering levels and pushing back new model views in resetHierarchyConfiguration is correct. However, it's important to ensure that the size of model_views_ is always in sync with the number of levels. If the number of levels can change dynamically, additional logic may be needed to handle resizing of model_views_.

  • 495-502: The logic for retrieving the model view in advanceLevel is correct. However, it's important to ensure that the model_views_ vector has been properly initialized before this function is called. If the vector is not correctly initialized, accessing an element could lead to undefined behavior.

  • 575-583: The addition of the model_views_ member is consistent with the changes in the functions that manage model views. Ensure that the model_views_ vector is properly managed throughout the class to prevent issues such as out-of-bounds access or memory leaks.

  • 807-807: The addition of the getModelView_ function is consistent with the changes in the functions that manage model views. Ensure that this function is used consistently throughout the class to access model views.

src/amr/physical_models/hybrid_model.hpp (3)
  • 7-7: The addition of the include statement for "core/data/grid/grid.hpp" is consistent with the PR's objective to transition to a Grid-based system.

  • 37-38: The introduction of the grid_type alias within the HybridModel class is consistent with the PR's objective to refactor the codebase to use a new Grid class template.

  • 27-43: The reorganization and addition of type aliases within the HybridModel class are consistent with the PR's objective to refactor the codebase to use a new Grid class template.

src/amr/solvers/solver.hpp (5)
  • 12-28: The addition of the PHARE::solver namespace and the ISolverModelView class is consistent with the PR summary. However, the class is currently empty, which may be intentional for future extensions.

  • 44-49: The addition of new typedefs within the ISolver class aligns with the PR summary and is a common practice to simplify complex type names.

  • 86-92: The method signature changes for advanceLevel reflect the transition to using the new hierarchy_t and ISolverModelView& types, which is consistent with the PR summary.

  • 99-103: The method signature change for allocate to accept patch_t& is consistent with the PR summary and reflects the refactoring towards the new type aliases.

  • 108-116: The addition of the make_view method and the constructor change for ISolver are consistent with the PR summary. The constructor now takes a string parameter, which is a change from the previous version.

src/amr/solvers/solver_mhd.hpp (2)
  • 17-19: The addition of type aliases patch_t, level_t, and hierarchy_t is consistent with the PR's objective of refactoring and aligns with the broader transition to a grid-based system. These aliases will help standardize types across the codebase.

  • 41-56: The changes in method signatures for allocate and advanceLevel and the addition of the make_view method are consistent with the PR's objective. However, the make_view method is not implemented and throws a runtime error. Ensure that this is the intended behavior and that there is a plan to implement this method in the future.

src/amr/solvers/solver_ppc.hpp (7)
  • 11-17: The inclusion of "amr/solvers/solver_ppc_model_view.hpp" and the addition of Faraday_t faraday_1; suggest that the SolverPPC class is being extended to use a model view for the Faraday update step, which aligns with the PR title "hierarchy views". This change should be verified across the codebase to ensure consistency.

  • 99-101: The addition of the make_view function is a significant change as it introduces a new way of creating views for the solver. This function should be checked to ensure that it is being used correctly wherever SolverPPC instances are created and that the dynamic cast is safe and appropriate.

  • 205-215: The restoreState_ function now uses std::move to restore particle states. This is an efficient way to transfer ownership of the particle data without copying. However, it should be ensured that the tmpDomain and patchGhost maps are properly managed after the move operation to avoid accessing moved-from objects.

  • 227-250: The advanceLevel function orchestrates the sequence of operations for advancing the solver's state. The changes here seem to reflect the new model view system and should be checked to ensure that the order of operations is correct and that all necessary state is preserved between steps.

  • 269-275: The faraday_1 operation within predictor1_ is a new addition and should be checked for correctness. It's important to ensure that the lambda passed to faraday_1 correctly captures the necessary state and that the newTime parameter is used appropriately within the function.

  • 401-427: The _debug_log_move_ions function is a new debug utility. It's important to ensure that this function is only compiled in debug builds to avoid performance overhead in release builds. The use of PHARE_DEBUG_DO macro suggests this, but it should be verified.

  • 433-463: The moveIons_ function has been updated, and it's crucial to ensure that the sequence of updates and ghost fills is correct and that the UpdaterMode is used appropriately. The changes should be checked against the model's requirements for ion movement.

src/amr/solvers/solver_ppc_model_view.hpp (1)
  • 35-48: The AmpereTransformer and OhmTransformer classes are defined but do not contain any implementation. Please verify if this is intentional or if the implementation is pending.
src/amr/tagging/default_hybrid_tagger_strategy.hpp (1)
  • 42-46: The changes to the NdArrayView instantiation are consistent with the broader refactoring from a Field-based to a Grid-based system and the removal of the Pointer template parameter as described in the PR summary. This change should be verified across the codebase to ensure that all instances of NdArrayView instantiation have been updated accordingly.
src/core/data/electrons/electrons.hpp (7)
  • 10-10: The addition of #include "core/logger.hpp" is consistent with the changes and may be necessary for logging within the file.

  • 139-140: The change from references to objects for ions_ and J_ in StandardHybridElectronFluxComputer alters the ownership and lifecycle management of these members. Ensure that this change is intentional and that all necessary adjustments have been made throughout the codebase to accommodate this new ownership model.

  • 157-160: The constructor of IsothermalElectronPressureClosure now takes an Ions object instead of a FluxComputer object. Verify that all instantiations of this class have been updated to pass the correct type of argument.

  • 169-171: The isUsable and isSettable methods in IsothermalElectronPressureClosure are now const, which is a good practice as it indicates that these methods do not modify the object state.

  • 219-220: The computePressure method in IsothermalElectronPressureClosure now requires a GridLayout parameter. Ensure that all calls to this method have been updated to include this new parameter.

  • 252-255: The constructor of ElectronMomentModel now takes an Ions object instead of a reference. This change in parameter type could have implications on object management and ownership. Verify that this change is intentional and that all necessary adjustments have been made throughout the codebase.

  • 324-324: The move constructor for Electrons is explicitly deleted. Ensure that this is intentional and that there are no attempts to move Electrons objects within the codebase, as this would now result in a compilation error.

src/core/data/field/field.hpp (2)
  • 58-68: The summary states that the average function has been moved outside the core namespace, but the hunk shows it is still within the core namespace. Please verify this discrepancy.

  • 31-38: The new constructor for the Field class is correctly implemented, initializing the base class and member variables as expected.

src/core/data/grid/grid.hpp (8)
  • 34-35: The move assignment operator is deleted, which is inconsistent with the default move constructor. Consider providing a default move assignment operator to maintain consistency with move semantics.
-    Grid& operator=(Grid&& source)      = delete;
+    Grid& operator=(Grid&& source)      = default;
  • 86-87: The average function uses a hard-coded double type, which may not match the value_type of the Grid. Consider using the value_type of the Grid in the std::plus operation.
-                   std::plus<double>());
+                   std::plus<typename Grid<NdArrayImpl, PhysicalQuantity>::value_type>());
  • 82-90: The average function does not check if the sizes of the input Grid objects are the same before performing the operation. Consider adding a size check to prevent undefined behavior.

  • 73-73: The Grid class initializes the name_ member with a default value of "No Name". Consider enforcing the name to be provided during construction to avoid objects without meaningful names.

  • 64-64: The copyData method uses assert to check the size of the Grid objects, which will not be performed in release builds. Consider using a runtime check that remains in release builds.

  • 69-70: The overloaded operator& returns the address of field_, which could be misleading. Consider providing a more explicit method to get the address of field_.

  • 20-75: The Grid class does not provide any documentation comments. Adding documentation would improve code readability and maintainability.

  • 20-75: Given the significant refactoring from Field to Grid, ensure that all related changes are consistent across the codebase and that dependent modules are updated accordingly.

src/core/data/grid/gridlayout.hpp (6)
  • 328-332: The function physicalStartIndex has been templated with Field_t to generalize its use, which aligns with the refactoring goal of making the code more generic.

  • 370-374: The function physicalEndIndex has been templated with Field_t to generalize its use, which aligns with the refactoring goal of making the code more generic.

  • 407-413: The function ghostStartIndex has been templated with Field_t to generalize its use, which aligns with the refactoring goal of making the code more generic.

  • 450-453: The function ghostEndIndex has been templated with Field_t to generalize its use, which aligns with the refactoring goal of making the code more generic.

  • 467-473: The function fieldNodeCoordinates has been templated with Field_t to generalize its use, which aligns with the refactoring goal of making the code more generic. However, the static assertion ensures that the number of indices provided matches the dimension, which is a good practice for compile-time error checking.

  • 961-965: The function fieldCentering has been templated with Field_t to generalize its use, which aligns with the refactoring goal of making the code more generic.

src/core/data/ions/ion_population/ion_population.hpp (5)
  • 24-30: The addition of grid_type and field_type type aliases, as well as the dimension constant, aligns with the PR's objective to transition to a grid-based system. These changes are consistent with the overall refactoring effort and should be beneficial for standardizing data representation.

  • 151-157: The addition of levelGhostParticlesOld and levelGhostParticlesNew member functions is consistent with the PR's objective to enhance the IonPopulation class's functionality. These methods provide access to different states of ghost particles, which could be important for AMR functionalities.

  • 170-176: The const and non-const overloads for levelGhostParticlesNew are correctly implemented, following the established pattern in the class for providing access to particle arrays.

  • 192-198: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [180-196]

The changes to the density member function, adding const qualifiers, are consistent with best practices for const-correctness. This ensures that the function does not modify the object state, which is a good practice for accessor methods.

  • 151-161: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [24-197]

The changes in the IonPopulation class are consistent with the PR's objective to refactor the codebase to a grid-based system. The new member functions and type aliases support this transition and are likely to improve the codebase's maintainability and performance.

src/core/data/ions/ions.hpp (3)
  • 26-31: The introduction of grid_type as a type alias is consistent with the PR's objective of transitioning to a Grid-based system. This change should be reflected in all places where IonPopulation::grid_type is used within the Ions class.

  • 40-41: The addition of default move and copy constructors is a good practice for classes that manage resources, which can help ensure that instances of Ions are copied and moved correctly. This is especially important given the presence of pointers like rho_ and massDensity_ within the class.

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

The changes to the Ions class are consistent with the PR's objective of transitioning to a Grid-based system and do not appear to introduce any new issues or regressions. The addition of default move and copy constructors is a good practice and likely to improve the maintainability and readability of the code. These changes are likely to have a significant impact on the codebase, requiring updates to dependent modules and potentially affecting the behavior of the software.

src/core/data/ndarray/ndarray_vector.hpp (7)
  • 131-150: The changes to the NdArrayView class reflect the removal of the Pointer template parameter and the introduction of pointer_type. The constructors have been updated accordingly, and new methods for iterator support and zeroing the array have been added. These changes are consistent with the summary provided.

  • 184-189: The fill_from method correctly checks for size compatibility before copying data, which is a good error handling practice.

  • 197-197: The zero method is implemented efficiently using std::fill to zero out the array.

  • 191-195: The begin and end methods are correctly provided in both const and non-const versions to support iteration over the array.

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

The operator() overloads for element access are updated to use the viewer alias and are consistent with the removal of the Pointer template parameter.

  • 200-200: The ptr_ member is safely initialized to nullptr, ensuring a valid state upon default construction.

  • 201-201: The nCells_ member is not default-initialized, but this is mitigated by the fact that the constructors of NdArrayView always initialize it.

src/core/data/vecfield/vecfield.hpp (4)
  • 23-40: The changes to the VecField class template, including the renaming of the template parameter from NdArrayImpl to Grid_t, the addition of new member declarations, and the change from deleted to defaulted copy and move constructors and assignment operators, are consistent with the PR's objective of transitioning to a grid-based system. These changes should be verified across the codebase to ensure that all instances of VecField and related classes are updated accordingly.

  • 66-71: The getFieldNamesAndQuantities method's implementation is consistent with the PR's objective and the summary. It is now using the VecFieldProperties struct to return the properties of the field components, which aligns with the refactoring towards a more grid-centric approach.

  • 127-130: The change in the return type of the getComponent method to auto& is consistent with the PR's objective of transitioning to a grid-based system and the summary. This change simplifies the method signature and is in line with modern C++ practices.

  • 144-147: The change in the return type of the getComponent method to auto const& for the const version of the method is consistent with the PR's objective and the summary. This change simplifies the method signature and is in line with modern C++ practices.

src/core/models/hybrid_state.hpp (1)
  • 75-83: The changes to getCompileTimeResourcesUserList to include the J variable in the returned tuple are consistent with the PR's objective of transitioning to a grid-based system. Ensure that all dependent code that uses this function is updated to handle the additional tuple element.
src/core/numerics/faraday/faraday.hpp (1)
  • 50-60: The new operator() method does not appear to be related to the PR's objective of transitioning from a Field-based representation to a Grid-based system. If this method is part of the refactoring, ensure that it aligns with the new grid-based architecture and that any necessary updates are made to use grid types instead of field types.
src/core/utilities/types.hpp (3)
  • 72-76: The addition of the Tuple alias within the type_list struct is a straightforward enhancement that allows for easier use of std::tuple with the types provided to type_list.

  • 330-346: The change to make all, any, and none functions constexpr is a good improvement, enabling compile-time evaluation where possible.

  • 360-462: The introduction of the Apply struct and related functions for compile-time iteration is a sophisticated addition that can enhance the metaprogramming capabilities of the codebase.

src/diagnostic/detail/types/fluid.hpp (1)
  • 192-197: The change from &(*field.begin()) to field.data() in the writeDS lambda function simplifies the way the address of the data buffer is obtained and is consistent with standard C++ behavior for contiguous storage. This change should be verified to ensure that it does not alter the expected behavior of the program, especially if the field object's data() method has been overridden or behaves differently from the standard library containers.
src/phare_core.hpp (7)
  • 5-5: The inclusion of "core/data/grid/grid.hpp" is consistent with the PR's objective of refactoring to a grid-based system.

  • 38-46: The introduction of Grid_t and ArrayView_t types and their usage in VecField_t and Field_t is consistent with the PR's objective of transitioning to a grid-based system.

  • 35-46: No code removals or replacements are observed in this hunk, which is consistent with the summary provided.

  • 44-44: The Electromag_t type alias has been updated to use the new VecField_t which now uses the Grid_t type, reflecting the changes in the underlying data structure for electromagnetic fields.

  • 45-46: The YeeLayout_t and GridLayout_t type aliases remain unchanged, indicating that the grid layout implementation details are not affected by the transition to the new grid system.

  • 50-55: The introduction of ParticleArray_t and ParticleSoA_t type aliases is consistent with the PR's objective of refactoring to accommodate the new grid structures.

  • 55-55: The IonPopulation_t type alias has been updated to use VecField_t and GridLayout_t, which have been updated to use the new grid types, reflecting the changes in the underlying data structure for ion populations.

src/simulator/phare_types.hpp (1)
  • 19-24: The addition of the Grid_t type alias aligns with the PR's objective of refactoring the codebase to a grid-based system. Ensure that the introduction of this alias is reflected in all relevant parts of the codebase where Grid_t should be used.
tests/amr/data/field/coarsening/test_linear_coarsen.hpp (4)
  • 5-11: The inclusion of new headers and the removal of old ones is consistent with the transition from Field to Grid as mentioned in the PR objectives and summaries. Ensure that the removed headers are no longer needed and that the new headers are correctly providing the necessary functionality.

  • 55-61: The change from Field to Grid in the EMData struct's type definition is consistent with the PR's objective to transition to a grid-based system. Ensure that all usages of EMData and its Field_t type are updated accordingly.

  • 91-97: The change from Field to Grid in the FieldCoarsenTestData struct's type definition is consistent with the PR's objective. Ensure that all usages of FieldCoarsenTestData and its Field_t type are updated accordingly.

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

Given the user's preference for minimal and efficient code, it's important to ensure that the changes made here do not introduce unnecessary complexity or redundancy. The changes appear to be straightforward type updates, but it's worth double-checking that these updates have not led to any redundant code or missed opportunities for further optimization.

tests/amr/data/field/copy_pack/field_data_test_param.hpp (2)
  • 15-25: The changes align with the PR's objective of transitioning to a grid-based system, as indicated by the inclusion of the grid header and the update to the type alias.

  • 281-284: The type aliases are updated to reflect the transition to the grid-based system, which is consistent with the PR's objective and the summary.

tests/amr/data/field/geometry/test_field_geometry.cpp (2)
  • 11-15: The inclusion of "core/data/grid/grid.hpp" and related grid headers is consistent with the PR's objective to refactor the codebase to use a grid-based system.

  • 35-35: The change of the type alias "Field1D" to use the new Grid class is in line with the PR's objective of transitioning from a Field-based to a Grid-based system.

tests/amr/data/field/refine/test_field_refine.cpp (1)
  • 78-84: The change from Field to Grid in the type alias FieldT is consistent with the PR's objective of refactoring the codebase to use a grid-based system. Ensure that any test logic that depends on the behavior of the original Field type is updated to work with the new Grid type if there are differences in behavior or interface.
tests/amr/data/field/refine/test_field_refinement_on_hierarchy.cpp (2)
  • 22-23: The change from Field to Grid in the type alias FieldND is consistent with the PR objective and the summary provided, indicating a shift to a grid-based system.

  • 53-54: The change from Field to Grid in the type alias FieldND within the test case is consistent with the PR objective and the summary provided, indicating a shift to a grid-based system.

tests/amr/data/field/refine/test_field_refinement_on_hierarchy.hpp (2)
  • 6-10: The addition of the include statement for "core/data/grid/grid.hpp" is consistent with the PR's objective of refactoring the codebase to use a Grid-based system instead of a Field-based representation. This change is expected as part of the transition and should be reflected in the logic of the test suite.

  • 6-12: Please verify that the rest of the test suite has been updated to reflect the transition from Field to Grid and that the new Grid class is being utilized as intended. This may involve checking for updates to test cases, type aliases, and logic within the test suite to ensure compatibility with the new grid-based system.

tests/amr/data/field/time_interpolate/test_field_data_time_interpolate.cpp (3)
  • 13-18: The changes in the includes reflect the transition from Field to Grid as outlined in the PR objectives and summary. This is consistent with the broader refactoring effort across the codebase.

  • 48-54: The update of the type alias FieldND to use Grid instead of Field is consistent with the PR's objective of refactoring the codebase to use a grid-based system.

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

Overall, the changes in the test file are consistent with the PR's objective of transitioning to a grid-based system, and no further issues are observed within the provided context.

tests/amr/data/field/variable/test_field_variable.cpp (3)
  • 8-15: The changes in the includes and the template alias FieldVar are consistent with the PR's objective of refactoring the codebase to use a Grid-based system instead of Field.

  • 51-53: The update of the template alias FieldVar to use Grid instead of Field is a key change that aligns with the PR's objective of refactoring the codebase to use a Grid-based system.

  • 50-53: The tests have been updated to use the new FieldVar template alias, which now uses Grid. This ensures that the tests are consistent with the changes made to the codebase.

tests/amr/models/test_models.cpp (1)
  • 29-49: The changes in the type aliases and class instantiations are consistent with the transition to a Grid-based system as outlined in the PR summary. The new Grid1D, VecField1D, GridImplYee1D, ParticleArray1D, GridYee1D, and related types are correctly defined and used, which aligns with the objective of refactoring the codebase to use a grid-based representation. This should improve the structure and organization of the code.
tests/amr/resources_manager/test_resources_manager.cpp (3)
  • 5-11: The inclusion of "core/data/grid/grid.hpp" is consistent with the PR's objective of refactoring to a Grid-based system.

  • 32-48: The changes in type aliases are consistent with the PR's objective of transitioning to a Grid-based system and do not introduce unnecessary complexity, aligning with the user's preference for minimal and efficient code.

  • 50-51: The updates to createInitDict using InitFunctionT are consistent with the PR's objective of refactoring and ensure type safety in the initialization dictionary.

tests/amr/resources_manager/test_resources_manager_basic_hierarchy.hpp (3)
  • 31-39: Initialization of member variables in the constructor appears correct and aligns with the PR objectives.

  • 54-55: Hard-coded grid size in init method. Ensure this is intentional and aligns with the test's design.

  • 60-64: Usage of a static variable counterId to generate unique IDs for patch levels appears to be a deliberate design choice.

tests/amr/tagging/test_tagging.cpp (2)
  • 164-164: The change from Field to Grid_t aligns with the PR's objective of transitioning from a Field-based representation to a Grid-based system.

  • 161-167: Given the significant refactoring from Field to Grid_t, it's important to ensure that the associated tests are updated and that new tests are added to cover the new functionality and data structures.

tests/core/data/electrons/test_electrons.cpp (7)
  • 5-5: The addition of #include "core/data/grid/grid.hpp" aligns with the PR's objective of transitioning to a Grid-based system.

  • 20-20: The addition of #include <string_view> is likely related to the use of std::string_view in the code, which is a more efficient way to handle strings when copies are not needed.

  • 127-136: The changes in the ElectronsTest struct, including the addition of densityName and updates to type definitions for GridND and VecFieldND, are consistent with the PR's objective of refactoring to a grid-based system.

  • 146-160: The addition of GridND variables and template member functions _ions and _J in the ElectronsTest struct is in line with the PR's objective of enhancing the grid-based functionalities.

  • 142-204: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [192-219]

The constructor of ElectronsTest has been updated to initialize the new GridND and VecFieldND variables, which is consistent with the PR's objective of refactoring to a grid-based system.

  • 235-238: The fill lambda functions have been updated to initialize the fields for different dimensions, which is necessary due to the changes in the data structures and types.

  • 599-601: The main function is standard for a test suite and has no issues.

tests/core/data/field/test_field.hpp (2)
  • 4-14: The addition of #include "core/data/ndarray/ndarray_vector.hpp" and the changes to the template parameters are consistent with the overall refactoring effort described in the PR summary. Ensure that the new dependency does not introduce any circular dependencies and that all affected code has been updated to reflect the new template parameters.

  • 173-193: The addition of new template functions for testing different field types is consistent with the refactoring effort and the transition from Field to Grid. Ensure that these new functions are covered by unit tests to verify their correctness and that they do not introduce any unintended side effects.

tests/core/data/grid/test_grid.cpp (6)
  • 5-8: The inclusion of "core/data/grid/grid.hpp" aligns with the PR's objective of transitioning to a Grid-based system.

  • 13-53: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [15-59]

The renaming of test classes and the use of Grid class in place of Field is consistent with the PR's objective and the summary provided.

  • 135-168: The tests for the Grid class are consistent with the changes made in the previous hunks.

  • 192-204: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [173-201]

The tests for the Grid class are consistent with the changes made in the previous hunks.

  • 242-251: The test for the average function is consistent with the PR's objective of adding new functionalities to the Grid class.

  • 272-281: The tests for the average function for 2D and 3D grids are consistent with the PR's objective of adding new functionalities to the Grid class.

tests/core/data/gridlayout/gridlayout_base_params.hpp (5)
  • 24-24: The summary indicates that std::shared_ptr<GridLayout<GridLayoutImpl>> layout; should have been replaced with std::shared_ptr<Grid_t> layout;, but the code still shows the original layout declaration. Please verify if this is an oversight in the summary or if the code change was missed.

  • 32-32: The change from Field to Grid for the field member is consistent with the PR objectives and the summary.

  • 35-39: The update to the makeIt_ function to use Grid_t is consistent with the PR objectives and the summary.

  • 41-41: The makeMyField_ function indirectly reflects the transition to Grid by utilizing the updated makeIt_ function.

  • 17-41: The refactoring of the GridLayoutTestParam struct to use the Grid class template aligns with the user's preference for minimal and efficient code.

tests/core/data/gridlayout/gridlayout_deriv.hpp (4)
  • 5-8: The changes in the header files are consistent with the PR objectives and the summary provided, indicating a shift from Field to Grid in the codebase.

  • 27-31: The replacement of Field with Grid for the By and Ez variables in the a1DDerivative class is consistent with the PR objectives and the summary provided.

  • 47-51: The replacement of Field with Grid for the By and Ez variables in the a2DDerivative class is consistent with the PR objectives and the summary provided.

  • 67-71: The replacement of Field with Grid for the By and Ez variables in the a3DDerivative class is consistent with the PR objectives and the summary provided.

tests/core/data/gridlayout/gridlayout_laplacian.hpp (4)
  • 2-8: The changes in the import statements align with the PR objectives and the generated summaries, indicating a shift from Field to Grid based system.

  • 25-30: The variable type changes from Field to Grid for Jx, Jy, and Jz in the 1D case are consistent with the PR objectives and the generated summaries.

  • 47-52: The variable type changes from Field to Grid for Jx, Jy, and Jz in the 2D case are consistent with the PR objectives and the generated summaries.

  • 69-74: The variable type changes from Field to Grid for Jx, Jy, and Jz in the 3D case are consistent with the PR objectives and the generated summaries.

tests/core/data/ion_population/test_ion_population.cpp (1)
  • 24-30: The addition of grid_type within the DummyVecField struct aligns with the broader refactoring effort from Field to Grid and is consistent with the PR objectives. The change is localized to this test file and does not appear to affect external modules.
tests/core/data/ions/test_ions.cpp (5)
  • 9-15: The addition of the include statement for "core/data/grid/grid.hpp" aligns with the PR's objective of transitioning to a Grid-based system.

  • 37-38: The modification of the type alias VecField1D to use Grid1D is consistent with the PR's objective of refactoring to a Grid-based system.

  • 37-37: The introduction of the type alias Grid1D is consistent with the PR's objective of refactoring to a Grid-based system.

  • 38-38: The update of the type VecField1D to use Grid1D is consistent with the PR's objective of refactoring to a Grid-based system.

  • 41-41: The type IonPopulation1D correctly uses VecField1D as indicated in the PR summary. The summary contains an error in stating that IonPopulation1D was changed to use GridYee1D instead of VecField1D.

tests/core/data/vecfield/test_main.cpp (6)
  • 6-9: The inclusion of both grid.hpp and field.hpp headers suggests that Field related code might still be present in the file or the codebase. Since the PR objective is to transition from Field to Grid, verify that the inclusion of field.hpp is still necessary.

  • 27-30: The VecFieldGeneric class correctly uses the Grid class template, aligning with the PR objective to transition from Field to Grid.

  • 38-39: The introduction of the VecField_t template alias is consistent with the PR objective and the summary provided. It replaces the VecField instances with a Grid-based type.

  • 92-109: The VecFieldTest class correctly uses the VecField_t template alias and Grid with NdArrayVector, which is consistent with the PR objective to transition from Field to Grid.

  • 303-312: The test case TEST(aVecField, dataCanBeCopiedIntoAnother) correctly uses VecField_t and Grid with NdArrayVector, which is consistent with the PR objective to transition from Field to Grid.

  • 318-324: The test case TEST(aVecField, dataCanBeCopiedIntoAnother) also correctly uses VecField_t and Grid with NdArrayVector for the second set of grids, aligning with the PR objective to transition from Field to Grid.

tests/core/numerics/ampere/test_main.cpp (7)
  • 5-11: The inclusion of both grid.hpp and field.hpp suggests that Field types may still be in use, which could be inconsistent with the PR's objective to transition fully to Grid. Verify if Field types are still needed or if their inclusion is a leftover from before the refactoring.

  • 35-40: The refactoring of GridLayoutMock structs is not mentioned in the summary. If these changes are significant, the summary should be updated to reflect them.

  • 71-72: The introduction of the Grid_t alias and its usage in the test classes is consistent with the PR's objective to transition to a Grid-based system.

  • 125-143: The update of the Ampere test classes to use Grid_t and VecField<Grid_t> is consistent with the PR's objective to transition to a Grid-based system.

  • 167-185: The update of the Ampere tests for 2D cases to reflect the new Grid system is consistent with the PR's objective to transition to a Grid-based system.

  • 209-228: The update of the Ampere tests for 3D cases to reflect the new Grid system is consistent with the PR's objective to transition to a Grid-based system.

  • 5-11: The summary of generated summaries mentions the removal of the pre-increment operator method from the box_iterator class in the Box class. Verify this change in the relevant files.

tests/core/numerics/faraday/test_main.cpp (5)
  • 5-11: The inclusion of grid-related headers aligns with the PR objective of transitioning to a Grid-based system.

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

The GridLayoutMock structs still use FieldMock instead of the new Grid-based system. Verify if FieldMock needs to be updated to align with the new Grid system.

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

The test classes have been updated to use Grid_t, which is consistent with the PR objective of transitioning to a Grid-based system.

  • 246-271: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [70-322]

The test cases appear to be correctly testing the Faraday functionality with the new Grid system.

  • 5-11: > Note: This review was outside the patches, and no patch overlapping with it was found. Original lines [322-328]

The main function for running the tests is correctly set up.

using patch_data_type = FieldData<GridLayoutT, typename ResourcesUser::field_type>;
using variable_type = FieldVariable<GridLayoutT, typename ResourcesUser::field_type>;
using patch_data_type = FieldData<GridLayoutT, typename ResourcesUser::grid_type>;
using variable_type = FieldVariable<GridLayoutT, typename ResourcesUser::grid_type>;
using internal_type_ptr = typename ResourcesUser::field_type*;
Copy link

Choose a reason for hiding this comment

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

The internal_type_ptr type alias still references typename ResourcesUser::field_type. If the transition from Field to Grid is complete, this might be an oversight and should be updated to use grid_type instead.

-        using internal_type_ptr = typename ResourcesUser::field_type*;
+        using internal_type_ptr = typename ResourcesUser::grid_type*;

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
using internal_type_ptr = typename ResourcesUser::field_type*;
using internal_type_ptr = typename ResourcesUser::grid_type*;

Comment on lines +63 to +64
std::transform(std::begin(f1), std::end(f1), std::begin(f2), std::begin(avg),
std::plus<double>());
Copy link

Choose a reason for hiding this comment

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

The average function uses std::plus<double>(), which assumes the Field's value type is double. If Field can have other value types, this could lead to incorrect behavior. Consider using the value_type of Field instead.

Comment on lines +49 to +50
auto dim
= static_cast<unsigned short int>(inputDatabase->getDatabase("Main")->getInteger("dim"));
Copy link

Choose a reason for hiding this comment

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

Redundant retrieval of dimension from inputDatabase in the init method, as it is already stored in the dimension member variable.

- auto dim = static_cast<unsigned short int>(inputDatabase->getDatabase("Main")->getInteger("dim"));
+ auto dim = dimension;

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
auto dim
= static_cast<unsigned short int>(inputDatabase->getDatabase("Main")->getInteger("dim"));
auto dim = dimension;

Comment on lines 179 to 184
increment(dim - 1);
return *this;
}
box_iterator& operator++() const
{
increment(dim - 1);
return *this;
}


bool operator!=(box_iterator const& other) const
{
Copy link

Choose a reason for hiding this comment

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

The pre-increment operator method box_iterator& operator++() is no longer marked as const. This change may affect how the iterator is used with const instances of Box. Please verify that this change is intentional and does not negatively impact the usage of box_iterator in contexts where const correctness is expected.

Comment on lines +154 to +156
NO_DISCARD ParticleArray const& levelGhostParticlesOld() const
{
return const_cast<IonPopulation*>(this)->levelGhostParticlesOld();
Copy link

Choose a reason for hiding this comment

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

The use of const_cast in the const overloads of levelGhostParticlesOld, levelGhostParticlesNew, and density is a common pattern to avoid code duplication. However, it's important to ensure that the non-const versions of these functions do not perform any non-const operations on the object to maintain const-correctness.

Also applies to: 173-175, 193-195

Comment on lines 289 to 290
auto gsi_X = this->layout.ghostStartIndex(field, Direction::X);
auto gei_X = this->layout.ghostEndIndex(field, Direction::X);
Copy link

Choose a reason for hiding this comment

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

The same copy-paste error is present in the 3D fill lambda function where Viy and Jy are filled twice, and Viz and Jz are not filled at all. This should be corrected to ensure that all components are initialized properly.

- fill(Viy, [](double x, double y, double z) {
-     return std::cosh(0.4 * x) * std::cosh(0.4 * y) * std::cosh(0.4 * z);
- });
- fill(Jy, [](double x, double y, double z) {
-     return std::sinh(0.4 * x) * std::sinh(0.4 * y) * std::sinh(0.4 * z);
- });
+ fill(Viz, [](double x, double y, double z) {
+     return std::cosh(0.4 * x) * std::cosh(0.4 * y) * std::cosh(0.4 * z);
+ });
+ fill(Jz, [](double x, double y, double z) {
+     return std::sinh(0.4 * x) * std::sinh(0.4 * y) * std::sinh(0.4 * z);
+ });

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
auto gsi_X = this->layout.ghostStartIndex(field, Direction::X);
auto gei_X = this->layout.ghostEndIndex(field, Direction::X);
auto gsi_X = this->layout.ghostStartIndex(field, Direction::X);
auto gei_X = this->layout.ghostEndIndex(field, Direction::X);

@@ -42,7 +42,7 @@ void DefaultHybridTaggerStrategy<HybridModel>::tag(HybridModel& model,

// SAMRAI tags int* buffer is FORTRAN ordering so we set false to the view
bool constexpr c_ordering = false;
auto tagsv = core::NdArrayView<dimension, int, int*, c_ordering>(tags, layout.nbrCells());
auto tagsv = core::NdArrayView<dimension, int, c_ordering>(tags, layout.nbrCells());

if constexpr (dimension == 1 and false)
Copy link

Choose a reason for hiding this comment

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

The if constexpr block with the condition dimension == 1 and false will never execute and appears to be dead code. Consider removing it to clean up the codebase, especially given the preference for minimal and efficient code.

-    if constexpr (dimension == 1 and false)
-    {
-    }

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if constexpr (dimension == 1 and false)

Comment on lines +226 to +241
operator bool() const
{
using Tuple = decltype((*this)());
auto constexpr tuple_size = std::tuple_size_v<Tuple>;
Tuple tup = (*this)();

return core::for_N_all<tuple_size>([&](auto i) {
auto const& [k, v] = std::get<i>(tup);
auto isUsable = v->isUsable();
if (!isUsable)
{
PHARE_LOG_LINE_STR("NOT USABLE: " << k);
}
return isUsable;
});
}
Copy link

Choose a reason for hiding this comment

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

The conversion operator to bool in PatchState_t performs a complex check which could be a performance concern if used frequently. Consider optimizing this if it's a common operation.

Comment on lines +144 to +152
auto& operator*()
{
assert(view.states[idx] == true);
return view.states[idx];
}
auto& operator*() const
{
assert(view.states[idx] == true);
return view.states[idx];
Copy link

Choose a reason for hiding this comment

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

The assert statement in the iterator's dereference operator is good for debug builds but might be unnecessary overhead in release builds. Consider using a debug-only assert or providing a way to disable it in release builds.

return *this;
}

bool operator!=(iterator const& that) const { return &view != &that.view or idx != that.idx; }
Copy link

Choose a reason for hiding this comment

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

The not-equal operator in the iterator class template should only compare the index if the views are the same, not the pointers to the views.

- bool operator!=(iterator const& that) const { return &view != &that.view or idx != that.idx; }
+ bool operator!=(iterator const& that) const { return &view == &that.view && idx != that.idx; }

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
bool operator!=(iterator const& that) const { return &view != &that.view or idx != that.idx; }
bool operator!=(iterator const& that) const { return &view == &that.view && idx != that.idx; }

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: 1

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between e14b580 and 471233b.
Files selected for processing (1)
  • src/amr/solvers/solver_ppc.hpp (6 hunks)
Additional comments: 8
src/amr/solvers/solver_ppc.hpp (8)
  • 11-17: The addition of solver_ppc_model_view.hpp aligns with the summary's mention of new include directives and the introduction of model views.

  • 56-56: Verify the usage of the new member variable faraday_1 within the class to ensure it's correctly integrated and utilized.

  • 214-215: Ensure that the keys used in restoreState_ always exist in tmpDomain and patchGhost to prevent potential exceptions when keys are not found.

  • 227-251: The changes in advanceLevel seem to follow a logical sequence of operations for advancing the simulation level. Ensure that the order of operations is correct and aligns with the intended simulation behavior.

  • 257-297: The changes in predictor1_, predictor2_, and corrector_ functions should be verified for correctness, ensuring they align with the intended simulation behavior and the new Grid class integration.

  • 401-429: Verify the usage and invocation of the _debug_log_move_ions debug function to ensure it's correctly integrated and can be controlled or disabled as needed.

  • 433-463: The changes in moveIons_ should be verified for correctness, ensuring that ion updates and ghost particle management align with the intended simulation behavior and the new Grid class integration.

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

The provided hunks do not show the shift from Field to Grid as mentioned in the summary. Ensure that the changes in the SolverPPC class are consistent with the broader refactor across the codebase.

Comment on lines 184 to 192
{
for (auto& patch : level)
for (auto& state : view)
{
std::stringstream ss;
ss << patch->getGlobalId();

auto _ = rm.setOnPatch(*patch, ions);
for (auto& pop : ions)
ss << state.patch->getGlobalId();
for (auto& pop : state.ions)
{
auto key = ss.str() + "_" + pop.name();
if (!tmpDomain.count(key))
Copy link

Choose a reason for hiding this comment

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

The use of stringstream for string concatenation in saveState_ could be inefficient, especially in a multi-threaded context. Consider using a more efficient string concatenation method if performance is a concern.

@PhilipDeegan
Copy link
Member Author

closing this while I finish it just to not trigger any builds on commit

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.

1 participant