SimVascular / SimVascular/svMultiPhysics

Adding unit tests for reading files

Open
#364 11 comments 1 reaction 1 assignee View on GitHub

@zasexton is already working on this.

Since Apr 30, 2025.

test
Dominant language
C++
Stars
45
Forks
61
Avg merge
5d 23h
Merged PRs (30d)
11

Description

Problem

The read_files.cpp file contains a number of important I/O and setup functions that are responsible for reading simulation input data (mesh data, boundary conditions, materials, domain definitions, outputs, etc.). However, many of these functions are not currently covered by unit tests. This leaves the codebase vulnerable to regressions or silent failures during refactors or feature additions. Currently this is a problem when 1-way coupling physics of fluid solutions to subsequent darcy simulations.

Having no test coverage means we cannot easily verify the correctness of new input features (e.g., node-based Dirichlet BCs, spatially varying parameters) or detect accidental breakage during development.

Solution

Similar to the current unit test case template for the material models in tests/unitTest/test.cpp (which should probably also be renamed for clarity) we plan to add the following test file: test_read_files.cpp which will exercise the following functions from the read_files.cpp:

void face_match(...);
void read_bc(...);
void read_bct(...);
void read_bf(...);
void read_cplbc_initialization_file(...);
void read_domain(...);
void read_eq(...);
void read_files(...);
void read_fourier_coeff_values_file(...);
void read_ls(...);
void read_mat_model(...);
void read_outputs(...);
void read_rmsh(...);
void read_spatial_values(...);
void read_temporal_values(...);
void read_temp_spat_values(...);
void read_trac_bcff(...);
void read_fluid_visc_model(...);
void read_solid_visc_model(...);
void read_wall_props_ff(...);
void set_cmm_bdry(...);
void set_equation_properties(...);

Each test case will:

  • Load a minimal representative XML input (or mock file) for that function’s expected input schema
  • Verify that correct values are parsed into the appropriate fields of bcType, dmnType, eqType, or related structs
  • Test both expected and edge cases (e.g., missing tags, malformed values)
  • Validate against the expected output via assertions on member values (e.g. bc.spatial_values, eq.phys, dmn.prop)
Additional context
  • The lack of automated tests for the read_files namespace leaves uncertainty about the robustness of functions and their utilization in larger integration tests
  • Several of these functions (e.g., read_eq, read_bc, read_domain) serve as critical infrastructure for new physics
  • This effort aligns with the broader effort to improve test coverage across svMultiPhysics especially the unit-testing
  • where file-based input is required, minimal mock input files will be added under tests/unitTests/data
Code of Conduct
  • I agree to follow this project's Code of Conduct and Contributing Guidelines

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.