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

Simplify block generation #78

Merged
merged 42 commits into from
Nov 27, 2023

Conversation

mrp089
Copy link
Member

@mrp089 mrp089 commented Nov 20, 2023

Current situation

Closes #70 and #71: Simplifies block generation and introduces more error checking.

Release Notes

Major structure:

  • Model.cpp: block_factory_map replaces switch case statement to generate new blocks
  • Introduced InputParameter struct to store properties of input parameters (name, array?, optional?, number?, default value)
  • Set InputParameter, BlockType (e.g. blood_vessel), and BlockClass (e.g. closed_loop) in the constructor of all derived Block classes

Major in solve/SimulationParameters.cpp (the file formerly known as io/configreader.hpp):

  • Functions get_param_scalar and get_param_vector return an error if the input parameter is not optional and doesn't exist
  • New universal generate_block function to create a block, read its input parameters, and register block and parameters with Model
  • Replaced all block-specific parameter setups with generate_block
  • Broke load_simulation_params up into sub-functions and introduced more input-checking:
    • create_vessels
    • create_coupling
    • create_bounary_conditions
    • create_junctions
    • create_closed_loop

New error checks:

Minor:

  • Doxygen: Set WARN_AS_ERROR to FAIL_ON_WARNINGS. This runs the whole build and throws all warnings as errors. (YES fails after the first error, which is annoying for debugging).
  • Split up ClosedLoopCoronaryBC into ClosedLoopCoronaryLeftBC and ClosedLoopCoronaryRightBC (replaces side input parameter)

Limitations:

  • There are still places in SimulationParameters.cpp that are very block-specific (especially in create_coupling). These could be replaced in the future by using BlockType, BlockClass, or new Block attributes.
  • Add/move more error checks to validate_input.

Documentation

I updated the Doxygen documentation. After merging this, we can create a section on creating new blocks in the developer guide (#66).

Testing

We have built ourselves a very nice CI framework! I worked myself through all the block and interface tests. I made the following changes to the input files:

  • Removed empty vessels and junctions inputs as they are no longer required
  • Removed side input parameter and renamed ClosedLoopCoronary blocks
  • Removed unused input (unsteady in ClosedLoopRCR, ClosedLoopCoronary and C in BloodVesselJunction)

Code of Conduct & Contributing Guidelines

@mrp089
Copy link
Member Author

mrp089 commented Nov 20, 2023

I added more input checks after talking to @richterjakob and edited the first comment accordingly.

src/model/Model.cpp Outdated Show resolved Hide resolved
Copy link
Member

@menon-karthik menon-karthik left a comment

Choose a reason for hiding this comment

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

This looks really good @mrp089. Thanks for this much-needed work! I have a few minor comments.

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.

Add checking for a valid JSON to the svzerodsolver application
2 participants