From 52f74c79758d58f6eef0d9bf9e7f4d5bff390836 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 30 Oct 2026 15:20:37 +0900 Subject: [PATCH] feat(torsion): ATTACHMENTS on a line restrained in torsion A finite-EI line restrained in torsion refused discrete ATTACHMENTS. The static start of an attachment line solves the smeared equilibrium and carries it to the lumped loads by the attachment polish; the torsion stage ran before the polish, whose untwisted solves would unwind it. A line with ATTACHMENTS now takes its torsion stage after the polish, on the discrete equilibrium, with the modules' net weights and current drag as nodal loads (the drag to a fixed point of the twisted state, every pass from the polished untwisted state). The twisted start gets the mesh safety diagnosis (kink limit away from the modules; under tensile_safety no compression with the coupling force added). The deck rule and its Python mirror are removed. New gate torsion_attachments: neutral modules reproduce the bare twisted line (GJ Phi / L, 720 deg); a lazy wave with 25 modules and one turn of pretwist keeps tension, torque and twist over a still 10 s run in still water and in a cross-flow current (the torsion stage before the polish rang by 3.4e-3 of the torque); a coupling-compressed twisted line with a neutral module is refused under tensile_safety as the bare line is. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 6 + CMakeLists.txt | 7 + doc/capabilities.rst | 5 +- doc/driver_format.md | 7 +- doc/theory.rst | 3 +- doc/troubleshooting.rst | 5 +- python/cabledyn/deck_file.py | 6 - python/tests/test_deck_native_parity.py | 2 +- src/CableDyn_DeckDriver.f90 | 256 ++++++++++++++--- tests/data/lazy_wave_torsion_attachments.dat | 51 ++++ tests/test_torsion_attachments.f90 | 278 +++++++++++++++++++ tests/test_torsion_deck.f90 | 12 +- 12 files changed, 575 insertions(+), 63 deletions(-) create mode 100644 tests/data/lazy_wave_torsion_attachments.dat create mode 100644 tests/test_torsion_attachments.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index ed89f606..1fd9b19e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,12 @@ All notable changes to CableDyn are recorded in this file. The format follows line rolled at 60 deg/s the coupled torque is the quasi-static `GJ phi / L` to 3e-6 N m, and `SaveState`/`RestoreState` carry the rotations. Python: `CableDyn.init_deck_rotating`, `update_rotations`, `coupled_moments`. +- `ATTACHMENTS` on a finite-EI line restrained in torsion: the torsion stage of the static start + runs on the discrete equilibrium, after the attachment polish, with the modules' net weights + and current drag (to a fixed point) as nodal loads. A lazy wave with 25 buoyancy modules and + one turn of pretwist, in still water and in a cross-flow current, keeps its torque, twist and + fairlead tension over a still 10 s run to the output precision (a torsion stage before the + polish would ring by 3e-3 of the torque); neutral modules reproduce the bare line's GJ Phi / L. - OpenFAST linearisation with the line dynamics, as MoorDyn-F's: the continuous states are the interior-node positions of every `EI = 0` line (MoorDyn's names and order) and the free degrees of freedom of every finite-EI cable (node positions and tangents), then their diff --git a/CMakeLists.txt b/CMakeLists.txt index 86650b99..80bb7490 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2095,6 +2095,13 @@ target_link_libraries(test_torsion_deck PRIVATE cabledyn_core) add_test(NAME torsion_deck COMMAND test_torsion_deck) set_tests_properties(torsion_deck PROPERTIES LABELS "fortran;driver;integration;static;dynamic") +add_executable(test_torsion_attachments tests/test_torsion_attachments.f90) +target_link_libraries(test_torsion_attachments PRIVATE cabledyn_core) +add_test(NAME torsion_attachments + COMMAND test_torsion_attachments ${CMAKE_CURRENT_SOURCE_DIR}/tests/data/lazy_wave_torsion_attachments.dat + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(torsion_attachments PROPERTIES LABELS "fortran;driver;integration;static;dynamic") + add_executable(test_section_curvature tests/test_section_curvature.f90) target_link_libraries(test_section_curvature PRIVATE cabledyn_core) add_test(NAME section_curvature COMMAND test_section_curvature) diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 06cb61a7..37dd07fb 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -96,7 +96,7 @@ Line and constitutive capability range graphs. Stopped by name: the standalone mixed ``EI = 0`` + finite-EI aggregate and ``CableDyn_InitDeck``/``InitDeckAt`` (which move the line ends by translation only), OpenFAST linearisation of a line restrained in torsion, - rod ends, bodies other than Rigid6, lines with ``ATTACHMENTS``, modal analysis, and + rod ends, bodies other than Rigid6, modal analysis, and ``False alpha_force_blend``. Not modelled: seabed friction against twist, anisotropic sections, self-contact of a loop (see :ref:`theory-torsion`) * - Hockling loops, nonlinear cross-section laws @@ -106,7 +106,8 @@ Line and constitutive capability production route * - Discrete attachments (``ATTACHMENTS``: buoyancy modules, clumps) - Supported - - lumped at nodes of a finite-EI cable, standalone and coupled; rejected on the two-moving-end + - lumped at nodes of a finite-EI cable, standalone and coupled, also on a line restrained in + torsion (they add no polar inertia to its twist); rejected on the two-moving-end compatibility solver * - Bend stiffeners (``STIFFENERS``) - Supported with limits diff --git a/doc/driver_format.md b/doc/driver_format.md index 4b26a61a..93552c5b 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -862,7 +862,7 @@ Scope. A torsionally restrained line needs a finite-EI line with a `Fixed` End B `GJ` on every section, and, at End A, a `Fixed`, `Coupled`/`Vessel` point or a Rigid6 `Body` point; in a coupled OpenFAST or FAST.Farm run the End A frame turns with the platform (see the manual's OpenFAST page, Line torsion). Each of the following stops with a named error: -torsion on an `EI = 0` line, on a rod end or on a `Point3` body, a line with `ATTACHMENTS`, +torsion on an `EI = 0` line, on a rod end or on a `Point3` body, modal analysis (`nModes`), a dynamic or coupled run with `False alpha_force_blend`, any restrained end (one end included) in a standalone deck mixing `EI = 0` and finite-EI lines without a body or through the C API's `CableDyn_InitDeck`/`InitDeckAt`, which move the line @@ -945,7 +945,10 @@ Behaviour: - The static equilibrium is solved first with each attachment's net weight spread over the two elements at its node, then carried to the discrete loads by continuation. The current drag depends on the node's depth and line direction, so the final solve is repeated until the - node positions change by less than 1e-9 m. + node positions change by less than 1e-9 m. On a line restrained in torsion the torsion stage + (the imposed twist) follows on the discrete equilibrium, with the attachments' net weights + and drag as nodal loads (the drag again to a fixed point), so a run starts in the twisted + equilibrium. An attachment adds no polar inertia to the line's twist. - A row fails if the line is not finite-EI, the arc lies beyond the line, every one of `Mass`, `Volume`, `CdA` and `CdAx` is zero, a value is negative or non-finite, or a series has a non-positive diff --git a/doc/theory.rst b/doc/theory.rst index 76bab7a5..faecf21e 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -442,7 +442,8 @@ post-buckled states of the validation (see :doc:`validation`) that rate is 0.05 same term enters the dynamic effective tangent, scaled by :math:`1 - \alpha_f` of the force blend, and is frozen together with a reused factorisation. -**Statics and stability.** The imposed twist is the last static load stage, ramped from the +**Statics and stability.** The imposed twist is the last static load stage (on a line with +``ATTACHMENTS``, after the attachment polish, on the discrete equilibrium), ramped from the geometric twist of the untwisted equilibrium in steps of at most :math:`\pi/4`. Each converged stage is tested for stability by the inertia of :math:`\mathbf{K}` on the free DOFs, :math:`\operatorname{neg}(\mathbf{K}) = \operatorname{neg}(\mathbf{B}) - diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index c9179535..b9bb2e23 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -393,10 +393,9 @@ Torsion with Fixed End B`` - torsion is solved on cubic-Hermite lines whose End B is an anchor. * - ``a torsional END CONNECTION on a rod end is not supported`` / ``on a body needs a Rigid6 - body`` / ``torsion is not combined with ATTACHMENTS in this build`` + body`` - outside the torsion scope (:doc:`capabilities`). Move End A to a ``Fixed``, - ``Coupled``/``Vessel`` point or a Rigid6 body, or represent the modules as a smeared - buoyancy section. + ``Coupled``/``Vessel`` point or a Rigid6 body. * - ``a line restrained in torsion needs a host that turns its fairlead frame`` - the standalone deck that mixes ``EI = 0`` and finite-EI lines without a body, and the C API's ``CableDyn_InitDeck``/``InitDeckAt``, move the line ends by translation only. Run the diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 19745538..7ec699f9 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -4225,7 +4225,6 @@ def _check_torsion_lines( and FAST.Farm routes turn the fairlead frame with the platform and accept it. """ # _check_attachments has already accepted every LineID as an integer - attachment_lines = {str(_native_int(row.tokens[0])) for row in self._rows("ATTACHMENTS")} torsion_lines: set[str] = set() has_torsion_column = False for line_id, ends in torsion_ends.items(): @@ -4259,11 +4258,6 @@ def _check_torsion_lines( f'its LINE TYPES row "{name}" must give an explicit GJ > 0 (the 14-column ' "row; torsion has no EI/1.3 default)" ) - if line_id in attachment_lines: - raise DeckFormatError( - f"{self._label}: line {line_id}: torsion is not combined with ATTACHMENTS " - "in this build" - ) if _rod_point(point_types[end_a]) is not None: raise DeckFormatError( f"{self._label}: line {line_id}: a torsional END CONNECTION on a rod end is " diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index 21d15d46..be2879ca 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -1057,7 +1057,7 @@ def test_torsion_scope_rules_follow_the_native_checks(): f"1 50.0 10.0 0.0 0.0 0.0\n{_BAR} OPTIONS {_BAR}", ), ) - _rejects(attachments, "torsion is not combined with ATTACHMENTS") + DeckFile.from_text(attachments) # a torsional line with ATTACHMENTS is accepted # restrained at both ends, End B must be Fixed _rejects( _torsion_two_moving("1 A Pinned 1 0 0 Rigid 0 0 1 0\n"), diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 6c7fdd97..6ca7bfce 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -1824,6 +1824,10 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! static load stage on the final mesh, then installed in the cable. LOGICAL :: tors_line TYPE(CD_HermiteTorsionType) :: tors + ! the residual tolerance the accepted torsion stage met (torsion_note) + REAL(wp) :: tors_tol_used + CHARACTER(*), PARAMETER :: TWISTED_WHAT = 'finite-EI static solve with discrete ATTACHMENTS: the twisted '// & + 'discrete equilibrium ' ! the torque-tension coupling force (K/GJ) M_t of every element of the twisted static state ! (allocated by torsion_stage under coupling only), for the final mesh safety diagnosis REAL(wp), ALLOCATABLE :: tors_axial_offset(:) @@ -2968,7 +2972,9 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, 'found, so a cross-flow or a lateral disturbance can move the line away from it' CALL report_note(note_text) END IF - IF (tors_line) THEN + ! A line with ATTACHMENTS takes its torsion stage on the discrete equilibrium, after the + ! attachment polish (torsion_after_attachments). + IF (tors_line .AND. .NOT. has_att) THEN CALL torsion_stage(es, em) IF (es /= CD_DECKDRV_OK) THEN ErrStat = es @@ -2976,6 +2982,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ErrMsg = 'CableDyn_DeckDriver: line '//TRIM(int_to_str(ln%id))//': '//TRIM(em) RETURN END IF + CALL torsion_note() END IF IF (contact_enabled) CALL anchor_overshoot_note() ! Safety is independent of the opt-in adaptive accuracy policy. Diagnose the @@ -3116,9 +3123,24 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, 'load steps) and passed the acceptance checks of the smeared state') END IF ! On the final mesh, with the bare weights the polished state carries; the bending-length - ! rule of the note uses the smeared section weights w. - CALL handoff_lateral_note(l0, l0, ea, ei, w_bare, w, diam, opts%rhoW*opts%g*QUARTER_PI*diam**2, fixed_dofs, & - .TRUE.) + ! rule of the note uses the smeared section weights w. A line restrained in torsion starts + ! from the twisted state, whose stability the torsion stage tests (with the same static + ! constraints: its static solve runs in 3D), so the note of the untwisted state is not + ! written for it. + IF (.NOT. tors_line) & + CALL handoff_lateral_note(l0, l0, ea, ei, w_bare, w, diam, opts%rhoW*opts%g*QUARTER_PI*diam**2, & + fixed_dofs, .TRUE.) + IF (tors_line) THEN + CALL torsion_after_attachments(es, em) + IF (es == CD_DECKDRV_OK) CALL twisted_attachment_checks(es, em) + IF (es /= CD_DECKDRV_OK) THEN + ErrStat = es + IF (INDEX(em, 'CableDyn_DeckDriver: ') == 1) em = em(LEN('CableDyn_DeckDriver: ') + 1:) + ErrMsg = 'CableDyn_DeckDriver: line '//TRIM(int_to_str(ln%id))//': '//TRIM(em) + RETURN + END IF + CALL torsion_note() + END IF w = w_bare WRITE (note_text, '(A,I0,A,I0,A,ES10.3,A)') 'line ', ln%id, ': ', SIZE(att_node), & ' attachment(s) lumped at the nearest nodes (largest arc offset ', att_offset, ' m)' @@ -3306,42 +3328,57 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, END IF CONTAINS - SUBROUTINE torsion_stage(est, emt) + SUBROUTINE torsion_stage(est, emt, f_nodal) !! The condensed-torsion load stage of a line restrained in torsion at both ends: from the !! converged untwisted state on the final mesh (l0_am), CD_HermiteCable_Static_Solve ramps !! the imposed twist Phi = Pretwist(End B) - Pretwist(End A) with the same loads, contact, !! end connections and current as the untwisted solve, tests every stage for stability and !! descends from an unstable one. End frames are taken in the solve frame: internal end 1 !! is deck End B (global axes), end 2 deck End A (its parent's axes, turned with it). + !! f_nodal: the stage of a line with ATTACHMENTS, after the attachment polish (the final + !! mesh then is l0, with the bare weights w_bare and the deck mesh l0_deck_att), with the + !! attachments' lumped loads. INTEGER, INTENT(OUT) :: est CHARACTER(*), INTENT(OUT) :: emt + REAL(wp), INTENT(IN), OPTIONAL :: f_nodal(:) REAL(wp) :: nvec(3), dvec(3), tol_t INTEGER :: k, attempt - CHARACTER(320) :: tnote + LOGICAL :: nodal_loads TYPE(CD_HermiteTorsionType) :: tors0 + ! the deck mesh, the final mesh and its per-element arrays of this stage + REAL(wp), ALLOCATABLE :: ld(:), lf(:), w_fin(:) est = CD_DECKDRV_OK emt = '' + IF (PRESENT(f_nodal)) THEN + ld = l0_deck_att + lf = l0 + w_fin = w_bare + ELSE + ld = l0 + lf = l0_am + w_fin = w_am + END IF tors = CD_HermiteTorsionType() tors%active = .TRUE. tors%quadrature_order = opts%bending_quadrature_order tors%gj = gj_in - IF (SIZE(l0_am) /= SIZE(l0)) CALL remap_elem_by_reference_arc(tors%gj, l0, l0_am) + IF (SIZE(lf) /= SIZE(ld)) CALL remap_elem_by_reference_arc(tors%gj, ld, lf) ! torque-tension coupling: K/GJ per element (left unallocated without coupling) IF (ANY(ABS(ktt_in) > CD_ZERO)) THEN tors%couple = ktt_in/gj_in - IF (SIZE(l0_am) /= SIZE(l0)) CALL remap_elem_by_reference_arc(tors%couple, l0, l0_am) + IF (SIZE(lf) /= SIZE(ld)) CALL remap_elem_by_reference_arc(tors%couple, ld, lf) END IF ! the polar rotary inertia Irn per element: the dynamics then carries a twist angle at ! every node (CD_HermiteCable_Dyn_Set_Torsion) tors%irn = i_rn_in - IF (SIZE(l0_am) /= SIZE(l0)) CALL remap_elem_by_reference_arc(tors%irn, l0, l0_am) + IF (SIZE(lf) /= SIZE(ld)) CALL remap_elem_by_reference_arc(tors%irn, ld, lf) ! torsional damping (GJ|K|Bt): a negative value is -zeta of an element's critical torsional ! damping l0 sqrt(GJ Irn), on the final mesh IF (ANY(ABS(bt_in) > CD_ZERO)) THEN tors%bt = bt_in - IF (SIZE(l0_am) /= SIZE(l0)) CALL remap_elem_by_reference_arc(tors%bt, l0, l0_am) + IF (SIZE(lf) /= SIZE(ld)) CALL remap_elem_by_reference_arc(tors%bt, ld, lf) DO k = 1, SIZE(tors%bt) - IF (tors%bt(k) < CD_ZERO) tors%bt(k) = -tors%bt(k)*l0_am(k)*SQRT(tors%gj(k)*tors%irn(k)) + IF (tors%bt(k) < CD_ZERO) tors%bt(k) = -tors%bt(k)*lf(k)*SQRT(tors%gj(k)*tors%irn(k)) END DO END IF DO k = 1, 2 @@ -3367,8 +3404,10 @@ SUBROUTINE torsion_stage(est, emt) tors%phi = ln%tors_pretwist(2) - ln%tors_pretwist(1) ! Rotating a buckled shape about a common clamp axis is an exact symmetry only without ! weight or current, with both ends clamped on one axis. - tors%zero_mode_allowed = .NOT. ANY(ABS(w_am) > CD_ZERO) .AND. .NOT. opts%has_current .AND. & - ALL(endconn_mode == CD_ENDCONN_RIGID) .AND. & + nodal_loads = .FALSE. + IF (PRESENT(f_nodal)) nodal_loads = ANY(ABS(f_nodal) > CD_ZERO) + tors%zero_mode_allowed = .NOT. ANY(ABS(w_fin) > CD_ZERO) .AND. .NOT. opts%has_current .AND. & + .NOT. nodal_loads .AND. ALL(endconn_mode == CD_ENDCONN_RIGID) .AND. & DOT_PRODUCT(tors%ends(:, 1), tors%ends(:, 3)) > CD_ONE - 1.0e-12_wp ! As for the untwisted solve: a residual stall at the tight standalone tolerance is ! repeated at the coupled static tolerance (a round-off floor of a stiff, light line). @@ -3378,7 +3417,20 @@ SUBROUTINE torsion_stage(est, emt) tors = tors0 tol_t = static_tol_target IF (attempt == 2) tol_t = COUPLED_STATIC_TOL - IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN + IF (PRESENT(f_nodal)) THEN + ! after the attachment polish every array is on the final mesh l0 + IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN + CALL hermite_static_torsion(l0, l0, ea, ei, w_bare, diam, opts%rhoW*opts%g*QUARTER_PI*diam**2, & + q_static, curv, fixed_dofs, contact_enabled, contact_z, frame_cs, & + endconn_k, endconn_d0_local, endconn_mode, opts, tol_t, tors, est, emt, & + bathymetry=bathymetry, cur_obj=cur_obj, f_nodal=f_nodal) + ELSE + CALL hermite_static_torsion(l0, l0, ea, ei, w_bare, diam, opts%rhoW*opts%g*QUARTER_PI*diam**2, & + q_static, curv, fixed_dofs, contact_enabled, contact_z, frame_cs, & + endconn_k, endconn_d0_local, endconn_mode, opts, tol_t, tors, est, emt, & + cur_obj=cur_obj, f_nodal=f_nodal) + END IF + ELSE IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN CALL hermite_static_torsion(l0, l0_am, ea_am, ei_am, w_am, diam, dry_b, q_static, curv, fixed_am, & contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, & endconn_mode, opts, tol_t, tors, est, emt, bathymetry=bathymetry, & @@ -3391,18 +3443,99 @@ SUBROUTINE torsion_stage(est, emt) IF (est == CD_DECKDRV_OK .OR. est == CD_DECKDRV_BADINPUT) EXIT IF (static_tol_target >= COUPLED_STATIC_TOL) EXIT END DO - IF (est == CD_DECKDRV_OK .AND. tol_t > static_tol_target) THEN + tors_tol_used = tol_t + IF (est /= CD_DECKDRV_OK) RETURN + IF (ALLOCATED(tors%couple)) tors_axial_offset = tors%couple*tors%torque + END SUBROUTINE torsion_stage + + SUBROUTINE torsion_note() + !! The notes of the accepted torsion stage: a residual floor above the tolerance, and the + !! imposed twist and torque. + CHARACTER(320) :: tnote + IF (tors_tol_used > static_tol_target) THEN WRITE (tnote, '(A,I0,A,ES9.2,A,ES9.2)') 'line ', ln%id, ': torsion static residual floor above the '// & - 'tolerance ', static_tol_target, '; twisted equilibrium accepted at ', tol_t + 'tolerance ', static_tol_target, '; twisted equilibrium accepted at ', tors_tol_used CALL report_note(tnote) END IF - IF (est /= CD_DECKDRV_OK) RETURN - IF (ALLOCATED(tors%couple)) tors_axial_offset = tors%couple*tors%torque WRITE (tnote, '(A,I0,A,ES12.5,A,ES12.5,A,I0,A,I0,A)') 'line ', ln%id, ': torsion solved, imposed twist ', & tors%phi*45.0_wp/QUARTER_PI, ' deg, torque ', tors%torque, ' N m (', tors%ramp_steps, & ' twist stage(s), ', tors%descents, ' buckling descent(s))' CALL report_note(tnote) - END SUBROUTINE torsion_stage + END SUBROUTINE torsion_note + + SUBROUTINE torsion_after_attachments(est, emt) + !! The torsion stage of a line with ATTACHMENTS, on its discrete equilibrium (after the + !! attachment polish): the attachments' net weights -(m - rho V) g e_z at their nodes and, + !! in a deck current, their drag at the twisted state as nodal loads. The drag depends on + !! the node's depth and line tangent, so the stage is repeated, each time a fresh torsion + !! solve from the last state, with the drag of the last solution until the solution stops + !! moving (fixed point, as in attachment_static_polish). + INTEGER, INTENT(OUT) :: est + CHARACTER(*), INTENT(OUT) :: emt + INTEGER, PARAMETER :: MAX_FIXED_POINT = 60 + REAL(wp), PARAMETER :: FIXED_POINT_TOL = 1.0e-9_wp ! m + REAL(wp), ALLOCATABLE :: f_att(:), f_drag(:), q_prev(:), q_polished(:) + LOGICAL :: has_drag + INTEGER :: k, fp + est = CD_DECKDRV_OK + emt = '' + ! every pass starts from the polished, untwisted discrete state (a pass from the last twisted + ! state would first relax it, and a writhe a buckling descent left could put Theta_0 a turn + ! away, on another branch) + q_polished = q_static + ALLOCATE (f_att(SIZE(q_static)), f_drag(SIZE(q_static))) + f_att = CD_ZERO + DO k = 1, SIZE(att_node) + f_att(6*(att_node(k) - 1) + 3) = f_att(6*(att_node(k) - 1) + 3) - & + (ln%att(2, k) - opts%rhoW*ln%att(3, k))*opts%g + END DO + has_drag = opts%has_current .AND. ANY(ln%att(4, :) > CD_ZERO .OR. ln%att(6, :) > CD_ZERO) + DO fp = 1, MAX_FIXED_POINT + f_drag = CD_ZERO + IF (has_drag) THEN + CALL attachment_static_drag(q_static, att_node, ln%att, opts, frame_cs, f_drag, est, emt) + IF (est /= CD_DECKDRV_OK) THEN + emt = 'finite-EI static attachment drag failed: '//TRIM(emt) + RETURN + END IF + END IF + q_prev = q_static + q_static = q_polished + CALL torsion_stage(est, emt, f_att + f_drag) + IF (est /= CD_DECKDRV_OK) RETURN + IF (.NOT. has_drag) RETURN + IF (MAXVAL(ABS(q_static - q_prev)) <= FIXED_POINT_TOL) RETURN + END DO + est = CD_DECKDRV_SOLVEFAIL + emt = 'finite-EI torsion static solve with discrete ATTACHMENTS: the attachment current drag did not '// & + 'settle to a fixed point' + END SUBROUTINE torsion_after_attachments + + SUBROUTINE twisted_attachment_checks(est, emt) + !! The mesh safety diagnosis of the twisted discrete start of a line with ATTACHMENTS (the + !! smeared-state diagnosis above saw the untwisted state): the kink limit away from the + !! attachment nodes and, under tensile_safety True, no axial compression, the + !! torque-tension coupling force (K/GJ) M_t added (attachment_mesh_checks). + INTEGER, INTENT(OUT) :: est + CHARACTER(*), INTENT(OUT) :: emt + LOGICAL :: accepted_t + CHARACTER(1024) :: msg_t + est = CD_DECKDRV_OK + emt = '' + IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN + CALL attachment_mesh_checks(l0, q_static, ea, ei, att_node, contact_z, & + opts%tensile_mode == CD_HCDYN_TENSILE_ERROR, TWISTED_WHAT, accepted_t, msg_t, & + bathymetry=bathymetry, frame_cs=frame_cs, axial_offset=tors_axial_offset) + ELSE + CALL attachment_mesh_checks(l0, q_static, ea, ei, att_node, contact_z, & + opts%tensile_mode == CD_HCDYN_TENSILE_ERROR, TWISTED_WHAT, accepted_t, msg_t, & + axial_offset=tors_axial_offset) + END IF + IF (.NOT. accepted_t) THEN + est = CD_DECKDRV_SOLVEFAIL + emt = TRIM(msg_t) + END IF + END SUBROUTINE twisted_attachment_checks SUBROUTINE bow_route(done, why) !! A line too long for its span whose anchor walk failed or reached an equilibrium the @@ -6458,12 +6591,13 @@ END SUBROUTINE hermite_static_stable SUBROUTINE hermite_static_torsion(l0_deck, l0, ea, ei, w, diam_deck, dry_deck, q, curv, fixed_dofs, & contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0, endconn_mode, opts, & - tol, tors, ErrStat, ErrMsg, bathymetry, cur_obj) + tol, tors, ErrStat, ErrMsg, bathymetry, cur_obj, f_nodal) !! Torsion stage of a deck cable on its final mesh l0: CD_HermiteCable_Static_Solve from the !! converged untwisted state q (one EI and buoyancy stage, a polish) with the torsion !! description tors, under the same contact, dry-buoyancy, end-connection and current terms - !! as hermite_static_stable. On success q and curv hold the twisted equilibrium and tors its - !! accepted Theta, torque and stability report. + !! as hermite_static_stable, and the nodal loads f_nodal (the discrete ATTACHMENTS). On + !! success q and curv hold the twisted equilibrium and tors its accepted Theta, torque and + !! stability report. REAL(wp), INTENT(IN) :: l0_deck(:), l0(:), ea(:), ei(:), w(:), diam_deck(:), dry_deck(:) REAL(wp), INTENT(INOUT) :: q(:), curv(:) INTEGER, INTENT(IN) :: fixed_dofs(:) @@ -6476,6 +6610,7 @@ SUBROUTINE hermite_static_torsion(l0_deck, l0, ea, ei, w, diam_deck, dry_deck, q CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry TYPE(CD_HermiteStaticCurrentType), INTENT(IN), OPTIONAL :: cur_obj + REAL(wp), INTENT(IN), OPTIONAL :: f_nodal(:) REAL(wp), ALLOCATABLE :: diam(:), dry(:), knnode(:), q_out(:) REAL(wp) :: res INTEGER :: i, ne, it, es @@ -6505,7 +6640,8 @@ SUBROUTINE hermite_static_torsion(l0_deck, l0, ea, ei, w, diam_deck, dry_deck, q bending_quadrature_order=opts%bending_quadrature_order, & endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry, & - water_weight=opts%rhoW*opts%g, current=cur_obj, torsion=tors) + water_weight=opts%rhoW*opts%g, current=cur_obj, torsion=tors, & + f_nodal=f_nodal) ELSE CALL CD_HermiteCable_Static_Solve(l0, ea, ei, w, q, fixed_dofs, contact_z, CD_ZERO, 1, 200, & tol, 0.7_wp, q_out, curv, res, it, es, em, n_buoy_steps=1, & @@ -6513,7 +6649,8 @@ SUBROUTINE hermite_static_torsion(l0_deck, l0, ea, ei, w, diam_deck, dry_deck, q bending_quadrature_order=opts%bending_quadrature_order, & endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry, & - water_weight=opts%rhoW*opts%g, current=cur_obj, torsion=tors) + water_weight=opts%rhoW*opts%g, current=cur_obj, torsion=tors, & + f_nodal=f_nodal) END IF IF (es == CD_HCSTAT_BADINPUT) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI torsion static solve rejected the input: '//TRIM(em)); RETURN @@ -6553,12 +6690,52 @@ SUBROUTINE CD_Attachment_Discrete_Verdict(l0, q, ea, ei, w, diam, endconn_mode, CHARACTER(*), PARAMETER :: WHAT = 'finite-EI static solve with discrete ATTACHMENTS: the discrete '// & 'equilibrium reached after a failed Newton solve (pseudo-transient '// & 'continuation, line search or smaller load steps) ' + LOGICAL :: physical, mesh_ok + CHARACTER(1024) :: em + accepted = .FALSE. + message = '' + IF (PRESENT(bathymetry) .AND. PRESENT(frame_cs)) THEN + CALL attachment_mesh_checks(l0, q, ea, ei, att_node, contact_z, tensile_error, WHAT, mesh_ok, message, & + bathymetry=bathymetry, frame_cs=frame_cs) + ELSE + CALL attachment_mesh_checks(l0, q, ea, ei, att_node, contact_z, tensile_error, WHAT, mesh_ok, message) + END IF + IF (.NOT. mesh_ok) RETURN + CALL audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, em, ignore_kink=.TRUE.) + IF (.NOT. physical) THEN + message = WHAT//'is rejected: '//TRIM(em); RETURN + END IF + IF (.NOT. stable) THEN + message = WHAT//'is an unstable equilibrium (tangent stiffness not positive definite)'; RETURN + END IF + accepted = .TRUE. + END SUBROUTINE CD_Attachment_Discrete_Verdict + + SUBROUTINE attachment_mesh_checks(l0, q, ea, ei, att_node, contact_z, tensile_error, what, accepted, message, & + bathymetry, frame_cs, axial_offset) + !! The mesh safety checks of a discrete attachment equilibrium on its mesh l0 with state q: + !! 1. the kink limit (h*kappa <= CD_HC_KINK_LIMIT), except on the elements beside an + !! attachment node att_node, where the lumped load turns the line by a slope jump that the + !! C1 Hermite elements carry as curvature (h*kappa of about twice the jump) at any mesh + !! size; + !! 2. with tensile_error (tensile_safety True), no axial compression in the mesh safety + !! diagnosis (the strict, smoothed compression mode), axial_offset (the torque-tension + !! coupling force (K/GJ) M_t of a twisted line, per element) added to the resultant. + !! accepted is false when a check fails, and message (what, then the check) names it. + REAL(wp), INTENT(IN) :: l0(:), q(:), ea(:), ei(:), contact_z + INTEGER, INTENT(IN) :: att_node(:) + LOGICAL, INTENT(IN) :: tensile_error + CHARACTER(*), INTENT(IN) :: what + LOGICAL, INTENT(OUT) :: accepted + CHARACTER(*), INTENT(OUT) :: message + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + REAL(wp), INTENT(IN), OPTIONAL :: frame_cs(2) + REAL(wp), INTENT(IN), OPTIONAL :: axial_offset(:) TYPE(CD_HermiteResolutionType) :: diag REAL(wp), ALLOCATABLE :: hk(:) LOGICAL, ALLOCATABLE :: beside(:) REAL(wp) :: hk_peak INTEGER :: ne, e, k, es, e_peak - LOGICAL :: physical CHARACTER(1024) :: em accepted = .FALSE. message = '' @@ -6567,13 +6744,15 @@ SUBROUTINE CD_Attachment_Discrete_Verdict(l0, q, ea, ei, w, diam, endconn_mode, IF (PRESENT(bathymetry) .AND. PRESENT(frame_cs)) THEN CALL CD_HermiteCable_Resolution_Metrics(l0, q, contact_z, CD_ZERO, CD_HC_KINK_LIMIT, diag, es, em, & bathymetry=bathymetry, contact_frame_cs=frame_cs, EA=ea, EI=ei, & - compression_mode=CD_HC_COMPRESSION_STRICT, elem_h_kappa=hk) + compression_mode=CD_HC_COMPRESSION_STRICT, elem_h_kappa=hk, & + axial_offset=axial_offset) ELSE CALL CD_HermiteCable_Resolution_Metrics(l0, q, contact_z, CD_ZERO, CD_HC_KINK_LIMIT, diag, es, em, & - EA=ea, EI=ei, compression_mode=CD_HC_COMPRESSION_STRICT, elem_h_kappa=hk) + EA=ea, EI=ei, compression_mode=CD_HC_COMPRESSION_STRICT, elem_h_kappa=hk, & + axial_offset=axial_offset) END IF IF (es /= CD_HCSTAT_OK) THEN - message = WHAT//'could not be diagnosed: '//TRIM(em); RETURN + message = what//'could not be diagnosed: '//TRIM(em); RETURN END IF beside = .FALSE. DO k = 1, SIZE(att_node) @@ -6593,24 +6772,17 @@ SUBROUTINE CD_Attachment_Discrete_Verdict(l0, q, ea, ei, w, diam, endconn_mode, IF (hk_peak > CD_HC_KINK_LIMIT) THEN WRITE (em, '(A,ES12.5,A,ES12.5,A,I0,A)') 'is unresolved/kinked: max(h*kappa)=', hk_peak, & ' > safety limit=', CD_HC_KINK_LIMIT, ' at element ', e_peak, ' (away from the attachment nodes)' - message = WHAT//TRIM(em); RETURN + message = what//TRIM(em); RETURN END IF IF (tensile_error .AND. diag%axial_compression) THEN WRITE (em, '(A,ES12.5,A,ES12.5,A,I0,A,F8.5,A,ES12.5)') & 'carries axial compression under tensile_safety True: element-mean axial force=', & diag%axial_strain_min_resultant, ' N below tolerance=', diag%axial_tolerance, ' N at element ', & diag%axial_strain_min_elem, ', xi=', diag%axial_strain_min_xi, ', strain=', diag%axial_strain_min - message = WHAT//TRIM(em); RETURN - END IF - CALL audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, em, ignore_kink=.TRUE.) - IF (.NOT. physical) THEN - message = WHAT//'is rejected: '//TRIM(em); RETURN - END IF - IF (.NOT. stable) THEN - message = WHAT//'is an unstable equilibrium (tangent stiffness not positive definite)'; RETURN + message = what//TRIM(em); RETURN END IF accepted = .TRUE. - END SUBROUTINE CD_Attachment_Discrete_Verdict + END SUBROUTINE attachment_mesh_checks SUBROUTINE audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, message, compression_note, & ignore_kink) @@ -17280,8 +17452,8 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio SUBROUTINE check_torsion_line(ln, es_t, em_t) !! A line with a torsional END CONNECTIONS restraint: a finite-EI (cubic-Hermite) line. With !! both ends restrained (torsion active) End B must be Fixed, every section's LINE TYPES row - !! must give an explicit GJ, End A may not be a rod end, a body End A must be a Rigid6 body, - !! and ATTACHMENTS are not combined with it. + !! must give an explicit GJ, End A may not be a rod end, and a body End A must be a Rigid6 + !! body. TYPE(DeckLine), INTENT(IN) :: ln INTEGER, INTENT(OUT) :: es_t CHARACTER(*), INTENT(OUT) :: em_t @@ -17326,10 +17498,6 @@ SUBROUTINE check_torsion_line(ln, es_t, em_t) RETURN END IF END DO - IF (ALLOCATED(ln%att)) THEN - CALL fail(es_t, em_t, 'line '//TRIM(lid)//': torsion is not combined with ATTACHMENTS in this build') - RETURN - END IF jp = find_point(points, ln%nodeA) IF (jp < 1) RETURN IF (is_rod_point_type(points(jp)%ptype)) THEN diff --git a/tests/data/lazy_wave_torsion_attachments.dat b/tests/data/lazy_wave_torsion_attachments.dat new file mode 100644 index 00000000..55662a0d --- /dev/null +++ b/tests/data/lazy_wave_torsion_attachments.dat @@ -0,0 +1,51 @@ +--------------------- CableDyn Input File ------------------------------------ +Lazy-wave power cable with discrete buoyancy modules, restrained in torsion +-- The cable of lazy_wave_touchdown_planar_coarse_att.dat (25 discrete buoyancy modules at a 4 m pitch +-- from 80 m to 176 m), clamped at both ends and restrained in torsion (Rigid) with one turn of +-- pretwist at End B, and the polar inertia Irn = 1 kg m of its LINE TYPES row, so its dynamics carry +-- a twist angle at every node. The torsion stage runs on the discrete equilibrium, after the +-- attachment polish, with the modules' net weights (and, in a deck current, their drag) as nodal +-- loads. A still run from it keeps its torque, twist and fairlead tension. +--------------------- LINE TYPES --------------------------------------------- +Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat +(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-) +bare 0.16 36.70 4.69e8 0.0 1.99e4 1.0e8 1.5e4 1.0 1.0 1.2 0.1 1.0 0.0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +7 Coupled 30.0 0.0 -20.0 +8 Fixed 500.0 0.0 -200.0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +4 7 8 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +4 bare 80.0 20 +4 bare 100.0 25 +4 bare 420.0 42 +--------------------- ATTACHMENTS ------------------------------------------- +LineID ArcLength Mass Volume CdA Ca CdAx +(-) (m) (kg) (m^3) (m^2) (-) (m^2) +4 80.0:4.0:176.0 91.32 0.18378 1.392 1.0 0.0 +--------------------- END CONNECTIONS ---------------------------------------- +LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist +(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg) +4 A Rigid 0.1058 0 -0.9944 Rigid 0 1 0 0 +4 B Rigid 1 0 0 Rigid 0 1 0 360 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +3.0e6 kBot +3.0e5 cBot +0.35 frictionMu +200.0 WtrDpth +0.025 dtM +10.0 TMax +--------------------- OUTPUTS ------------------------------------------------ +FairTen4 +Torq4N1 +Torq4N88 +Twist4 +--------------------- END ---------------------------------------------------- diff --git a/tests/test_torsion_attachments.f90 b/tests/test_torsion_attachments.f90 new file mode 100644 index 00000000..d050c461 --- /dev/null +++ b/tests/test_torsion_attachments.f90 @@ -0,0 +1,278 @@ +! File: tests/test_torsion_attachments.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +!> Deck-level gates of a line restrained in torsion with discrete ATTACHMENTS (the torsion stage +!> on the discrete equilibrium, after the attachment polish): +!> 1. neutral attachments (mass = rhoW volume, no drag) on the straight neutral line of +!> test_torsion_deck held taut, two turns of pretwist: the torque and the twist are those of the +!> bare line, GJ Phi / L and 720 deg; +!> 2. the lazy wave of tests/data/lazy_wave_torsion_attachments.dat (25 buoyancy modules, one turn +!> of pretwist, Irn 1 kg m: the nodal twist), in still water and in a cross-flow current +!> (the attachment drag of the twisted state, to a fixed point): a still 10 s run keeps the +!> fairlead tension, the torque at both ends and the twist of its static start. A torsion +!> stage on the smeared state, before the polish, leaves the discrete start untwisted and the +!> run rings by 3e-3 of the torque; +!> 3. the mesh safety diagnosis of the twisted discrete start: a line of test_torsion_coupling +!> (GJ|K, stretched by 1e-4, Phi = -45 deg, tensile_safety True) whose coupling force +!> compresses it is refused with one neutral module as without it (the diagnosis of the +!> untwisted smeared state alone would let it start). +!> +!> Usage: test_torsion_attachments +PROGRAM test_torsion_attachments + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, RHOW = 1025.0_wp + REAL(wp), PARAMETER :: GJ = 5.0e4_wp, L = 100.0_wp + INTEGER :: n_fail = 0 + CHARACTER(512) :: lazy_wave + + IF (COMMAND_ARGUMENT_COUNT() /= 1) THEN + WRITE (*, '(A)') 'usage: test_torsion_attachments ' + ERROR STOP 2 + END IF + CALL GET_COMMAND_ARGUMENT(1, lazy_wave) + CALL check_neutral() + CALL check_still_lazy_wave('still water', '') + CALL check_still_lazy_wave('cross-flow current', 'uniform 0.2 0.3 0.0 current') + CALL check_tensile_safety() + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' torsion attachment check(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: torsion with ATTACHMENTS (neutral modules, still lazy wave in water and current)' + +CONTAINS + + SUBROUTINE require(cond, msg) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: msg + IF (.NOT. cond) THEN + n_fail = n_fail + 1 + WRITE (*, '(A,A)') 'FAILED: ', msg + END IF + END SUBROUTINE require + + SUBROUTINE run_deck(path, root, ok) + CHARACTER(*), INTENT(IN) :: path, root + LOGICAL, INTENT(OUT) :: ok + LOGICAL :: conv + INTEGER :: es + CHARACTER(2048) :: em + CALL CD_Run_Deck_Driver(path, root, conv, es, em) + ok = es == CD_DECKDRV_OK .AND. conv + IF (.NOT. ok) WRITE (*, '(A)') ' '//TRIM(path)//': '//TRIM(em) + END SUBROUTINE run_deck + + SUBROUTINE read_rows(path, ncol, vals, nrow, ok) + !! Every data row of a driver .out file (up to SIZE(vals, 2) rows), ncol columns each. + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: ncol + REAL(wp), INTENT(OUT) :: vals(:, :) + INTEGER, INTENT(OUT) :: nrow + LOGICAL, INTENT(OUT) :: ok + INTEGER :: u, ios + CHARACTER(2048) :: buf + ok = .FALSE. + nrow = 0 + vals = 0.0_wp + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (u, '(A)', IOSTAT=ios) buf + READ (u, '(A)', IOSTAT=ios) buf + DO WHILE (nrow < SIZE(vals, 2)) + READ (u, *, IOSTAT=ios) vals(1:ncol, nrow + 1) + IF (ios /= 0) EXIT + nrow = nrow + 1 + END DO + CLOSE (u) + ok = nrow > 0 .AND. ALL(IEEE_IS_FINITE(vals(1:ncol, 1:nrow))) + END SUBROUTINE read_rows + + SUBROUTINE write_straight(path, attachments) + !! The straight neutral line of test_torsion_deck (100 m along +x at z = -50 from a Coupled End A + !! to a Fixed End B, clamped, rigid in torsion, two turns of pretwist at End B; statics only), held + !! taut at 0.5 % strain (a weightless line at zero strain has no unique static shape), with or + !! without three neutral attachments. + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(IN) :: attachments + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'torsion with neutral attachments' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + WRITE (u, '(A,ES24.16,A)') 'cab 0.2 ', RHOW*0.25_wp*PI*0.04_wp, & + ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0e-12 0.0 0.0 0.0 0.0' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 100.5 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab 100.0 40' + IF (attachments) THEN + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca' + WRITE (u, '(A)') '(-) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 25.0:25.0:75.0 102.5 0.1 0.0 1.0' + END IF + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + WRITE (u, '(A)') '1 A Rigid 1 0 0 Rigid 0 0 1 0' + WRITE (u, '(A)') '1 B Rigid 1 0 0 Rigid 0 0 1 720' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.1 dtM' + WRITE (u, '(A)') '0.0 TMax' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Torq1N1' + WRITE (u, '(A)') 'Torq1N41' + WRITE (u, '(A)') 'Twist1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_straight + + SUBROUTINE check_neutral() + REAL(wp) :: bare(4, 1), att(4, 1), m_ref + INTEGER :: nb, na + LOGICAL :: ok + CALL write_straight('tatt_bare.dat', .FALSE.) + CALL write_straight('tatt_neutral.dat', .TRUE.) + CALL run_deck('tatt_bare.dat', 'tatt_bare', ok) + CALL require(ok, '1: the bare twisted line solves') + IF (.NOT. ok) RETURN + CALL run_deck('tatt_neutral.dat', 'tatt_neutral', ok) + CALL require(ok, '1: the twisted line with neutral ATTACHMENTS solves') + IF (.NOT. ok) RETURN + CALL read_rows('tatt_bare.out', 4, bare, nb, ok) + CALL require(ok, '1: bare output') + CALL read_rows('tatt_neutral.out', 4, att, na, ok) + CALL require(ok, '1: neutral-attachment output') + IF (.NOT. ok) RETURN + m_ref = GJ*(4.0_wp*PI)/L + WRITE (*, '(A,3ES16.8,A,3ES16.8,A,ES16.8)') '1 neutral modules: Torq A, B, Twist ', att(2:4, 1), & + '; bare ', bare(2:4, 1), '; GJ Phi / L ', m_ref + CALL require(MAXVAL(ABS(att(2:3, 1) - m_ref)) <= 1.0e-6_wp*m_ref .AND. ABS(att(4, 1) - 720.0_wp) <= 1.0e-6_wp, & + '1: neutral modules leave the torque GJ Phi / L and the twist 720 deg') + CALL require(MAXVAL(ABS(att(2:4, 1) - bare(2:4, 1))) <= 1.0e-9_wp*m_ref, & + '1: neutral modules reproduce the bare line') + END SUBROUTINE check_neutral + + SUBROUTINE check_still_lazy_wave(label, option) + !! The lazy wave deck, optionally with one more OPTIONS row, run still for 10 s. + CHARACTER(*), INTENT(IN) :: label, option + INTEGER, PARAMETER :: MAXROW = 1000 + REAL(wp), ALLOCATABLE :: vals(:, :) + REAL(wp) :: spread(4) + INTEGER :: nrow, j + LOGICAL :: ok + CHARACTER(64) :: path, root + root = 'tatt_lw_'//MERGE('still ', 'current', LEN_TRIM(option) == 0) + path = TRIM(root)//'.dat' + CALL copy_with_option(TRIM(lazy_wave), TRIM(path), option, ok) + CALL require(ok, '2 '//label//': the deck is written') + IF (.NOT. ok) RETURN + CALL run_deck(TRIM(path), TRIM(root), ok) + CALL require(ok, '2 '//label//': the lazy wave with modules and torsion solves and runs') + IF (.NOT. ok) RETURN + ALLOCATE (vals(5, MAXROW)) + CALL read_rows(TRIM(root)//'.out', 5, vals, nrow, ok) + CALL require(ok .AND. nrow == 401, '2 '//label//': 401 output rows') + IF (.NOT. ok) RETURN + DO j = 1, 4 + spread(j) = (MAXVAL(vals(j + 1, 1:nrow)) - MINVAL(vals(j + 1, 1:nrow)))/ABS(vals(j + 1, 1)) + END DO + WRITE (*, '(A,A,A,4ES14.6,A,4ES10.2)') '2 ', label, ': FairTen, Torq A, Torq B, Twist ', vals(2:5, 1), & + '; relative spread over 10 s ', spread + CALL require(ABS(vals(5, 1)) > 300.0_wp, '2 '//label//': the static start is twisted (one turn of pretwist)') + CALL require(MAXVAL(spread) <= 1.0e-6_wp, '2 '//label//': a still run keeps the twisted discrete static start') + END SUBROUTINE check_still_lazy_wave + + SUBROUTINE check_tensile_safety() + !! The coupled line of test_torsion_coupling's compression gate with one neutral module. + INTEGER :: u + LOGICAL :: conv + INTEGER :: es + CHARACTER(2048) :: em + OPEN (NEWUNIT=u, FILE='tatt_comp.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'torsion with attachments under tensile_safety' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + WRITE (u, '(A,ES24.16,A)') 'cab 0.2 ', RHOW*0.25_wp*PI*0.04_wp, & + ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4|4.0e5 1.0 1.0e-9 0.0 0.0 0.0 0.0' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab 99.9900 40' + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca' + WRITE (u, '(A)') '(-) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 50.0 102.5 0.1 0.0 1.0' + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + WRITE (u, '(A)') '1 A Rigid 1 0 0 Rigid 0 0 1 0' + WRITE (u, '(A)') '1 B Rigid 1 0 0 Rigid 0 0 1 -45' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') 'True tensile_safety' + WRITE (u, '(A)') '0.1 dtM' + WRITE (u, '(A)') '0.0 TMax' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL CD_Run_Deck_Driver('tatt_comp.dat', 'tatt_comp', conv, es, em) + WRITE (*, '(A)') '3 tensile_safety with a neutral module: '//TRIM(em) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'twisted discrete equilibrium carries axial compression') > 0, & + '3: the coupling-compressed twisted start with ATTACHMENTS is refused under tensile_safety True') + END SUBROUTINE check_tensile_safety + + SUBROUTINE copy_with_option(src, dst, option, ok) + !! Copy deck src to dst, inserting the row option after the TMax row (none if blank). + CHARACTER(*), INTENT(IN) :: src, dst, option + LOGICAL, INTENT(OUT) :: ok + INTEGER :: ui, uo, ios + CHARACTER(512) :: buf + ok = .FALSE. + OPEN (NEWUNIT=ui, FILE=src, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + OPEN (NEWUNIT=uo, FILE=dst, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + IF (ios /= 0) THEN + CLOSE (ui) + RETURN + END IF + DO + READ (ui, '(A)', IOSTAT=ios) buf + IF (ios /= 0) EXIT + WRITE (uo, '(A)') TRIM(buf) + IF (LEN_TRIM(option) > 0 .AND. INDEX(buf, 'TMax') > 0) WRITE (uo, '(A)') option + END DO + CLOSE (ui) + CLOSE (uo) + ok = .TRUE. + END SUBROUTINE copy_with_option + +END PROGRAM test_torsion_attachments diff --git a/tests/test_torsion_deck.f90 b/tests/test_torsion_deck.f90 index 36734b9c..e82e29d8 100644 --- a/tests/test_torsion_deck.f90 +++ b/tests/test_torsion_deck.f90 @@ -1005,8 +1005,8 @@ SUBROUTINE write_lines(path, rows) END SUBROUTINE write_lines SUBROUTINE check_scope_refusals() - !! 6 (continued). Torsion outside its scope stops by name: End A on a rod end, End A on a - !! Point3 body, and a torsional line carrying ATTACHMENTS. + !! 6 (continued). Torsion outside its scope stops by name: End A on a rod end and End A on a + !! Point3 body; a torsional line carrying ATTACHMENTS solves (test_torsion_attachments). CHARACTER(120) :: tail(9), ty(4) ty(1) = '--- LINE TYPES ---' ty(2) = 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' @@ -1055,8 +1055,12 @@ SUBROUTINE check_scope_refusals() '--- END CONNECTIONS ---', 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist', & '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)', '1 A Rigid 1 0 0 Rigid 0 0 1 0', & '1 B Rigid 1 0 0 Rigid 0 0 1 0', tail(5:9)]) - CALL expect_error('a torsional line with ATTACHMENTS is named', 'tdeck_s3.dat', 'tdeck_s3', & - 'not combined with ATTACHMENTS') + BLOCK + LOGICAL :: ok + CHARACTER(512) :: em + CALL run_deck('tdeck_s3.dat', 'tdeck_s3', ok, em) + CALL require(ok, 'a torsional line with ATTACHMENTS solves (got: '//TRIM(em)//')') + END BLOCK END SUBROUTINE check_scope_refusals END PROGRAM test_torsion_deck