Skip to content

Commit

Permalink
Processed Richard's review comments
Browse files Browse the repository at this point in the history
- Reuse attributes `normal_stiffness` and `shear_stiffness` in the single-stage tests.
- Extracted a method that asserts the results of a multi-stage test.
- Simplified the linear solver settings.
- Made the analysis flags more consistent with those of the single stage tests.
  • Loading branch information
avdg81 committed Oct 1, 2024
1 parent ed54c04 commit a9a2944
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"buffer_size": 2,
"echo_level": 1,
"clear_storage": false,
"compute_reactions": true,
"compute_reactions": false,
"move_mesh_flag": false,
"reform_dofs_at_each_step": true,
"reform_dofs_at_each_step": false,
"nodal_smoothing": false,
"block_builder": true,
"block_builder": false,
"solution_type": "Quasi-Static",
"scheme_type": "Newmark",
"reset_displacements": false,
Expand All @@ -38,7 +38,7 @@
"rayleigh_m": 0.0,
"rayleigh_k": 0.0,
"strategy_type": "newton_raphson",
"convergence_criterion": "displacement_criterion",
"convergence_criterion": "residual_criterion",
"displacement_relative_tolerance": 1.0E-4,
"displacement_absolute_tolerance": 1.0E-4,
"residual_relative_tolerance": 1.0E-4,
Expand All @@ -51,7 +51,7 @@
"desired_iterations": 4,
"max_radius_factor": 10.0,
"min_radius_factor": 0.1,
"calculate_reactions": true,
"calculate_reactions": false,
"max_line_search_iterations": 5,
"first_alpha_value": 0.5,
"second_alpha_value": 1.0,
Expand All @@ -60,14 +60,7 @@
"line_search_tolerance": 0.5,
"rotation_dofs": false,
"linear_solver_settings": {
"solver_type": "amgcl",
"smoother_type": "ilu0",
"krylov_type": "gmres",
"coarsening_type": "aggregation",
"max_iteration": 100,
"verbosity": 0,
"tolerance": 1.0e-6,
"scaling": false
"solver_type": "LinearSolversApplication.sparse_lu"
},
"problem_domain_sub_model_part_list": ["Interfaces"],
"processes_sub_model_part_list": ["FixedNodes","AllNodes","DisplacedNodes"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
"buffer_size": 2,
"echo_level": 1,
"clear_storage": false,
"compute_reactions": true,
"compute_reactions": false,
"move_mesh_flag": false,
"reform_dofs_at_each_step": true,
"reform_dofs_at_each_step": false,
"nodal_smoothing": false,
"block_builder": true,
"block_builder": false,
"solution_type": "Quasi-Static",
"scheme_type": "Newmark",
"reset_displacements": false,
Expand All @@ -37,7 +37,7 @@
"rayleigh_m": 0.0,
"rayleigh_k": 0.0,
"strategy_type": "newton_raphson",
"convergence_criterion": "displacement_criterion",
"convergence_criterion": "residual_criterion",
"displacement_relative_tolerance": 1.0E-4,
"displacement_absolute_tolerance": 1.0E-4,
"residual_relative_tolerance": 1.0E-4,
Expand All @@ -50,7 +50,7 @@
"desired_iterations": 4,
"max_radius_factor": 10.0,
"min_radius_factor": 0.1,
"calculate_reactions": true,
"calculate_reactions": false,
"max_line_search_iterations": 5,
"first_alpha_value": 0.5,
"second_alpha_value": 1.0,
Expand All @@ -59,14 +59,7 @@
"line_search_tolerance": 0.5,
"rotation_dofs": false,
"linear_solver_settings": {
"solver_type": "amgcl",
"smoother_type": "ilu0",
"krylov_type": "gmres",
"coarsening_type": "aggregation",
"max_iteration": 100,
"verbosity": 0,
"tolerance": 1.0e-6,
"scaling": false
"solver_type": "LinearSolversApplication.sparse_lu"
},
"problem_domain_sub_model_part_list": ["Interfaces"],
"processes_sub_model_part_list": ["FixedNodes","AllNodes","DisplacedNodes"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"buffer_size": 2,
"echo_level": 1,
"clear_storage": false,
"compute_reactions": true,
"compute_reactions": false,
"move_mesh_flag": false,
"reform_dofs_at_each_step": true,
"reform_dofs_at_each_step": false,
"nodal_smoothing": false,
"block_builder": true,
"block_builder": false,
"solution_type": "Quasi-Static",
"scheme_type": "Newmark",
"reset_displacements": false,
Expand All @@ -38,7 +38,7 @@
"rayleigh_m": 0.0,
"rayleigh_k": 0.0,
"strategy_type": "newton_raphson",
"convergence_criterion": "displacement_criterion",
"convergence_criterion": "residual_criterion",
"displacement_relative_tolerance": 1.0E-4,
"displacement_absolute_tolerance": 1.0E-4,
"residual_relative_tolerance": 1.0E-4,
Expand All @@ -51,7 +51,7 @@
"desired_iterations": 4,
"max_radius_factor": 10.0,
"min_radius_factor": 0.1,
"calculate_reactions": true,
"calculate_reactions": false,
"max_line_search_iterations": 5,
"first_alpha_value": 0.5,
"second_alpha_value": 1.0,
Expand All @@ -60,14 +60,7 @@
"line_search_tolerance": 0.5,
"rotation_dofs": false,
"linear_solver_settings": {
"solver_type": "amgcl",
"smoother_type": "ilu0",
"krylov_type": "gmres",
"coarsening_type": "aggregation",
"max_iteration": 100,
"verbosity": 0,
"tolerance": 1.0e-6,
"scaling": false
"solver_type": "LinearSolversApplication.sparse_lu"
},
"problem_domain_sub_model_part_list": ["Interfaces"],
"processes_sub_model_part_list": ["FixedNodes","AllNodes","LoadedSide"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
"buffer_size": 2,
"echo_level": 1,
"clear_storage": false,
"compute_reactions": true,
"compute_reactions": false,
"move_mesh_flag": false,
"reform_dofs_at_each_step": true,
"reform_dofs_at_each_step": false,
"nodal_smoothing": false,
"block_builder": true,
"block_builder": false,
"solution_type": "Quasi-Static",
"scheme_type": "Newmark",
"reset_displacements": false,
Expand All @@ -37,7 +37,7 @@
"rayleigh_m": 0.0,
"rayleigh_k": 0.0,
"strategy_type": "newton_raphson",
"convergence_criterion": "displacement_criterion",
"convergence_criterion": "residual_criterion",
"displacement_relative_tolerance": 1.0E-4,
"displacement_absolute_tolerance": 1.0E-4,
"residual_relative_tolerance": 1.0E-4,
Expand All @@ -50,7 +50,7 @@
"desired_iterations": 4,
"max_radius_factor": 10.0,
"min_radius_factor": 0.1,
"calculate_reactions": true,
"calculate_reactions": false,
"max_line_search_iterations": 5,
"first_alpha_value": 0.5,
"second_alpha_value": 1.0,
Expand All @@ -59,14 +59,7 @@
"line_search_tolerance": 0.5,
"rotation_dofs": false,
"linear_solver_settings": {
"solver_type": "amgcl",
"smoother_type": "ilu0",
"krylov_type": "gmres",
"coarsening_type": "aggregation",
"max_iteration": 100,
"verbosity": 0,
"tolerance": 1.0e-6,
"scaling": false
"solver_type": "LinearSolversApplication.sparse_lu"
},
"problem_domain_sub_model_part_list": ["Interfaces"],
"processes_sub_model_part_list": ["FixedNodes","AllNodes","LoadedSide"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ def assert_outputs_for_3_plus_3_line_interface_element(self, simulation):

# Check the horizontal element
shear_traction = 667.0
shear_stiffness = 1.5e7
expected_horizontal_displacement = -shear_traction / shear_stiffness
expected_horizontal_displacement = -shear_traction / self.shear_stiffness
normal_traction = 333.0
normal_stiffness = 3.0e7
expected_vertical_displacement = -normal_traction / normal_stiffness
expected_vertical_displacement = -normal_traction / self.normal_stiffness
top_node_indices = [3, 4, 5] # These correspond to nodes 11, 12, 13
for index in top_node_indices:
self.assertAlmostEqual(displacements[index][0], expected_horizontal_displacement)
Expand All @@ -65,8 +63,8 @@ def assert_outputs_for_3_plus_3_line_interface_element(self, simulation):

# Check the vertical element
left_node_indices = [6, 7, 8] # These correspond to nodes 21, 22, 23
expected_horizontal_displacement = normal_traction / normal_stiffness
expected_vertical_displacement = -shear_traction / shear_stiffness
expected_horizontal_displacement = normal_traction / self.normal_stiffness
expected_vertical_displacement = -shear_traction / self.shear_stiffness
for index in left_node_indices:
self.assertAlmostEqual(displacements[index][0], expected_horizontal_displacement)
self.assertAlmostEqual(displacements[index][1], expected_vertical_displacement)
Expand All @@ -87,6 +85,23 @@ def assertVectorsAlmostEqual(self, actual_vectors, expected_vectors):
self.assertVectorAlmostEqual(actual_vector, expected_vector)


def assert_results_of_multi_stage_test(self, stage, displacement_vector):
expected_displacement_vectors = [[0.0, 0.0, 0.0]] * 3 # the first three nodes have been fixed
expected_displacement_vectors += [displacement_vector] * 3 # the last three nodes have prescribed non-zero displacements
self.assertVectorsAlmostEqual(test_helper.get_displacement(stage), expected_displacement_vectors)

expected_normal_relative_displacement = displacement_vector[1]
expected_tangential_relative_displacement = displacement_vector[0]
expected_relative_displacement_vectors = [[expected_normal_relative_displacement, expected_tangential_relative_displacement]] * 3
self.assertVectorsAlmostEqual(test_helper.get_on_integration_points(stage, Kratos.STRAIN)[0],
expected_relative_displacement_vectors)

expected_traction_vectors = [[self.normal_stiffness * expected_normal_relative_displacement,
self.shear_stiffness * expected_tangential_relative_displacement]] * 3
self.assertVectorsAlmostEqual(test_helper.get_on_integration_points(stage, Kratos.CAUCHY_STRESS_VECTOR)[0],
expected_traction_vectors)


def test_multi_stage_3_plus_3_line_interface_element_with_dirichlet_conditions(self):
file_path = test_helper.get_file_path(os.path.join('line_interface_elements', 'Dirichlet_multi_stage'))

Expand All @@ -97,23 +112,9 @@ def test_multi_stage_3_plus_3_line_interface_element_with_dirichlet_conditions(s
prescribed_displacement_vectors = [[-8.8933333333333332e-5, -2.22e-5, 0.0], [-2.0e-4, -4.44e-5, 0.0]]
for file_name, displacement_vector in zip(project_parameters_file_names, prescribed_displacement_vectors):
stage = test_helper.make_geomechanics_analysis(self.model, os.path.join(file_path, file_name))

stage.Run()

expected_displacement_vectors = [[0.0, 0.0, 0.0]] * 3 # the first three nodes have been fixed
expected_displacement_vectors += [displacement_vector] * 3 # the last three nodes have prescribed non-zero displacements
self.assertVectorsAlmostEqual(test_helper.get_displacement(stage), expected_displacement_vectors)

expected_normal_relative_displacement = displacement_vector[1]
expected_tangential_relative_displacement = displacement_vector[0]
expected_relative_displacement_vectors = [[expected_normal_relative_displacement, expected_tangential_relative_displacement]] * 3
self.assertVectorsAlmostEqual(test_helper.get_on_integration_points(stage, Kratos.STRAIN)[0],
expected_relative_displacement_vectors)

expected_traction_vectors = [[self.normal_stiffness * expected_normal_relative_displacement,
self.shear_stiffness * expected_tangential_relative_displacement]] * 3
self.assertVectorsAlmostEqual(test_helper.get_on_integration_points(stage, Kratos.CAUCHY_STRESS_VECTOR)[0],
expected_traction_vectors)
self.assert_results_of_multi_stage_test(stage, displacement_vector)

os.chdir(initial_cwd)

Expand All @@ -128,23 +129,9 @@ def test_multi_stage_3_plus_3_line_interface_element_with_neumann_conditions(sel
expected_displacement_vectors_of_loaded_side = [[-8.8933333333333332e-5, -2.22e-5, 0.0], [-2.0e-4, -4.44e-5, 0.0]]
for file_name, displacement_vector in zip(project_parameters_file_names, expected_displacement_vectors_of_loaded_side):
stage = test_helper.make_geomechanics_analysis(self.model, os.path.join(file_path, file_name))

stage.Run()

expected_displacement_vectors = [[0.0, 0.0, 0.0]] * 3 # the first three nodes have been fixed
expected_displacement_vectors += [displacement_vector] * 3 # the last three nodes have been displaced
self.assertVectorsAlmostEqual(test_helper.get_displacement(stage), expected_displacement_vectors)

expected_normal_relative_displacement = displacement_vector[1]
expected_tangential_relative_displacement = displacement_vector[0]
expected_relative_displacement_vectors = [[expected_normal_relative_displacement, expected_tangential_relative_displacement]] * 3
self.assertVectorsAlmostEqual(test_helper.get_on_integration_points(stage, Kratos.STRAIN)[0],
expected_relative_displacement_vectors)

expected_traction_vectors = [[self.normal_stiffness * expected_normal_relative_displacement,
self.shear_stiffness * expected_tangential_relative_displacement]] * 3
self.assertVectorsAlmostEqual(test_helper.get_on_integration_points(stage, Kratos.CAUCHY_STRESS_VECTOR)[0],
expected_traction_vectors)
self.assert_results_of_multi_stage_test(stage, displacement_vector)

os.chdir(initial_cwd)

Expand Down

0 comments on commit a9a2944

Please sign in to comment.