Skip to content

Commit

Permalink
Add some a check for a valid first line in temporal data files. (SimV…
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbolt authored Sep 6, 2024
1 parent 5b14e1c commit b2271ee
Showing 1 changed file with 15 additions and 5 deletions.
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

0 comments on commit b2271ee

Please sign in to comment.