Skip to content

Refactor layer#1120

Merged
eivindjahren merged 27 commits intomainfrom
refactor_layer
Mar 2, 2026
Merged

Refactor layer#1120
eivindjahren merged 27 commits intomainfrom
refactor_layer

Conversation

@eivindjahren
Copy link
Collaborator

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the layer implementation by refactoring from C to C++, adding comprehensive test coverage, and improving code maintainability. The changes convert legacy C-style memory management to modern C++ patterns while preserving the public API for compatibility with existing C code.

Changes:

  • Refactored layer.cpp from C to C++ using modern patterns (std::vector, new/delete, member functions)
  • Added comprehensive test suite test_layer.cpp with 663 lines covering layer functionality
  • Updated CMakeLists.txt to include new test file and private headers

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 10 comments.

File Description
lib/resdata/layer.cpp Modernized from C to C++ with std::vector replacing raw arrays, new/delete instead of malloc/free, member functions for encapsulation, and BlockTracer class for cleaner recursive tracing
lib/tests/test_layer.cpp Comprehensive test suite covering getters/setters, barriers, edge tracing, cell operations, and grid integration with multiple edge cases
lib/CMakeLists.txt Added test_layer.cpp to test suite and included private headers directory for internal API access

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@eivindjahren eivindjahren force-pushed the refactor_layer branch 5 times, most recently from a7042fa to 99b5a62 Compare February 13, 2026 10:36
@eivindjahren eivindjahren self-assigned this Feb 13, 2026
@eivindjahren eivindjahren moved this to Ready for Review in SCOUT Feb 13, 2026
@eivindjahren eivindjahren force-pushed the refactor_layer branch 2 times, most recently from 4c202e5 to 8dd83be Compare February 13, 2026 14:27
Copy link

@ajaust ajaust left a comment

Choose a reason for hiding this comment

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

Looks great. I also like the really small commit. 🙂
I have only added minor comments and ideas on how to sprinkle more STL on the file. You are free to decide what makes sense here.


static int layer_get_global_cell_index__(const layer_type *layer, int i,
int j) {
static int global_cell_index(const layer_type *layer, int i, int j) {
Copy link

Choose a reason for hiding this comment

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

In the previous commit, the renaming to global_interior_index dropped cell from the original name. In this commit, cell is still part of the name. Is there are difference between the two, i.e., is the global_interior_index not referring to a cell or is it clear from context?

@github-project-automation github-project-automation bot moved this from Ready for Review to Reviewed in SCOUT Feb 27, 2026
@eivindjahren eivindjahren merged commit a57abdb into main Mar 2, 2026
13 checks passed
@github-project-automation github-project-automation bot moved this from Reviewed to Done in SCOUT Mar 2, 2026
@eivindjahren eivindjahren deleted the refactor_layer branch March 2, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants