diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 0b77789a..c9e957f1 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -4792,6 +4792,17 @@ 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, @@ -4928,6 +4939,13 @@ def is_body_kind(kind: str, pinned: bool) -> bool: raise DeckFormatError( f"{self._label}: used LINE TYPE {line_type!r} requires Diam > 0" ) + # native finalize_checks: a finite-EI line carries its mass in the bending dynamics + # and its weight in the statics + if ei > 0.0 and mass <= 0.0: + raise DeckFormatError( + f"{self._label}: used LINE TYPE {line_type!r}: MassDenInAir must be > 0 on a " + "finite-EI line" + ) damping, coefficient = line_type_scales[line_type] if ( 0.0 < ea_static < _NATIVE_MIN_EA @@ -5100,6 +5118,27 @@ def is_body_kind(kind: str, pinned: bool) -> bool: # Native check_channel: ids are digit strings compared by value, so leading zeros # are accepted (FairTen01 is FairTen1). stiffened_lines = {str(_native_int(row.tokens[0])) for row in self._rows("STIFFENERS")} + # Point

p channels are read from the EI=0 system's point store. The aggregate + # (a host route, or the standalone mixed deck) has no live entry for a Coupled/Vessel + # point that only finite-EI lines reach (native validate_aggregate_point_channels); + # the standalone multibody march has no system without an EI=0 line. + finite_line_set = set(finite_line_ids) + cable_points = { + end + for line_id, ends in normalized_line_endpoints.items() + if line_id in finite_line_set + for end in ends + } + chain_points = { + end + for line_id, ends in normalized_line_endpoints.items() + if line_id not in finite_line_set + for end in ends + } + aggregate_points = self.caller_driven or mixed_route + multibody_without_system = ( + deck_driver_route and needs_multibody and line_ids and all(finite_lines) + ) for channel in channels: lowered = channel.lower() endpoint_channel = re.fullmatch( @@ -5108,9 +5147,9 @@ def is_body_kind(kind: str, pinned: bool) -> bool: lowered, ) # Con

p{x,y,z} is the native alias of Point

p{x,y,z} (MoorDyn v1 spelling). - point_channel = re.fullmatch(r"(?:point|con)([0-9]+)p([xyz])", lowered) + position_channel = re.fullmatch(r"(?:point|con)([0-9]+)p([xyz])", lowered) # Point

F{x,y,z,H}: resultant of the line-end forces on the point. - point_channel = point_channel or re.fullmatch(r"point([0-9]+)f([xyzh])", lowered) + point_channel = position_channel or re.fullmatch(r"point([0-9]+)f([xyzh])", lowered) # MoorDyn-F body/rod channels (native parse_object_channel, OBJ_QTY) body_channel = re.fullmatch(r"body([0-9]+)(?:p|r|v|rv|a|ra|f|m)[xyz]", lowered) rod_channel = re.fullmatch( @@ -5179,6 +5218,23 @@ def is_body_kind(kind: str, pinned: bool) -> bool: raise DeckFormatError( f"{self._label}: OUTPUT {channel!r} references an unknown point" ) + position = position_channel is not None + if ( + position + and aggregate_points + and point_id in cable_points + and point_id not in chain_points + and point_types.get(point_id) in {"coupled", "vessel"} + ): + raise DeckFormatError( + f"{self._label}: aggregate OUTPUT {channel!r} targets a cable-only point; " + "use the finite-EI cable line-node position channel instead" + ) + if position and multibody_without_system: + raise DeckFormatError( + f"{self._label}: OUTPUT {channel!r}: Point channels need an EI=0 mooring " + "system (a cable-endpoint Point channel is not supported)" + ) continue # TDP{s,x,y,z,Lay,Exc,Grd}: the touchdown point of line L (native # CD_Parse_TDP_Channel) @@ -5188,6 +5244,14 @@ def is_body_kind(kind: str, pinned: bool) -> bool: raise DeckFormatError( f"{self._label}: OUTPUT {channel!r} references an unknown line" ) + # native CD_Range_Setup: the touchdown point lies on a seabed, which a standalone + # deck states itself (a host gives its own water depth) + if not self.caller_driven and not (has_depth or has_bathymetry): + raise DeckFormatError( + f"{self._label}: TDP channels of line " + f"{_channel_id(touchdown_channel.group(1))} need a seabed (WtrDpth or a " + "bathymetry file)" + ) continue if lowered.startswith(("torq", "twist")): # native: TorqN, TwistN and Twist on a torsional line diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index f968114a..df4b1368 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -2573,3 +2573,143 @@ def test_static_check_clock_gets_the_native_verdict(text, accepted, tmp_path): ) assert python_accepts == accepted assert (completed.returncode == 0) == accepted, completed.stdout + completed.stderr + + +# --------------------------------------------------------------- deck rules of the native routes + +_STIFF = "stiff 0.252 390.0 1.674e9 -1.0 1.0e4 1.37 0.64 1.0 0.0\n" +_CHAIN_TYPE = "chain 0.252 390.0 1.674e9 -1.0 0.0 1.37 0.64 1.0 0.0\n" +# _HELD with a second (finite-EI) line type and its line 1 split between both types +_SPLIT_LINE = _edit( + _HELD, + (_CHAIN_TYPE, _CHAIN_TYPE + _STIFF), + ("1 chain 410.0 41\n", "1 chain 200.0 20\n1 stiff 210.0 21\n"), +) +# ... and a second, EI=0 line beside it (the standalone mixed route) +_SPLIT_LINE_AND_CHAIN = _edit( + _SPLIT_LINE, + ( + "2 Coupled 0.0 0.0 0.0 0 0 0 0\n", + "2 Coupled 0.0 0.0 0.0 0 0 0 0\n3 Fixed -400.0 0.0 -50.0 0 0 0 0\n", + ), + ("1 2 1 -\n", "1 2 1 -\n2 2 3 -\n"), + ("1 stiff 210.0 21\n", "1 stiff 210.0 21\n2 chain 410.0 41\n"), +) +# a finite-EI line on its own +_FINITE = _edit(_HELD, (_CHAIN_TYPE, _CHAIN_TYPE.replace(" 0.0 1.37", " 1.0e4 1.37"))) +# a finite-EI line from Coupled point 2 beside an EI=0 line from Coupled point 4 (the mixed route) +_FINITE_AND_CHAIN = _edit( + _HELD, + (_CHAIN_TYPE, _CHAIN_TYPE + _STIFF), + ( + "2 Coupled 0.0 0.0 0.0 0 0 0 0\n", + "2 Coupled 0.0 0.0 0.0 0 0 0 0\n" + "3 Fixed -400.0 0.0 -50.0 0 0 0 0\n4 Coupled -10.0 0.0 0.0 0 0 0 0\n", + ), + ("1 2 1 -\n", "1 2 1 -\n2 4 3 -\n"), + ("1 chain 410.0 41\n", "1 stiff 410.0 41\n2 chain 410.0 41\n"), +) +# the submerged Rigid6 buoy of the examples with finite-EI legs (the standalone multibody march) +_BUOY_FINITE_LEGS = _example( + "rigid6_buoy.dat", + ("5.0e7 -1.0 0.0 ", "5.0e7 -1.0 1.0e3 "), + ("60.0 TMax", "0.04 TMax"), +) +_BUOY_FORCES = _edit( + _BUOY_FINITE_LEGS, + ('"Point1px"\n"Point1pz"\n"Point2pz"\n"Point3pz"\n', '"Point1Fx"\n"Point2Fz"\n'), +) + + +_NO_SEABED_TDP = _edit(_STATIC, ("50.0 WtrDpth\n", ""), ("FairTen1\n", "FairTen1\nTDP1s\n")) +_FINITE_POINT_POSITIONS = _edit(_FINITE, ("FairTen1\n", "FairTen1\nPoint2px\nPoint1pz\nPoint2Fz\n")) +_MIXED_CABLE_POINT = _edit(_FINITE_AND_CHAIN, ("FairTen1\n", "FairTen1\nPoint2px\n")) +_MIXED_CHAIN_POINT = _edit(_FINITE_AND_CHAIN, ("FairTen1\n", "FairTen1\nPoint4px\nPoint2Fz\n")) +# (name, deck, caller_driven, message): None accepts +_ROUTE_RULE_CASES = [ + # TDP channels need a seabed on the standalone routes (a host gives the depth) + ("tdp-no-seabed", _NO_SEABED_TDP, False, r"TDP channels of line 1 need a seabed"), + ("tdp-no-seabed-host", _NO_SEABED_TDP, True, None), + ("tdp-seabed", _edit(_STATIC, ("FairTen1\n", "FairTen1\nTDP1s\n")), False, None), + # a finite-EI line needs mass, on every route + ("finite-mass-0", _edit(_FINITE, (" 390.0 ", " 0 ")), False, r"MassDenInAir must be > 0"), + ("finite-mass-neg", _edit(_FINITE, (" 390.0 ", " -1 ")), False, r"MassDenInAir must be > 0"), + ( + "finite-mass-neg-host", + _edit(_FINITE, (" 390.0 ", " -1 ")), + True, + 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", + ), + ("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 + # finite-EI lines alone has no live entry there, and a multibody march with no EI=0 line + # has no system at all + ("finite-point-channels", _FINITE_POINT_POSITIONS, False, None), + ( + "finite-cable-point-host", + _edit(_FINITE, ("FairTen1\n", "FairTen1\nPoint2px\n")), + True, + r"targets a cable-only point", + ), + ( + "finite-fixed-point-host", + _edit(_FINITE, ("FairTen1\n", "FairTen1\nPoint1pz\nPoint2Fz\n")), + True, + None, + ), + ("mixed-cable-point", _MIXED_CABLE_POINT, False, r"targets a cable-only point"), + ("mixed-chain-point", _MIXED_CHAIN_POINT, False, None), + ("buoy-finite-legs-forces", _BUOY_FORCES, False, None), + ( + "buoy-finite-legs-positions", + _BUOY_FINITE_LEGS, + False, + r"Point channels need an EI=0 mooring system", + ), +] + + +@pytest.mark.parametrize( + ("text", "caller_driven", "message"), + [pytest.param(*case[1:], id=case[0]) for case in _ROUTE_RULE_CASES], +) +def test_route_rules_of_the_native_reader(text, caller_driven, message): + if message is None: + DeckFile.from_text(text, caller_driven=caller_driven) + else: + _rejects(text, message, caller_driven=caller_driven) + + +@pytest.mark.skipif( + not _PARITY_DRIVER or not Path(_PARITY_DRIVER).is_file(), + reason="set CABLEDYN_TEST_DRIVER to a built native driver to run the route-rule parity", +) +@pytest.mark.parametrize( + "text", + [pytest.param(case[1], id=case[0]) for case in _ROUTE_RULE_CASES if not case[2]], +) +def test_route_rules_match_the_driver(text, tmp_path): + deck = tmp_path / "rules.dat" + deck.write_text(text, encoding="utf-8") + completed = subprocess.run( + [_PARITY_DRIVER, str(deck), str(tmp_path / "rules")], + 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, + ) + assert completed.returncode in (0, 1), completed.stderr[-600:] + assert _accepted(deck) == (completed.returncode == 0), completed.stderr[-600:] diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index ed2473df..dd6a08ab 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -9634,6 +9634,17 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) ! coerced through the all-lines Hermite builder. IF (.NOT. all_lines_have_finite_ei(types, lines, sections)) 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 @@ -18962,6 +18973,12 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio CALL fail(ErrStat, ErrMsg, 'LINE TYPE "'//TRIM(types(idx)%name)// & '": Diam and EA must be > 0'); RETURN END IF + ! A finite-EI line carries its mass in the bending dynamics and its weight in the statics + ! (an EI=0 line without mass is refused as net-buoyant below). + IF (types(idx)%ei > CD_ZERO .AND. .NOT. (types(idx)%mass > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPE "'//TRIM(types(idx)%name)// & + '": MassDenInAir must be > 0 on a finite-EI line'); RETURN + END IF ! Net-buoyant gate: EI=0 decks cannot build a lazy-wave arch. The finite-EI ! route has the cubic-Hermite arch seed and may proceed. A dynamic standalone ! run gets its clock from dtM; the executable's metadata scan also admits a diff --git a/tests/test_deck_driver.f90 b/tests/test_deck_driver.f90 index 224a106d..78f0d38a 100644 --- a/tests/test_deck_driver.f90 +++ b/tests/test_deck_driver.f90 @@ -2166,6 +2166,37 @@ SUBROUTINE check_parser_hardening() CALL require(es_l == CD_DECKDRV_OK, 'caller-driven current deck needs no dtM: '//TRIM(em_l)) 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. + 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' + CHARACTER(:), ALLOCATABLE :: body + CHARACTER(1) :: nl + CHARACTER(8), PARAMETER :: MASSES(2) = [CHARACTER(8) :: '0.0', '-1.0'] + INTEGER :: k, m + nl = NEW_LINE('a') + DO m = 1, SIZE(MASSES) + body = hardening_deck(ANCHOR, SECTION, '0.1 dtM'//nl//'0.2 TMax', 'FairTen1') + k = INDEX(body, CHAIN_ROW) + CALL require(k > 0, 'finite-EI mass fixture locates the LINE TYPES row') + IF (k == 0) CYCLE + body = body(1:k - 1)//'chain 0.252 '//TRIM(MASSES(m))//' 1.674e9 -1.0 1.0e4 1.37 0.64 1.0 0.0'// & + body(k + LEN(CHAIN_ROW):) + CALL expect_badinput('deck_hard_finite_mass.dat', body, 'a finite-EI line type of mass '//TRIM(MASSES(m)), & + 'LINE TYPE "chain": MassDenInAir must be > 0 on a finite-EI line') + END DO + body = hardening_deck(ANCHOR, '1 chain 200.0 20'//nl//'1 stiff 210.0 21', '0.1 dtM'//nl//'0.2 TMax', & + 'FairTen1') + k = INDEX(body, CHAIN_ROW) + CALL require(k > 0, 'split-line fixture locates the LINE TYPES row') + IF (k > 0) THEN + 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') + END IF + END BLOCK END SUBROUTINE check_parser_hardening FUNCTION rigid6_failure_deck(failure_rows, extra_point) RESULT(body)