Conversation
6dddb01 to
ae3e40c
Compare
7128979 to
34d516c
Compare
54e693d to
c00493e
Compare
725bf56 to
4024d87
Compare
f8780d7 to
5945639
Compare
4ee589b to
3378ce7
Compare
3378ce7 to
99c4652
Compare
08288b4 to
920dcb1
Compare
920dcb1 to
db16aa1
Compare
| #include "SAMRAI/geom/CartesianPatchGeometry.h" | ||
| #include "SAMRAI/hier/PatchGeometry.h" |
There was a problem hiding this comment.
typically SAMRAI headers should come after our amr headers
we want to find mpi before samrai does so we can ignore certain warnings and override somethings (see: src/core/def/phare_mpi.hpp)
this file is a good example
so we can spot duplicates the group ordering should be from shortest line to longest and lines of the same length organised alphabetically from first differing character
There was a problem hiding this comment.
Yeah I have not been very rigorous and clean on header includes up to now. I agree they must be sorted in some way, but sorting by length has the disadvantage of breaking logical grouping like here
Couldn't we switch to alphabetical order within groups of headers, with groups ordering ( 1 PHARE namespaces, 2 SAMRAI, 3 STL) and enforce everything via clang-format ?
There was a problem hiding this comment.
we don't let clang-format sort includes
|
|
||
| namespace PHARE::amr | ||
| { | ||
| using core::dirX; |
There was a problem hiding this comment.
I don't think you're using this, but also try to avoid using statements at namespace scope, there can be unintended side affects
| namespace PHARE | ||
| { | ||
| namespace amr | ||
| { |
There was a problem hiding this comment.
new files namespacing should use namespace PHARE::amr to minimize indentation
| #include "amr/data/field/refine/field_moments_refiner.hpp" | ||
| #include "amr/data/field/refine/field_refine_operator.hpp" | ||
| #include "amr/data/field/refine/electric_field_refiner.hpp" | ||
| #include "amr/data/field/refine/magnetic_field_init_refiner.hpp" |
There was a problem hiding this comment.
not sure if this was you, but it is a duplicate you will spot if you consider the organising I suggested
src/amr/messengers/mhd_messenger.hpp
Outdated
| EalgoPatchGhost.registerRefine(*e_id, *e_id, *e_id, EfieldRefineOp_, | ||
| nonOverwriteInteriorTFfillPattern); |
There was a problem hiding this comment.
you should check if @UCaromel has these changes
src/core/boundary/boundary_defs.hpp
Outdated
|
|
||
| #include "core/data/grid/gridlayoutdefs.hpp" | ||
|
|
||
| #include "unordered_map" |
src/core/boundary/boundary_defs.hpp
Outdated
| auto it = typeMap_.find(name); | ||
| if (it == typeMap_.end()) | ||
| throw std::runtime_error("Wrong boundary location name = " + name); | ||
| return it->second; |
There was a problem hiding this comment.
if (auto it = typeMap_.find(name); it != typeMap_.end())
return it->second;
throw std::runtime_error("Wrong boundary location name = " + name);
or it could be
if (typeMap_.count(name))
return typeMap_.at(name);
throw std::runtime_error("Wrong boundary location name = " + name);
iterators are not deprecated, but kinda verbose
src/core/data/field/field_traits.hpp
Outdated
| { field.name() } -> std::convertible_to<std::string const&>; | ||
| { field.physicalQuantity() } -> std::same_as<typename T::physical_quantity_type const&>; | ||
|
|
||
| { field.isUsable() } -> std::same_as<bool>; |
There was a problem hiding this comment.
I don't think this should be here, this is more about samrai and how we set buffers
but a field should just be about data/size/shape/etc tbh
| Box<std::uint32_t, dimension> const& localGhostBox, | ||
| GridLayoutT const& gridLayout, double const time) | ||
| { | ||
| constexpr std::array<QtyCentering, N> centerings = {Centerings...}; |
There was a problem hiding this comment.
99% sure you don't need the <QtyCentering, N> whether you do remove it I'll leave to you
There was a problem hiding this comment.
I need it here to pass the direction as template parameter to apply_specialized
There was a problem hiding this comment.
what I meant specifically, initially, is the array could also look like
constexpr static std::array centerings{Centerings...}; the templates can be inferred.
| * @brief Define comparison of field boundary conditions based on the enum @c | ||
| * ScalarOrTensorFieldT. | ||
| */ | ||
| std::strong_ordering operator<=>(This const& other) const |
There was a problem hiding this comment.
Yeah this will disappear as it is actually not necessary
There was a problem hiding this comment.
it would have been our first operator of this kind, I hadn't really understood what it was for just yet
There was a problem hiding this comment.
It defines all comparison operators right away without manually defining <,>,>=,<=,==,!=
There was a problem hiding this comment.
yeah I know it as the "spaceship" operator, I meant your usage in the current context ;)
There was a problem hiding this comment.
I see sorry it was to define priorities between boundary conditions at corner and edges
|
|
||
|
|
||
| template<auto direction, auto offset> | ||
| NO_DISCARD constexpr auto neighbor() const |
There was a problem hiding this comment.
not sure I like this, something to discuss with nico maybe
I would suggest something like but for a point, not sure I see the benefit to the template params
There was a problem hiding this comment.
used here for instance. Isn't it useful (more efficient) in a context where the offset and the direction are known at compile time ?
There was a problem hiding this comment.
result[d] += static_cast<Type>(offset);
I think at this point, there is implicit runtime copies, so it's kinda just delaying the inevitable.
| cmake_minimum_required (VERSION 3.20.1) | ||
| project(test-tensor-field-data) | ||
|
|
||
| set(SOURCES_INC |
There was a problem hiding this comment.
if you end up with more than one test file you might want something more like this
|
|
||
|
|
||
| protected: | ||
| /// Reference to the resources manager. |
| { | ||
| using core::dirX; | ||
| using core::dirY; | ||
| using core::dirZ; |
There was a problem hiding this comment.
could probably be moved at private class scope as @PhilipDeegan suggested
| * | ||
| * @see GridLayout | ||
| * | ||
| */ |
There was a problem hiding this comment.
Could we want more minimal concepts to make maintenance easier ? Not sure if LSP can understand less explicit concepts tho.
There was a problem hiding this comment.
Sure there are choices to be made about what should be in the concept or not. But if a definition is missing, code editors like VSCode will not provide hints, auto-completion, definition overview, etc...
There was a problem hiding this comment.
something like this could be simpler than manually listing all the functions expected, assuming it works for LSP
| }(); | ||
|
|
||
| for_N<N>([&](auto i) { | ||
| constexpr QtyCentering centering = centerings[i]; |
There was a problem hiding this comment.
and this can be auto if you like, I think it's clear what centerings are
| } | ||
| } | ||
|
|
||
| NO_DISCARD auto rbegin() { return reverse_iterator{this, upper}; } |
There was a problem hiding this comment.
we're trying to minimize the use of the box iterator for performance reasons
we should talk about why you need this to see if we can not use it
There was a problem hiding this comment.
This is because for some boundary conditions (cf FieldDivergenceFreeTransverseNeumanBoundaryCondition) I need to fill ghost cells in a particular order.
I actually let Gemini write this reverse iterator by showing it the direct one to spare my time. I just wanted something that works for now, regardless of performance.
Don't you agree that we should be able to write an iterator that is efficient ?
There was a problem hiding this comment.
I've demonstrated that the new version is more efficient, in some contexts at least, it should work for reverse iteration, and hopefully never need std::uint{-1} by using something like this
| { | ||
| // Point precisely to the index that index_[0]-- creates after passing 'lower' | ||
| auto end_idx = lower; | ||
| end_idx[0]--; |
There was a problem hiding this comment.
end_idx[0]--; has an implicit copy which I'm not positive can be optimized out
so you should aim for --end_idx[0]; when possible (like here)
| using signed_t = std::make_signed_t<Type>; | ||
| if (static_cast<signed_t>(index_[0]) >= static_cast<signed_t>(box_->lower[0])) |
There was a problem hiding this comment.
you're going to need to explain this to me, I don't see how whether it's signed or unsigned should matter
There was a problem hiding this comment.
is for Box<std::uint32_t. dim>::lower[0] == 0 ?
Start implementing boundary conditions