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

Add a check for a valid first line in temporal data files. #258

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions Code/Source/svFSI/read_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1546,9 +1546,8 @@ void read_fiber_temporal_values_file(FiberReinforcementStressParameters& fiber_p

int i, j;
temporal_values_file >> i >> j;

if (i < 2) {
throw std::runtime_error("The fiber reinforcement stress the values file '" + file_name + "' has an incorrect format.");
if ((i == 0) || (j == 0) || (i < 2)) {
throw std::runtime_error("Error reading the first line of the fiber reinforcement stress the values file '" + file_name + "' has an incorrect format.");
}

lDmn.stM.Tf.gt.d = 1;
Expand Down Expand Up @@ -2362,6 +2361,9 @@ void read_temp_spat_values(const ComMod& com_mod, const mshType& msh, const face

int ndof, num_ts, num_nodes;
file_stream >> ndof >> num_ts >> num_nodes;
if ((ndof == 0) || (num_ts == 0) || (num_nodes == 0)) {
throw std::runtime_error("Error reading the first line of the temporal and spatial values file '" + file_name + "'.");
}

if (num_nodes != lFa.nNo) {
throw std::runtime_error("The number of nodes (" + std::to_string(num_nodes) + ") in the temporal and spatial values file '" +
Expand Down Expand Up @@ -2474,6 +2476,9 @@ void read_temp_spat_values(const ComMod& com_mod, const mshType& msh, const std:
//
int ndof, num_ts, num_nodes;
file_stream >> ndof >> num_ts >> num_nodes;
if ((ndof == 0) || (num_ts == 0) || (num_nodes == 0)) {
throw std::runtime_error("Error reading the first line of the temporal and spatial values file '" + file_name + "'.");
}
#ifdef debug_read_ts_values_bf
dmsg << "ndof: " << ndof;
dmsg << "num_ts: " << num_ts;
Expand Down Expand Up @@ -2581,8 +2586,8 @@ void read_temporal_values(const std::string& file_name, bcType& lBc)

int i, j;
temporal_values_file >> i >> j;
if (i < 2) {
throw std::runtime_error("The temporal values file '" + file_name + "' has an incorrect format.");
if ((i == 0) || (j == 0) || (i < 2)) {
throw std::runtime_error("Error reading the first line of the temporal values file '" + file_name + "'.");
}
lBc.gt.n = j;

Expand All @@ -2606,6 +2611,11 @@ void read_temporal_values(const std::string& file_name, bcType& lBc)
}
values.push_back(value);
}

if (values.size() != 2) {
throw std::runtime_error("Error reading values for the temporal values file '" + file_name + "' for line '" + line + "'.");
}

temporal_values.push_back(values);
}

Expand Down
Loading