Skip to content

Commit 78788ff

Browse files
Review comments
1 parent 8186f69 commit 78788ff

File tree

4 files changed

+31
-29
lines changed

4 files changed

+31
-29
lines changed

tests/test_cosserat_curve.py

-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ def test_cosserat_curve_mesh_warp(
206206
Rotation([0, 0, 1], -0.5 * np.pi) * Rotation([0, 1, 0], -0.5 * np.pi)
207207
),
208208
)
209-
print("###", type(mesh), mesh)
210209
assert_results_equal(get_corresponding_reference_file_path(), mesh, rtol=1e-10)
211210

212211

tests/test_four_c_simulation.py

+19-9
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ def test_four_c_simulation_beam_and_solid_tube(
361361
nodes = [32, 69]
362362
add_result_description(input_file, displacements, nodes)
363363

364+
# Call get_unique_geometry_sets to check that this does not affect the
365+
# mesh creation.
366+
mesh.get_unique_geometry_sets(link_to_nodes="all_nodes")
367+
364368
# Add mesh to input file
365369
input_file.add(mesh)
366370

@@ -574,6 +578,9 @@ def test_four_c_simulation_rotated_beam_axis(
574578
# Create input file
575579
input_file = InputFile()
576580

581+
# Create mesh
582+
mesh = Mesh()
583+
577584
# Set header
578585
set_header_static(input_file, time_step=0.05, n_steps=20)
579586

@@ -591,17 +598,17 @@ def test_four_c_simulation_rotated_beam_axis(
591598

592599
# Create mesh.
593600
for i in range(3):
594-
mesh = Mesh()
601+
mesh_line = Mesh()
595602

596603
# Create the first line.
597604
set_1 = create_beam_mesh_line(
598-
mesh, Beam3rHerm2Line3, mat, [0, 0, 0], 1.0 * direction, n_el=3
605+
mesh_line, Beam3rHerm2Line3, mat, [0, 0, 0], 1.0 * direction, n_el=3
599606
)
600607

601608
if not i == 0:
602609
# In the second case rotate the line, so the triads do not
603610
# match any more.
604-
mesh.rotate(Rotation(direction, alpha))
611+
mesh_line.rotate(Rotation(direction, alpha))
605612

606613
if i == 2:
607614
# The third line is with couplings.
@@ -611,7 +618,7 @@ def test_four_c_simulation_rotated_beam_axis(
611618

612619
# Add the second line.
613620
set_2 = create_beam_mesh_line(
614-
mesh,
621+
mesh_line,
615622
Beam3rHerm2Line3,
616623
mat,
617624
1.0 * direction,
@@ -621,7 +628,7 @@ def test_four_c_simulation_rotated_beam_axis(
621628
)
622629

623630
# Add boundary conditions.
624-
mesh.add(
631+
mesh_line.add(
625632
BoundaryCondition(
626633
set_1["start"],
627634
{
@@ -633,7 +640,7 @@ def test_four_c_simulation_rotated_beam_axis(
633640
bc_type=mpy.bc.dirichlet,
634641
)
635642
)
636-
mesh.add(
643+
mesh_line.add(
637644
BoundaryCondition(
638645
set_2["end"],
639646
{
@@ -648,19 +655,22 @@ def test_four_c_simulation_rotated_beam_axis(
648655

649656
if i == 2:
650657
# In the third case add a coupling.
651-
mesh.couple_nodes()
658+
mesh_line.couple_nodes()
652659

653660
# Add the mesh to the input file.
654-
input_file.add(mesh)
661+
mesh.add(mesh_line)
655662

656663
# Each time move the whole mesh.
657-
input_file.mesh.translate([1, 0, 0])
664+
mesh.translate([1, 0, 0])
658665

659666
# Add result checks.
660667
displacements = [[1.5015284845, 0.35139255451, -1.0126517891]] * 3
661668
nodes = [13, 26, 40]
662669
add_result_description(input_file, displacements, nodes)
663670

671+
# Add the mesh to the input file
672+
input_file.add(mesh)
673+
664674
# Check the created input file
665675
assert_results_equal(get_corresponding_reference_file_path(), input_file)
666676

tests/test_mesh_creation_functions.py

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
from meshpy.core.node import NodeCosserat
3535
from meshpy.core.rotation import Rotation
3636
from meshpy.four_c.element_beam import Beam3eb, Beam3rHerm2Line3
37-
from meshpy.four_c.input_file import InputFile
3837
from meshpy.four_c.material import MaterialEulerBernoulli, MaterialReissner
3938
from meshpy.mesh_creation_functions.beam_basic_geometry import (
4039
create_beam_mesh_arc_at_node,

tests/test_meshpy.py

+12-18
Original file line numberDiff line numberDiff line change
@@ -1173,14 +1173,10 @@ def test_meshpy_replace_nodes_geometry_set(
11731173
def create_beam_to_solid_conditions_model(get_corresponding_reference_file_path):
11741174
"""Create the input file for the beam-to-solid input conditions tests."""
11751175

1176-
# TODO rework this test once the input file is refactored, i.e.
1177-
# input_file, mesh = InputFile(yaml_file=...)
1178-
# ... add different geometry sets to the mesh
1179-
# input_file.add(mesh)
1180-
# this way it is tested exhaustively rather than accessing the mesh
1181-
# in the input file during the beam mesh creation
1182-
1183-
# Create input file.
1176+
# TODO update this function to take the "full_import" argument
1177+
# Then return the input file and corresponding mesh.
1178+
1179+
# Create input file
11841180
input_file = InputFile(
11851181
yaml_file=get_corresponding_reference_file_path(
11861182
reference_file_base_name="test_create_cubit_input_block"
@@ -1411,13 +1407,13 @@ def test_meshpy_stvenantkirchhoff_solid(
14111407

14121408
material_2 = MaterialStVenantKirchhoff(youngs_modulus=370, nu=0.20, density=5.2e-7)
14131409

1414-
# Create input file
1415-
input_file = InputFile()
1416-
input_file.add(material_1)
1417-
input_file.add(material_2)
1410+
# Create mesh
1411+
mesh = Mesh()
1412+
mesh.add(material_1)
1413+
mesh.add(material_2)
14181414

14191415
# Compare with the reference file
1420-
assert_results_equal(get_corresponding_reference_file_path(), input_file)
1416+
assert_results_equal(get_corresponding_reference_file_path(), mesh)
14211417

14221418

14231419
@pytest.mark.parametrize(
@@ -1811,8 +1807,7 @@ def create_mesh(mesh):
18111807
mesh_ref_2.translate(translate)
18121808

18131809
mesh = Mesh()
1814-
mesh.add(mesh_ref_1)
1815-
mesh.add(mesh_ref_2)
1810+
mesh.add(mesh_ref_1, mesh_ref_2)
18161811

18171812
# Now copy the first mesh and add them together in the input file.
18181813
mesh_copy_1 = Mesh()
@@ -1822,8 +1817,7 @@ def create_mesh(mesh):
18221817
mesh_copy_2.translate(translate)
18231818

18241819
mesh_copy = Mesh()
1825-
mesh_copy.add(mesh_copy_1)
1826-
mesh_copy.add(mesh_copy_2)
1820+
mesh_copy.add(mesh_copy_1, mesh_copy_2)
18271821

18281822
# Check that the input files are the same.
18291823
# TODO: add reference file check here as well
@@ -1854,7 +1848,7 @@ def test_meshpy_mesh_add_checks():
18541848
mesh.add(geometry_set)
18551849

18561850
# Add the objects again and check for errors.
1857-
# TODO catch and test errors
1851+
# TODO catch and test error messages
18581852
with pytest.raises(ValueError):
18591853
mesh.add(node)
18601854
with pytest.raises(ValueError):

0 commit comments

Comments
 (0)