diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 322be45f..3acd9424 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -3146,6 +3146,12 @@ def _check_stiffeners( raise DeckFormatError( f"{where}: STIFFENERS InnerD must be smaller than RootOD and TipOD" ) + # as wide as the widest line type at most (native, LINE TYPES Diam <= 1e3 m) + if max(root_od, tip_od) > _NATIVE_MAX_DIAMETER: + raise DeckFormatError( + f"{where}: STIFFENERS RootOD and TipOD must be at most 1e3 m, as a line " + "type's Diam" + ) extent[(line_id, end)] = extent.get((line_id, end), 0.0) + length for line_id in sorted({key[0] for key in extent}, key=int): if not any( diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index d3dde783..521b9d80 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -942,6 +942,8 @@ def test_attachment_arc_length_lies_on_the_line(arc, accepted): ("1 A 0.0 0.45 0.45 0.17 5.0e7 1150", "Length, RootOD, TipOD and E must be > 0"), ("1 A 0.4 0.45 0.45 -0.1 5.0e7 1150", "InnerD and Density must be >= 0"), ("1 A 0.4 0.45 0.15 0.17 5.0e7 1150", "InnerD must be smaller than RootOD and TipOD"), + ("1 A 0.4 1.0e6 0.45 0.17 5.0e7 1150", "RootOD and TipOD must be at most 1e3 m"), + ("1 A 0.4 0.45 1001.0 0.17 5.0e7 1150", "RootOD and TipOD must be at most 1e3 m"), ("1 B 167.0 0.45 0.45 0.17 5.0e7 1150", "are longer than the line"), ], ) @@ -2790,3 +2792,38 @@ def test_a_compression_refinement_leaves_where_it_was_stops_the_refinement(tmp_p -900: ] assert _accepted(deck) + + +@pytest.mark.parametrize( + ("od", "accepted"), [("1000.0", True), ("1000.001", False), ("1e6", False)] +) +def test_stiffener_diameter_bound_matches_the_driver(od, accepted, tmp_path): + # a sleeve as wide as the widest line type (Diam <= 1e3 m) at most + text = _example( + "lazy_wave_bend_stiffener.dat", + (_STIFFENER_ROOT, f"1 A 0.4 {od} 0.45 0.17 5.0e7 1150"), + ) + if accepted: + DeckFile.from_text(text) + else: + _rejects(text, "RootOD and TipOD must be at most 1e3 m") + if not _PARITY_DRIVER or not Path(_PARITY_DRIVER).is_file(): + return + deck = tmp_path / "stiffener.dat" + deck.write_text(_static_check(text), encoding="utf-8") + shutil.copytree(EXAMPLES / "data", tmp_path / "data") + completed = subprocess.run( + [_PARITY_DRIVER, str(deck), str(tmp_path / "stiffener")], + capture_output=True, + text=True, + errors="replace", + cwd=tmp_path, + timeout=600, + env={**os.environ, "OMP_NUM_THREADS": "1", "OPENBLAS_NUM_THREADS": "1"}, + check=False, + ) + if accepted: + assert completed.returncode != 1 or "at most 1e3 m" not in completed.stderr + else: + assert completed.returncode == 1, completed.stderr[-600:] + assert "RootOD and TipOD must be at most 1e3 m" in completed.stderr diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 10f30fed..f90ec706 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -11468,7 +11468,9 @@ SUBROUTINE CD_Stiffener_Overlay(stf, l0, diam, ei, mpl) IF (.NOT. (covered > CD_ZERO)) CYCLE IF (PRESENT(ei)) THEN IF (ei_line > CD_ZERO) THEN - compliance = compliance + (l0(e) - covered)/ei_line + ! the bare part: rows meeting inside the element can sum past its length by round-off, + ! which a soft cable's EI would turn into a negative compliance + compliance = compliance + MAX(CD_ZERO, l0(e) - covered)/ei_line ei(e) = l0(e)/compliance ELSE IF (covered >= l0(e)*(CD_ONE - 1.0e-12_wp)) THEN ! an EI = 0 element bends only where the sleeve covers all of it; a bare part has an @@ -16931,6 +16933,10 @@ SUBROUTINE append_line_stiffener(row, lines, ErrStat, ErrMsg) IF (.NOT. (vals(4) < MIN(vals(2), vals(3)))) THEN CALL fail(ErrStat, ErrMsg, 'STIFFENERS InnerD must be smaller than RootOD and TipOD'); RETURN END IF + ! as wide as the widest line type at most (LINE TYPES Diam <= 1e3 m) + IF (MAX(vals(2), vals(3)) > 1.0e3_wp) THEN + CALL fail(ErrStat, ErrMsg, 'STIFFENERS RootOD and TipOD must be at most 1e3 m, as a line type''s Diam'); RETURN + END IF ! a segment starts where the previous segment of the same line end stops s0 = CD_ZERO nold = 0 diff --git a/tests/test_bend_stiffener.f90 b/tests/test_bend_stiffener.f90 index c7a9b6b6..9a0fae19 100644 --- a/tests/test_bend_stiffener.f90 +++ b/tests/test_bend_stiffener.f90 @@ -36,6 +36,7 @@ PROGRAM test_bend_stiffener CALL case_cylinder() CALL case_cone() + CALL case_row_boundary_roundoff() CALL case_node_stiffness() CALL case_grammar() CALL case_coupled() @@ -143,6 +144,31 @@ SUBROUTINE case_cone() 'cone: bare elements unchanged') END SUBROUTINE case_cone + SUBROUTINE case_row_boundary_roundoff() + !! Two stiffener rows meeting inside an element (a 0.4 m cylinder, then a cone) cover it in two + !! parts whose sum can exceed the element length by round-off. Divided by a soft cable's + !! EI, that excess once made the compliance negative and the element EI negative. Swept + !! over the cable EI and the element length (the second length is that of the shipped + !! lazy-wave example, 68.114 m in 448 elements). + REAL(wp), PARAMETER :: EI_C(5) = [1.0e-300_wp, 1.0e-12_wp, 1.0e-3_wp, 1.0_wp, 2.0e4_wp] + REAL(wp), PARAMETER :: L_ELEM(3) = [0.15_wp, 68.114_wp/448.0_wp, 0.3_wp/7.0_wp] + REAL(wp), PARAMETER :: OD_ROOT(3) = [0.45_wp, 10.0_wp, 1.0e6_wp] + REAL(wp) :: stf(8, 2), l0(40), ei(40), mpl(40), dv(40) + INTEGER :: i, j, k + DO k = 1, SIZE(OD_ROOT) + stf(:, 1) = [1.0_wp, 0.0_wp, 0.4_wp, OD_ROOT(k), OD_ROOT(k), 0.17_wp, 5.0e7_wp, 1150.0_wp] + stf(:, 2) = [1.0_wp, 0.4_wp, 4.0_wp, OD_ROOT(k), 0.18_wp, 0.17_wp, 5.0e7_wp, 1150.0_wp] + DO j = 1, SIZE(L_ELEM) + DO i = 1, SIZE(EI_C) + l0 = L_ELEM(j); ei = EI_C(i); mpl = 36.7_wp; dv = 0.16_wp + CALL CD_Stiffener_Overlay(stf, l0, dv, ei=ei, mpl=mpl) + CALL require(ALL(ei >= EI_C(i)*(1.0_wp - 1.0e-12_wp)) .AND. ALL(ei < HUGE(ei)), & + 'row boundary: every element EI is at least the cable EI and finite') + END DO + END DO + END DO + END SUBROUTINE case_row_boundary_roundoff + SUBROUTINE case_node_stiffness() !! Ten 1 m elements, line type EI_C on the first six and 2 EI_C beyond, under a cylinder over !! 0-2 m (OD 0.6), a cone over 2-5 m (0.6 -> 0.3) and a cone over 5-7.5 m (0.25 -> 0.22),