diff --git a/CHANGELOG.md b/CHANGELOG.md index 79d6a94..75944ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,13 +17,14 @@ All notable changes to CableDyn are recorded in this file. The format follows pinned cable match this to 0.05 %. It acts on every dynamic route beside the axial (`BA`) and torsional (`GJ|K|Bt`) damping, with exact Jacobians; the Python deck reader and builder take the same forms. -- In-line VIV of finite-EI cables: an optional `VIV` section row `TypeName ClX [alpha]` adds the +- In-line VIV: an optional `VIV` section row `TypeName ClX [alpha]` adds the in-line vortex-shedding force of Ulveseter et al. (2018), `1/2 rho D ClX cos(phi_x) U v_n` along the relative flow, with its phase slaved to twice the cross-flow one in a band `alpha` (default 0.15). On the taut line of `examples/viv_taut_cable_inline.dat` the in-line response runs at - twice the cross-flow frequency, A/D 0.19 against 0.03 with the lift alone. Exact Jacobians; the - phase is in the step-recovery, snapshot and checkpoint state; the Python deck reader and - builder take the section. `EI = 0` lines refuse it for now. + twice the cross-flow frequency, A/D 0.19 against 0.03 with the lift alone, on `EI = 0` lines and + finite-EI cables alike (within 1 % of each other). Exact Jacobians; the phase is in the + step-recovery, snapshot and checkpoint state; the Python deck reader and builder take the + section. ## [0.4.2] - 2026-11-09 diff --git a/doc/capabilities.rst b/doc/capabilities.rst index a19239c..165be86 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -147,8 +147,8 @@ Line and constitutive capability * - In-line VIV (``VIV`` section ``ClX``, ``alpha``) - Standalone and coupled - the in-line shedding force of Ulveseter et al. (2018) at twice the cross-flow frequency, on - finite-EI cables of the Hermite and multibody marches (:ref:`theory-viv-inline`), its state - in the checkpoint; not on ``EI = 0`` lines yet + ``EI = 0`` lines and finite-EI cables wherever the cross-flow lift runs + (:ref:`theory-viv-inline`), its state in the checkpoint Loads and environment --------------------- diff --git a/doc/concepts.rst b/doc/concepts.rst index f54b107..6038ea9 100644 --- a/doc/concepts.rst +++ b/doc/concepts.rst @@ -82,7 +82,7 @@ coefficients (``Cd_n``, ``Cd_t``, ``Ca_n``, ``Ca_t``). ``EI`` is the switch betw (next section). Axial response can be linear ``EA`` or a stateful constitutive model (viscoelastic, Syrope) — see :doc:`theory`. A 10-column row may end with MoorDyn's cross-flow VIV columns ``Cl`` or ``Cl dF cF`` (lift coefficient and synchronisation band; see -:ref:`theory-viv`), and a ``VIV`` section row adds the in-line force of a finite-EI type +:ref:`theory-viv`), and a ``VIV`` section row adds the in-line force of a type (:ref:`theory-viv-inline`). Two solver paths, selected by ``EI`` diff --git a/doc/driver_format.md b/doc/driver_format.md index e2c3548..9c7d638 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -296,7 +296,7 @@ the half-range and centre of its band in non-dimensional frequency (MoorDyn's `d `cF = 0.18` when only `Cl` is given). `Cl = 0` is no VIV; `Cl > 0` needs `cF > 0` and `0 <= dF < cF`, and the line's drag in water. It acts in the dynamics on `EI = 0` lines and finite-EI cables (see [Cross-flow VIV](theory.rst)); the 14-column row has no VIV columns. The -in-line force of a finite-EI type is a [VIV](#viv-optional-finite-ei-lines) section row. +in-line force of a type is a [VIV](#viv-optional) section row. **Viscoelastic axial stiffness (MoorDyn `ElasticMod`).** The EA and BA columns accept bar-separated parts: @@ -1145,7 +1145,7 @@ Behaviour: `NodeA`) the `End` column follows the written row, so the stiffener stays on the same physical end. Stiffeners run wherever the cubic-Hermite cable does, standalone and coupled. -### VIV (optional, finite-EI lines) +### VIV (optional) In-line vortex-induced vibration of a line type: a second vortex-shedding force along the relative flow, the direction of the drag, at twice the cross-flow frequency (Ulveseter et al. @@ -1174,8 +1174,9 @@ Behaviour: - The Outputs flag `V` file carries the in-line force with the lift, and the phase is part of the step-recovery, snapshot and checkpoint state. A row with `ClX = 0` leaves the run exactly as without it. -- It acts on finite-EI lines (`EI > 0`) on every route the cubic-Hermite cable runs; an `EI = 0` - line of a type with `ClX > 0` stops by name. A row fails if it is not `TypeName ClX [alpha]`, +- It acts wherever the cross-flow lift does: on `EI = 0` lines (a node force over the node's + half elements, as the lift) and on finite-EI cables (integrated with the lift), standalone and + coupled. A row fails if it is not `TypeName ClX [alpha]`, names an undefined or already named type, or holds a value out of range, and `ClX > 0` fails on a type without the cross-flow lift. - See `examples/viv_taut_cable_inline.dat`. diff --git a/doc/outputs.rst b/doc/outputs.rst index b2b106b..a9c7ffa 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -340,8 +340,8 @@ write. Any other letter is a parse error. Mixed ``EI = 0`` + finite-EI decks rej flag ``V``; a static run carries no lift and writes no file). On an ``EI = 0`` line the end nodes carry none, as in MoorDyn; on a finite-EI line each element's lift is lumped to its two nodes (the translational part of its consistent load), so the end nodes carry - the lift of their half-elements, and a type with in-line VIV (the ``VIV`` section) adds - its in-line force. Zero on a line without VIV (``Cl = 0``) + the lift of their half-elements. On both, a type with in-line VIV (the ``VIV`` section) + adds its in-line force. Zero on a line without VIV (``Cl = 0``) * - ``r`` - ``.Line.range.out`` - range graph: minimum, maximum and mean over the run of the node tension, curvature, bend diff --git a/doc/theory.rst b/doc/theory.rst index 500779d..a35635f 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1174,7 +1174,7 @@ them with the rest of the state. In-line vortex-induced vibration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -A finite-EI line type can add the in-line shedding force of the combined cross-flow and in-line +A line type can add the in-line shedding force of the combined cross-flow and in-line model of :ref:`Ulveseter et al. (2018) `, a ``VIV`` section row ``TypeName ClX [alpha]`` (see :doc:`file_formats`). A second phase :math:`\phi_x` per node drives a force along the relative normal flow, per unit deformed length @@ -1197,14 +1197,22 @@ with the running RMS values of the cross-flow phase (:math:`\phi_{\dot x} = 0` a in-line motion). Ulveseter et al. take :math:`C_x = 0.85` and :math:`\alpha = 0.15` (the default here) with a cross-flow :math:`C_L` of 0.65. The in-line phase starts at twice the cross-flow one, so the two start locked. The in-line rate is twice the cross-flow one, so ``ClX > 0`` -needs the type's cross-flow :math:`C_L > 0`. The force is integrated with the lift at the same -Gauss points, :math:`\cos\phi_x` interpolated between the element's end nodes, and its exact -position and velocity derivatives enter the tangent. The phase is explicit with the Heun commit, +needs the type's cross-flow :math:`C_L > 0`. On an ``EI = 0`` line it is a node force like the +lift, + +.. math:: + + \mathbf{F}_x = \tfrac{1}{4}\rho\,d\,C_x\,(l_{i} + l_{i+1})\,U\cos\phi_x\;\mathbf{v}_n , + +with the lift's wetted fractions, node tangent and neighbour-averaged kinematics (for the phase +and in the force). On a finite-EI cable it is integrated with the lift at the same Gauss points, +:math:`\cos\phi_x` interpolated between the element's end nodes. Its exact position and velocity +derivatives enter the tangent on both. The phase is explicit with the Heun commit, its end-state rate taken from the end-state cross-flow rate. The phase and the two mean squares are part of the step-recovery, snapshot and checkpoint state, and a ``ClX`` of zero leaves the run exactly as without the row. On the taut line of ``viv_taut_cable_inline.dat`` the quarter span moves in line at twice the cross-flow frequency, A/D 0.19 against 0.03 with the cross-flow -lift alone. ``EI = 0`` lines do not take in-line VIV yet. +lift alone, and the same line as an ``EI = 0`` line gives the cable's amplitudes within 1 %. .. _theory-dry-buoyancy: diff --git a/examples/viv_taut_cable_inline.dat b/examples/viv_taut_cable_inline.dat index 187a9ee..f8c64b1 100644 --- a/examples/viv_taut_cable_inline.dat +++ b/examples/viv_taut_cable_inline.dat @@ -30,7 +30,7 @@ LineID LineType Length NumSegs 1 riser 99.9001 50 --------------------- VIV ---------------------------------------------- -- In-line VIV of a line type: the in-line shedding coefficient ClX (0 = off; it needs the type's --- cross-flow Cl > 0) and the band alpha (0 <= alpha < 1, default 0.15). Finite-EI lines only. +-- cross-flow Cl > 0) and the band alpha (0 <= alpha < 1, default 0.15). EI = 0 lines take it too. TypeName ClX alpha (-) (-) (-) riser 0.85 0.15 diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index 0e38138..1fd9b94 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -208,7 +208,7 @@ class LineType: in non-dimensional frequency). ``cl`` set writes the 13-column row, with MoorDyn's ``df = 0.08`` and ``cf = 0.18`` where they are ``None``. clx, il_alpha : float | None - Optional in-line VIV of a finite-EI type, a ``VIV`` section row + Optional in-line VIV of a type, a ``VIV`` section row ``Name ClX [alpha]``: the in-line shedding coefficient (it needs ``cl``, the in-line phase running at twice the cross-flow one) and the frequency band of that phase, ``0 <= il_alpha < 1``; ``None`` leaves alpha out of diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 6e4ca43..c55ac01 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -3180,20 +3180,17 @@ def _check_stiffeners( def _check_viv_section( self, - line_ids: set[str], - section_types_by_line: dict[str, list[str]], line_type_meta: dict[str, tuple[float, float, float, float]], lift_type_names: set[str], ) -> None: - """Native ``apply_type_viv`` and its finalize check for the VIV section. + """Native ``apply_type_viv`` for the VIV section. A row ``TypeName ClX [alpha]`` gives a line type in-line VIV: the in-line shedding coefficient ``ClX >= 0`` (0 = off) and the band ``0 <= alpha < 1`` (default 0.15) of its phase about twice the cross-flow one, so ``ClX > 0`` needs the type's LINE TYPES - lift ``Cl > 0``. A type takes one row; the in-line force acts on finite-EI lines. + lift ``Cl > 0``. A type takes one row. """ named: set[str] = set() - inline_types: set[str] = set() for row in self._rows("VIV"): where = self._at(row) if len(row.tokens) not in (2, 3): @@ -3228,16 +3225,6 @@ def _check_viv_section( "cross-flow lift (LINE TYPES Cl > 0): the in-line phase runs at twice the " "cross-flow one" ) - if clx > 0.0: - inline_types.add(name) - for line_id in sorted(line_ids, key=int): - names = section_types_by_line.get(line_id, []) - finite = any(line_type_meta[name][3] > 0.0 for name in names if name in line_type_meta) - if not finite and inline_types & set(names): - raise DeckFormatError( - f"{self._label}: line {line_id} is an EI = 0 line of a type with in-line VIV " - "(VIV ClX > 0): in-line VIV acts on finite-EI lines (EI > 0)" - ) def _legacy_rod_type_columns(self, record: DeckRecord) -> bool: """Return whether ``record`` sits under a legacy CableDyn ROD TYPES header. @@ -4409,7 +4396,7 @@ def end_key(token: str) -> str: ) self._check_stiffeners(line_ids, section_types_by_line, line_type_meta, line_lengths) - self._check_viv_section(line_ids, section_types_by_line, line_type_meta, viv_type_names) + self._check_viv_section(line_type_meta, viv_type_names) self._check_attachments(line_ids, section_types_by_line, line_type_meta, line_lengths) assigned_end_connections: set[tuple[str, str]] = set() diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index 4a71b90..735d489 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -1020,11 +1020,9 @@ def test_inline_viv_needs_the_crossflow_lift(): ) -def test_inline_viv_needs_a_finite_ei_line(): - text = _section(_example("viv_taut_line_crossflow.dat"), "VIV", "riser 0.85") - _rejects(text, re.escape("in-line VIV acts on finite-EI lines (EI > 0)")) - # a zero in-line coefficient is no in-line VIV, which the EI = 0 line takes - DeckFile.from_text(_section(_example("viv_taut_line_crossflow.dat"), "VIV", "riser 0.0")) +@pytest.mark.parametrize("row", ["riser 0.85", "riser 0.0"]) +def test_inline_viv_acts_on_an_ei0_line(row): + DeckFile.from_text(_section(_example("viv_taut_line_crossflow.dat"), "VIV", row)) def test_stiffener_needs_a_finite_ei_line(): diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index c51a281..ec1aa32 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -10367,7 +10367,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er REAL(wp), ALLOCATABLE :: ba(:), fluid_velocity(:, :), fluid_acceleration(:, :), drag_waterline(:) REAL(wp), ALLOCATABLE :: hydro_diam(:), hydro_cdn(:), hydro_cdt(:), hydro_can(:), hydro_cat(:) REAL(wp), ALLOCATABLE :: ve_ead(:), ve_bas(:), ve_bad(:), ve_ambl(:), ve_vbet(:) - REAL(wp), ALLOCATABLE :: viv_cl(:), viv_cf(:), viv_df(:) + REAL(wp), ALLOCATABLE :: viv_cl(:), viv_cf(:), viv_df(:), viv_clx(:), viv_al(:) LOGICAL, ALLOCATABLE :: syr_el(:) REAL(wp) :: anchor(3), fairlead(3), mode1_omega REAL(wp), PARAMETER :: factors(4) = [0.25_wp, 0.5_wp, 0.75_wp, CD_ONE] @@ -10406,10 +10406,12 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er ALLOCATE (ba(SIZE(l0)), hydro_diam(SIZE(l0)), hydro_cdn(SIZE(l0)), hydro_cdt(SIZE(l0)), & hydro_can(SIZE(l0)), hydro_cat(SIZE(l0)), ve_ead(SIZE(l0)), ve_bas(SIZE(l0)), & ve_bad(SIZE(l0)), ve_ambl(SIZE(l0)), ve_vbet(SIZE(l0)), viv_cl(SIZE(l0)), viv_cf(SIZE(l0)), & - viv_df(SIZE(l0)), syr_el(SIZE(l0))) + viv_df(SIZE(l0)), syr_el(SIZE(l0)), viv_clx(SIZE(l0)), viv_al(SIZE(l0))) viv_cl = CD_ZERO viv_cf = CD_ZERO viv_df = CD_ZERO + viv_clx = CD_ZERO + viv_al = CD_ZERO ve_ead = CD_ZERO ve_bas = CD_ZERO ve_bad = CD_ZERO @@ -10468,6 +10470,8 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er viv_cl(e) = types(line_section_type(sections, ln%id, i))%cl viv_cf(e) = types(line_section_type(sections, ln%id, i))%viv_cf viv_df(e) = types(line_section_type(sections, ln%id, i))%viv_df + viv_clx(e) = types(line_section_type(sections, ln%id, i))%clx + viv_al(e) = types(line_section_type(sections, ln%id, i))%il_alpha syr_el(e) = types(line_section_type(sections, ln%id, i))%is_syrope END DO END DO @@ -10475,6 +10479,8 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er viv_cl = viv_cl(SIZE(viv_cl):1:-1) viv_cf = viv_cf(SIZE(viv_cf):1:-1) viv_df = viv_df(SIZE(viv_df):1:-1) + viv_clx = viv_clx(SIZE(viv_clx):1:-1) + viv_al = viv_al(SIZE(viv_al):1:-1) ba = ba(SIZE(ba):1:-1) ve_ead = ve_ead(SIZE(ve_ead):1:-1) ve_bas = ve_bas(SIZE(ve_bas):1:-1) @@ -10764,8 +10770,15 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er BLOCK REAL(wp) :: seed(model%n_dof/3) CALL CD_Deck_VIV_Phase_Seed(model%l0, ln%ends_swapped, seed, zero=opts%viv_phase_zero) - CALL CD_Set_Model_VIV(model, opts%rhoW, viv_cl, hydro_diam, viv_cf, viv_df, tw, es, em, & - phase_seed=seed, tangent_reversed=.NOT. ln%ends_swapped) + ! with the in-line VIV of the VIV section where a type has ClX > 0 + IF (ANY(viv_clx > CD_ZERO)) THEN + CALL CD_Set_Model_VIV(model, opts%rhoW, viv_cl, hydro_diam, viv_cf, viv_df, tw, es, em, & + phase_seed=seed, tangent_reversed=.NOT. ln%ends_swapped, clx=viv_clx, & + il_alpha=viv_al) + ELSE + CALL CD_Set_Model_VIV(model, opts%rhoW, viv_cl, hydro_diam, viv_cf, viv_df, tw, es, em, & + phase_seed=seed, tangent_reversed=.NOT. ln%ends_swapped) + END IF END BLOCK IF (es == CD_MODEL_OK) CALL CD_Recompute_Model_Acceleration(model, es, em) IF (es /= CD_MODEL_OK) THEN @@ -11602,20 +11615,6 @@ SUBROUTINE finite_viv_arrays(ln, sections, types, cl, cf, df, clx, il_alpha) il_alpha = il_alpha(SIZE(il_alpha):1:-1) END SUBROUTINE finite_viv_arrays - LOGICAL FUNCTION line_has_viv_il(ln, types, sections) RESULT(has) - !! Whether a section of the line uses a line type with in-line VIV (VIV ClX > 0). - TYPE(DeckLine), INTENT(IN) :: ln - TYPE(DeckLineType), INTENT(IN) :: types(:) - TYPE(DeckSection), INTENT(IN) :: sections(:) - INTEGER :: j - has = .FALSE. - DO j = 1, SIZE(sections) - IF (sections(j)%line_id /= ln%id) CYCLE - IF (sections(j)%ltype < 1 .OR. sections(j)%ltype > SIZE(types)) CYCLE - IF (types(sections(j)%ltype)%clx > CD_ZERO) has = .TRUE. - END DO - END FUNCTION line_has_viv_il - LOGICAL FUNCTION line_has_viv(ln, types, sections) RESULT(has) !! Whether a section of the line uses a line type with a VIV lift coefficient Cl > 0. TYPE(DeckLine), INTENT(IN) :: ln @@ -19783,15 +19782,6 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio END IF END DO - ! VIV in-line rows: the in-line force acts on finite-EI lines - DO j = 1, SIZE(lines) - IF (line_is_finite_ei(lines(j), types, sections)) CYCLE - IF (.NOT. line_has_viv_il(lines(j), types, sections)) CYCLE - at_line = lines(j)%deck_line - CALL fail(ErrStat, ErrMsg, 'line '//TRIM(int_to_str(lines(j)%id))//' is an EI = 0 line of a type with '// & - 'in-line VIV (VIV ClX > 0): in-line VIV acts on finite-EI lines (EI > 0)'); RETURN - END DO - ! STIFFENERS: bend stiffeners sleeving the ends of a finite-EI line DO j = 1, SIZE(lines) IF (.NOT. ALLOCATED(lines(j)%stf)) CYCLE diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index 638ba1f..0696012 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -57,7 +57,7 @@ MODULE CableDyn_Model CD_Added_Mass_Element, CD_Added_Mass_Element_Matrix, CD_Added_Mass_Element_Force, & CD_Submerged_Fraction USE CableDyn_VIV, ONLY: CD_VIV_Node_Lift, CD_VIV_Crossflow_Motion, CD_VIV_Phase_Rate, CD_VIV_Mean_Square, & - CD_VIV_Wrap_Phase, CD_VIV_NM, CD_VIV_TWO_PI + CD_VIV_Wrap_Phase, CD_VIV_NM, CD_VIV_TWO_PI, CD_VIV_Node_Inline, CD_VIV_Inline_Phase_Rate USE CableDyn_Dynamic, ONLY: GenAlphaConfig, CD_CableGenAlphaWorkspace, CD_Clear_GenAlpha_Workspace, & CD_Cable_Initial_Acceleration, CD_Cable_Gen_Alpha_Step, CD_Cable_Step_Loads, & CD_DYN_OK, CD_DYN_ALLOCFAIL, & @@ -98,6 +98,7 @@ MODULE CableDyn_Model PUBLIC :: CD_Set_Model_VIV PUBLIC :: CD_Latch_Model_VIV_Window PUBLIC :: CD_Get_Model_VIV_State, CD_Set_Model_VIV_State, CD_Model_Has_VIV, CD_Get_Model_VIV_Lift + PUBLIC :: CD_Model_Has_VIV_Inline PUBLIC :: CD_Get_Model_Tension PUBLIC :: CD_Get_Model_Internal_Rates PUBLIC :: CD_Get_Model_EndForces @@ -153,6 +154,7 @@ MODULE CableDyn_Model TYPE :: CD_ModelCommitSlot REAL(wp), ALLOCATABLE :: q(:), v(:), a(:), ve_dl_1(:), syrope_slow(:), syrope_tmax(:) REAL(wp), ALLOCATABLE :: fr_anchor(:, :), l0_c(:), l0_dot_c(:), viv_phi(:), viv_ms(:, :) + REAL(wp), ALLOCATABLE :: vil_phi(:), vil_ms(:, :) END TYPE CD_ModelCommitSlot ! Diagnostics of the rotation- and snap-resolved sub-stepping (CD_Step_Model): calls counts @@ -410,6 +412,17 @@ MODULE CableDyn_Model REAL(wp), ALLOCATABLE :: viv_phi_rollback(:), viv_ms_rollback(:, :) REAL(wp), ALLOCATABLE :: recovery_viv_phi(:), recovery_viv_ms(:, :) REAL(wp), ALLOCATABLE :: viv_phi_eval(:), viv_rate(:), viv_ms_next(:, :), viv_phi_next(:) + ! In-line VIV (CD_Set_Model_VIV clx, il_alpha; Ulveseter et al. 2018): per element the in-line + ! shedding coefficient vil_cx (0 = no in-line force), per node the band vil_alpha, the in-line + ! phase vil_phi and the running mean squares of the in-line velocity and acceleration vil_ms, + ! with the cross-flow state's rollback, recovery, eval, rate and next twins. vil_node marks a + ! cross-flow node next to a vil_cx > 0 element. + LOGICAL :: has_viv_il = .FALSE. + REAL(wp), ALLOCATABLE :: vil_cx(:), vil_alpha(:) + LOGICAL, ALLOCATABLE :: vil_node(:) + REAL(wp), ALLOCATABLE :: vil_phi(:), vil_ms(:, :), vil_phi_rollback(:), vil_ms_rollback(:, :) + REAL(wp), ALLOCATABLE :: recovery_vil_phi(:), recovery_vil_ms(:, :) + REAL(wp), ALLOCATABLE :: vil_phi_eval(:), vil_rate(:), vil_ms_next(:, :), vil_phi_next(:) TYPE(GenAlphaConfig) :: cfg ! Run audit of the committed host steps (CD_Audit_Model_Step), diagnostics only: never part ! of the state, of a copy, or of a result. audit_t holds the segment tensions of the last two @@ -2301,6 +2314,13 @@ LOGICAL FUNCTION sub_alloc(model, has_pres) RESULT(ok) IF (istat /= 0) RETURN END IF END IF + IF (model%has_viv_il) THEN + IF (.NOT. sized(s%vil_phi, SIZE(model%vil_phi))) THEN + IF (ALLOCATED(s%vil_phi)) DEALLOCATE (s%vil_phi, s%vil_ms) + ALLOCATE (s%vil_phi(SIZE(model%vil_phi)), s%vil_ms(2, SIZE(model%vil_phi)), STAT=istat) + IF (istat /= 0) RETURN + END IF + END IF END ASSOCIATE END DO IF (.NOT. sized(model%sub_t0, model%n_elem)) THEN @@ -2331,11 +2351,12 @@ END FUNCTION sized END FUNCTION sub_alloc SUBROUTINE commit_state_copy(model, to_model, q, v, a, ve_dl_1, syrope_slow, syrope_tmax, fr_anchor, & - l0_c, l0_dot_c, viv_phi, viv_ms) + l0_c, l0_dot_c, viv_phi, viv_ms, vil_phi, vil_ms) !! The one list of the state a line step commits: the kinematics, the viscoelastic dl_1, the !! Syrope slow strain and running maximum tension, the friction anchors, the unstretched !! lengths and rates the committed state was reached with (l0_c, l0_dot_c, active line - !! control), and the VIV shedding phases and running mean squares. to_model = + !! control), and the VIV shedding phases and running mean squares (cross-flow, and in-line + !! with vil_phi, vil_ms). to_model = !! .FALSE. saves the model's state into the arrays given, .TRUE. returns the model to them. !! Every snapshot of the committed state in this module goes through here (the sub-step !! slots of CD_Step_Model, save_recovery_state and restore_recovery_state). A state a step @@ -2349,6 +2370,7 @@ SUBROUTINE commit_state_copy(model, to_model, q, v, a, ve_dl_1, syrope_slow, syr REAL(wp), INTENT(INOUT) :: q(:), v(:), a(:) REAL(wp), INTENT(INOUT), OPTIONAL :: ve_dl_1(:), syrope_slow(:), syrope_tmax(:), fr_anchor(:, :) REAL(wp), INTENT(INOUT), OPTIONAL :: l0_c(:), l0_dot_c(:), viv_phi(:), viv_ms(:, :) + REAL(wp), INTENT(INOUT), OPTIONAL :: vil_phi(:), vil_ms(:, :) IF (to_model) THEN model%q = q model%v = v @@ -2368,6 +2390,11 @@ SUBROUTINE commit_state_copy(model, to_model, q, v, a, ve_dl_1, syrope_slow, syr model%viv_ms = viv_ms model%viv_phi_eval = viv_phi END IF + IF (model%has_viv_il .AND. PRESENT(vil_phi) .AND. PRESENT(vil_ms)) THEN + model%vil_phi = vil_phi + model%vil_ms = vil_ms + model%vil_phi_eval = vil_phi + END IF ELSE q = model%q v = model%v @@ -2386,6 +2413,10 @@ SUBROUTINE commit_state_copy(model, to_model, q, v, a, ve_dl_1, syrope_slow, syr viv_phi = model%viv_phi viv_ms = model%viv_ms END IF + IF (model%has_viv_il .AND. PRESENT(vil_phi) .AND. PRESENT(vil_ms)) THEN + vil_phi = model%vil_phi + vil_ms = model%vil_ms + END IF END IF END SUBROUTINE commit_state_copy @@ -2397,7 +2428,8 @@ SUBROUTINE sub_store(model, slot) model%sub_slot(slot)%ve_dl_1, model%sub_slot(slot)%syrope_slow, & model%sub_slot(slot)%syrope_tmax, model%sub_slot(slot)%fr_anchor, & model%sub_slot(slot)%l0_c, model%sub_slot(slot)%l0_dot_c, & - model%sub_slot(slot)%viv_phi, model%sub_slot(slot)%viv_ms) + model%sub_slot(slot)%viv_phi, model%sub_slot(slot)%viv_ms, & + model%sub_slot(slot)%vil_phi, model%sub_slot(slot)%vil_ms) END SUBROUTINE sub_store SUBROUTINE sub_load(model, slot) @@ -2408,7 +2440,8 @@ SUBROUTINE sub_load(model, slot) model%sub_slot(slot)%ve_dl_1, model%sub_slot(slot)%syrope_slow, & model%sub_slot(slot)%syrope_tmax, model%sub_slot(slot)%fr_anchor, & model%sub_slot(slot)%l0_c, model%sub_slot(slot)%l0_dot_c, & - model%sub_slot(slot)%viv_phi, model%sub_slot(slot)%viv_ms) + model%sub_slot(slot)%viv_phi, model%sub_slot(slot)%viv_ms, & + model%sub_slot(slot)%vil_phi, model%sub_slot(slot)%vil_ms) END SUBROUTINE sub_load SUBROUTINE sub_lengths_target(model) @@ -2736,6 +2769,7 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM CALL viv_step_begin(model, dt, ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) THEN model%viv_phi_eval = model%viv_phi + IF (model%has_viv_il) model%vil_phi_eval = model%vil_phi RETURN END IF END IF @@ -2857,6 +2891,7 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM IF (ALLOCATED(f_ext_new)) model%f_ext = f_ext_new model%ve_dt = CD_ZERO IF (model%has_viv) model%viv_phi_eval = model%viv_phi + IF (model%has_viv_il) model%vil_phi_eval = model%vil_phi CALL CD_Profile_Count_Line_Step(n_iter) IF (es /= CD_DYN_OK) THEN ErrStat = model_status_from_dyn(es) @@ -2993,6 +3028,11 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM model%viv_phi = model%viv_phi_next model%viv_ms = model%viv_ms_next model%viv_phi_eval = model%viv_phi + IF (model%has_viv_il) THEN + model%vil_phi = model%vil_phi_next + model%vil_ms = model%vil_ms_next + model%vil_phi_eval = model%vil_phi + END IF END IF model%q = model%q_step model%v = model%v_step @@ -3376,7 +3416,8 @@ SUBROUTINE save_recovery_state(model) CALL commit_state_copy(model, .FALSE., model%recovery_q0, model%recovery_v0, model%recovery_a0, & model%recovery_ve_dl_1, model%recovery_syrope_slow, model%recovery_syrope_tmax, & model%recovery_fr_anchor, model%recovery_l0_c, model%recovery_l0_dot_c, & - model%recovery_viv_phi, model%recovery_viv_ms) + model%recovery_viv_phi, model%recovery_viv_ms, model%recovery_vil_phi, & + model%recovery_vil_ms) END SUBROUTINE save_recovery_state SUBROUTINE restore_recovery_state(model) @@ -3385,7 +3426,8 @@ SUBROUTINE restore_recovery_state(model) CALL commit_state_copy(model, .TRUE., model%recovery_q0, model%recovery_v0, model%recovery_a0, & model%recovery_ve_dl_1, model%recovery_syrope_slow, model%recovery_syrope_tmax, & model%recovery_fr_anchor, model%recovery_l0_c, model%recovery_l0_dot_c, & - model%recovery_viv_phi, model%recovery_viv_ms) + model%recovery_viv_phi, model%recovery_viv_ms, model%recovery_vil_phi, & + model%recovery_vil_ms) model%ve_dt = CD_ZERO END SUBROUTINE restore_recovery_state @@ -3883,7 +3925,7 @@ SUBROUTINE CD_Set_Model_Syrope_State(model, slow, tmax, ErrStat, ErrMsg) END SUBROUTINE CD_Set_Model_Syrope_State SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, ErrMsg, phase_seed, & - tangent_reversed) + tangent_reversed, clx, il_alpha) !! Install the cross-flow VIV model (CableDyn_VIV) on an initialised line. Per element: !! the lift coefficient cl (0 = no lift on that element), hydrodynamic diameter, and the !! synchronisation centre cf and half-range df of the non-dimensional shedding frequency; @@ -3899,6 +3941,10 @@ SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, !! An all-zero cl leaves the model without VIV. The mesh must be the single chain the !! line builder makes (element e joins nodes e and e+1). The caller recomputes the !! acceleration if the lift should enter the initial state (CD_Recompute_Model_Acceleration). + !! In-line VIV (Ulveseter et al. 2018; both or neither): clx, per element, the in-line shedding + !! coefficient (0: none; > 0 only where cl > 0, the in-line phase running at twice the + !! cross-flow one) and il_alpha its band (0 <= alpha < 1); the in-line phase of a node starts at + !! twice its cross-flow phase. TYPE(CD_ModelType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: rho, cl(:), diameter(:), cf(:), df(:), t_window INTEGER, INTENT(OUT) :: ErrStat @@ -3908,8 +3954,10 @@ SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, !! MoorDyn's, so a node at rest takes the cross-flow phase pi (CD_VIV_Phase_Rate phi_rest); !! .FALSE. on a line the reader turned around, whose tangent runs as MoorDyn's LOGICAL, INTENT(IN), OPTIONAL :: tangent_reversed + REAL(wp), INTENT(IN), OPTIONAL :: clx(:), il_alpha(:) INTEGER :: n_nodes, n_elem, e, nd, istat, k REAL(wp) :: wsum + LOGICAL :: want_il ErrStat = CD_MODEL_OK ErrMsg = '' @@ -3943,6 +3991,31 @@ SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, RETURN END IF END IF + IF (PRESENT(clx) .NEQV. PRESENT(il_alpha)) THEN + CALL fail(ErrStat, ErrMsg, 'in-line VIV clx and il_alpha go together') + RETURN + END IF + want_il = .FALSE. + IF (PRESENT(clx)) THEN + IF (SIZE(clx) /= n_elem .OR. SIZE(il_alpha) /= n_elem) THEN + CALL fail(ErrStat, ErrMsg, 'in-line VIV clx and il_alpha must each have shape (n_elem)') + RETURN + END IF + IF (.NOT. (CD_All_Finite(clx) .AND. CD_All_Finite(il_alpha))) THEN + CALL fail(ErrStat, ErrMsg, 'in-line VIV clx and il_alpha must be finite') + RETURN + END IF + IF (ANY(clx < CD_ZERO) .OR. ANY(clx > CD_ZERO .AND. .NOT. (il_alpha >= CD_ZERO .AND. il_alpha < CD_ONE))) THEN + CALL fail(ErrStat, ErrMsg, 'in-line VIV needs clx >= 0 and 0 <= il_alpha < 1 where clx > 0') + RETURN + END IF + IF (ANY(clx > CD_ZERO .AND. .NOT. (cl > CD_ZERO))) THEN + CALL fail(ErrStat, ErrMsg, 'in-line VIV (clx > 0) needs the cross-flow lift (cl > 0) on the same '// & + 'element: its phase rate is twice the cross-flow one') + RETURN + END IF + want_il = ANY(clx > CD_ZERO) + END IF CALL clear_viv(model) IF (.NOT. ANY(cl > CD_ZERO)) RETURN IF (.NOT. (CD_Is_Finite(rho) .AND. rho > CD_ZERO)) THEN @@ -4020,6 +4093,43 @@ SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, model%viv_phi_rest = 0.5_wp*CD_VIV_TWO_PI IF (PRESENT(tangent_reversed)) model%viv_phi_rest = MERGE(0.5_wp*CD_VIV_TWO_PI, CD_ZERO, tangent_reversed) model%has_viv = .TRUE. + IF (.NOT. want_il) RETURN + ALLOCATE (model%vil_cx(n_elem), model%vil_alpha(n_nodes), model%vil_node(n_nodes), model%vil_phi(n_nodes), & + model%vil_ms(2, n_nodes), model%vil_phi_rollback(n_nodes), model%vil_ms_rollback(2, n_nodes), & + model%recovery_vil_phi(n_nodes), model%recovery_vil_ms(2, n_nodes), model%vil_phi_eval(n_nodes), & + model%vil_rate(n_nodes), model%vil_ms_next(2, n_nodes), model%vil_phi_next(n_nodes), STAT=istat) + IF (istat /= 0) THEN + CALL clear_viv(model) + CALL alloc_fail(ErrStat, ErrMsg, 'in-line VIV storage allocation failed') + RETURN + END IF + model%vil_cx = MERGE(clx, CD_ZERO, clx > CD_ZERO) + model%vil_alpha = CD_ZERO + model%vil_node = .FALSE. + model%vil_phi = CD_ZERO + model%vil_ms = CD_ZERO + DO nd = 2, n_nodes - 1 + IF (.NOT. model%viv_node(nd)) CYCLE + wsum = CD_ZERO + DO k = nd - 1, nd + IF (.NOT. (clx(k) > CD_ZERO)) CYCLE + wsum = wsum + model%l0(k) + model%vil_alpha(nd) = model%vil_alpha(nd) + model%l0(k)*il_alpha(k) + END DO + IF (.NOT. (wsum > CD_ZERO)) CYCLE + model%vil_node(nd) = .TRUE. + model%vil_alpha(nd) = model%vil_alpha(nd)/wsum + model%vil_phi(nd) = CD_VIV_Wrap_Phase(2.0_wp*model%viv_phi(nd)) + END DO + model%vil_phi_rollback = model%vil_phi + model%vil_ms_rollback = model%vil_ms + model%recovery_vil_phi = model%vil_phi + model%recovery_vil_ms = model%vil_ms + model%vil_phi_eval = model%vil_phi + model%vil_rate = CD_ZERO + model%vil_ms_next = model%vil_ms + model%vil_phi_next = model%vil_phi + model%has_viv_il = .TRUE. END SUBROUTINE CD_Set_Model_VIV SUBROUTINE CD_Latch_Model_VIV_Window(model, dt) @@ -4034,17 +4144,22 @@ SUBROUTINE CD_Latch_Model_VIV_Window(model, dt) model%viv_tw = REAL(CD_VIV_NM, wp)*dt END SUBROUTINE CD_Latch_Model_VIV_Window - SUBROUTINE CD_Get_Model_VIV_State(model, phi, ms, t_window, ErrStat, ErrMsg) + SUBROUTINE CD_Get_Model_VIV_State(model, phi, ms, t_window, ErrStat, ErrMsg, phi_x, ms_x) !! Copy the committed VIV state for a checkpoint: the shedding phase per node (n_nodes), !! the running mean squares of the cross-flow velocity and acceleration (2, n_nodes), and - !! the averaging time (0 while unlatched). A model without VIV returns zeros. + !! the averaging time (0 while unlatched). A model without VIV returns zeros. phi_x and ms_x + !! (both or neither, same shapes) take the in-line phase and mean squares, zero without + !! in-line VIV. TYPE(CD_ModelType), INTENT(IN) :: model REAL(wp), INTENT(OUT) :: phi(:), ms(:, :), t_window INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: phi_x(:), ms_x(:, :) phi = CD_ZERO ms = CD_ZERO t_window = CD_ZERO + IF (PRESENT(phi_x)) phi_x = CD_ZERO + IF (PRESENT(ms_x)) ms_x = CD_ZERO ErrStat = CD_MODEL_OK ErrMsg = '' IF (.NOT. model%initialized) THEN @@ -4056,20 +4171,36 @@ SUBROUTINE CD_Get_Model_VIV_State(model, phi, ms, t_window, ErrStat, ErrMsg) CALL fail(ErrStat, ErrMsg, 'VIV state outputs must have shapes (n_nodes) and (2, n_nodes)') RETURN END IF + IF (PRESENT(phi_x) .NEQV. PRESENT(ms_x)) THEN + CALL fail(ErrStat, ErrMsg, 'in-line VIV state outputs phi_x and ms_x go together') + RETURN + END IF + IF (PRESENT(phi_x)) THEN + IF (SIZE(phi_x) /= model%n_dof/3 .OR. SIZE(ms_x, 1) /= 2 .OR. SIZE(ms_x, 2) /= model%n_dof/3) THEN + CALL fail(ErrStat, ErrMsg, 'in-line VIV state outputs must have shapes (n_nodes) and (2, n_nodes)') + RETURN + END IF + END IF IF (.NOT. model%has_viv) RETURN phi = model%viv_phi ms = model%viv_ms t_window = model%viv_tw + IF (PRESENT(phi_x) .AND. model%has_viv_il) THEN + phi_x = model%vil_phi + ms_x = model%vil_ms + END IF END SUBROUTINE CD_Get_Model_VIV_State - SUBROUTINE CD_Set_Model_VIV_State(model, phi, ms, t_window, ErrStat, ErrMsg) + SUBROUTINE CD_Set_Model_VIV_State(model, phi, ms, t_window, ErrStat, ErrMsg, phi_x, ms_x) !! Overwrite the committed VIV state from a checkpoint (see CD_Get_Model_VIV_State). !! Fails closed on a model without VIV, a shape mismatch, non-finite values, a negative - !! mean square or averaging time. + !! mean square or averaging time. A model with in-line VIV needs phi_x and ms_x, one without + !! refuses them. TYPE(CD_ModelType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: phi(:), ms(:, :), t_window INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: phi_x(:), ms_x(:, :) ErrStat = CD_MODEL_OK ErrMsg = '' IF (.NOT. model%initialized) THEN @@ -4093,6 +4224,31 @@ SUBROUTINE CD_Set_Model_VIV_State(model, phi, ms, t_window, ErrStat, ErrMsg) CALL fail(ErrStat, ErrMsg, 'VIV mean squares and averaging time must be non-negative') RETURN END IF + IF (((PRESENT(phi_x) .AND. PRESENT(ms_x)) .NEQV. model%has_viv_il) .OR. (PRESENT(phi_x) .NEQV. PRESENT(ms_x))) THEN + CALL fail(ErrStat, ErrMsg, 'the in-line VIV state (phi_x, ms_x) goes with a model with in-line VIV') + RETURN + END IF + IF (model%has_viv_il) THEN + IF (SIZE(phi_x) /= model%n_dof/3 .OR. SIZE(ms_x, 1) /= 2 .OR. SIZE(ms_x, 2) /= model%n_dof/3) THEN + CALL fail(ErrStat, ErrMsg, 'in-line VIV state inputs must have shapes (n_nodes) and (2, n_nodes)') + RETURN + END IF + IF (.NOT. (CD_All_Finite(phi_x) .AND. CD_All_Finite(ms_x))) THEN + CALL fail(ErrStat, ErrMsg, 'in-line VIV state mirror must be finite') + RETURN + END IF + IF (ANY(ms_x < CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'in-line VIV mean squares must be non-negative') + RETURN + END IF + model%vil_phi = phi_x + model%vil_ms = ms_x + model%vil_phi_rollback = phi_x + model%vil_ms_rollback = ms_x + model%recovery_vil_phi = phi_x + model%recovery_vil_ms = ms_x + model%vil_phi_eval = phi_x + END IF model%viv_phi = phi model%viv_ms = ms model%viv_tw = t_window @@ -4111,8 +4267,7 @@ SUBROUTINE CD_Get_Model_VIV_Lift(model, lift, ErrStat, ErrMsg) REAL(wp), INTENT(OUT) :: lift(:, :) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: nd, ia - REAL(wp) :: coef, uu(3) + INTEGER :: nd LOGICAL :: ok lift = CD_ZERO ErrStat = CD_MODEL_OK @@ -4129,30 +4284,81 @@ SUBROUTINE CD_Get_Model_VIV_Lift(model, lift, ErrStat, ErrMsg) IF (.NOT. model%has_viv) RETURN DO nd = 2, model%n_dof/3 - 1 IF (.NOT. model%viv_node(nd)) CYCLE - CALL viv_node_coef(model, model%q, nd, coef, uu) - ia = 3*nd - 2 - CALL CD_VIV_Node_Lift(model%q(ia - 3:ia - 1), model%q(ia + 3:ia + 5), smoothed(model%v, ia), uu, coef, & - model%viv_phi(nd), lift(:, nd), ok) + CALL viv_node_load(model, model%q, model%v, nd, .FALSE., lift(:, nd), ok) END DO END SUBROUTINE CD_Get_Model_VIV_Lift + PURE LOGICAL FUNCTION CD_Model_Has_VIV_Inline(model) RESULT(has) + !! True if the model carries the in-line VIV phase state (as well as the cross-flow one). + TYPE(CD_ModelType), INTENT(IN) :: model + has = model%has_viv_il + END FUNCTION CD_Model_Has_VIV_Inline + + SUBROUTINE viv_node_load(model, q, v, nd, in_step, force, ok, jac_v, jac_prev, jac_next) + !! The VIV load on interior node nd at (q, v): the cross-flow lift (CD_VIV_Node_Lift) and, + !! with in-line VIV, the in-line force (CD_VIV_Node_Inline), at the step's evaluation phases + !! (in_step) or the committed ones, with the smoothed node velocity; the residual Jacobians + !! with respect to that velocity and the two neighbour positions (all three or none). + TYPE(CD_ModelType), INTENT(IN) :: model + REAL(wp), INTENT(IN) :: q(:), v(:) + INTEGER, INTENT(IN) :: nd + LOGICAL, INTENT(IN) :: in_step + REAL(wp), INTENT(OUT) :: force(3) + LOGICAL, INTENT(OUT) :: ok + REAL(wp), INTENT(OUT), OPTIONAL :: jac_v(3, 3), jac_prev(3, 3), jac_next(3, 3) + REAL(wp) :: coef, coefx, uu(3), phi, fx(3), jv(3, 3), jp(3, 3), jn(3, 3) + INTEGER :: ia + LOGICAL :: il + il = .FALSE. + IF (model%has_viv_il) il = model%vil_node(nd) + IF (il) THEN + CALL viv_node_coef(model, q, nd, coef, uu, coefx) + ELSE + CALL viv_node_coef(model, q, nd, coef, uu) + END IF + ia = 3*nd - 2 + phi = model%viv_phi(nd) + IF (in_step) phi = model%viv_phi_eval(nd) + IF (PRESENT(jac_v)) THEN + CALL CD_VIV_Node_Lift(q(ia - 3:ia - 1), q(ia + 3:ia + 5), smoothed(v, ia), uu, coef, phi, force, ok, & + jac_v, jac_prev, jac_next) + ELSE + CALL CD_VIV_Node_Lift(q(ia - 3:ia - 1), q(ia + 3:ia + 5), smoothed(v, ia), uu, coef, phi, force, ok) + END IF + IF (.NOT. (ok .AND. il)) RETURN + phi = model%vil_phi(nd) + IF (in_step) phi = model%vil_phi_eval(nd) + IF (PRESENT(jac_v)) THEN + CALL CD_VIV_Node_Inline(q(ia - 3:ia - 1), q(ia + 3:ia + 5), smoothed(v, ia), uu, coefx, phi, fx, ok, jv, jp, jn) + jac_v = jac_v + jv + jac_prev = jac_prev + jp + jac_next = jac_next + jn + ELSE + CALL CD_VIV_Node_Inline(q(ia - 3:ia - 1), q(ia + 3:ia + 5), smoothed(v, ia), uu, coefx, phi, fx, ok) + END IF + force = force + fx + END SUBROUTINE viv_node_load + PURE LOGICAL FUNCTION CD_Model_Has_VIV(model) RESULT(has) !! True if the model carries the cross-flow VIV phase state. TYPE(CD_ModelType), INTENT(IN) :: model has = model%has_viv END FUNCTION CD_Model_Has_VIV - SUBROUTINE viv_node_coef(model, q, nd, coef, uu) + SUBROUTINE viv_node_coef(model, q, nd, coef, uu, coefx) !! Lift scale of interior node nd at positions q, sum over its two elements of !! (1/2 l0_e w_e)(1/2 rho D_e Cl_e) with w_e the wetted fraction under the drag waterline - !! (as MoorDyn's 1/4 rho d Cl (F_i l_i + F_i+1 l_i+1)), and the ambient fluid velocity there. + !! (as MoorDyn's 1/4 rho d Cl (F_i l_i + F_i+1 l_i+1)), and the ambient fluid velocity there; + !! coefx (optional, in-line VIV) the same sum with the in-line coefficient C_x. TYPE(CD_ModelType), INTENT(IN) :: model REAL(wp), INTENT(IN) :: q(:) INTEGER, INTENT(IN) :: nd REAL(wp), INTENT(OUT) :: coef, uu(3) + REAL(wp), INTENT(OUT), OPTIONAL :: coefx INTEGER :: e REAL(wp) :: wla, wlb, frac coef = CD_ZERO + IF (PRESENT(coefx)) coefx = CD_ZERO DO e = nd - 1, nd IF (.NOT. (model%viv_cl(e) > CD_ZERO)) CYCLE wla = CD_ZERO @@ -4163,6 +4369,7 @@ SUBROUTINE viv_node_coef(model, q, nd, coef, uu) END IF CALL CD_Submerged_Fraction(q(3*e) - wla, q(3*e + 3) - wlb, frac) coef = coef + 0.25_wp*model%viv_rho*model%viv_d(e)*model%viv_cl(e)*model%l0(e)*frac + IF (PRESENT(coefx)) coefx = coefx + 0.25_wp*model%viv_rho*model%viv_d(e)*model%vil_cx(e)*model%l0(e)*frac END DO uu = CD_ZERO IF (ALLOCATED(model%fluid_velocity)) uu = model%fluid_velocity(:, nd) @@ -4180,7 +4387,7 @@ SUBROUTINE viv_step_begin(model, dt, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: nd, ia - REAL(wp) :: w, alpha_f, yd, ydd, un, coef, uu(3) + REAL(wp) :: w, alpha_f, yd, ydd, un, coef, uu(3), xd, xdd LOGICAL :: ok ErrStat = CD_MODEL_OK ErrMsg = '' @@ -4191,12 +4398,17 @@ SUBROUTINE viv_step_begin(model, dt, ErrStat, ErrMsg) model%viv_rate = CD_ZERO model%viv_ms_next = model%viv_ms model%viv_phi_eval = model%viv_phi + IF (model%has_viv_il) THEN + model%vil_rate = CD_ZERO + model%vil_ms_next = model%vil_ms + model%vil_phi_eval = model%vil_phi + END IF DO nd = 2, model%n_dof/3 - 1 IF (.NOT. model%viv_node(nd)) CYCLE CALL viv_node_coef(model, model%q, nd, coef, uu) ia = 3*nd - 2 CALL CD_VIV_Crossflow_Motion(model%q(ia - 3:ia - 1), model%q(ia + 3:ia + 5), smoothed(model%v, ia), & - smoothed(model%a, ia), uu, yd, ydd, un, ok) + smoothed(model%a, ia), uu, yd, ydd, un, ok, xd, xdd) IF (.NOT. ok) THEN CALL fail(ErrStat, ErrMsg, 'VIV phase: the neighbours of a node coincide (no line tangent)') RETURN @@ -4207,6 +4419,13 @@ SUBROUTINE viv_step_begin(model, dt, ErrStat, ErrMsg) model%viv_phi(nd), un, model%viv_dn(nd), model%viv_cf(nd), & model%viv_df(nd), phi_rest=model%viv_phi_rest) model%viv_phi_eval(nd) = model%viv_phi(nd) + (CD_ONE - alpha_f)*dt*model%viv_rate(nd) + IF (.NOT. model%has_viv_il) CYCLE + IF (.NOT. model%vil_node(nd)) CYCLE + model%vil_ms_next(1, nd) = CD_VIV_Mean_Square(model%vil_ms(1, nd), xd, w) + model%vil_ms_next(2, nd) = CD_VIV_Mean_Square(model%vil_ms(2, nd), xdd, w) + model%vil_rate(nd) = CD_VIV_Inline_Phase_Rate(xd, xdd, model%vil_ms_next(1, nd), model%vil_ms_next(2, nd), & + model%vil_phi(nd), model%viv_rate(nd), model%vil_alpha(nd)) + model%vil_phi_eval(nd) = model%vil_phi(nd) + (CD_ONE - alpha_f)*dt*model%vil_rate(nd) END DO END SUBROUTINE viv_step_begin @@ -4220,18 +4439,20 @@ SUBROUTINE viv_step_end(model, dt, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: nd, ia - REAL(wp) :: w, yd, ydd, un, coef, uu(3), ms1, ms2, rate_end + REAL(wp) :: w, yd, ydd, un, coef, uu(3), ms1, ms2, rate_end, xd, xdd, rate_end_x LOGICAL :: ok ErrStat = CD_MODEL_OK ErrMsg = '' w = MIN(CD_ONE, dt/model%viv_tw) model%viv_phi_next = model%viv_phi + IF (model%has_viv_il) model%vil_phi_next = model%vil_phi DO nd = 2, model%n_dof/3 - 1 IF (.NOT. model%viv_node(nd)) CYCLE CALL viv_node_coef(model, model%q_step, nd, coef, uu) ia = 3*nd - 2 CALL CD_VIV_Crossflow_Motion(model%q_step(ia - 3:ia - 1), model%q_step(ia + 3:ia + 5), & - smoothed(model%v_step, ia), smoothed(model%a_step, ia), uu, yd, ydd, un, ok) + smoothed(model%v_step, ia), smoothed(model%a_step, ia), uu, yd, ydd, un, ok, & + xd, xdd) IF (.NOT. ok) THEN CALL fail(ErrStat, ErrMsg, 'VIV phase: the neighbours of a node coincide (no line tangent)') RETURN @@ -4241,10 +4462,23 @@ SUBROUTINE viv_step_end(model, dt, ErrStat, ErrMsg) rate_end = CD_VIV_Phase_Rate(yd, ydd, ms1, ms2, model%viv_phi(nd) + dt*model%viv_rate(nd), un, & model%viv_dn(nd), model%viv_cf(nd), model%viv_df(nd), phi_rest=model%viv_phi_rest) model%viv_phi_next(nd) = CD_VIV_Wrap_Phase(model%viv_phi(nd) + 0.5_wp*dt*(model%viv_rate(nd) + rate_end)) + IF (.NOT. model%has_viv_il) CYCLE + IF (.NOT. model%vil_node(nd)) CYCLE + ! the in-line rate at the end state is slaved to the end cross-flow rate (Eq. 6) + ms1 = CD_VIV_Mean_Square(model%vil_ms_next(1, nd), xd, w) + ms2 = CD_VIV_Mean_Square(model%vil_ms_next(2, nd), xdd, w) + rate_end_x = CD_VIV_Inline_Phase_Rate(xd, xdd, ms1, ms2, model%vil_phi(nd) + dt*model%vil_rate(nd), & + rate_end, model%vil_alpha(nd)) + model%vil_phi_next(nd) = CD_VIV_Wrap_Phase(model%vil_phi(nd) + 0.5_wp*dt*(model%vil_rate(nd) + rate_end_x)) END DO IF (.NOT. CD_All_Finite(model%viv_phi_next)) THEN CALL fail(ErrStat, ErrMsg, 'VIV phase update produced a non-finite phase') END IF + IF (model%has_viv_il) THEN + IF (.NOT. CD_All_Finite(model%vil_phi_next)) THEN + CALL fail(ErrStat, ErrMsg, 'in-line VIV phase update produced a non-finite phase') + END IF + END IF END SUBROUTINE viv_step_end PURE FUNCTION smoothed(x, ia) RESULT(xs) @@ -4282,6 +4516,20 @@ SUBROUTINE clear_viv(model) IF (ALLOCATED(model%viv_rate)) DEALLOCATE (model%viv_rate) IF (ALLOCATED(model%viv_ms_next)) DEALLOCATE (model%viv_ms_next) IF (ALLOCATED(model%viv_phi_next)) DEALLOCATE (model%viv_phi_next) + IF (ALLOCATED(model%vil_cx)) DEALLOCATE (model%vil_cx) + IF (ALLOCATED(model%vil_alpha)) DEALLOCATE (model%vil_alpha) + IF (ALLOCATED(model%vil_node)) DEALLOCATE (model%vil_node) + IF (ALLOCATED(model%vil_phi)) DEALLOCATE (model%vil_phi) + IF (ALLOCATED(model%vil_ms)) DEALLOCATE (model%vil_ms) + IF (ALLOCATED(model%vil_phi_rollback)) DEALLOCATE (model%vil_phi_rollback) + IF (ALLOCATED(model%vil_ms_rollback)) DEALLOCATE (model%vil_ms_rollback) + IF (ALLOCATED(model%recovery_vil_phi)) DEALLOCATE (model%recovery_vil_phi) + IF (ALLOCATED(model%recovery_vil_ms)) DEALLOCATE (model%recovery_vil_ms) + IF (ALLOCATED(model%vil_phi_eval)) DEALLOCATE (model%vil_phi_eval) + IF (ALLOCATED(model%vil_rate)) DEALLOCATE (model%vil_rate) + IF (ALLOCATED(model%vil_ms_next)) DEALLOCATE (model%vil_ms_next) + IF (ALLOCATED(model%vil_phi_next)) DEALLOCATE (model%vil_phi_next) + model%has_viv_il = .FALSE. model%has_viv = .FALSE. model%viv_rho = CD_ZERO model%viv_tw = CD_ZERO @@ -7040,6 +7288,33 @@ SUBROUTINE CD_Copy_Model(src, dst, ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) RETURN CALL copy_real1(src%viv_phi_next, work%viv_phi_next, 'viv_phi_next', ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) RETURN + work%has_viv_il = src%has_viv_il + CALL copy_real1(src%vil_cx, work%vil_cx, 'vil_cx', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%vil_alpha, work%vil_alpha, 'vil_alpha', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_logical1(src%vil_node, work%vil_node, 'vil_node', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%vil_phi, work%vil_phi, 'vil_phi', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real2(src%vil_ms, work%vil_ms, 'vil_ms', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%vil_phi_rollback, work%vil_phi_rollback, 'vil_phi_rollback', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real2(src%vil_ms_rollback, work%vil_ms_rollback, 'vil_ms_rollback', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%recovery_vil_phi, work%recovery_vil_phi, 'recovery_vil_phi', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real2(src%recovery_vil_ms, work%recovery_vil_ms, 'recovery_vil_ms', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%vil_phi_eval, work%vil_phi_eval, 'vil_phi_eval', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%vil_rate, work%vil_rate, 'vil_rate', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real2(src%vil_ms_next, work%vil_ms_next, 'vil_ms_next', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%vil_phi_next, work%vil_phi_next, 'vil_phi_next', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN work%initialized = src%initialized ! Commit: release the caller's previous model, then move the fully-built copy in component by @@ -7196,6 +7471,20 @@ SUBROUTINE commit_model_copy(from, to) CALL MOVE_ALLOC(from%viv_rate, to%viv_rate) CALL MOVE_ALLOC(from%viv_ms_next, to%viv_ms_next) CALL MOVE_ALLOC(from%viv_phi_next, to%viv_phi_next) + to%has_viv_il = from%has_viv_il + CALL MOVE_ALLOC(from%vil_cx, to%vil_cx) + CALL MOVE_ALLOC(from%vil_alpha, to%vil_alpha) + CALL MOVE_ALLOC(from%vil_node, to%vil_node) + CALL MOVE_ALLOC(from%vil_phi, to%vil_phi) + CALL MOVE_ALLOC(from%vil_ms, to%vil_ms) + CALL MOVE_ALLOC(from%vil_phi_rollback, to%vil_phi_rollback) + CALL MOVE_ALLOC(from%vil_ms_rollback, to%vil_ms_rollback) + CALL MOVE_ALLOC(from%recovery_vil_phi, to%recovery_vil_phi) + CALL MOVE_ALLOC(from%recovery_vil_ms, to%recovery_vil_ms) + CALL MOVE_ALLOC(from%vil_phi_eval, to%vil_phi_eval) + CALL MOVE_ALLOC(from%vil_rate, to%vil_rate) + CALL MOVE_ALLOC(from%vil_ms_next, to%vil_ms_next) + CALL MOVE_ALLOC(from%vil_phi_next, to%vil_phi_next) IF (from%has_bathymetry) THEN to%bathymetry%nx = from%bathymetry%nx @@ -7842,16 +8131,14 @@ SUBROUTINE model_contributor_load(model, q, v, force, jac_q, jac_v, ErrStat, Err IF (model%has_viv) THEN BLOCK INTEGER :: nd, ia - REAL(wp) :: fl(3), jv3(3, 3), jp3(3, 3), jn3(3, 3), coef, uu(3) + REAL(wp) :: fl(3), jv3(3, 3), jp3(3, 3), jn3(3, 3) LOGICAL :: ok DO nd = 2, SIZE(q)/3 - 1 IF (.NOT. model%viv_node(nd)) CYCLE - CALL viv_node_coef(model, q, nd, coef, uu) ia = 3*nd - 2 - CALL CD_VIV_Node_Lift(q(ia - 3:ia - 1), q(ia + 3:ia + 5), smoothed(v, ia), uu, coef, & - model%viv_phi_eval(nd), fl, ok, jv3, jp3, jn3) + CALL viv_node_load(model, q, v, nd, .TRUE., fl, ok, jv3, jp3, jn3) IF (.NOT. ok) THEN - CALL fail(ErrStat, ErrMsg, 'VIV lift: the neighbours of a node coincide (no line tangent)') + CALL fail(ErrStat, ErrMsg, 'VIV load: the neighbours of a node coincide (no line tangent)') RETURN END IF force(ia:ia + 2) = force(ia:ia + 2) + fl @@ -8161,16 +8448,14 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q ! and the position Jacobian through the node tangent (the two neighbours) BLOCK INTEGER :: nd, ia, ra, cb - REAL(wp) :: fl(3), jv3(3, 3), jp3(3, 3), jn3(3, 3), coef, uu(3) + REAL(wp) :: fl(3), jv3(3, 3), jp3(3, 3), jn3(3, 3) LOGICAL :: ok DO nd = 2, n/3 - 1 IF (.NOT. model%viv_node(nd)) CYCLE - CALL viv_node_coef(model, q, nd, coef, uu) ia = 3*nd - 2 - CALL CD_VIV_Node_Lift(q(ia - 3:ia - 1), q(ia + 3:ia + 5), smoothed(v, ia), uu, coef, & - model%viv_phi_eval(nd), fl, ok, jv3, jp3, jn3) + CALL viv_node_load(model, q, v, nd, .TRUE., fl, ok, jv3, jp3, jn3) IF (.NOT. ok) THEN - CALL fail(ErrStat, ErrMsg, 'VIV lift: the neighbours of a node coincide (no line tangent)') + CALL fail(ErrStat, ErrMsg, 'VIV load: the neighbours of a node coincide (no line tangent)') RETURN END IF force(ia:ia + 2) = force(ia:ia + 2) + fl @@ -8413,16 +8698,14 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node IF (model%has_viv .AND. .NOT. ends) THEN BLOCK INTEGER :: nd, ia - REAL(wp) :: fl(3), coef, uu(3) + REAL(wp) :: fl(3) LOGICAL :: ok DO nd = 2, nn - 1 IF (.NOT. model%viv_node(nd)) CYCLE - CALL viv_node_coef(model, q, nd, coef, uu) ia = 3*nd - 2 - CALL CD_VIV_Node_Lift(q(ia - 3:ia - 1), q(ia + 3:ia + 5), smoothed(v, ia), uu, coef, & - model%viv_phi_eval(nd), fl, ok) + CALL viv_node_load(model, q, v, nd, .TRUE., fl, ok) IF (.NOT. ok) THEN - CALL fail(ErrStat, ErrMsg, 'VIV lift: the neighbours of a node coincide (no line tangent)') + CALL fail(ErrStat, ErrMsg, 'VIV load: the neighbours of a node coincide (no line tangent)') RETURN END IF force(ia:ia + 2) = force(ia:ia + 2) + fl diff --git a/src/CableDyn_System.f90 b/src/CableDyn_System.f90 index 272563b..0f1fd32 100644 --- a/src/CableDyn_System.f90 +++ b/src/CableDyn_System.f90 @@ -18,6 +18,7 @@ MODULE CableDyn_System CD_Model_Has_Viscoelastic, CD_Get_Model_VE_Dl1, CD_Set_Model_VE_Dl1, & CD_Model_Has_Syrope, CD_Get_Model_Syrope_State, CD_Set_Model_Syrope_State, & CD_Model_Has_VIV, CD_Get_Model_VIV_State, CD_Set_Model_VIV_State, CD_Get_Model_VIV_Lift, & + CD_Model_Has_VIV_Inline, & CD_Model_Has_Friction, CD_Get_Model_Friction_Anchors, CD_Set_Model_Friction_Anchors, & CD_Latch_Model_VIV_Window, & CD_Get_Model_EndNodeMassDiag, CD_Get_Model_EndNodeAddedMass, & @@ -236,6 +237,8 @@ MODULE CableDyn_System ! VIV shedding phase and cross-flow mean squares join the snapshot (phi then the two ! mean squares per node, 3 per node: sized like snap_q, line by line). REAL(wp), ALLOCATABLE :: snap_viv(:) + ! and the in-line phase and mean squares of a line with in-line VIV, laid out the same way + REAL(wp), ALLOCATABLE :: snap_vil(:) LOGICAL :: snap_valid = .FALSE. ! Adaptive-substep fallback tripwire: how many times CD_Step_System entered the ! subdivision retry of this system since its initialisation or the last @@ -478,6 +481,7 @@ SUBROUTINE CD_End_System(system, ErrStat, ErrMsg) IF (ALLOCATED(system%snap_fbase)) DEALLOCATE (system%snap_fbase) IF (ALLOCATED(system%snap_ve_dl_1)) DEALLOCATE (system%snap_ve_dl_1) IF (ALLOCATED(system%snap_viv)) DEALLOCATE (system%snap_viv) + IF (ALLOCATED(system%snap_vil)) DEALLOCATE (system%snap_vil) IF (ALLOCATED(system%snap_syrope_slow)) DEALLOCATE (system%snap_syrope_slow, system%snap_syrope_tmax) IF (ALLOCATED(system%snap_fr_anchor)) DEALLOCATE (system%snap_fr_anchor) IF (ALLOCATED(system%snap_sub)) DEALLOCATE (system%snap_sub) @@ -954,19 +958,22 @@ END SUBROUTINE CD_Get_System_Line_Syrope_State PURE INTEGER FUNCTION CD_System_Line_VIV_MirrorSize(system, line_index) RESULT(n) !! Reals of one contained line's VIV checkpoint block (CD_Get_System_Line_VIV_State): - !! 3 per node plus the averaging time, or 0 for a line without VIV. + !! 3 per node plus the averaging time, 3 per node more with in-line VIV, or 0 for a line + !! without VIV. TYPE(CD_SystemType), INTENT(IN) :: system INTEGER, INTENT(IN) :: line_index n = 0 IF (line_index < 1 .OR. line_index > system%n_lines) RETURN IF (.NOT. CD_Model_Has_VIV(system%lines(line_index))) RETURN n = 3*SIZE(system%lines(line_index)%viv_phi) + 1 + IF (CD_Model_Has_VIV_Inline(system%lines(line_index))) n = n + 3*SIZE(system%lines(line_index)%viv_phi) END FUNCTION CD_System_Line_VIV_MirrorSize SUBROUTINE CD_Get_System_Line_VIV_State(system, line_index, buf, ErrStat, ErrMsg) !! One contained line's committed VIV state as a flat checkpoint block: the shedding !! phases (n_nodes), the cross-flow velocity and acceleration mean squares interleaved - !! per node (2 n_nodes), then the averaging time. + !! per node (2 n_nodes), then the averaging time; with in-line VIV then the in-line phases + !! and mean squares the same way (3 n_nodes). TYPE(CD_SystemType), INTENT(IN) :: system INTEGER, INTENT(IN) :: line_index REAL(wp), INTENT(OUT) :: buf(:) @@ -974,7 +981,7 @@ SUBROUTINE CD_Get_System_Line_VIV_State(system, line_index, buf, ErrStat, ErrMsg CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: nn, es CHARACTER(160) :: em - REAL(wp), ALLOCATABLE :: phi(:), ms(:, :) + REAL(wp), ALLOCATABLE :: phi(:), ms(:, :), phx(:), msx(:, :) buf = CD_ZERO CALL validate_line_index(system, line_index, ErrStat, ErrMsg) @@ -983,9 +990,9 @@ SUBROUTINE CD_Get_System_Line_VIV_State(system, line_index, buf, ErrStat, ErrMsg CALL fail(ErrStat, ErrMsg, 'line VIV state block has the wrong size') RETURN END IF - nn = (SIZE(buf) - 1)/3 - ALLOCATE (phi(nn), ms(2, nn)) - CALL CD_Get_Model_VIV_State(system%lines(line_index), phi, ms, buf(3*nn + 1), es, em) + nn = SIZE(system%lines(line_index)%viv_phi) + ALLOCATE (phi(nn), ms(2, nn), phx(nn), msx(2, nn)) + CALL CD_Get_Model_VIV_State(system%lines(line_index), phi, ms, buf(3*nn + 1), es, em, phi_x=phx, ms_x=msx) IF (es /= CD_MODEL_OK) THEN ErrStat = CD_SYSTEM_SOLVEFAIL ErrMsg = 'CableDyn_System: line VIV state query failed: '//TRIM(em) @@ -993,6 +1000,10 @@ SUBROUTINE CD_Get_System_Line_VIV_State(system, line_index, buf, ErrStat, ErrMsg END IF buf(1:nn) = phi buf(nn + 1:3*nn) = RESHAPE(ms, [2*nn]) + IF (CD_Model_Has_VIV_Inline(system%lines(line_index))) THEN + buf(3*nn + 2:4*nn + 1) = phx + buf(4*nn + 2:6*nn + 1) = RESHAPE(msx, [2*nn]) + END IF ErrStat = CD_SYSTEM_OK ErrMsg = '' END SUBROUTINE CD_Get_System_Line_VIV_State @@ -1014,9 +1025,15 @@ SUBROUTINE CD_Set_System_Line_VIV_State(system, line_index, buf, ErrStat, ErrMsg CALL fail(ErrStat, ErrMsg, 'line VIV state block has the wrong size') RETURN END IF - nn = (SIZE(buf) - 1)/3 - CALL CD_Set_Model_VIV_State(system%lines(line_index), buf(1:nn), RESHAPE(buf(nn + 1:3*nn), [2, nn]), & - buf(3*nn + 1), es, em) + nn = SIZE(system%lines(line_index)%viv_phi) + IF (CD_Model_Has_VIV_Inline(system%lines(line_index))) THEN + CALL CD_Set_Model_VIV_State(system%lines(line_index), buf(1:nn), RESHAPE(buf(nn + 1:3*nn), [2, nn]), & + buf(3*nn + 1), es, em, phi_x=buf(3*nn + 2:4*nn + 1), & + ms_x=RESHAPE(buf(4*nn + 2:6*nn + 1), [2, nn])) + ELSE + CALL CD_Set_Model_VIV_State(system%lines(line_index), buf(1:nn), RESHAPE(buf(nn + 1:3*nn), [2, nn]), & + buf(3*nn + 1), es, em) + END IF IF (es /= CD_MODEL_OK) THEN ErrStat = CD_SYSTEM_SOLVEFAIL ErrMsg = 'CableDyn_System: line VIV state reload failed: '//TRIM(em) @@ -1429,7 +1446,7 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, LOGICAL :: conv2, stall2 CHARACTER(1024) :: em REAL(wp), ALLOCATABLE :: q0(:), v0(:), a0(:), qm(:), vm(:), am(:), qs(:), vs(:), as(:) - REAL(wp), ALLOCATABLE :: dl1s(:), slows(:), tmaxs(:), frs(:, :), hmaxs(:), l0cs(:), l0dcs(:), vivs(:) + REAL(wp), ALLOCATABLE :: dl1s(:), slows(:), tmaxs(:), frs(:, :), hmaxs(:), l0cs(:), l0dcs(:), vivs(:), vils(:) TYPE(CD_SubstepStats), ALLOCATABLE :: subs(:) converged = .FALSE. @@ -1571,8 +1588,9 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, IF (CD_Model_Has_Friction(system%lines(i))) nfr = nfr + SIZE(system%lines(i)%fr_anchor, 2) END DO ALLOCATE (qs(ntot), vs(ntot), as(ntot), dl1s(nve), slows(nsy), tmaxs(nsy), frs(2, nfr), & - hmaxs(system%n_lines), subs(system%n_lines), l0cs(nel), l0dcs(nel), vivs(ntot)) + hmaxs(system%n_lines), subs(system%n_lines), l0cs(nel), l0dcs(nel), vivs(ntot), vils(ntot)) vivs = CD_ZERO + vils = CD_ZERO lo = 1 lo_ve = 1 lo_sy = 1 @@ -1588,6 +1606,7 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, hmaxs(i) = system%lines(i)%audit_hmax subs(i) = system%lines(i)%sub_stats IF (system%lines(i)%has_viv) CALL pack_viv(system%lines(i), vivs(lo:hi)) + IF (system%lines(i)%has_viv_il) CALL pack_vil(system%lines(i), vils(lo:hi)) lo = hi + 1 ne = SIZE(system%lines(i)%l0_c) l0cs(lo_el:lo_el + ne - 1) = system%lines(i)%l0_c @@ -1638,6 +1657,7 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, system%lines(i)%audit_hmax = hmaxs(i) system%lines(i)%sub_stats = subs(i) IF (system%lines(i)%has_viv) CALL unpack_viv(system%lines(i), vivs(lo:hi)) + IF (system%lines(i)%has_viv_il) CALL unpack_vil(system%lines(i), vils(lo:hi)) lo = hi + 1 ne = SIZE(system%lines(i)%l0_c) system%lines(i)%l0_c = l0cs(lo_el:lo_el + ne - 1) @@ -3353,6 +3373,10 @@ SUBROUTINE save_line_states(system, ErrStat, ErrMsg) system%lines(i)%viv_phi_rollback = system%lines(i)%viv_phi system%lines(i)%viv_ms_rollback = system%lines(i)%viv_ms END IF + IF (system%lines(i)%has_viv_il) THEN + system%lines(i)%vil_phi_rollback = system%lines(i)%vil_phi + system%lines(i)%vil_ms_rollback = system%lines(i)%vil_ms + END IF END DO END SUBROUTINE save_line_states @@ -3383,6 +3407,11 @@ SUBROUTINE restore_line_states(system) system%lines(i)%viv_ms = system%lines(i)%viv_ms_rollback system%lines(i)%viv_phi_eval = system%lines(i)%viv_phi END IF + IF (system%lines(i)%has_viv_il) THEN + system%lines(i)%vil_phi = system%lines(i)%vil_phi_rollback + system%lines(i)%vil_ms = system%lines(i)%vil_ms_rollback + system%lines(i)%vil_phi_eval = system%lines(i)%vil_phi + END IF END DO END SUBROUTINE restore_line_states @@ -3408,6 +3437,27 @@ PURE SUBROUTINE unpack_viv(line, buf) line%viv_phi_eval = line%viv_phi END SUBROUTINE unpack_viv + PURE SUBROUTINE pack_vil(line, buf) + !! A line's committed in-line VIV state as 3 reals per node (pack_viv's layout). + TYPE(CD_ModelType), INTENT(IN) :: line + REAL(wp), INTENT(OUT) :: buf(:) + INTEGER :: nn + nn = SIZE(line%vil_phi) + buf(1:nn) = line%vil_phi + buf(nn + 1:3*nn) = RESHAPE(line%vil_ms, [2*nn]) + END SUBROUTINE pack_vil + + PURE SUBROUTINE unpack_vil(line, buf) + !! Inverse of pack_vil; the in-step phase returns to the committed one. + TYPE(CD_ModelType), INTENT(INOUT) :: line + REAL(wp), INTENT(IN) :: buf(:) + INTEGER :: nn + nn = SIZE(line%vil_phi) + line%vil_phi = buf(1:nn) + line%vil_ms = RESHAPE(buf(nn + 1:3*nn), [2, nn]) + line%vil_phi_eval = line%vil_phi + END SUBROUTINE unpack_vil + SUBROUTINE restore_failed_step(system, failed_stat, msg, converged, stalled, n_iter, ErrStat, ErrMsg) TYPE(CD_SystemType), INTENT(INOUT) :: system INTEGER, INTENT(IN) :: failed_stat @@ -3507,7 +3557,8 @@ SUBROUTINE CD_System_Snapshot(system, ErrStat, ErrMsg) ALLOCATE (system%snap_l0(netot), system%snap_l0_dot(netot), system%snap_fbase(ntot), & system%snap_l0_c(netot), system%snap_l0_dot_c(netot), & system%snap_ve_dl_1(netot), system%snap_syrope_slow(netot), & - system%snap_syrope_tmax(netot), system%snap_fr_anchor(ntot), system%snap_viv(ntot)) + system%snap_syrope_tmax(netot), system%snap_fr_anchor(ntot), system%snap_viv(ntot), & + system%snap_vil(ntot)) END BLOCK END IF lo = 1 @@ -3522,6 +3573,7 @@ SUBROUTINE CD_System_Snapshot(system, ErrStat, ErrMsg) system%snap_fr_anchor(lo:lo + 2*SIZE(system%lines(i)%fr_anchor, 2) - 1) = & RESHAPE(system%lines(i)%fr_anchor, [2*SIZE(system%lines(i)%fr_anchor, 2)]) IF (system%lines(i)%has_viv) CALL pack_viv(system%lines(i), system%snap_viv(lo:hi)) + IF (system%lines(i)%has_viv_il) CALL pack_vil(system%lines(i), system%snap_vil(lo:hi)) lo = hi + 1 END DO IF (.NOT. ALLOCATED(system%snap_sub)) ALLOCATE (system%snap_sub(system%n_lines)) @@ -3592,6 +3644,7 @@ SUBROUTINE CD_System_Restore(system, ErrStat, ErrMsg) system%lines(i)%fr_anchor = RESHAPE(system%snap_fr_anchor(lo:lo + 2*SIZE(system%lines(i)%fr_anchor, 2) - 1), & [2, SIZE(system%lines(i)%fr_anchor, 2)]) IF (system%lines(i)%has_viv) CALL unpack_viv(system%lines(i), system%snap_viv(lo:hi)) + IF (system%lines(i)%has_viv_il) CALL unpack_vil(system%lines(i), system%snap_vil(lo:hi)) lo = hi + 1 END DO IF (ALLOCATED(system%snap_sub)) THEN diff --git a/tests/test_model.f90 b/tests/test_model.f90 index a16f32e..35e48fe 100644 --- a/tests/test_model.f90 +++ b/tests/test_model.f90 @@ -53,7 +53,8 @@ PROGRAM test_model CALL case_resolved_substeps() CALL case_substep_paths() CALL case_substep_snap_only() - CALL case_substeps_restore_viv_state() + CALL case_substeps_restore_viv_state(.FALSE.) + CALL case_substeps_restore_viv_state(.TRUE.) CALL case_coupled_load_sign() CALL case_coupled_motion_update() CALL case_external_load_update() @@ -1721,7 +1722,7 @@ SUBROUTINE case_damping_model_load() CALL require(es == CD_MODEL_OK, 'damping:end') END SUBROUTINE case_damping_model_load - SUBROUTINE case_substeps_restore_viv_state() + SUBROUTINE case_substeps_restore_viv_state(inline) !! The rotation-resolved sub-stepping of a line carrying VIV: a 10 m taut line in a 0.5 m/s !! cross current with Cl 0.8 on every element, End B heaved by 1 m over 2 s so that its !! chords turn by more than a degree per 0.02 s step. Solving the first sub-stepped pass @@ -1729,14 +1730,16 @@ SUBROUTINE case_substeps_restore_viv_state() !! nothing bit for bit, the shedding phases and running mean squares included; a failing !! sub-step (TEST-ONLY sub_test_fail) returns the plain step, and the run then equals the !! run with ei0_substeps off bit for bit. Without the VIV state in the sub-step slots the - !! sub-steps advanced the phase again from the plain step's phase. + !! sub-steps advanced the phase again from the plain step's phase. inline adds in-line VIV + !! (clx 0.85): its phase and mean squares follow the same rules, and a model copy carries them. + LOGICAL, INTENT(IN) :: inline INTEGER, PARAMETER :: NE = 10, NN = NE + 1, NSTEP = 60 REAL(wp), PARAMETER :: DT = 0.02_wp, AMP = 1.0_wp, PER = 2.0_wp TYPE(CD_ModelType) :: auto_m, rep_m, fb_m, off_m TYPE(GenAlphaConfig) :: cfg INTEGER :: conn(2, NE), fixed(6), es, k, n_iter REAL(wp) :: q0(3*NN), v0(3*NN), f_ext(3*NN), pq(3*NN), pv(3*NN), pa(3*NN), fluid(3, NN), wl(NN) - REAL(wp) :: l0(NE), ea(NE), rho_a(NE), cl(NE), dia(NE), cf(NE), df(NE), phi0(NN), w, t + REAL(wp) :: l0(NE), ea(NE), rho_a(NE), cl(NE), dia(NE), cf(NE), df(NE), phi0(NN), w, t, phx0(NN) LOGICAL :: conv, stalled, all_conv CHARACTER(200) :: em @@ -1766,10 +1769,17 @@ SUBROUTINE case_substeps_restore_viv_state() drag_diameter=0.1_wp, drag_cdn=1.2_wp, drag_cdt=0.0_wp) CALL require(es == CD_MODEL_OK, 'substep-viv:init: '//TRIM(em)) IF (es /= CD_MODEL_OK) RETURN - CALL CD_Set_Model_VIV(auto_m, 1025.0_wp, cl, dia, cf, df, 0.25_wp, es, em) + IF (inline) THEN + CALL CD_Set_Model_VIV(auto_m, 1025.0_wp, cl, dia, cf, df, 0.25_wp, es, em, clx=0.85_wp + 0.0_wp*cl, & + il_alpha=0.15_wp + 0.0_wp*cl) + ELSE + CALL CD_Set_Model_VIV(auto_m, 1025.0_wp, cl, dia, cf, df, 0.25_wp, es, em) + END IF CALL require(es == CD_MODEL_OK, 'substep-viv:viv: '//TRIM(em)) IF (es /= CD_MODEL_OK) RETURN + CALL require(auto_m%has_viv_il .EQV. inline, 'substep-viv:in-line installed as asked') phi0 = auto_m%viv_phi + IF (inline) phx0 = auto_m%vil_phi CALL CD_Copy_Model(auto_m, rep_m, es, em) rep_m%sub_test_repeat = .TRUE. CALL CD_Copy_Model(auto_m, fb_m, es, em) @@ -1807,6 +1817,14 @@ SUBROUTINE case_substeps_restore_viv_state() CALL require(fb_m%sub_stats%fallbacks > 0 .AND. ALL(fb_m%q == off_m%q) .AND. ALL(fb_m%v == off_m%v) .AND. & ALL(fb_m%a == off_m%a) .AND. ALL(fb_m%viv_phi == off_m%viv_phi) .AND. & ALL(fb_m%viv_ms == off_m%viv_ms), 'substep-viv:fallback-is-the-plain-step') + IF (inline) THEN + CALL require(rep_m%has_viv_il .AND. fb_m%has_viv_il .AND. off_m%has_viv_il, 'substep-viv:copies-carry-in-line') + CALL require(ANY(auto_m%vil_phi /= phx0) .AND. ANY(auto_m%vil_ms /= 0.0_wp), 'substep-viv:in-line-states-move') + CALL require(ALL(rep_m%vil_phi == auto_m%vil_phi) .AND. ALL(rep_m%vil_ms == auto_m%vil_ms), & + 'substep-viv:in-line-restore-is-complete') + CALL require(ALL(fb_m%vil_phi == off_m%vil_phi) .AND. ALL(fb_m%vil_ms == off_m%vil_ms), & + 'substep-viv:in-line-fallback-is-the-plain-step') + END IF CALL CD_End_Model(auto_m, es, em) CALL CD_End_Model(rep_m, es, em) CALL CD_End_Model(fb_m, es, em) diff --git a/tests/test_viv_coupled.f90 b/tests/test_viv_coupled.f90 index fd9aa2a..5304511 100644 --- a/tests/test_viv_coupled.f90 +++ b/tests/test_viv_coupled.f90 @@ -23,7 +23,10 @@ PROGRAM test_viv_coupled !! step: 0.5 s), and over 500 coupling steps when the deck has no dtM (5 s); !! * phase seed: MoorDyn's 2 pi i/N with node i counted from the deck's End A, also on a deck !! written anchor first (which the reader turns around) and, through CD_Deck_VIV_Phase_Seed, - !! at the deck nodes of a refined mesh (added nodes interpolated in arc length). + !! at the deck nodes of a refined mesh (added nodes interpolated in arc length); + !! * in-line VIV (a VIV section, ClX 0.85, on both lines): the checkpoint blocks grow by the + !! in-line phase and mean squares (3 per node), the restarted run continues bit for bit with + !! both phases, a rebuild without the VIV state does not, and a rewound step repeats. USE CableDyn_Precision, ONLY: wp USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_End, CD_AGG_OK, & CD_AGG_NMovingPoints, CD_AGG_GetMovingPointMesh, CD_AGG_Step_Moving, & @@ -41,15 +44,23 @@ PROGRAM test_viv_coupled REAL(wp), PARAMETER :: MD_AD = 0.662_wp, MD_F = 0.293_wp INTEGER, PARAMETER :: MID = 26 INTEGER :: nfail + ! the deck of the restart and rewind cases, and whether its lines carry in-line VIV + CHARACTER(32) :: deck_name = 'viv_coupled.dat' + LOGICAL :: il_case = .FALSE. nfail = 0 CALL write_deck('viv_coupled.dat', 0.8_wp) CALL write_deck('viv_coupled_nolift.dat', 0.0_wp) + CALL write_deck('viv_coupled_il.dat', 0.8_wp, inline=.TRUE.) CALL case_lockin() CALL case_restart() CALL case_rewind() CALL case_window() CALL case_seed() + deck_name = 'viv_coupled_il.dat' + il_case = .TRUE. + CALL case_restart() + CALL case_rewind() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' coupled VIV check(s) failed' ERROR STOP 1 @@ -96,7 +107,7 @@ SUBROUTINE case_restart() TYPE(CD_AGG_ModuleType) :: a, b, c INTEGER :: s LOGICAL :: same_b, same_c - IF (.NOT. start(a, 'viv_coupled.dat')) RETURN + IF (.NOT. start(a, TRIM(deck_name))) RETURN DO s = 1, NPRE IF (.NOT. advance(a)) RETURN END DO @@ -111,8 +122,8 @@ SUBROUTINE case_restart() same_b = same_b .AND. identical(a, b) same_c = same_c .AND. identical(a, c) END DO - CALL check(same_b, 'the restarted run continues bit for bit') - CALL check(.NOT. same_c, 'a restart without the VIV state does not') + CALL check(same_b, TRIM(deck_name)//': the restarted run continues bit for bit') + CALL check(.NOT. same_c, TRIM(deck_name)//': a restart without the VIV state does not') CALL finish(a) CALL finish(b) CALL finish(c) @@ -123,8 +134,8 @@ SUBROUTINE case_rewind() TYPE(CD_AGG_ModuleType) :: a, b INTEGER :: s, es CHARACTER(512) :: em - IF (.NOT. start(a, 'viv_coupled.dat')) RETURN - IF (.NOT. start(b, 'viv_coupled.dat')) RETURN + IF (.NOT. start(a, TRIM(deck_name))) RETURN + IF (.NOT. start(b, TRIM(deck_name))) RETURN DO s = 1, 500 IF (.NOT. advance(a)) RETURN IF (.NOT. advance(b)) RETURN @@ -138,7 +149,7 @@ SUBROUTINE case_rewind() IF (.NOT. advance(a)) RETURN IF (.NOT. advance(b)) RETURN END DO - CALL check(identical(a, b), 'a rewound step repeats bit for bit') + CALL check(identical(a, b), TRIM(deck_name)//': a rewound step repeats bit for bit') CALL CD_AGG_End(a, es, em) CALL CD_AGG_End(b, es, em) END SUBROUTINE case_rewind @@ -285,7 +296,7 @@ LOGICAL FUNCTION rebuild(a, b, with_viv) RESULT(ok) fresh(:) INTEGER :: es, npt, il, ndof, nv, nvc CHARACTER(512) :: em - ok = start(b, 'viv_coupled.dat') + ok = start(b, TRIM(deck_name)) IF (.NOT. ok) RETURN npt = CD_AGG_NMovingPoints(a, es, em) ALLOCATE (pos(3, npt), vel(3, npt), acc(3, npt), load(3, npt)) @@ -300,7 +311,7 @@ LOGICAL FUNCTION rebuild(a, b, with_viv) RESULT(ok) a_interior=aL(4:ndof - 3)) ok = ok .AND. es == CD_SYSTEM_OK nv = CD_System_Line_VIV_MirrorSize(a%sys%fast%system, il) - ok = ok .AND. nv == 3*(ndof/3) + 1 + ok = ok .AND. nv == MERGE(6, 3, il_case)*(ndof/3) + 1 IF (with_viv .AND. nv > 0) THEN ALLOCATE (buf(nv)) CALL CD_Get_System_Line_VIV_State(a%sys%fast%system, il, buf, es, em) @@ -313,7 +324,7 @@ LOGICAL FUNCTION rebuild(a, b, with_viv) RESULT(ok) ALLOCATE (buf(CD_HFMF_MirrorSize(a%cables(1))), fresh(CD_HFMF_MirrorSize(b%cables(1)))) CALL CD_HFMF_PackMirror(a%cables(1), buf, es, em) nvc = CD_HFMF_VIVMirrorSize(a%cables(1)) - ok = ok .AND. nvc == 3*a%cables(1)%line%nn + 1 + ok = ok .AND. nvc == MERGE(6, 3, il_case)*a%cables(1)%line%nn + 1 IF (.NOT. with_viv) THEN ! the cable's VIV block as the fresh build has it (the torsion-free cable ends with it) CALL CD_HFMF_PackMirror(b%cables(1), fresh, es, em) @@ -325,12 +336,16 @@ LOGICAL FUNCTION rebuild(a, b, with_viv) RESULT(ok) END FUNCTION rebuild LOGICAL FUNCTION identical(a, b) RESULT(same) - !! Both lines' state and shedding phases are the same bits. + !! Both lines' state and shedding phases (in-line too in the in-line case) are the same bits. TYPE(CD_AGG_ModuleType), INTENT(IN) :: a, b same = MAXVAL(ABS(a%sys%fast%system%lines(1)%q - b%sys%fast%system%lines(1)%q)) <= 0.0_wp .AND. & MAXVAL(ABS(a%sys%fast%system%lines(1)%viv_phi - b%sys%fast%system%lines(1)%viv_phi)) <= 0.0_wp .AND. & MAXVAL(ABS(a%cables(1)%line%q - b%cables(1)%line%q)) <= 0.0_wp .AND. & MAXVAL(ABS(a%cables(1)%line%viv_phi - b%cables(1)%line%viv_phi)) <= 0.0_wp + IF (.NOT. (same .AND. il_case)) RETURN + same = a%sys%fast%system%lines(1)%has_viv_il .AND. a%cables(1)%line%has_viv_il .AND. & + MAXVAL(ABS(a%sys%fast%system%lines(1)%vil_phi - b%sys%fast%system%lines(1)%vil_phi)) <= 0.0_wp .AND. & + MAXVAL(ABS(a%cables(1)%line%vil_phi - b%cables(1)%line%vil_phi)) <= 0.0_wp END FUNCTION identical SUBROUTINE response(z, ad, f) @@ -355,13 +370,14 @@ SUBROUTINE response(z, ad, f) IF (n > 1) f = REAL(n - 1, wp)/(t1 - t0) END SUBROUTINE response - SUBROUTINE write_deck(path, cl, window, dtm, anchor_first) + SUBROUTINE write_deck(path, cl, window, dtm, anchor_first, inline) !! The EI = 0 riser (line 1) and the finite-EI cable (line 2), 20 m apart across the current; - !! VIVrmsWindow 0.25 s unless window is given (0: none), and a deck dtM when dtm is given. + !! VIVrmsWindow 0.25 s unless window is given (0: none), and a deck dtM when dtm is given; + !! inline adds the in-line VIV of both types (a VIV section, ClX 0.85). CHARACTER(*), INTENT(IN) :: path REAL(wp), INTENT(IN) :: cl REAL(wp), INTENT(IN), OPTIONAL :: window, dtm - LOGICAL, INTENT(IN), OPTIONAL :: anchor_first + LOGICAL, INTENT(IN), OPTIONAL :: anchor_first, inline INTEGER :: u LOGICAL :: stock REAL(wp) :: tw @@ -396,6 +412,15 @@ SUBROUTINE write_deck(path, cl, window, dtm, anchor_first) WRITE (u, '(A)') '1 riser 1 2 '//TRIM(ADJUSTL(len_txt))//' 50 -' WRITE (u, '(A)') '2 cable 3 4 '//TRIM(ADJUSTL(len_txt))//' 50 -' END IF + IF (PRESENT(inline)) THEN + IF (inline) THEN + WRITE (u, '(A)') '--------------------- VIV ---' + WRITE (u, '(A)') 'TypeName ClX alpha' + WRITE (u, '(A)') '(name) (-) (-)' + WRITE (u, '(A)') 'riser 0.85 0.15' + WRITE (u, '(A)') 'cable 0.85 0.15' + END IF + END IF WRITE (u, '(A)') '--------------------- OPTIONS ---' WRITE (u, '(A)') '100.0 WtrDpth' WRITE (u, '(A)') '1025.0 rhoW' diff --git a/tests/test_viv_inline_deck.f90 b/tests/test_viv_inline_deck.f90 index a84c40c..39162cf 100644 --- a/tests/test_viv_inline_deck.f90 +++ b/tests/test_viv_inline_deck.f90 @@ -8,8 +8,11 @@ PROGRAM test_viv_inline_deck !! D1 with ClX 0.85 the quarter-span in-line (y) response oscillates at twice the mid-span !! cross-flow (z) frequency and is larger than without the VIV section; !! D2 a VIV row with ClX 0 is the deck without the section, to the printed digits; - !! D3 malformed rows, an unknown or repeated type, ClX on a type without the cross-flow lift, - !! alpha outside [0, 1) and in-line VIV on an EI = 0 line are refused by name. + !! D3 malformed rows, an unknown or repeated type, ClX on a type without the cross-flow lift + !! and alpha outside [0, 1) are refused by name; + !! D4 the same deck as an EI = 0 line (the lumped node force, neighbour-averaged kinematics) + !! matches the finite-EI cable: cross-flow and in-line amplitudes within 2 %, the same + !! frequencies within one 0.01 Hz bin. USE CableDyn_Precision, ONLY: wp USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK IMPLICIT NONE @@ -222,6 +225,34 @@ SUBROUTINE check_runs() ay_cf/D CALL require(ABS(fy/fz - 2.0_wp) <= 0.15_wp, 'D1: the in-line response is at twice the cross-flow frequency') CALL require(ay_il > 2.0_wp*ay_cf, 'D1: the in-line force raises the in-line response') + ! D4: the EI = 0 line + BLOCK + REAL(wp), ALLOCATABLE :: te(:, :) + INTEGER :: ne0 + REAL(wp) :: az_f, az_0, ay_f, ay_0, fz_f, fy_f + CALL window(ti, ni, 50.0_wp, tt, z, y) + az_f = 0.5_wp*(MAXVAL(z) - MINVAL(z)) + ay_f = 0.5_wp*(MAXVAL(y) - MINVAL(y)) + fz_f = peak_frequency(tt, z) + fy_f = peak_frequency(tt, y) + CALL write_deck('vid_ei0.dat', 'riser 0.85 0.15', 100.0_wp, ei='0.0') + CALL run('vid_ei0.dat', 'vid_ei0', ok, msg) + CALL require(ok, 'D4: the EI = 0 in-line VIV deck runs: '//TRIM(msg)) + CALL read_out('vid_ei0.out', te, ne0) + CALL require(ne0 == ni, 'D4: the EI = 0 run wrote the same rows') + IF (ne0 /= ni) RETURN + CALL window(te, ne0, 50.0_wp, tt, z, y) + az_0 = 0.5_wp*(MAXVAL(z) - MINVAL(z)) + ay_0 = 0.5_wp*(MAXVAL(y) - MINVAL(y)) + WRITE (*, '(A,2F8.4,A,2F8.4)') 'D4: CF and IL amplitude/D, EI = 0 line ', az_0/D, ay_0/D, & + ', finite-EI cable ', az_f/D, ay_f/D + WRITE (*, '(A,2F8.4,A,2F8.4)') 'D4: CF and IL frequency [Hz], EI = 0 line ', peak_frequency(tt, z), & + peak_frequency(tt, y), ', finite-EI cable ', fz_f, fy_f + CALL require(ABS(az_0/az_f - 1.0_wp) <= 0.02_wp .AND. ABS(ay_0/ay_f - 1.0_wp) <= 0.02_wp, & + 'D4: the EI = 0 line matches the cable''s amplitudes within 2 %') + CALL require(ABS(peak_frequency(tt, z) - fz_f) <= 0.01_wp .AND. ABS(peak_frequency(tt, y) - fy_f) <= 0.01_wp, & + 'D4: and its frequencies within 0.01 Hz') + END BLOCK END SUBROUTINE check_runs SUBROUTINE check_refusals() @@ -232,7 +263,6 @@ SUBROUTINE check_refusals() CALL refused('riser 0.85 1.0', '0 <= alpha < 1', 'alpha = 1') CALL refused('riser 0.85 x', 'plain numbers', 'a non-numeric alpha') CALL refused('riser 0.85', 'cross-flow lift', 'ClX on a type without the cross-flow lift', cl='0.0') - CALL refused('riser 0.85', 'finite-EI lines', 'in-line VIV on an EI = 0 line', ei='0.0') END SUBROUTINE check_refusals SUBROUTINE refused(rows, needle, what, ei, cl)