Skip to content

Fix for user-defined inlet velocity profile failure#556

Open
ktbolt wants to merge 5 commits into
SimVascular:mainfrom
ktbolt:User-defied-inlet-velocity-profile-fails_555
Open

Fix for user-defined inlet velocity profile failure#556
ktbolt wants to merge 5 commits into
SimVascular:mainfrom
ktbolt:User-defied-inlet-velocity-profile-fails_555

Conversation

@ktbolt

@ktbolt ktbolt commented May 27, 2026

Copy link
Copy Markdown
Collaborator

This is a simple fix for #555.

There is no CI test for a user-defined inlet velocity profile.

@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.08%. Comparing base (5118d56) to head (3134a3e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #556   +/-   ##
=======================================
  Coverage   69.08%   69.08%           
=======================================
  Files         181      181           
  Lines       34256    34257    +1     
  Branches     5931     5932    +1     
=======================================
+ Hits        23665    23666    +1     
  Misses      10454    10454           
  Partials      137      137           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hanzhao2020

Copy link
Copy Markdown
Contributor

Looks good to me!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a solver initialization issue that breaks user-defined inlet velocity profiles (Issue #555) by avoiding an unconditional reallocation of bcType::gx during boundary-condition initialization.

Changes:

  • Preserve previously-read user-defined spatial profile data in lBc.gx by only allocating when it is empty.
  • Prevents user-defined profile values from being reset to zero during bc_ini().

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

Comment on lines +301 to +305
// lBc.gx may have values set when for example when
// reading in a user-defined profile.
if (lBc.gx.size() == 0) {
lBc.gx.resize(lFa.nNo);
}

@aabrown100-git aabrown100-git May 30, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@ktbolt is it worth validating that lBc.gx.size() == lFa.nNo if it's not 0?

lBc.gx.resize(lFa.nNo);
//if (.NOT.ALLOCATED(lBc.gx)) ALLOCATE(lBc.gx(lFa.nNo))

// lBc.gx may have values set when for example when

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@ktbolt do you have a test you can add for user-defined spatial profile?


// lBc.gx may have values set when for example when
// reading in a user-defined profile.
if (lBc.gx.size() == 0) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Interesting, so previously any time a user defined a spatial profile the solver would fail?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@aabrown100-git Correct; there are no CI tests for the Spatial_profile_file_path parameter.

Comment on lines +301 to +305
// lBc.gx may have values set when for example when
// reading in a user-defined profile.
if (lBc.gx.size() == 0) {
lBc.gx.resize(lFa.nNo);
}

@aabrown100-git aabrown100-git May 30, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@ktbolt is it worth validating that lBc.gx.size() == lFa.nNo if it's not 0?

lBc.gx.resize(lFa.nNo);
//if (.NOT.ALLOCATED(lBc.gx)) ALLOCATE(lBc.gx(lFa.nNo))

// lBc.gx may have values set when for example when

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@ktbolt do you have a test you can add for user-defined spatial profile?

@ktbolt

ktbolt commented May 30, 2026

Copy link
Copy Markdown
Collaborator Author

@aabrown100-git It might be good to check that lBc.gx.size() == lFa.nNo although in the current code lBc.gx is only resized for lFa.nNo.

@ktbolt

ktbolt commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

@aabrown100-git I am undecided about adding a CI test since the user-defined profile impact such only a small section of code; don't want to have too many CI cases. Maybe this should be a Unit Test ?

@aabrown100-git

aabrown100-git commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

@aabrown100-git I am undecided about adding a CI test since the user-defined profile impact such only a small section of code; don't want to have too many CI cases. Maybe this should be a Unit Test ?

@ktbolt I think a CI test would be good. We could do a unit test too, but would a unit test have caught this bug? I'm thinking a unit test would verify that user-defined profile data is read in correctly, but would we need another unit test to verify that it is not inadvertently overwritten like in this case?

A simple CI test could be just another variation of our fluid/pipe_RCR_... tests, like pipe_RCR_user_defined_profile

@ktbolt

ktbolt commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator Author

@aabrown100-git We would need two unit tests

  1. Test reading velocity profile text file
  2. Test that lBc.gx is computed correctly

My feeling is that this code is somewhat isolated from other code development so a CI test is not needed; also worried about the proliferation of CI tests.

@aabrown100-git

Copy link
Copy Markdown
Collaborator

@ktbolt Sounds good, doesn't hurt to add those unit tests. Would the second test check lBc.gx as it is passed through several functions, or are you thinking just testing bc_ini()?

Regarding the proliferation of CI tests, are you concerned about the testing time becoming too long? Perhaps we could start creating a different type of CI test that just checks the simulation runs without error, without checking that the solution matches some reference. We could make these very fast (1 timestep, 1 Newton iteration, big tolerances).

@ktbolt

ktbolt commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator Author

@aabrown100-git I was thinking to test baf_ini_ns::bc_ini since that is where lBc.gx is computed.

I am worried about the testing time as we keep adding more CI tests for added functionality (2D struct, electromechanics, etc.) and having tests that are really not integration tests.

CI tests checking to see if a simulation just runs without an error is an interesting idea but I think the cases it would be useful for could just be covered by unit tests maybe.

Note that we will start adding Example large and complex simulations for the User Guide ; some will need to be run on an HPC system. These simulations will be run and the results evaluated on a regular basis, maybe once a month or so or when a major code change is merged; would be good to collect execution times too.

@aabrown100-git

Copy link
Copy Markdown
Collaborator

@ktbolt Okay sounds good about the unit tests!

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.

4 participants