SimVascular / SimVascular/svZeroDSolver

Incomplete Implementation for Windows OS in svzerodsolver.cpp: Reads input files but does not save path for output.csv

Open Beginner friendly
#238 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
22
Forks
45
PR merge metrics
No merged PRs in 30d

Description

Description

On Windows machines, the code for reading the input files works, but that path is not properly handled with the implementation of the if/else statements:

if (argc == 3) {
output_file_name = argv[2];

} else {
// If output file is not provided, default is <path to .json>+"output.csv"
std::size_t end_of_path = input_file_name.rfind("/");

if (end_of_path == std::string::npos) {
  end_of_path = input_file_name.rfind("\\");  // For Windows paths (?)  **<-- will find input file**

  // If <path to .json> is still not found, use current directory
  if (end_of_path == std::string::npos) {
    output_file_path = ".";
  }
} else {
  output_file_path = input_file_name.substr(0, end_of_path); **<-- skips because if {} was evaluated (missing path)**
}

output_file_name = output_file_path + "/output.csv";
std::cout << "[svzerodsolver] Output will be written to '"
          << output_file_name << "'." << std::endl;
;

}

Reproduction

Any code that relies on svzerodsolver.cpp implementation (originally found from 0d simulations in svVascularize gui).

OS: Windows 11

Expected behavior

Adding one short else statement fixed this issue, allowing the output file to save properly on my machine:

if (end_of_path == std::string::npos) {
  end_of_path = input_file_name.rfind("\\");  

  // If <path to .json> is still not found, use current directory
  if (end_of_path == std::string::npos) {
    output_file_path = ".";
  }
  **else {
    output_file_path = input_file_name.substr(0, end_of_path); <-- new code
  }** 
} 
else {
  output_file_path = input_file_name.substr(0, end_of_path);
}
Additional context

No response

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.

Research direction

Start in svzerodsolver.cpp at the output-file path handling for the input JSON argument, and reproduce the behavior with a Windows-style path. Verify that an omitted output argument produces output.csv beside the input file, while a bare filename still uses the current directory. Confirm the result on Windows or with path-focused tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.