Skip to content

Commit

Permalink
Updated test_helper + test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mcgicjn2 committed Oct 18, 2023
1 parent cbf5b18 commit 7a445ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def run_and_assert_1d_column(self, file_path, node_nbrs, direction):

# find index of expected time of wave arrival in time list
res_keys = list(res.keys())
print("TEST", res.keys())
ini_time_idx = test_helper.find_closest_index_greater_than_value(res_keys, expected_ini_time)

# calculate velocity after wave arrival
Expand Down
48 changes: 15 additions & 33 deletions applications/GeoMechanicsApplication/tests/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,52 +172,34 @@ def get_nodal_variable_from_ascii(filename: str, variable: str):

# read data
with open(filename, "r") as f:
all_data = f.readlines()
all_lines = f.readlines()

add_var = False

data = []
time_steps = []
all_var_data = []
res = {}

# read all data at each time step of variable
for line in all_data:
for line in all_lines:

if "End Values" in line and add_var:
add_var = False
all_var_data.append(data)
data = []

if add_var:
data.append(line)
if line.startswith("Values"):
continue;
lineSplit = line.split()
lineSplit[0] = int(lineSplit[0])
for ind, strVal in enumerate(lineSplit[1:]):
lineSplit[ind+1] = float(strVal)
if (len(lineSplit[1:])==1):
res[time_step][lineSplit[0]] = lineSplit[1]
else:
res[time_step][lineSplit[0]] = lineSplit[1:]

if r'"' + variable + r'"' in line:
time_step = float(line.split()[3])

time_steps.append(time_step)
res[time_step] = {}
add_var=True

# initialise results dictionary
res = {"time": time_steps}

for var_data in all_var_data:
var_data.pop(0)

# convert var data to floats
for i, _ in enumerate(var_data):
line = var_data[i].split()
line[1] = float(line[1])
line[2] = float(line[2])
line[3] = float(line[3])
var_data[i] = line

# add node numbers as dict keys
for line in var_data:
res[line[0]] = []

for var_data in all_var_data:
for line in var_data:
res[line[0]].append(line[1:])

return res


Expand Down

0 comments on commit 7a445ac

Please sign in to comment.