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 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)