diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index c9e957f1..ace78d84 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -4792,17 +4792,6 @@ def is_body_kind(kind: str, pinned: bool) -> bool: f"{self._label}: a mixed-topology deck (bodies, rods, dynamic points, EI=0 and " "finite-EI lines together) does not support motionFile coupling" ) - if deck_driver_route and not needs_multibody: - # native CD_Run_Deck_Driver: the standalone finite-EI march builds every line as a - # finite-EI cable, so a line's sections all need a finite EI - for line_id, section_types in section_types_by_line.items(): - finite_sections = [line_type_meta[name][3] > 0.0 for name in section_types] - if any(finite_sections) and not all(finite_sections): - raise DeckFormatError( - f"{self._label}: LINE {line_id} combines EI=0 and finite-EI sections, " - "which the standalone finite-EI march does not take: give every section " - "of the line a finite EI" - ) if deck_driver_route and needs_multibody and (has_dtm or has_tmax): self._check_multibody_cable_ends( finite_line_ids, diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index df4b1368..ff1a1c3b 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -2641,14 +2641,9 @@ def test_static_check_clock_gets_the_native_verdict(text, accepted, tmp_path): r"MassDenInAir must be > 0", ), ("finite-mass-small", _edit(_FINITE, (" 390.0 ", " 1e-3 ")), False, None), - # the standalone finite-EI march takes lines whose sections all have a finite EI - ("split-line", _SPLIT_LINE, False, r"LINE 1 combines EI=0 and finite-EI sections"), - ( - "split-line-static", - _static_check(_SPLIT_LINE, keep_dtm=True), - False, - r"LINE 1 combines EI=0 and finite-EI sections", - ), + # a line with EI = 0 and finite-EI sections is one finite-EI cable on every route + ("split-line", _SPLIT_LINE, False, None), + ("split-line-static", _static_check(_SPLIT_LINE, keep_dtm=True), False, None), ("split-line-host", _SPLIT_LINE, True, None), ("split-line-mixed-route", _SPLIT_LINE_AND_CHAIN, False, None), # Point

p channels are read from the EI=0 system: on the aggregate a Coupled point of diff --git a/python/tests/test_objects.py b/python/tests/test_objects.py index 6486fc45..25a82e4f 100644 --- a/python/tests/test_objects.py +++ b/python/tests/test_objects.py @@ -598,3 +598,88 @@ def test_c_api_takes_bodies_or_rods_not_both(tmp_path): still.write_text(base, encoding="utf-8") with CableDyn() as model: model.init_deck(still) + + +_SPLIT_LINE_DECK = """Split line: an EI = 0 chain section and a finite-EI section of one line +--- LINE TYPES --- +Name Diam Mass EA BA EI Cdn Cdt Can Cat +chain 0.252 390.0 1.674e9 -1.0 0.0 1.37 0.64 1.0 0.0 +stiff 0.252 390.0 1.674e9 -1.0 1.0e4 1.37 0.64 1.0 0.0 +--- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +1 Fixed 400.0 0.0 -50.0 0 0 0 0 +2 Coupled 0.0 0.0 0.0 0 0 0 0 +--- LINES --- +ID NodeA NodeB Outputs +1 2 1 - +--- SECTIONS --- +LineID LineType Length NumSegs +{sections}--- OPTIONS --- +9.80665 g +1025.0 rhoW +50.0 WtrDpth +0.1 dtM +1.0 TMax +{motion}--- OUTPUTS --- +FairTen1 +AnchTen1 +L1N10px +L1N10pz +Ten1N30 +L1N35pz +Curv1N35 +--- need this line --- +""" + + +def _surge(t: float) -> tuple[float, float, float]: + """A smooth 0.5 m surge of the fairlead from rest over the first second.""" + s = min(max(t, 0.0), 1.0) + return ( + 0.5 * (10 * s**3 - 15 * s**4 + 6 * s**5), + 0.5 * (30 * s**2 - 60 * s**3 + 30 * s**4), + 0.5 * (60 * s - 180 * s**2 + 120 * s**3), + ) + + +@needs_driver +@pytest.mark.parametrize( + "sections", + ["1 chain 200.0 20\n1 stiff 210.0 21\n", "1 stiff 210.0 21\n1 chain 200.0 20\n"], + ids=["chain-at-fairlead", "chain-at-anchor"], +) +def test_split_line_runs_standalone_as_on_the_c_api(tmp_path, sections): + # a line of EI = 0 and finite-EI sections is one finite-EI cable on every route + times = [round(0.1 * k, 10) for k in range(11)] + (tmp_path / "m.txt").write_text( + "".join( + f"{t:.10g} 2 {_surge(t)[0]!r} 0 0 {_surge(t)[1]!r} 0 0 {_surge(t)[2]!r} 0 0\n" + for t in times + ), + encoding="utf-8", + ) + deck = _write( + tmp_path, + "split.dat", + _SPLIT_LINE_DECK.format(sections=sections, motion="m.txt motionFile\n"), + ) + result = _driver_run(deck, tmp_path) + main = result.read_main() + channels = list(main.channels[1:]) + host = _write(tmp_path, "split_host.dat", _SPLIT_LINE_DECK.format(sections=sections, motion="")) + with CableDyn(host) as model: + (line,) = model.lines + assert line.finite_ei + q0, _, _ = model.get_coupled_motion() + for k, t in enumerate(times): + if k: + x, v, a = _surge(t) + model.step( + 0.1, + q0 + np.array([x, 0.0, 0.0]), + np.array([v, 0.0, 0.0]), + np.array([a, 0.0, 0.0]), + ) + row = int(np.argmin(np.abs(main.values[:, 0] - t))) + assert abs(main.values[row, 0] - t) < 1.0e-9 + _assert_close(model.channels(channels), main.values[row, 1:], f"channels at t={t}") diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 6aa49a46..5349dcb4 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -9758,23 +9758,13 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) RETURN END IF IF (has_finite) THEN - ! The standalone finite-EI march owns one homogeneous family of bending - ! lines. Mixed EI=0/EI>0 composition belongs to the aggregate route; keep - ! this guard ahead of the Hermite dispatch so an EI=0 line can never be - ! coerced through the all-lines Hermite builder. - IF (.NOT. all_lines_have_finite_ei(types, lines, sections)) THEN + ! The standalone finite-EI march owns the finite-EI lines: a line with any finite-EI + ! section, built as one cable whose EI = 0 sections carry no bending, as on the coupled + ! aggregate. A deck of separate EI=0 and finite-EI lines belongs to the aggregate route + ! (the standalone executable sends it there); keep this guard ahead of the Hermite + ! dispatch so a line without a finite-EI section is never coerced through the builder. + IF (.NOT. ALL([(line_is_finite_ei(lines(li), types, sections), li=1, SIZE(lines))])) THEN IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) - ! name the line that has both kinds of section (the standalone executable sends a deck - ! of separate EI=0 and finite-EI lines to the aggregate, never here) - DO li = 1, SIZE(lines) - IF (line_is_finite_ei(lines(li), types, sections) .AND. & - .NOT. all_lines_have_finite_ei(types, lines(li:li), sections)) THEN - CALL fail(ErrStat, ErrMsg, 'LINE '//TRIM(int_to_str(lines(li)%id))//' combines EI=0 and '// & - 'finite-EI sections, which the standalone finite-EI march does not take: give every '// & - 'section of the line a finite EI') - RETURN - END IF - END DO CALL fail(ErrStat, ErrMsg, 'mixed EI=0 and finite-EI dynamic decks are not supported by this entry point') RETURN END IF @@ -39763,9 +39753,9 @@ END FUNCTION deck_has_torsion_columns LOGICAL FUNCTION line_is_finite_ei(ln, types, sections) RESULT(is_finite) !! A LINE is a finite-EI (bending) cable iff ANY of its sections has EI > 0. - !! Factored from all_lines_have_finite_ei's per-line finite test so the OpenFAST - !! aggregate (CD_Init_Deck_Aggregate) can partition a mixed deck into its - !! {EI=0 mooring} and {finite-EI cable} subsets from one shared predicate. + !! The one predicate every route partitions a deck by: the coupled aggregate and the + !! multibody march into their {EI=0 mooring} and {finite-EI cable} subsets, the standalone + !! finite-EI march into the cables it builds. TYPE(DeckLine), INTENT(IN) :: ln TYPE(DeckLineType), INTENT(IN) :: types(:) TYPE(DeckSection), INTENT(IN) :: sections(:) @@ -39782,28 +39772,6 @@ LOGICAL FUNCTION line_is_finite_ei(ln, types, sections) RESULT(is_finite) END DO END FUNCTION line_is_finite_ei - LOGICAL FUNCTION all_lines_have_finite_ei(types, lines, sections) RESULT(all_finite) - !! Every line is fully finite-EI: each line has at least one finite-EI section - !! (line_is_finite_ei) AND no line carries an EI=0 section. Used to reject a deck - !! that mixes EI=0 and finite-EI sections on the standalone finite-EI dynamic path. - TYPE(DeckLineType), INTENT(IN) :: types(:) - TYPE(DeckLine), INTENT(IN) :: lines(:) - TYPE(DeckSection), INTENT(IN) :: sections(:) - INTEGER :: i, j - all_finite = .TRUE. - DO i = 1, SIZE(lines) - DO j = 1, SIZE(sections) - IF (sections(j)%line_id /= lines(i)%id) CYCLE - IF (sections(j)%ltype < 1 .OR. sections(j)%ltype > SIZE(types)) THEN - all_finite = .FALSE. - CYCLE - END IF - IF (.NOT. (types(sections(j)%ltype)%ei > CD_ZERO)) all_finite = .FALSE. - END DO - all_finite = all_finite .AND. line_is_finite_ei(lines(i), types, sections) - END DO - END FUNCTION all_lines_have_finite_ei - INTEGER FUNCTION point_index(points, id) RESULT(idx) TYPE(DeckPoint), INTENT(IN) :: points(:) INTEGER, INTENT(IN) :: id diff --git a/tests/test_deck_driver.f90 b/tests/test_deck_driver.f90 index 78f0d38a..d22041f9 100644 --- a/tests/test_deck_driver.f90 +++ b/tests/test_deck_driver.f90 @@ -2167,8 +2167,7 @@ SUBROUTINE check_parser_hardening() IF (es_l == CD_DECKDRV_OK) CALL CD_End_Deck_Aggregate(cagg) END BLOCK - ! A finite-EI line needs mass, and the standalone finite-EI march a line whose sections all - ! have a finite EI: both are named input errors, not a failure inside the model build. + ! A finite-EI line needs mass: a named input error, not a failure inside the model build. BLOCK CHARACTER(*), PARAMETER :: CHAIN_ROW = 'chain 0.252 390.0 1.674e9 -1.0 0.0 1.37 0.64 1.0 0.0' CHARACTER(*), PARAMETER :: STIFF_ROW = 'stiff 0.252 390.0 1.674e9 -1.0 1.0e4 1.37 0.64 1.0 0.0' @@ -2192,9 +2191,12 @@ SUBROUTINE check_parser_hardening() k = INDEX(body, CHAIN_ROW) CALL require(k > 0, 'split-line fixture locates the LINE TYPES row') IF (k > 0) THEN + ! a line of EI=0 and finite-EI sections is one finite-EI cable, as on the coupled aggregate body = body(1:k - 1)//CHAIN_ROW//nl//STIFF_ROW//body(k + LEN(CHAIN_ROW):) - CALL expect_badinput('deck_hard_split_line.dat', body, 'a line of EI=0 and finite-EI sections', & - 'LINE 1 combines EI=0 and finite-EI sections') + CALL write_text_file('deck_hard_split_line.dat', body) + CALL CD_Run_Deck_Driver('deck_hard_split_line.dat', 'deck_hard_split_line', conv_l, es_l, em_l) + CALL require(es_l == CD_DECKDRV_OK .AND. conv_l, 'a line of EI=0 and finite-EI sections runs: '// & + TRIM(em_l)) END IF END BLOCK END SUBROUTINE check_parser_hardening