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

[GeoMechanicsApplication] Fix issues in integration tests hindering a coverage report for them #13084

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def test_1d_consolidation(self):

# set stage parameters
parameters_stages = [None] * n_stages

initial_directory = os.getcwd()
os.chdir(file_path)
for idx, parameter_file_name in enumerate(parameter_file_names):
with open(parameter_file_name, 'r') as parameter_file:
Expand Down Expand Up @@ -104,5 +106,7 @@ def test_1d_consolidation(self):
for rmse_stage in rmse_stages:
self.assertLess(rmse_stage, accuracy)

os.chdir(initial_directory)

if __name__ == '__main__':
KratosUnittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ def test_triaxial_comp_6n(self):
stages = test_helper.get_separated_stages(directory_names)

effective_stresses_stages = [None] * n_stages
initial_directory = os.getcwd()

# run stages and get results
for idx, stage in enumerate(stages):
os.chdir(directory_names[idx])
stage.Run()
effective_stresses_stages[idx] = test_helper.get_cauchy_stress_tensor(stage)
os.chdir(initial_directory)

# Assert
stage_nr = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __test_saturated_below_phreatic_level_pw(self, test_name):

# set stage parameters
parameters_stages = []
initial_directory = os.getcwd()
os.chdir(file_path)
for parameter_file_name in parameter_file_names:
with open(parameter_file_name, 'r') as parameter_file:
Expand All @@ -38,6 +39,7 @@ def __test_saturated_below_phreatic_level_pw(self, test_name):
stage_water_pressure.append(test_helper.get_water_pressure(stage))
coords.append(test_helper.get_nodal_coordinates(stage))

os.chdir(initial_directory)
# get y coords of all the nodes
y_coords = [coord[1] for coord in coords[0]]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,28 @@ def critical_head_loop(self, file_path, kappa, d70, Hc, search_type='linear'):
[('7.10', 3.00E-04, 1.157E-12, 10.29, 11.3, 7.5, 'test_compare_sellmeijer/HeightAquiferD10L30.gid')])
def test_sellmeijers_rule_height(self, name, d70, kappa, h_c, h_n, length_n, test_name_gid):
file_path = test_helper.get_file_path(os.path.join('./', test_name_gid))
initial_directory = os.getcwd()
os.chdir(file_path)
critical_head_found, length = self.critical_head_loop(file_path, kappa, d70, h_n, 'linear')
self.results = {"value_name": name, "test_result_h": h_c, "kratos_results_h": critical_head_found,
"equivalent_software_h": h_n, "kratos_results_l": length, "equivalent_software_l": length_n}
self.assertAlmostEqual(h_n, critical_head_found, 1,
f"Critical head kratos: {critical_head_found}, old geo flow {h_n}")
os.chdir(initial_directory)

@parameterized.expand(
[('7.10', 3.00E-04, 1.157E-12, 10.29, 11.3, 7.5, 'test_compare_sellmeijer/HeightAquiferD10L30line')])
def test_sellmeijers_rule_height_line(self, name, d70, kappa, h_c, h_n, length_n, test_name_line):
file_path = test_helper.get_file_path(os.path.join('./', test_name_line))
initial_directory = os.getcwd()
os.chdir(file_path)
critical_head_found, length = self.critical_head_loop(file_path, kappa, d70, h_n, 'linear')
self.results = {"value_name": name, "test_result_h": h_c, "kratos_results_h": critical_head_found,
"equivalent_software_h": h_n, "kratos_results_l": length, "equivalent_software_l": length_n}
self.assertAlmostEqual(h_n, critical_head_found, 1,
f"Critical head kratos: {critical_head_found}, old geo flow {h_n}")
os.chdir(initial_directory)


if __name__ == '__main__':
KratosUnittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,14 @@ def critical_head_loop(self, file_path, kappa, d70, Hc, search_type='linear'):
('7.36', 3.00E-04, 1.157E-10, 4.61, 5.3, 27, 'test_compare_sellmeijer/HeightAquiferD30L90.gid')])
def test_sellmeijers_rule_height(self, name, d70, kappa, h_c, h_n, length_n, test_name_gid):
file_path = test_helper.get_file_path(os.path.join('./', test_name_gid))
initial_directory = os.getcwd()
os.chdir(file_path)
critical_head_found, length = self.critical_head_loop(file_path, kappa, d70, h_n, 'linear')
self.results = {"value_name": name, "test_result_h": h_c, "kratos_results_h": critical_head_found,
"equivalent_software_h": h_n, "kratos_results_l": length, "equivalent_software_l": length_n}
self.assertAlmostEqual(h_n, critical_head_found, 1,
f"Critical head kratos: {critical_head_found}, old geo flow {h_n}")
os.chdir(initial_directory)

@parameterized.expand(
[('7.1', 1.00E-04, 1.157E-12, 3.43, 3.7, 6, 'test_compare_sellmeijer/HeightAquiferD10L30line'),
Expand Down Expand Up @@ -194,9 +196,11 @@ def test_sellmeijers_rule_height(self, name, d70, kappa, h_c, h_n, length_n, tes
('7.36', 3.00E-04, 1.157E-10, 4.61, 5.3, 27, 'test_compare_sellmeijer/HeightAquiferD30L90line')])
def test_sellmeijers_rule_height_line(self, name, d70, kappa, h_c, h_n, length_n, test_name_line):
file_path = test_helper.get_file_path(os.path.join('./', test_name_line))
initial_directory = os.getcwd()
os.chdir(file_path)
critical_head_found, length = self.critical_head_loop(file_path, kappa, d70, h_n, 'linear')
self.results = {"value_name": name, "test_result_h": h_c, "kratos_results_h": critical_head_found,
"equivalent_software_h": h_n, "kratos_results_l": length, "equivalent_software_l": length_n}
self.assertAlmostEqual(h_n, critical_head_found, 1,
f"Critical head kratos: {critical_head_found}, old geo flow {h_n}")
os.chdir(initial_directory)
Loading