-
Notifications
You must be signed in to change notification settings - Fork 24
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
Charge #861
Charge #861
Conversation
WalkthroughWalkthroughThis set of changes enhances the clarity and specificity of density-related computations across multiple components of the system. Key modifications involve renaming methods and variables related to particle density and charge density, thereby improving code interpretability and aligning terminology with their actual functions. These updates refine data processing and ensure that the simulation framework can handle more nuanced interactions involving both types of densities. Changes
Possibly related PRs
Suggested labels
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Outside diff range, codebase verification and nitpick comments (3)
src/amr/level_initializer/hybrid_level_initializer.hpp (1)
101-101
: Clarify the TODO comment.The TODO comment suggests uncertainty about whether charge density is needed. This should be clarified and resolved to ensure the correct density computation is used.
src/core/numerics/ion_updater/ion_updater.hpp (1)
110-110
: Clarify the TODO comment.The TODO comment suggests uncertainty about whether charge density is needed. This should be clarified and resolved to ensure the correct density computation is used.
src/core/data/electrons/electrons.hpp (1)
105-105
: Clarify the TODO comment.The TODO comment suggests uncertainty about the equivalence of particle density and charge density. This should be clarified and resolved to ensure the correct density computation is used.
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (14)
- src/amr/level_initializer/hybrid_level_initializer.hpp (1 hunks)
- src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (1 hunks)
- src/amr/physical_models/hybrid_model.hpp (1 hunks)
- src/core/data/electrons/electrons.hpp (3 hunks)
- src/core/data/ions/ion_population/ion_population.hpp (5 hunks)
- src/core/data/ions/ions.hpp (8 hunks)
- src/core/numerics/interpolator/interpolator.hpp (3 hunks)
- src/core/numerics/ion_updater/ion_updater.hpp (4 hunks)
- src/core/numerics/moments/moments.hpp (1 hunks)
- tests/core/data/electrons/test_electrons.cpp (7 hunks)
- tests/core/data/ion_population/test_ion_population_fixtures.hpp (1 hunks)
- tests/core/numerics/interpolator/test_main.cpp (5 hunks)
- tests/core/numerics/ion_updater/test_updater.cpp (9 hunks)
- tests/simulator/test_initialization.py (1 hunks)
Files skipped from review due to trivial changes (2)
- tests/core/data/ion_population/test_ion_population_fixtures.hpp
- tests/simulator/test_initialization.py
Additional context used
Path-based instructions (9)
src/core/numerics/moments/moments.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/data/ions/ion_population/ion_population.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/amr/physical_models/hybrid_model.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/amr/level_initializer/hybrid_level_initializer.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/numerics/ion_updater/ion_updater.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/data/electrons/electrons.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/data/ions/ions.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/numerics/interpolator/interpolator.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.
Additional comments not posted (59)
src/core/numerics/moments/moments.hpp (2)
44-44
: Approved: Addition ofchargeDensity
parameter.The
chargeDensity
parameter is correctly extracted from thepop
object.
50-50
: Approved: Integration ofchargeDensity
parameter ininterpolate
calls.The
chargeDensity
parameter is consistently integrated across different deposit types.Also applies to: 55-55, 60-60
src/core/data/ions/ion_population/ion_population.hpp (5)
37-38
: Approved: Initialization ofparticleDensity_
andchargeDensity_
.The constructor correctly initializes
particleDensity_
andchargeDensity_
instead ofrho_
.
53-54
: Approved: Integration ofparticleDensity_
andchargeDensity_
inisUsable
.The
isUsable
method correctly includes checks forparticleDensity_
andchargeDensity_
.
60-61
: Approved: Integration ofparticleDensity_
andchargeDensity_
inisSettable
.The
isSettable
method correctly includes checks forparticleDensity_
andchargeDensity_
.
86-87
: Approved: Update ofdensity
method to returnparticleDensity_
.The
density
method is correctly updated to returnparticleDensity_
and is marked for removal.
112-113
: Approved: Integration ofparticleDensity_
andchargeDensity_
ingetCompileTimeResourcesViewList
.The
getCompileTimeResourcesViewList
method correctly includesparticleDensity_
andchargeDensity_
.src/amr/physical_models/hybrid_model.hpp (1)
157-157
: Approved: Update to useparticleDensityName
instead ofdensityName
.The method correctly uses
particleDensityName
instead ofdensityName
for retrieving the ion density name.src/core/numerics/ion_updater/ion_updater.hpp (3)
161-161
: Ensure consistency in density computation.The change to use
pop.chargeDensity()
instead ofpop.density()
should be consistent across all relevant methods to avoid discrepancies in density calculations.
184-184
: Ensure consistency in density computation.The change to use
pop.chargeDensity()
instead ofpop.density()
should be consistent across all relevant methods to avoid discrepancies in density calculations.
272-272
: Ensure consistency in density computation.The change to use
pop.chargeDensity()
instead ofpop.density()
should be consistent across all relevant methods to avoid discrepancies in density calculations.src/core/data/electrons/electrons.hpp (2)
284-284
: Ensure consistency in density computation.The change to use
computeParticleDensity()
instead ofcomputeDensity()
should be consistent across all relevant methods to avoid discrepancies in density calculations.
313-313
: Ensure consistency in density computation.The change to use
computeParticleDensity()
instead ofcomputeDensity()
should be consistent across all relevant methods to avoid discrepancies in density calculations.src/core/data/ions/ions.hpp (7)
44-46
: Initialization of new density variables looks good.The constructor now initializes
particleDensity_
andchargeDensity_
correctly.
63-64
: Getter methods for density variables are consistent.The getter methods for
particleDensity_
andchargeDensity_
are consistent with the rest of the class.Also applies to: 68-70, 72-73
78-79
: Static methods for density names improve clarity.The static methods
particleDensityName
andchargeDensityName
enhance the clarity of the code.
Line range hint
85-97
:computeParticleDensity
method updates are correct.The method now correctly computes and accumulates densities into
particleDensity_
.
193-193
: Usability and settability checks includechargeDensity_
.The methods
isUsable
andisSettable
now correctly include checks forchargeDensity_
.Also applies to: 210-210
237-237
: Compile-time resources view includeschargeDensity_
.The method
getCompileTimeResourcesViewList
now includeschargeDensity_
, ensuring it is part of the compile-time resources view.
272-274
: Member variable declarations are consistent.The addition of
particleDensity_
andchargeDensity_
is consistent with the rest of the class and necessary for the new functionality.tests/core/data/electrons/test_electrons.cpp (6)
151-151
: Renaming of tensor fields improves clarity.The tensor fields
M
andprotons_M
have been renamed toionTensor
andprotonTensor
, improving clarity and consistency.
153-153
: Renaming of density fields improves clarity.The density fields
Nibuffer
andNiProtons
have been renamed toionParticleDensity
,ionChargeDensity
,protonParticleDensity
, andprotonChargeDensity
, improving clarity and consistency.
166-166
: Parameter list update in_ions
function is correct.The parameter list of the
_ions
function has been updated to include the new variable names, ensuring correct handling of the renamed variables.
170-174
: Buffer setting logic in_ions
function is correct.The buffer setting logic in the
_ions
function has been updated to use the new variable names, ensuring correct buffer setting.Also applies to: 179-183
195-206
: Constructor initialization is correct.The constructor has been updated to initialize the renamed variables, ensuring correct initialization.
245-245
: Fill operations are correctly updated.The fill operations have been updated to use the renamed variables, ensuring correct handling.
Also applies to: 274-274, 321-321
src/core/numerics/interpolator/interpolator.hpp (3)
472-472
: Operator overloads updated to includechargeDensity
.The operator overloads now include a
chargeDensity
parameter, enhancing functionality.Also applies to: 508-508
492-494
:particleToMesh_
call forchargeDensity
is correct.The new call to
particleToMesh_
ensures that both density and charge density are processed correctly.
511-511
: Forwarding ofchargeDensity
parameter is correct.The forwarding of parameters in the second operator overload now correctly includes
chargeDensity
.tests/core/numerics/interpolator/test_main.cpp (6)
519-519
: LGTM! New member variablerho_c
added.The addition of the new member variable
rho_c
for charge density is appropriate.
530-530
: LGTM! Initialization ofrho_c
in the constructor.The initialization of
rho_c
in the constructor is correct.
637-637
: LGTM! Updated function call to includerho_c
.The function call to
interpolator
now includesrho_c
, which is appropriate for handling charge density.
683-683
: LGTM! New member variablerho_c
added.The addition of the new member variable
rho_c
for charge density is appropriate.
690-690
: LGTM! Initialization ofrho_c
in the constructor.The initialization of
rho_c
in the constructor is correct.
704-704
: LGTM! Updated function call to includerho_c
.The function call to
interpolator
now includesrho_c
, which is appropriate for handling charge density.tests/core/numerics/ion_updater/test_updater.cpp (20)
215-215
: LGTM! New member variableionChargeDensity
added.The addition of the new member variable
ionChargeDensity
for charge density is appropriate.
218-218
: LGTM! New member variableprotonChargeDensity
added.The addition of the new member variable
protonChargeDensity
for charge density is appropriate.
220-220
: LGTM! New member variablealphaChargeDensity
added.The addition of the new member variable
alphaChargeDensity
for charge density is appropriate.
243-246
: LGTM! Initialization ofionChargeDensity
in the constructor.The initialization of
ionChargeDensity
in the constructor is correct.
251-251
: LGTM! Initialization ofprotonChargeDensity
in the constructor.The initialization of
protonChargeDensity
in the constructor is correct.
255-255
: LGTM! Initialization ofalphaChargeDensity
in the constructor.The initialization of
alphaChargeDensity
in the constructor is correct.
284-285
: LGTM! Initialization ofionChargeDensity
in the copy constructor.The initialization of
ionChargeDensity
in the copy constructor is correct.
290-291
: LGTM! Initialization ofprotonChargeDensity
in the copy constructor.The initialization of
protonChargeDensity
in the copy constructor is correct.
294-294
: LGTM! Initialization ofalphaChargeDensity
in the copy constructor.The initialization of
alphaChargeDensity
in the copy constructor is correct.
319-319
: LGTM! Copying data forionChargeDensity
.The copying of data for
ionChargeDensity
is correct.
322-322
: LGTM! Copying data forprotonChargeDensity
.The copying of data for
protonChargeDensity
is correct.
324-324
: LGTM! Copying data foralphaChargeDensity
.The copying of data for
alphaChargeDensity
is correct.
338-338
: LGTM! Setting buffer forionChargeDensity
.The setting of the buffer for
ionChargeDensity
is correct.
346-346
: LGTM! Setting buffer forprotonChargeDensity
.The setting of the buffer for
protonChargeDensity
is correct.
355-355
: LGTM! Setting buffer foralphaChargeDensity
.The setting of the buffer for
alphaChargeDensity
is correct.
563-563
: LGTM! Updated function call to includechargeDensity
.The function call to
interpolate
now includeschargeDensity
, which is appropriate for handling charge density.
567-567
: LGTM! Updated function call to includechargeDensity
.The function call to
interpolate
now includeschargeDensity
, which is appropriate for handling charge density.
572-572
: LGTM! Updated function call to includechargeDensity
.The function call to
interpolate
now includeschargeDensity
, which is appropriate for handling charge density.
585-585
: LGTM! AccessingprotonChargeDensity
.The access to
protonChargeDensity
is correct.
591-591
: LGTM! AccessingalphaChargeDensity
.The access to
alphaChargeDensity
is correct.src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (4)
373-373
: LGTM!The introduction of the
chargeDensity
variable aligns with the PR's objective.
386-386
: LGTM! Verify the function definition.The
interpolate_
function call now correctly includes thechargeDensity
parameter.Ensure that the
interpolate_
function definition is updated to match this call.
383-383
: LGTM! Verify the function definition.The
interpolate_
function call now correctly includes thechargeDensity
parameter.Ensure that the
interpolate_
function definition is updated to match this call.
376-376
: LGTM! Verify the function definition.The
interpolate_
function call now correctly includes thechargeDensity
parameter.Ensure that the
interpolate_
function definition is updated to match this call.
@@ -526,7 +547,7 @@ struct IonUpdaterTest : public ::testing::Test | |||
PHARE::core::LevelGhostDeposit{}); | |||
|
|||
|
|||
ions.computeDensity(); | |||
ions.computeParticleDensity(); // TODO ouam : should we need here the charge density |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update method name to computeChargeDensity
.
The method computeParticleDensity
should be updated to computeChargeDensity
to reflect the new focus on charge density.
- ions.computeParticleDensity(); // TODO ouam : should we need here the charge density
+ ions.computeChargeDensity(); // TODO ouam : should we need here the charge density
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. Thoroughly test & benchmark the code to ensure it meets the requirements.
ions.computeParticleDensity(); // TODO ouam : should we need here the charge density | |
ions.computeChargeDensity(); // TODO ouam : should we need here the charge density |
NO_DISCARD field_type const& density() const { return particleDensity_; } // TODO ouam : to remove | ||
NO_DISCARD field_type& density() { return particleDensity_; } // TODO ouam : to remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder: Remove the density
method.
The TODO comment indicates that the density
method should be removed.
Do you want me to assist with the removal of the density
method or open a GitHub issue to track this task?
@@ -164,22 +163,24 @@ | |||
template<typename... Args> | |||
auto static _ions(Args&... args) | |||
{ | |||
auto const& [Fi, Nibuffer, NiProtons, Vi, M, protons_M, pack] | |||
auto const& [ionFlux, ionParticleDensity, ionChargeDensity, protonParticleDensity, protonChargeDensity, Vi, ionTensor, protonTensor, pack] |
Check notice
Code scanning / CodeQL
Unused local variable
= std::forward_as_tuple(args...); | ||
IonsT ions{createDict<dim>()["ions"]}; | ||
{ | ||
auto const& [V, m, d, md] = ions.getCompileTimeResourcesViewList(); | ||
d.setBuffer(&Nibuffer); | ||
auto const& [V, m, d, d_c, d_m] = ions.getCompileTimeResourcesViewList(); |
Check notice
Code scanning / CodeQL
Unused local variable
= std::forward_as_tuple(args...); | ||
IonsT ions{createDict<dim>()["ions"]}; | ||
{ | ||
auto const& [V, m, d, md] = ions.getCompileTimeResourcesViewList(); | ||
d.setBuffer(&Nibuffer); | ||
auto const& [V, m, d, d_c, d_m] = ions.getCompileTimeResourcesViewList(); |
Check notice
Code scanning / CodeQL
Unused local variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Outside diff range, codebase verification and nitpick comments (1)
src/core/numerics/moments/moments.hpp (1)
18-18
: AddchargeDensity().zero()
toresetMoments
function.The
resetMoments
function currently zerosparticleDensity
but notchargeDensity
. SincechargeDensity
is a member ofpop
, it should also be reset to ensure consistency and correctness.
- Update the
resetMoments
function to includepop.chargeDensity().zero();
.Analysis chain
Ensure zeroing of all relevant fields.
The
resetMoments
function now zerosparticleDensity
. Verify that all necessary fields, includingchargeDensity
, are reset if needed.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that all necessary fields, including `chargeDensity`, are reset in the `resetMoments` function. # Test: Search for the `resetMoments` function implementation. Expect: `chargeDensity().zero()` if needed. rg --type cpp --context 5 $'void resetMoments'Length of output: 682
Script:
#!/bin/bash # Description: Check if `chargeDensity` is a member function of `pop` and if it needs to be reset. # Test: Search for `chargeDensity` within the context of `pop` to see if it is a member function. rg --type cpp --context 5 'chargeDensity'Length of output: 32291
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (6)
- src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (1 hunks)
- src/core/data/ions/ion_population/ion_population.hpp (5 hunks)
- src/core/data/ions/ions.hpp (8 hunks)
- src/core/numerics/interpolator/interpolator.hpp (3 hunks)
- src/core/numerics/ion_updater/ion_updater.hpp (4 hunks)
- src/core/numerics/moments/moments.hpp (2 hunks)
Additional context used
Path-based instructions (6)
src/core/numerics/moments/moments.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/data/ions/ion_population/ion_population.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/numerics/ion_updater/ion_updater.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/data/ions/ions.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/numerics/interpolator/interpolator.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.
Additional comments not posted (18)
src/core/numerics/moments/moments.hpp (2)
43-44
: Clarify the use of particle and charge densities.The introduction of both
particleDensity
andchargeDensity
in thedepositParticles
function is clear. Ensure that their roles are well-documented and understood within the team.
50-60
: Consistent use of interpolate function.The
interpolate
function now uses bothparticleDensity
andchargeDensity
. Ensure that all necessary data is correctly passed and utilized within the function.src/core/data/ions/ion_population/ion_population.hpp (6)
37-38
: Initialization of density fields.The
particleDensity_
andchargeDensity_
fields are initialized with appropriate names. Ensure that these changes are reflected throughout the codebase.
53-59
: Ensure consistency in usability checks.The
isUsable
andisSettable
methods now include bothparticleDensity_
andchargeDensity_
. Verify that these checks are consistent with other parts of the code.
84-85
: Reminder: Remove thedensity
method.The TODO comment indicates that the
density
method should be removed. Ensure that this task is tracked and completed.
87-91
: Getter methods for densities.The introduction of
particleDensity
andchargeDensity
getter methods is clear. Ensure that these are used consistently throughout the codebase.
110-110
: Update resource view list.The
getCompileTimeResourcesViewList
method now includes bothparticleDensity_
andchargeDensity_
. Ensure that these changes are reflected in all relevant parts of the code.
134-135
: Declaration of density fields.The
particleDensity_
andchargeDensity_
fields are declared appropriately. Verify that their usage aligns with the intended functionality.src/core/numerics/ion_updater/ion_updater.hpp (3)
110-111
: Clarify TODO regarding charge density computation.The TODO comment suggests considering charge density computation for diagnostics. Ensure that this decision is documented and discussed with the team.
273-273
: Consistent use of interpolator in domain update.The
interpolator
function inupdateAndDepositAll_
now uses bothparticleDensity
andchargeDensity
. Ensure consistency with other methods.
Line range hint
162-185
:
Consistent use of interpolator function.The
interpolator
function now uses bothparticleDensity
andchargeDensity
. Ensure that all necessary data is correctly passed and utilized within the function.src/core/data/ions/ions.hpp (3)
85-97
: Optimize Particle Density Computation.The
computeParticleDensity()
method could be optimized by using a more efficient algorithm if performance becomes an issue. Currently, it usesstd::transform
to sum densities, which is clear and maintainable.
Line range hint
193-198
:
Ensure Usability Checks Include All Relevant Attributes.The
isUsable()
method now includes checks forparticleDensity_
andchargeDensity_
. Ensure that these attributes are correctly initialized and used throughout the codebase.
Line range hint
210-215
:
Ensure Settable Checks Include All Relevant Attributes.The
isSettable()
method now includes checks forparticleDensity_
andchargeDensity_
. Verify that these attributes are correctly settable in all contexts where they are used.src/core/numerics/interpolator/interpolator.hpp (2)
Line range hint
472-493
:
Verify Consistent Handling of New Parameters.The operator overload now includes both
particleDensity
andchargeDensity
. Ensure that all internal logic correctly handles these new parameters and that they are used consistently throughout the interpolation process.
508-511
: Ensure Consistency in Operator Overloads.The second operator overload now forwards the call to the first overload. Ensure that all necessary parameters are correctly passed and that any additional logic needed for
chargeDensity
is included.src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (2)
372-373
: Clarify Density Handling.The introduction of
particleDensity
andchargeDensity
improves clarity. Ensure that these variables are used consistently and verify that any logic dependent on these densities is updated accordingly.
376-386
: Verify Interpolation Logic.The
interpolate_
function now processes bothparticleDensity
andchargeDensity
. Ensure that the interpolation logic correctly handles both densities and that the coefficients used (alpha
and1 - alpha
) are applied correctly.
src/core/data/ions/ions.hpp
Outdated
NO_DISCARD field_type const& density() const { return particleDensity_; } // TODO ouam : to remove | ||
NO_DISCARD field_type& density() { return particleDensity_; } // TODO ouam : to remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider Removing Deprecated Methods.
The density()
methods have TODO comments indicating they should be removed. Consider removing them if they are no longer needed or used.
// Remove these methods if they are not used elsewhere
// NO_DISCARD field_type const& density() const { return particleDensity_; }
// NO_DISCARD field_type& density() { return particleDensity_; }
src/core/data/ions/ions.hpp
Outdated
: particleDensity_{particleDensityName(), HybridQuantity::Scalar::rho} | ||
, massDensity_{massDensityName(), HybridQuantity::Scalar::rho} | ||
, chargeDensity_{chargeDensityName(), HybridQuantity::Scalar::rho} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure Initialization Order Consistency.
The initialization order in the constructor should match the order of declaration in the class to prevent potential issues. Ensure that particleDensity_
, massDensity_
, and chargeDensity_
are declared in the same order as they are initialized.
- field_type particleDensity_;
- field_type massDensity_;
- field_type chargeDensity_;
+ field_type particleDensity_;
+ field_type chargeDensity_;
+ field_type massDensity_;
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. Thoroughly test & benchmark the code to ensure it meets the requirements.
: particleDensity_{particleDensityName(), HybridQuantity::Scalar::rho} | |
, massDensity_{massDensityName(), HybridQuantity::Scalar::rho} | |
, chargeDensity_{chargeDensityName(), HybridQuantity::Scalar::rho} | |
field_type particleDensity_; | |
field_type chargeDensity_; | |
field_type massDensity_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (4)
- src/diagnostic/detail/types/fluid.hpp (2 hunks)
- src/python3/patch_level.hpp (1 hunks)
- tests/core/numerics/ion_updater/test_updater.cpp (10 hunks)
- tests/diagnostic/test_diagnostics.hpp (1 hunks)
Additional context used
Path-based instructions (3)
src/python3/patch_level.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.tests/diagnostic/test_diagnostics.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/diagnostic/detail/types/fluid.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.
Additional comments not posted (9)
src/python3/patch_level.hpp (1)
62-62
: Ensure consistency with the charge density change.The change from
pop.density()
topop.chargeDensity()
reflects a shift in focus to charge density. Verify that all related logic and calculations are consistent with this change.Verification successful
Change to
chargeDensity
is consistent across the codebase.The transition from
pop.density()
topop.chargeDensity()
is consistently applied across the codebase, including in tests, core numerics, and diagnostics. This indicates that the change aligns with the intended functionality and is well-integrated. No further issues were identified.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify consistency of `chargeDensity` usage across the codebase. # Test: Search for `chargeDensity` usage. Expect: Consistent usage across relevant files. rg --type cpp -A 5 $'chargeDensity'Length of output: 24222
tests/diagnostic/test_diagnostics.hpp (1)
121-121
: Validate test logic with charge density.The change to
pop.chargeDensity()
in the test function aligns with the focus on charge density. Ensure that the test logic and expected outcomes reflect this shift.Verification successful
Test logic aligns with charge density focus.
The change to
pop.chargeDensity()
in the test function intest_diagnostics.hpp
is consistent with the focus on charge density. The test logic and expected outcomes appropriately reflect this shift, ensuring the tests remain valid and relevant.
tests/diagnostic/test_diagnostics.hpp
: Updated to usepop.chargeDensity()
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that test logic aligns with `chargeDensity`. # Test: Search for `chargeDensity` usage in tests. Expect: Consistent and relevant test logic. rg --type cpp -A 5 $'chargeDensity' tests/Length of output: 8360
src/diagnostic/detail/types/fluid.hpp (2)
201-201
: Ensure dataset info consistency with charge density.The change to
pop.chargeDensity()
ingetDataSetInfo
affects the dataset information. Verify that all related attributes and logic align with this focus.
310-310
: Ensure write logic consistency with charge density.The change to
pop.chargeDensity()
in thewrite
method affects data writing logic. Verify that the logic and data handling align with the focus on charge density.Verification successful
The write logic for
chargeDensity
is consistent. TheinfoDS
andwriteDS
functions, defined as lambdas influid.hpp
, handlechargeDensity
and other diagnostics data similarly, indicating a consistent approach.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify consistency of write logic with `chargeDensity`. # Test: Search for `chargeDensity` usage in write methods. Expect: Consistent handling. rg --type cpp -A 5 $'chargeDensity' src/diagnostic/detail/types/Length of output: 1121
Script:
#!/bin/bash # Search for the definitions of `infoDS` and `writeDS` to verify their handling of `chargeDensity`. ast-grep --lang cpp --pattern 'void infoDS($_, $_, $_) { $$$ }' ast-grep --lang cpp --pattern 'void writeDS($_, $_) { $$$ }'Length of output: 128
Script:
#!/bin/bash # Search for occurrences of `infoDS` and `writeDS` in the codebase to find their definitions. rg --type cpp 'infoDS' rg --type cpp 'writeDS'Length of output: 1080
tests/core/numerics/ion_updater/test_updater.cpp (5)
624-630
: Consider uncommenting charge density checks.The checks for
protonChargeDensity
andalphaChargeDensity
are commented out. If these checks are necessary for validating the correctness of the charge density, consider uncommenting them.
935-935
: Verify NaN checks for particle density.The method now includes checks to ensure
particleDensity
does not contain NaN values. Ensure these checks are comprehensive and consistent with similar checks in the method.
214-220
: Ensure consistency in variable naming.The addition of
ionChargeDensity
,protonChargeDensity
, andalphaChargeDensity
aligns with the new focus on charge density. Ensure that all instances of these variables across the codebase follow the same naming convention.Verification successful
Variable naming is consistent across the codebase.
The variables
ionChargeDensity
,protonChargeDensity
, andalphaChargeDensity
are consistently used across the relevant files, adhering to the naming conventions. No inconsistencies were found.
tests/core/numerics/ion_updater/test_updater.cpp
tests/core/data/electrons/test_electrons.cpp
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify consistency in naming for charge density variables. # Test: Search for occurrences of the new charge density variables. rg --type cpp 'ionChargeDensity|protonChargeDensity|alphaChargeDensity'Length of output: 3123
334-355
: Verify buffer settings for charge density variables.The method
setBuffers
now includes buffer settings forprotonChargeDensity
andalphaChargeDensity
. Ensure these settings are consistent and correctly integrated with the rest of the code.
243-255
: Check constructor initialization for new variables.The constructor now initializes
ionChargeDensity
,protonChargeDensity
, andalphaChargeDensity
. Verify that these variables are correctly used and initialized across all constructors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- tests/core/numerics/ion_updater/test_updater.cpp (11 hunks)
Files skipped from review as they are similar to previous changes (1)
- tests/core/numerics/ion_updater/test_updater.cpp
md.setBuffer(&ionMassDensity); | ||
} | ||
|
||
auto& pops = ions.getRunTimeResourcesViewList(); | ||
{ | ||
auto const& [F, M, d, particles] = pops[0].getCompileTimeResourcesViewList(); | ||
d.setBuffer(&protonDensity); | ||
auto const& [F, M, d, c, particles] = pops[0].getCompileTimeResourcesViewList(); |
Check notice
Code scanning / CodeQL
Unused local variable Note test
protons_M.set_on(M); | ||
protonF.set_on(F); | ||
particles.setBuffer(&protonPack); | ||
} | ||
|
||
{ | ||
auto const& [F, M, d, particles] = pops[1].getCompileTimeResourcesViewList(); | ||
d.setBuffer(&alphaDensity); | ||
auto const& [F, M, d, c, particles] = pops[1].getCompileTimeResourcesViewList(); |
Check notice
Code scanning / CodeQL
Unused local variable Note test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (2)
- src/core/data/ions/ions.hpp (8 hunks)
- tests/core/numerics/ion_updater/test_updater.cpp (11 hunks)
Files skipped from review as they are similar to previous changes (1)
- tests/core/numerics/ion_updater/test_updater.cpp
Additional context used
Path-based instructions (1)
src/core/data/ions/ions.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.
Additional comments not posted (8)
src/core/data/ions/ions.hpp (8)
66-67
: LGTM!The
particleDensity()
method correctly provides access toparticleDensity_
.
70-73
: LGTM!The
massDensity()
method correctly implements the logic based on thesameMasses_
condition.
75-76
: LGTM!The
chargeDensity()
method correctly provides access tochargeDensity_
.
81-82
: LGTM!The static methods
particleDensityName()
andchargeDensityName()
correctly return the respective density names.
88-100
: LGTM!The
computeParticleDensity()
method efficiently computes the total particle density by summing over all populations.
Line range hint
196-202
:
LGTM!The
isUsable()
method correctly checks the usability ofparticleDensity_
,chargeDensity_
, and other components.
Line range hint
213-219
:
LGTM!The
isSettable()
method correctly checks the settable state ofparticleDensity_
,chargeDensity_
, and other components.
240-242
: LGTM!The
getCompileTimeResourcesViewList()
method correctly returns a tuple includingparticleDensity_
,chargeDensity_
, and other components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- src/amr/tagging/default_hybrid_tagger_strategy.hpp (1 hunks)
Additional context used
Path-based instructions (1)
src/amr/tagging/default_hybrid_tagger_strategy.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.
Additional comments not posted (1)
src/amr/tagging/default_hybrid_tagger_strategy.hpp (1)
31-31
: LGTM! Verify the usage ofchargeDensity
.The renaming of the variable to use
chargeDensity
is appropriate and aligns with the PR objectives.Ensure that the transition from
density
tochargeDensity
is consistent across the codebase.Verification successful
Consistent Usage of
chargeDensity
VerifiedThe transition from ion density to ion charge density is consistently implemented across the codebase, as evidenced by its presence in both core logic and test files. This change aligns with the PR objectives and enhances clarity. No issues found.
chargeDensity
is used in core modules likeions
,ion_population
, andmoments
.- It is also present in test files, ensuring the new logic is adequately tested.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all instances where `chargeDensity` is used in the codebase. # Test: Search for the usage of `chargeDensity`. Expect: Consistent usage across relevant files. rg --type cpp 'chargeDensity'Length of output: 6535
…or pop.chargeDensity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (2)
src/amr/tagging/default_hybrid_tagger_strategy.hpp (1)
39-39
: LGTM, but the variableN
is unused.The code changes are approved.
However, the variable
N
is not used in the function body, so this change has no effect on the function's behavior. Consider removing the unused variable.Apply this diff to remove the unused variable:
- auto& N = model.state.ions.chargeDensity();
src/amr/level_initializer/hybrid_level_initializer.hpp (1)
101-101
: Approved: Improved clarity by usingcomputeParticleDensity()
.The change from
ions.computeDensity()
toions.computeParticleDensity()
enhances the clarity and specificity of the code by explicitly referring to the particle density computation.However, the TODO comment raises a valid point:
// TODO ouam : do we need here the charge density
It's worth discussing whether charge density should also be computed at this point and, if so, determine the appropriate place to perform that computation. Consider adding this topic to the agenda for the next team discussion or creating a follow-up issue to track the resolution.
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (18)
- src/amr/level_initializer/hybrid_level_initializer.hpp (1 hunks)
- src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (1 hunks)
- src/amr/physical_models/hybrid_model.hpp (1 hunks)
- src/amr/tagging/default_hybrid_tagger_strategy.hpp (1 hunks)
- src/core/data/electrons/electrons.hpp (3 hunks)
- src/core/data/ions/ion_population/ion_population.hpp (5 hunks)
- src/core/data/ions/ions.hpp (8 hunks)
- src/core/numerics/interpolator/interpolator.hpp (3 hunks)
- src/core/numerics/ion_updater/ion_updater.hpp (4 hunks)
- src/core/numerics/moments/moments.hpp (2 hunks)
- src/diagnostic/detail/types/fluid.hpp (2 hunks)
- src/python3/patch_level.hpp (1 hunks)
- tests/core/data/electrons/test_electrons.cpp (7 hunks)
- tests/core/data/ion_population/test_ion_population_fixtures.hpp (1 hunks)
- tests/core/numerics/interpolator/test_main.cpp (5 hunks)
- tests/core/numerics/ion_updater/test_updater.cpp (11 hunks)
- tests/diagnostic/test_diagnostics.hpp (1 hunks)
- tests/simulator/test_initialization.py (1 hunks)
Files skipped from review due to trivial changes (3)
- tests/core/data/electrons/test_electrons.cpp
- tests/core/data/ion_population/test_ion_population_fixtures.hpp
- tests/simulator/test_initialization.py
Additional context used
Path-based instructions (13)
src/core/numerics/moments/moments.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/amr/tagging/default_hybrid_tagger_strategy.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/data/ions/ion_population/ion_population.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/amr/physical_models/hybrid_model.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/amr/level_initializer/hybrid_level_initializer.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/python3/patch_level.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/data/electrons/electrons.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/numerics/ion_updater/ion_updater.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/data/ions/ions.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.tests/diagnostic/test_diagnostics.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/diagnostic/detail/types/fluid.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/numerics/interpolator/interpolator.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.
Additional comments not posted (39)
src/core/numerics/moments/moments.hpp (2)
18-18
: LGTM!The code changes are approved.
43-44
: LGTM!The code changes are approved.
Also applies to: 50-50, 55-55, 60-60
src/core/data/ions/ion_population/ion_population.hpp (6)
37-38
: LGTM!The code changes are approved.
53-53
: LGTM!The code changes are approved.
59-59
: LGTM!The code changes are approved.
84-85
: The existing comments are still valid and applicable:coderabbitai[bot]: Reminder: Remove the
density
method.The TODO comment indicates that the
density
method should be removed.Do you want me to assist with the removal of the
density
method or open a GitHub issue to track this task?
87-88
: LGTM!The code changes are approved.
Also applies to: 90-91
110-110
: LGTM!The code changes are approved.
src/amr/physical_models/hybrid_model.hpp (1)
157-157
: Approved: Improved clarity by using particle density.The change from
state.ions.densityName()
tostate.ions.particleDensityName()
for assigninghybridInfo.modelIonDensity
enhances the clarity and specificity of the code by explicitly referring to the particle density instead of a general density term.src/python3/patch_level.hpp (1)
62-64
: Approved with Verification: Usingpop.chargeDensity()
for setting patch data.The change from
pop.density()
topop.chargeDensity()
enhances the clarity and specificity of the code by explicitly using the charge density of each ion population when setting the patch data.However, it's important to verify that using charge density aligns with the intended behavior and purpose of the
PatchLevel
class. Ensure that this change is consistently applied throughout the class and does not introduce any unintended side effects.Please run the following script to verify the usage of
chargeDensity()
across the codebase:If the verification passes and the change aligns with the intended behavior, then this modification can be safely approved.
Verification successful
Verified: Change to
pop.chargeDensity()
is consistent and appropriate.The modification from
pop.density()
topop.chargeDensity()
insrc/python3/patch_level.hpp
aligns with the broader codebase strategy of using charge density for ion populations. This change is consistent with the intended behavior and does not introduce any unintended side effects.
- The usage of
chargeDensity()
is prevalent in contexts requiring charge-specific data, supporting the change.- Comments in the codebase suggest a transition away from using
density()
, further validating the modification.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `chargeDensity()` in the codebase. # Test 1: Search for usage of `chargeDensity()`. # Expect: Usage only in appropriate contexts. rg --type cpp $'chargeDensity\(\)' -A 5 # Test 2: Search for usage of `density()`. # Expect: No usage where `chargeDensity()` should be used instead. rg --type cpp $'density\(\)' -A 5Length of output: 20533
src/core/data/electrons/electrons.hpp (3)
105-105
: ****Skipping the review of this function as it's not implemented yet. The TODO comment suggests a future implementation.
284-284
: ****The code changes are approved. The function correctly delegates the call to
fluxComput_.computeParticleDensity()
.
313-313
: ****The code changes are approved. The function correctly delegates the call to
momentModel_.computeParticleDensity()
.src/core/numerics/ion_updater/ion_updater.hpp (3)
110-111
: ****The code changes are approved. The function correctly calls
ions.computeParticleDensity()
instead ofions.computeDensity()
, which is consistent with the changes in theIons
class.
Skipping the review of the commented out line as it's a TODO for future consideration and does not affect the current functionality.
162-162
: ****The code changes are approved. The function correctly calls
interpolator_
withpop.particleDensity()
andpop.chargeDensity()
instead ofpop.density()
, which is consistent with the changes in theIons
class.Also applies to: 185-185
273-273
: ****The code changes are approved. The function correctly calls
interpolator_
withpop.particleDensity()
andpop.chargeDensity()
instead ofpop.density()
, which is consistent with the changes in theIons
class.src/core/data/ions/ions.hpp (12)
44-44
: ****The code changes are approved. The member variable
particleDensity_
is correctly initialized in the constructor using the new nameparticleDensityName()
.
46-46
: ****The code changes are approved. The member variable
chargeDensity_
is correctly initialized in the constructor using the new namechargeDensityName()
.
63-64
: ****Skipping the review of these methods as the past review comments are still valid and applicable. Please refer to the previous comments for more details.
66-67
: ****The code changes are approved. The
particleDensity()
methods are correctly implemented and provide access to theparticleDensity_
member variable.
71-71
: ****The code changes are approved. The
massDensity()
method correctly returnsparticleDensity_
when all populations have the same mass, which optimizes the memory usage.
73-73
: ****The code changes are approved. The
massDensity()
method correctly returnsparticleDensity_
when all populations have the same mass, which optimizes the memory usage.
75-76
: ****The code changes are approved. The
chargeDensity()
methods are correctly implemented and provide access to thechargeDensity_
member variable.
81-81
: ****The code changes are approved. The static method
particleDensityName()
correctly returns the string "particleDensity" for the particle density name.
82-82
: ****The code changes are approved. The static method
chargeDensityName()
correctly returns the string "chargeDensity" for the charge density name.
88-90
: ****The code changes are approved. The method
computeParticleDensity()
correctly zeroes outparticleDensity_
before computing the particle density, which is consistent with the new naming convention.
98-100
: ****The code changes are approved. The method
computeParticleDensity()
correctly usespop.particleDensity()
instead ofpop.density()
to compute the particle density, which is consistent with the changes in theIonPopulation
class.
113-113
: ****The code changes are approved. The method
computeMassDensity()
correctly usespop.particleDensity()
instead ofpop.density()
to compute the mass density, which is consistent with the changes in theIonPopulation
class.tests/diagnostic/test_diagnostics.hpp (1)
125-125
: LGTM!The change from
pop.density()
topop.chargeDensity()
is approved. It aligns with the overall modifications to focus on charge density instead of standard density.src/diagnostic/detail/types/fluid.hpp (2)
201-201
: LGTM!The change from
pop.density()
topop.chargeDensity()
is approved. It aligns with the overall modifications to focus on charge density instead of standard density in thegetDataSetInfo
method.
310-310
: LGTM!The change from writing
pop.density()
topop.chargeDensity()
is approved. It aligns with the overall modifications to focus on charge density instead of standard density in thewrite
method.src/core/numerics/interpolator/interpolator.hpp (4)
472-472
: LGTM, but verify the implementation.The change in the operator's signature to accept both
particleDensity
andchargeDensity
fields is approved. It enhances the functionality by allowing the operator to process both particle density and charge density simultaneously.However, ensure that the corresponding changes in the implementation are correct and consistent with this modification.
490-491
: LGTM!The change to call
particleToMesh_
withparticleDensity
field and a lambda function that returns 1 is approved. It is consistent with the previous implementation for handling particle density.
492-493
: LGTM!The change to call
particleToMesh_
withchargeDensity
field and a lambda function that returns the particle's charge is approved. It correctly introduces the handling of charge density in the operator's implementation and aligns with the overall modifications.
508-508
: LGTM!The change in the operator's signature to accept both
particleDensity
andchargeDensity
fields is approved. It ensures consistency with the modification made to the other operator overload.tests/core/numerics/ion_updater/test_updater.cpp (3)
214-215
: LGTM!The changes to rename particle density variables and introduce charge density variables enhance the clarity and functionality of the code. The updates to the constructor, copy constructor, and
setBuffers
method are consistent with these changes.Also applies to: 217-220, 243-246, 249-256, 282-285, 288-296, 318-324, 334-338, 344-346, 353-355
550-551
: Update method name tocomputeParticleDensity
.The method
computeParticleDensity
aligns with the new focus on particle density.
585-586
: LGTM!The updates to use the new particle density variables in the checks are approved.
Also applies to: 591-592, 624-625, 630-631, 636-636
src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (1)
388-389
: LGTM!The changes to replace
density
withparticleDensity
and introducechargeDensity
enhance the clarity and functionality of the code. The updates to theinterpolate_
function parameters are consistent with these changes.Also applies to: 392-392, 399-399, 402-402
@@ -36,7 +36,7 @@ | |||
auto& By = model.state.electromag.B.getComponent(PHARE::core::Component::Y); | |||
auto& Bz = model.state.electromag.B.getComponent(PHARE::core::Component::Z); | |||
|
|||
auto& N = model.state.ions.density(); | |||
auto& N = model.state.ions.chargeDensity(); |
Check notice
Code scanning / CodeQL
Unused local variable Note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
tests/core/data/ions/test_ions.cpp (1)
157-157
: Update the test name and comment to reflect the change fromdensity
tochargeDensity
.The change in the test from checking
density()
tochargeDensity()
aligns with the PR objective of incorporating the concept of ion charge into the codebase. It also improves the robustness of the code by ensuring that thechargeDensity()
property is properly guarded against invalid access, similar todensity()
.However, please consider updating the test name and the comment above the test to reflect this change. For example:
TEST_F(theIons, throwIfAccessingChargeDensityWhileNotUsable) { EXPECT_ANY_THROW(auto& n = ions.chargeDensity()(0)); }
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (26)
- pyphare/pyphare/pharein/diagnostics.py (2 hunks)
- pyphare/pyphare/pharesee/plotting.py (1 hunks)
- pyphare/pyphare/pharesee/run/run.py (3 hunks)
- pyphare/pyphare_tests/test_pharesee/test_hierarchy.py (1 hunks)
- src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (2 hunks)
- src/diagnostic/detail/types/fluid.hpp (5 hunks)
- src/phare/phare_init.py (1 hunks)
- src/phare/phare_init_small.py (1 hunks)
- src/python3/patch_level.hpp (2 hunks)
- tests/core/data/electrons/test_electrons.cpp (7 hunks)
- tests/core/data/ions/test_ions.cpp (1 hunks)
- tests/diagnostic/init.py (1 hunks)
- tests/diagnostic/test_diagnostics.hpp (2 hunks)
- tests/diagnostic/test_diagnostics.ipp (1 hunks)
- tests/functional/alfven_wave/alfven_wave1d.py (1 hunks)
- tests/functional/dispersion/dispersion.py (1 hunks)
- tests/functional/harris/harris_2d_lb.py (1 hunks)
- tests/functional/shock/shock.py (1 hunks)
- tests/functional/td/td1d.py (1 hunks)
- tests/functional/tdtagged/td1dtagged.py (1 hunks)
- tests/functional/translation/translat1d.py (2 hunks)
- tests/simulator/refinement/test_2d_10_core.py (1 hunks)
- tests/simulator/refinement/test_2d_2_core.py (1 hunks)
- tests/simulator/test_advance.py (3 hunks)
- tests/simulator/test_initialization.py (3 hunks)
- tests/simulator/test_run.py (1 hunks)
Files skipped from review due to trivial changes (2)
- pyphare/pyphare/pharesee/run/run.py
- pyphare/pyphare_tests/test_pharesee/test_hierarchy.py
Files skipped from review as they are similar to previous changes (4)
- src/python3/patch_level.hpp
- tests/core/data/electrons/test_electrons.cpp
- tests/diagnostic/test_diagnostics.hpp
- tests/simulator/test_initialization.py
Additional context used
Path-based instructions (2)
src/diagnostic/detail/types/fluid.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.
Additional comments not posted (38)
tests/diagnostic/__init__.py (1)
31-31
: LGTM!The change from "density" to "charge_density" aligns with the PR objective and improves code clarity by using a more specific term. The modification is syntactically correct and does not introduce any logical issues.
src/phare/phare_init.py (1)
104-104
: LGTM!The change from
"density"
to"charge_density"
aligns with the PR objective of incorporating the concept of ion charge into the codebase. It enhances the clarity and specificity of the diagnostic data being processed by theFluidDiagnostics
function.src/phare/phare_init_small.py (1)
107-107
: LGTM!The change from "density" to "charge_density" aligns with the PR objective of incorporating the concept of ion charge into the codebase. It improves the clarity and accuracy of the code by using a more context-appropriate term for the quantity being processed by the
FluidDiagnostics
function.tests/functional/td/td1d.py (1)
103-103
: LGTM!The change from
"density"
to"charge_density"
aligns with the PR objective of incorporating the concept of ion charge into the codebase. It enhances clarity by using a more context-appropriate term for the quantity being diagnosed.tests/diagnostic/test_diagnostics.ipp (1)
17-17
: LGTM!The change from tracking ion density to ion charge density in the diagnostic dictionary aligns with the PR objective of incorporating the concept of ion charge into the codebase. This update enhances the clarity and accuracy of the code in relation to ion charge representation while preserving the overall structure of the diagnostic management.
tests/functional/dispersion/dispersion.py (1)
174-176
: LGTM!The change from
density
tocharge_density
aligns with the PR objective of incorporating the concept of ion charge into the codebase. It enhances clarity by using a more context-appropriate term and is consistent with the AI-generated summary of changes. This change is part of a broader effort to refine data processing and ensure the simulation framework can handle more nuanced interactions involving both particle density and charge density.tests/simulator/refinement/test_2d_2_core.py (1)
104-104
: LGTM!The change from "density" to "charge_density" enhances clarity and aligns the terminology with the actual function of the data being collected. This is consistent with the PR objective of incorporating the concept of ion charge into the codebase.
tests/functional/shock/shock.py (1)
110-110
: LGTM!The change from
"density"
to"charge_density"
enhances clarity and aligns with the PR objective of incorporating the concept of ion charge into the codebase. It uses a more context-appropriate term for the quantity being diagnosed, improving code interpretability.tests/simulator/refinement/test_2d_10_core.py (1)
104-104
: LGTM!The change from
"density"
to"charge_density"
enhances clarity and aligns with the PR objective of incorporating the concept of ion charge into the codebase. The usage of a more context-appropriate term for the diagnostic quantity improves code interpretability.tests/functional/translation/translat1d.py (2)
90-90
: LGTM!The change from
"density"
to"charge_density"
aligns with the PR objective, improves clarity, and is consistent with the AI-generated summary.
185-185
: LGTM!The change from
"density"
to"charge_density"
aligns with the PR objective, improves clarity, and is consistent with the AI-generated summary and the previous code segment.tests/functional/alfven_wave/alfven_wave1d.py (1)
99-99
: LGTM! The change enhances clarity and aligns with the PR objectives.Updating the
quantity
parameter value from"density"
to"charge_density"
improves the specificity and clarity of the diagnostics being collected. This change aligns with the PR objective of incorporating the concept of ion charge into the codebase and enhances code interpretability by using more context-appropriate terminology.tests/functional/harris/harris_2d_lb.py (2)
136-136
: LGTM!The change from "density" to "charge_density" aligns with the PR objective, enhances code clarity, and does not introduce any issues. Good work!
140-140
: Looks good!The change is consistent with the previous modification and aligns with the PR objective. The use of "charge_density" instead of "density" for the proton population diagnostic is clearer and more accurate.
tests/simulator/test_run.py (1)
149-149
: LGTM!The change from
"density"
to"charge_density"
aligns with the PR objective of incorporating the concept of ion charge into the codebase and enhancing clarity. The usage is consistent with theFluidDiagnostics
call.tests/functional/tdtagged/td1dtagged.py (1)
120-120
: LGTM!The change from
"density"
to"charge_density"
aligns with the PR objective and improves code clarity by using a more context-appropriate term for the diagnostic quantity. This rename is unlikely to have any negative impact on the existing functionality.pyphare/pyphare/pharesee/plotting.py (1)
277-277
: Approve the change in the filename for accessing charge density data.The change in the filename from
"ions_density.h5"
to"ions_charge_density.h5"
aligns with the PR objective of incorporating the concept of ion charge into the existing codebase. It also improves code interpretability by aligning the terminology with the actual function of the data being accessed.Verify if the new file
"ions_charge_density.h5"
exists and contains the expected charge density data by running the following script:pyphare/pyphare/pharein/diagnostics.py (2)
225-225
: LGTM!The addition of "charge_density" to the list of fluid quantities is a valid change that aligns with the PR objective of incorporating ion charge into the codebase.
294-294
: Verify the impact of replacing "density" with "charge_density".The change in the needed_quantities logic to include "charge_density" instead of "density" when not dealing with total ions is a valid update that aligns with the PR objective. It ensures that the FluidDiagnostics class prioritizes the newly introduced charge density over the generic density, enhancing the clarity and specificity of density-related computations.
However, it's important to verify that this change does not introduce any unintended side effects or break existing functionality in other parts of the codebase that may rely on the "density" quantity being present in the needed_quantities.
To verify the impact of this change, you can run the following script:
Please let me know if you have any concerns or if you would like me to assist with updating any impacted parts of the codebase.
Verification successful
Change from "density" to "charge_density" is safe and consistent.
The modification of
needed_quantities
to include "charge_density" instead of "density" is localized to thepyphare/pyphare/pharein/diagnostics.py
file and does not affect other parts of the codebase. There are no other dependencies on "density" in this context, confirming that the change aligns with the intended update without introducing unintended side effects.
- File:
pyphare/pyphare/pharein/diagnostics.py
- Lines: Instances of
needed_quantities
are correctly updated.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: # Verify that replacing "density" with "charge_density" in needed_quantities # does not break existing functionality in other parts of the codebase. # Test 1: Search for usage of needed_quantities in the codebase. echo "Searching for usage of needed_quantities..." rg --type python -w needed_quantities # Test 2: Search for usage of "density" in the context of needed_quantities. echo "Searching for usage of 'density' in the context of needed_quantities..." rg --type python -A 5 -B 5 $'needed_quantities\s*=\s*\[.*"density".*\]' # Expected results: # - Test 1 should return all locations where needed_quantities is used. # Review these locations to ensure the change doesn't break existing logic. # - Test 2 should ideally return no results. If there are any matches, # investigate further to determine if the usage of "density" needs to be # updated to "charge_density" or if it's a valid use case.Length of output: 430
Script:
#!/bin/bash # Description: # Verify that replacing "density" with "charge_density" in needed_quantities # does not break existing functionality in other parts of the codebase. # Find all Python files and search for usage of needed_quantities. echo "Searching for usage of needed_quantities..." fd -e py | xargs rg -w needed_quantities # Find all Python files and search for usage of "density" in the context of needed_quantities. echo "Searching for usage of 'density' in the context of needed_quantities..." fd -e py | xargs rg -A 5 -B 5 $'needed_quantities\s*=\s*\[.*"density".*\]'Length of output: 708
src/diagnostic/detail/types/fluid.hpp (12)
149-149
: LGTM!The change from "density" to "charge_density" improves clarity and specificity, aligning with the overall goal of the PR.
201-201
: LGTM!Replacing
pop.density()
withpop.chargeDensity()
improves clarity and specificity, aligning with the overall goal of the PR.
209-209
: LGTM!The change from "density" to "charge_density" improves clarity and specificity, aligning with the overall goal of the PR.
210-210
: LGTM!Replacing
ions.density()
withions.chargeDensity()
improves clarity and specificity, aligning with the overall goal of the PR.
278-278
: LGTM!The change from "density" to "charge_density" improves clarity and specificity, aligning with the overall goal of the PR.
279-279
: LGTM!Replacing the argument "density" with "charge_density" in the
initDS()
call improves clarity and specificity, aligning with the overall goal of the PR.
310-310
: LGTM!Replacing
pop.density()
withpop.chargeDensity()
improves clarity and specificity, aligning with the overall goal of the PR.
318-318
: LGTM!The change from "density" to "charge_density" improves clarity and specificity, aligning with the overall goal of the PR.
319-319
: LGTM!Replacing
ions.density()
withions.chargeDensity()
improves clarity and specificity, aligning with the overall goal of the PR.
347-347
: LGTM!The change from "density" to "charge_density" improves clarity and specificity, aligning with the overall goal of the PR.
348-348
: LGTM!The change from "density" to "charge_density" improves clarity and specificity, aligning with the overall goal of the PR.
349-349
: LGTM!The change from "density" to "charge_density" improves clarity and specificity, aligning with the overall goal of the PR.
tests/simulator/test_advance.py (2)
155-155
: LGTM!The renaming of the quantity from "density" to "charge_density" enhances clarity by specifying that the diagnostics pertain to charge density rather than a more general density term, which could lead to confusion in the context of electromagnetic and fluid diagnostics.
225-225
: LGTM!The filename changes from "ions_density.h5" to "ions_charge_density.h5" are consistent with the alterations listed in the AI-generated summary, which indicate that the "density" term has been replaced with "charge_density". This enhances clarity by specifying that the diagnostics pertain to charge density rather than a more general density term.
Also applies to: 234-234
src/amr/messengers/hybrid_hybrid_messenger_strategy.hpp (5)
388-389
: Approved renaming for clarity.The renaming of
density
toparticleDensity
andchargeDensity
enhances code clarity by explicitly distinguishing between the two density types. This change aligns with the broader objective stated in the summary.
402-402
: Approved, with a note on verifying time-interpolation.Passing
particleDensity
,chargeDensity
, andflux
tointerpolate_
forlevelGhostNew
particles with a coefficient ofalpha
is consistent with the separate treatment of particle and charge densities. As mentioned in the previous comment, please verify the correctness of the overall time-interpolation logic involving thealpha
and1. - alpha
coefficients.
542-542
: Approved renaming for consistency and clarity.Renaming
Ni
tochargeDensity
enhances code clarity and maintains consistency with the changes made in thefillIonPopMomentGhosts
function. This change contributes to the overall objective of improving the interpretability of density-related computations.
399-399
: Verify the time-interpolation logic.Passing
particleDensity
,chargeDensity
, andflux
tointerpolate_
forlevelGhostOld
particles with a coefficient of1. - alpha
is consistent with the pattern of treating particle and charge densities separately. However, please verify the correctness of the broader time-interpolation logic and the specific role of the1. - alpha
coefficient in this context.Verification successful
Time-interpolation logic is correctly implemented.
The calculation and usage of
alpha
and1. - alpha
are consistent with standard linear interpolation practices. The broader time-interpolation logic, including the role of1. - alpha
, is correctly implemented across the codebase. The specific usage inhybrid_hybrid_messenger_strategy.hpp
aligns with these practices. No issues were found.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the time-interpolation logic and the role of the `1. - alpha` coefficient. # Test 1: Search for the calculation of `alpha`. # Expect: `alpha` should be computed as a time interpolation coefficient. rg --type cpp -A 5 $'alpha\s*=\s*\(' # Test 2: Search for other occurrences of `1. - alpha`. # Expect: Consistent usage in time-interpolation contexts. rg --type cpp -A 5 $'1\.\s*-\s*alpha'Length of output: 3794
392-392
: Verifyinterpolate_
handles the new density parameters correctly.Passing
particleDensity
andchargeDensity
separately tointerpolate_
enables a more nuanced treatment of particle interactions, which aligns with the objectives stated in the summary. Please ensure thatinterpolate_
is equipped to correctly handle the two separate density parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Outside diff range and nitpick comments (1)
pyphare/pyphare/pharesee/hierarchy/hierarchy.py (1)
368-368
: Consider the impact of increasing the subplot size on the overall plot layout.The subplot size has been increased from 6x6 to 16x16, which may improve visibility. However, please ensure that this change does not adversely affect the overall layout and appearance of the plot, especially when integrated with other subplots or figures.
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (17)
- pyphare/pyphare/pharein/diagnostics.py (1 hunks)
- pyphare/pyphare/pharesee/hierarchy/hierarchy.py (2 hunks)
- pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py (1 hunks)
- src/amr/level_initializer/hybrid_level_initializer.hpp (1 hunks)
- src/amr/physical_models/hybrid_model.hpp (1 hunks)
- src/core/data/electrons/electrons.hpp (4 hunks)
- src/core/data/ions/ion_population/ion_population.hpp (5 hunks)
- src/core/data/ions/ions.hpp (9 hunks)
- src/core/numerics/interpolator/interpolator.hpp (3 hunks)
- src/core/numerics/ion_updater/ion_updater.hpp (4 hunks)
- src/core/numerics/moments/moments.hpp (2 hunks)
- src/diagnostic/detail/types/fluid.hpp (5 hunks)
- tests/core/data/electrons/test_electrons.cpp (8 hunks)
- tests/core/numerics/ion_updater/test_updater.cpp (12 hunks)
- tests/diagnostic/init.py (1 hunks)
- tests/diagnostic/test_diagnostics.hpp (4 hunks)
- tests/simulator/test_advance.py (5 hunks)
Files skipped from review as they are similar to previous changes (5)
- pyphare/pyphare/pharein/diagnostics.py
- src/amr/level_initializer/hybrid_level_initializer.hpp
- src/amr/physical_models/hybrid_model.hpp
- src/diagnostic/detail/types/fluid.hpp
- tests/diagnostic/init.py
Additional context used
Path-based instructions (7)
src/core/numerics/moments/moments.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/data/ions/ion_population/ion_population.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/data/ions/ions.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/numerics/ion_updater/ion_updater.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/data/electrons/electrons.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.tests/diagnostic/test_diagnostics.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.src/core/numerics/interpolator/interpolator.hpp (1)
Pattern
**/*.hpp
: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.
GitHub Check: CodeQL
tests/core/data/electrons/test_electrons.cpp
[notice] 166-166: Unused local variable
Variable (unnamed local variable) is not used.
[notice] 171-171: Unused local variable
Variable (unnamed local variable) is not used.pyphare/pyphare/pharesee/hierarchy/hierarchy.py
[notice] 370-370: Unused local variable
Variable color is not used.tests/core/numerics/ion_updater/test_updater.cpp
[notice] 328-328: Unused local variable
Variable (unnamed local variable) is not used.
[notice] 337-337: Unused local variable
Variable (unnamed local variable) is not used.
[notice] 346-346: Unused local variable
Variable (unnamed local variable) is not used.
Ruff
pyphare/pyphare/pharesee/hierarchy/hierarchy.py
370-370: Local variable
color
is assigned to but never usedRemove assignment to unused variable
color
(F841)
tests/simulator/test_advance.py
50-50: Do not use mutable data structures for argument defaults
Replace with
None
; initialize within function(B006)
312-312: f-string without any placeholders
Remove extraneous
f
prefix(F541)
Additional comments not posted (65)
src/core/numerics/moments/moments.hpp (2)
18-19
: LGTM!The changes in the
resetMoments
function look good:
- The renaming of
density()
toparticleDensity()
improves clarity.- The addition of
chargeDensity().zero()
is consistent with the new density-related changes.- The function template and range-based for loop are used effectively.
44-46
: Looks good!The changes in the
depositParticles
function are well-implemented:
- The use of
particleDensity
andchargeDensity
instead ofdensity
aligns with the new density-related changes.- The
interpolate
function calls have been updated to include bothparticleDensity
andchargeDensity
.- The
if constexpr
statements effectively select the appropriate particle array based on theDepositTag
.Also applies to: 51-51, 56-56, 61-61
src/core/data/ions/ion_population/ion_population.hpp (5)
37-38
: LGTM!The introduction of
particleDensity_
andchargeDensity_
variables enhances clarity by explicitly distinguishing between particle density and charge density. The naming is clear and follows the existing naming convention. The initialization withHybridQuantity::Scalar::rho
is appropriate for density quantities.
53-54
: LGTM!The update to the
isUsable()
method to include checks for the usability ofparticleDensity_
andchargeDensity_
ensures that the method considers all relevant member variables. This change maintains the consistency and correctness of theisUsable()
method.
59-60
: LGTM!The update to the
isSettable()
method to include checks for the settable status ofparticleDensity_
andchargeDensity_
ensures that the method considers all relevant member variables. This change maintains the consistency and correctness of theisSettable()
method.
85-89
: LGTM!The introduction of getter methods for
particleDensity_
andchargeDensity_
provides a clean and consistent way to access these member variables. Providing both const and non-const versions allows for flexibility in usage. The naming of the getter methods follows the naming convention of the member variables, which is consistent with the existing code style.
108-109
: LGTM!The update to the
getCompileTimeResourcesViewList()
method to includeparticleDensity_
andchargeDensity_
in the returned tuple ensures that the method returns all relevant member variables. This change maintains the consistency and correctness of the method. The order of the variables in the tuple is consistent with their declaration order in the class, which enhances readability.src/core/data/ions/ions.hpp (10)
44-45
: LGTM!The changes improve code clarity and maintainability by:
- Replacing
rho_
with a more descriptive namechargeDensity_
.- Initializing
massDensity_
andchargeDensity_
using the corresponding name functions.
60-61
: LGTM!The
massDensity()
methods provide appropriate access to themassDensity_
member variable.
63-64
: LGTM!The
chargeDensity()
methods provide appropriate access to thechargeDensity_
member variable.
69-69
: LGTM!The renaming of
densityName()
tochargeDensityName()
improves code clarity and aligns with the new terminology.
75-88
: LGTM!The changes in the
computeChargeDensity()
method are consistent and correct:
- The renaming aligns with the new terminology and improves code clarity.
- The method correctly accumulates the charge density from each population into
chargeDensity_
.
Line range hint
113-144
: LGTM!The changes in the
computeBulkVelocity()
method are consistent and correct:
- Calling
computeMassDensity()
instead ofcomputeDensity()
aligns with the introduction of themassDensity_
member variable.- The bulk velocity components are correctly computed using
massDensity_
.
175-176
: LGTM!The changes in the
isUsable()
method are consistent and correct:
- The inclusion of
chargeDensity_
andmassDensity_
in the usability check aligns with the introduction of these member variables.- The change ensures that the usability condition accounts for these new attributes.
189-190
: LGTM!The changes in the
isSettable()
method are consistent and correct:
- The inclusion of
chargeDensity_
andmassDensity_
in the settability check aligns with the introduction of these member variables.- The change ensures that the settability condition accounts for these new attributes.
214-215
: LGTM!The inclusion of
chargeDensity_
in thegetCompileTimeResourcesViewList()
method is consistent with its importance in the resource management of the class.
239-239
: Ensure Initialization Order Consistency.The initialization order in the constructor should match the order of declaration in the class to prevent potential issues. Ensure that
particleDensity_
,massDensity_
, andchargeDensity_
are declared in the same order as they are initialized.- field_type particleDensity_; - field_type massDensity_; - field_type chargeDensity_; + field_type particleDensity_; + field_type chargeDensity_; + field_type massDensity_;src/core/numerics/ion_updater/ion_updater.hpp (4)
110-110
: Improved ion property assessment by computing charge density.The change from
computeDensity()
tocomputeChargeDensity()
enhances the way ion properties are assessed, potentially improving the accuracy of simulations involving ion interactions.
161-161
: Refined density calculations by separating particle and charge densities.The interpolator function now takes
pop.particleDensity()
andpop.chargeDensity()
as separate parameters instead of the previouspop.density()
. This change reflects a more granular approach to handling ion properties, allowing for separate treatment of particle and charge densities during interpolation. It enhances the functionality of theIonUpdater
class by refining the density calculations.
184-185
: This change is a duplicate of the one at line 161 and has already been reviewed.
273-274
: This change is a duplicate of the ones at lines 161 and 184-185 and has already been reviewed.src/core/data/electrons/electrons.hpp (3)
68-68
: Changes look good!The modifications to use
ions_.chargeDensity()
instead ofions_.density()
in thedensity()
andcomputeBulkVelocity()
methods are consistent with the purpose of theStandardHybridElectronFluxComputer
class. The electron velocity calculation now correctly uses the ion charge density.Also applies to: 81-81, 115-115, 122-122, 129-131
214-214
: Change looks good!The modification to use
ions_.chargeDensity()
instead ofions_.density()
in thecomputePressure()
method is consistent with the isothermal equation of state, which relates pressure to charge density and temperature.
Line range hint
232-360
: Electron moment model and interface look good!The
ElectronMomentModel
andElectrons
classes provide a consistent and correct abstraction for the electron moment computations, propagating the changes made to the underlyingStandardHybridElectronFluxComputer
andIsothermalElectronPressureClosure
classes.tests/diagnostic/test_diagnostics.hpp (4)
125-125
: LGTM!The change from
density()
tochargeDensity()
aligns with the PR objective and provides more accurate context for ions.
128-128
: Looks good!Using
ions.chargeDensity()
instead ofions.density()
is more accurate and aligns with the PR objective.
229-229
: Good catch!Increasing
expectedPopAttrFiles
from 5 to 6 is necessary to validate the inclusion of the new charge density attribute for each ion population.
Line range hint
239-251
: Looks good!The updates to
h5FileTypes
are necessary to validate the inclusion of charge density and mass density attributes in the HDF5 files, both at the overall ion level and for each ion population. These changes align with the PR objective and ensure comprehensive validation of the new attributes.pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py (1)
31-31
: LGTM!The addition of the
"charge_density": "rho"
mapping to thefield_qties
dictionary is consistent with the existing pattern and will enable the codebase to handle charge density using the symbol "rho". This change is unlikely to introduce any issues.tests/core/data/electrons/test_electrons.cpp (14)
129-130
: LGTM!The usage of type traits for compile-time dimensionality and interpolation order selection is a good practice.
151-151
: LGTM!The renaming of the member variables to
ionTensor
andprotonTensor
improves code clarity.
153-153
: LGTM!The renaming and addition of member variables improve code clarity and suggest an expansion of functionality.
166-167
: LGTM!The renaming and addition of variables in the structured binding declaration improve code clarity and suggest an expansion of functionality.
Tools
GitHub Check: CodeQL
[notice] 166-166: Unused local variable
Variable (unnamed local variable) is not used.
171-173
: LGTM!The renaming of variables in the structured binding declaration improves code clarity.
Tools
GitHub Check: CodeQL
[notice] 171-171: Unused local variable
Variable (unnamed local variable) is not used.
175-175
: LGTM!The renaming of the variable to
ionTensor
improves code clarity.
180-184
: LGTM!The renaming of variables in the structured binding declaration and the subsequent code improves code clarity.
196-197
: LGTM!The renaming of the member variables to
ionTensor
andprotonTensor
in the constructor improves code clarity.
198-205
: LGTM!The renaming and addition of member variables in the constructor improve code clarity and suggest an expansion of functionality.
207-208
: LGTM!The usage of the renamed variables in the
_ions
function call is consistent with the previous changes.
247-247
: LGTM!The renaming of the variable to
ionChargeDensity
improves code clarity.
276-277
: LGTM!The renaming of the variable to
ionChargeDensity
improves code clarity.
323-325
: LGTM!The renaming of the variable to
ionChargeDensity
improves code clarity.
373-373
: LGTM!The renaming of the variable to
ions.chargeDensity()
improves code clarity and consistency with theions
object.src/core/numerics/interpolator/interpolator.hpp (2)
472-474
: Improved functionality for handling particle and charge densities.The changes to the
operator()
function signature and body enable the interpolation of both particle density and charge density to the mesh. By callingparticleToMesh_
twice with different fields and lambda functions, the function can now handle the interpolation of both density types effectively.The addition of the
chargeDensity
parameter and the corresponding lambda function to extract the charge from each particle enhances the interpolation process and provides more flexibility in handling different density quantities.Overall, the changes are well-structured and improve the functionality of the interpolation process.
509-512
: Consistent changes with the other overload.The modifications to the
operator()
function signature and body are consistent with the changes made to the other overload. By accepting theparticleDensity
andchargeDensity
parameters and forwarding the call to the other overload, the function maintains consistency in behavior and interface.The changes ensure that both overloads of
operator()
handle the interpolation of particle density and charge density in a unified manner, providing a coherent and predictable interface for the users of theInterpolator
class.The updates are well-aligned with the overall modifications made to the class and enhance its usability and maintainability.
pyphare/pyphare/pharesee/hierarchy/hierarchy.py (1)
Line range hint
356-397
: Excellent refactoring to usepcolormesh
for more efficient rendering of colored boxes!The changes to utilize
pcolormesh
instead ofPatchCollection
are a significant improvement. Setting the facecolor for each box directly in a 2D array (ij
) and then visualizing it usingax.pcolormesh
is a cleaner and more efficient approach.The simplification of the tick logic and removal of the previous grid setup in favor of directly setting limits based on optional
xlim
andylim
parameters passed inkwargs
is also a nice touch, making the method more flexible.Great job on retaining the functionality to draw red rectangles around patches using the
Rectangle
class directly, ensuring consistency.Tools
Ruff
366-366: Local variable
mi
is assigned to but never usedRemove assignment to unused variable
mi
(F841)
366-366: Local variable
ma
is assigned to but never usedRemove assignment to unused variable
ma
(F841)
370-370: Local variable
color
is assigned to but never usedRemove assignment to unused variable
color
(F841)
GitHub Check: CodeQL
[notice] 370-370: Unused local variable
Variable color is not used.tests/simulator/test_advance.py (4)
50-50
: LGTM!The addition of the
model_init
parameter to initialize the particle model looks good.Tools
Ruff
50-50: Do not use mutable data structures for argument defaults
Replace with
None
; initialize within function(B006)
155-155
: LGTM!Renaming the diagnostic quantity from "density" to "charge_density" improves clarity and aligns with the physics.
Line range hint
225-234
: LGTM!Updating the filename for the HDF5 output of the charge density diagnostic to reflect the renaming of the diagnostic quantity is a good change.
292-292
: Verify the reason for relaxing the assertion tolerance.The assertion tolerance for floating-point comparisons has been relaxed from
5.5e-15
to2.5e-14
. Please ensure that this change is intentional and justified.tests/core/numerics/ion_updater/test_updater.cpp (15)
214-214
: LGTM!The renaming of
ionDensity
toionChargeDensity
improves code clarity and aligns with the goal of distinguishing between particle and charge density.
216-216
: LGTM!The renaming of
protonDensity
toprotonParticleDensity
improves code clarity and aligns with the goal of distinguishing between particle and charge density for protons.
217-217
: LGTM!The addition of
protonChargeDensity
variable enables explicit tracking of proton charge density, enhancing the code's ability to model nuanced interactions involving both particle and charge densities.
218-218
: LGTM!The renaming of
alphaDensity
toalphaParticleDensity
improves code clarity and aligns with the goal of distinguishing between particle and charge density for alpha particles.
219-219
: LGTM!The addition of
alphaChargeDensity
variable enables explicit tracking of alpha particle charge density, enhancing the code's ability to model nuanced interactions involving both particle and charge densities.
242-243
: LGTM!The initialization of
ionChargeDensity
is updated correctly to match the renaming fromionDensity
, setting the appropriate name, quantity, and allocation size.
246-247
: LGTM!The initialization of
protonParticleDensity
is updated correctly to match the renaming fromprotonDensity
, setting the appropriate name, quantity, and allocation size.
248-249
: LGTM!The initialization of the new
protonChargeDensity
variable is implemented correctly, setting the appropriate name, quantity, and allocation size. This addition aligns with the goal of tracking proton charge density.
250-251
: LGTM!The initialization of
alphaParticleDensity
is updated correctly to match the renaming fromalphaDensity
, setting the appropriate name, quantity, and allocation size.
252-253
: LGTM!The initialization of the new
alphaChargeDensity
variable is implemented correctly, setting the appropriate name, quantity, and allocation size. This addition aligns with the goal of tracking alpha particle charge density.
279-280
: LGTM!The initialization of
ionChargeDensity
in the copy constructor is updated correctly to match the renaming fromionDensity
, setting the appropriate name, quantity, and allocation size.
283-290
: LGTM!The initializations of
protonParticleDensity
,protonChargeDensity
,alphaParticleDensity
, andalphaChargeDensity
in the copy constructor are updated and added correctly. The changes are consistent with the renaming of particle density variables and the introduction of charge density variables, setting the appropriate names, quantities, and allocation sizes for each.
313-318
: LGTM!The data copying for
ionChargeDensity
,protonParticleDensity
,protonChargeDensity
,alphaParticleDensity
, andalphaChargeDensity
in the copy constructor is updated and added correctly. The changes are consistent with the renaming of particle density variables and the introduction of charge density variables, ensuring that the state of the source object is correctly replicated in the newly constructed object.
328-331
: LGTM!The buffer setting for
ionChargeDensity
in thesetBuffers
method is updated correctly to match the renaming fromionDensity
. The buffer setting forionMassDensity
remains unchanged. The method correctly updates the buffers for the charge and mass density variables.Tools
GitHub Check: CodeQL
[notice] 328-328: Unused local variable
Variable (unnamed local variable) is not used.
337-339
: LGTM!The buffer setting for
protonParticleDensity
in thesetBuffers
method is updated correctly to match the renaming fromd
. The addition of buffer setting forprotonChargeDensity
aligns with the introduction of this variable to track proton charge density. The method correctly updates the buffers for the proton particle and charge density variables.Tools
GitHub Check: CodeQL
[notice] 337-337: Unused local variable
Variable (unnamed local variable) is not used.
fig, ax = kwargs.get("subplot", plt.subplots(figsize=(6, 6))) | ||
fig, ax = kwargs.get("subplot", plt.subplots(figsize=(16, 16))) | ||
|
||
color = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the unused local variable color
.
The local variable color
is assigned a value but never used in the method. As indicated by the static analysis hints, it's best to remove this unused variable to improve code quality and cleanliness.
Apply this diff to remove the unused variable:
- color = 1
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. Thoroughly test & benchmark the code to ensure it meets the requirements.
color = 1 |
Tools
Ruff
370-370: Local variable
color
is assigned to but never usedRemove assignment to unused variable
color
(F841)
GitHub Check: CodeQL
[notice] 370-370: Unused local variable
Variable color is not used.
xlim=(-5, 50), | ||
ylim=(-5, 50), | ||
) | ||
fig.savefig(f"pd1.png") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the extraneous f
prefix from the string.
The string f"pd1.png"
does not contain any placeholders, so the f
prefix is unnecessary.
-fig.savefig(f"pd1.png")
+fig.savefig("pd1.png")
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. Thoroughly test & benchmark the code to ensure it meets the requirements.
fig.savefig(f"pd1.png") | |
fig.savefig("pd1.png") |
Tools
Ruff
312-312: f-string without any placeholders
Remove extraneous
f
prefix(F541)
@@ -47,7 +47,7 @@ | |||
largest_patch_size=20, | |||
cells=120, | |||
time_step=0.001, | |||
model_init={}, | |||
model_init={"seed": 2}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use None
as the default value for model_init
.
Mutable default arguments can lead to unexpected behavior. Consider using None
as the default value and initializing model_init
within the function.
-def getHierarchy(self, ndim, interp_order, refinement_boxes, qty, nbr_part_per_cell=100, density=_density, smallest_patch_size=None, largest_patch_size=20, cells=120, time_step=0.001, model_init={"seed": 2}, dl=0.2, extra_diag_options={}, time_step_nbr=1, timestamps=None, block_merging_particles=False, diag_outputs=""):
+def getHierarchy(self, ndim, interp_order, refinement_boxes, qty, nbr_part_per_cell=100, density=_density, smallest_patch_size=None, largest_patch_size=20, cells=120, time_step=0.001, model_init=None, dl=0.2, extra_diag_options={}, time_step_nbr=1, timestamps=None, block_merging_particles=False, diag_outputs=""):
+ if model_init is None:
+ model_init = {"seed": 2}
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. Thoroughly test & benchmark the code to ensure it meets the requirements.
model_init={"seed": 2}, | |
def getHierarchy(self, ndim, interp_order, refinement_boxes, qty, nbr_part_per_cell=100, density=_density, smallest_patch_size=None, largest_patch_size=20, cells=120, time_step=0.001, model_init=None, dl=0.2, extra_diag_options={}, time_step_nbr=1, timestamps=None, block_merging_particles=False, diag_outputs=""): | |
if model_init is None: | |
model_init = {"seed": 2} |
Tools
Ruff
50-50: Do not use mutable data structures for argument defaults
Replace with
None
; initialize within function(B006)
closed because of #891 |
Still on progress. This PR take into account the ion charge. I still need to replace the
density
functions byparticleDensity
orchargeDensity
depending on the context...Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests