Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/init sediment model #446

Open
wants to merge 13 commits into
base: v1
Choose a base branch
from
Open

Conversation

CFBaptista
Copy link
Contributor

This PR refactors the initialization of the sediment model by:

  • Removing unused variables
  • Removing stubs
  • Renaming variables names to more descriptive ones
  • Extracting large constructions to a separate function
  • Simplifying some logic

@verseve
Copy link
Member

verseve commented Aug 22, 2024

A general comment (did not go though the code in detail in yet): what about refactoring of the different structs that are part of the Sediment model? As discussed for the SBM concept we would like to sub-divide long structs in sub-structs, I think this is also applicable for the Sediment concept. Probably good to also ask @hboisgon to review this PR?

@CFBaptista
Copy link
Contributor Author

A general comment (did not go though the code in detail in yet): what about refactoring of the different structs that are part of the Sediment model? As discussed for the SBM concept we would like to sub-divide long structs in sub-structs, I think this is also applicable for the Sediment concept. Probably good to also ask @hboisgon to review this PR?

I completely agree and this is also what I intend to do.
I, however, prefer to implement the changes across multiple PR's instead of one big one.
Please refer to the task list in #382 for an overview.
Each task will be a separate PR.
If you feel that list is incomplete please let me know.
You can also add potentially missing steps yourself if you would like to.

@verseve verseve requested a review from hboisgon August 26, 2024 07:03
Copy link
Member

@verseve verseve left a comment

Choose a reason for hiding this comment

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

LGTM, only two small comments.

As suggested, would be good if @hboisgon also reviews this PR.

)

sediment_model = SedimentModel()
Copy link
Member

Choose a reason for hiding this comment

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

What is the advantage of doing this? Why not use directly SedimentModel()?

Copy link
Contributor Author

@CFBaptista CFBaptista Aug 27, 2024

Choose a reason for hiding this comment

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

It facilitates debugging.
Having the construction of an object as a separate statement instead of nesting its construction in the construction of another object adds additional flexibility for placing breakpoints.
For the same reasoning I also refrain from constructing objects during a return statement.

function init_overland_flow_sediment(river::Vector, number_of_cells::Integer)
river_cell = convert(Vector{Float}, river)

overland_flow_sediment = OverlandFlowSediment{Float}(;
Copy link
Member

Choose a reason for hiding this comment

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

Instead of Float you could also use T here, equal to the SBM model concept.

Copy link
Contributor Author

@CFBaptista CFBaptista Aug 27, 2024

Choose a reason for hiding this comment

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

I added an argument to the function call to generalize the construction of OverlandModelSediment.
It can now construct OverlandFlowSediment with type parameters other than Float as long as it is a subtype of AbstractFloat.

@CFBaptista CFBaptista linked an issue Aug 29, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor sediment model initialization
2 participants