From 6f382485968497c0afea1ded1a421255042012c5 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Mon, 26 Oct 2026 18:24:59 +0900 Subject: [PATCH] fix(openfast): restart a finite-EI cable from its committed boundary openfast -restart did not continue a run with a finite-EI cable bit for bit. The checkpoint rebuild moves each coupled end to the restored input mesh, the glue's input at the restart time, and the cable's mirror held only its free DOFs: its fairlead kept the restored mesh's bits instead of the boundary the uninterrupted run committed (with NumCrctn = 0 that run stepped with the extrapolated input). The EI=0 lines already reload their committed coupled motion. On the IEA-15 mixed deck restarted at 6 s, the lazy-wave cable's .CD.out channels drifted by up to 9.4e-7 (relative) within 4 s, while the chain-only deck stayed exact. The cable mirror gains a boundary block, reloaded after the move: [q; v; a] of the held DOFs (the held accelerations move here from the force-blend block, so the configuration blend restores them too), the end-connection directions and the parent frame (orientation, angular velocity and acceleration). Unpacking checks the orientation before it writes anything. The parent frame of a torsion cable now reloads as committed instead of being re-derived from its end frames. With the fix every .CD.out and OpenFAST row from 6 s to 10 s matches the uninterrupted run bit for bit at dtM = DT and 2 DT, NumCrctn 0 and 1, and with a rigid fairlead END CONNECTIONS row (before: 3 to 6 rows of the cable's channels differed in each). The mirror test covers the new layout, its round trip and the orientation check. Signed-off-by: Jae Hoon Seo --- ARCHITECTURE.md | 9 +- CHANGELOG.md | 4 + VALIDATION.md | 2 +- src/CableDyn_OpenFAST_HermiteFMF.f90 | 125 +++++++++++++++++---------- src/openfast/CableDyn_OF.f90 | 23 ++--- tests/test_hfmf_mirror.f90 | 35 +++++--- 6 files changed, 123 insertions(+), 75 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 082923e3..c1acf3b6 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -360,10 +360,11 @@ the exchange buildable and testable without OpenFAST. committed positions and holds them for the step. - **State mirror.** The authoritative state lives in the module instance, and `x%states` carries a mirror of it: line node velocities and positions, finite-EI - cable DOFs, constitutive states (`dl_1`, Syrope), friction anchors, and body and - rod states. Checkpoint/restart, correction iterations, and the framework - metadata use the mirror; a restart rebuilds the model from the packed deck and - the mirror. + cable DOFs, constitutive states (`dl_1`, Syrope), friction anchors, the committed + boundary kinematics of the coupled ends, and body and rod states. + Checkpoint/restart, correction iterations, and the framework metadata use the + mirror; a restart rebuilds the model from the packed deck and the mirror, which + then overrides the restored input mesh at the coupled ends. - **Scope.** Correction iterations, quasi-static linearisation, FAST.Farm shared moorings (`MooringMod = 5`), line failures, and active line-length control are supported. Combinations that are not supported coupled stop with a named error; diff --git a/CHANGELOG.md b/CHANGELOG.md index a2735045..134915c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,10 @@ All notable changes to CableDyn are recorded in this file. The format follows have a three-digit exponent (`ES15.6E3`, same width). The mixed `EI = 0` + finite-EI `.out`, the modal results, the static driver's mesh file and the OpenFAST module driver, which wrote such values without the exponent letter, do too. +- `openfast -restart` with a finite-EI cable continues the run bit for bit. The rebuild moved the + cable's fairlead to the restored input mesh, whose last bits differ from the boundary the + uninterrupted run committed, and the cable's `.CD.out` channels drifted by up to 1e-6 + (relative) within seconds. The checkpoint now carries the cable's committed boundary. ## [0.3.0] - 2026-10-23 diff --git a/VALIDATION.md b/VALIDATION.md index db4eb82b..a0f24c89 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -776,7 +776,7 @@ stop with a named error. | Nonzero `PtfmInit` | Pass verified | 6-DOF displaced free decay ≤0.51% | | Correction iterations (`NumCrctn > 0`) | Pass verified | bit-identical to own `NumCrctn = 0` run | | SeaState wave/current kinematics | Pass verified | wave A/B ≤0.16% of range | -| Checkpoint-restart (incl. Free/Connect points) | Pass verified | restarted window = continuous run to 0.0; also with supercycling (`dtM` > `DT`, the held SeaState fields and the predictor loads checkpointed): IEA-15 VolturnUS-S, turbulent wind and JONSWAP sea, `openfast -restart` at 50 s reproduces every later OpenFAST and `.CD.out` row of the chain mooring at `dtM` = 4 `DT` (extrapolated and held loads) and `DT`, and of the chain + 248-element power-cable mooring at `dtM` = 2 `DT` | +| Checkpoint-restart (incl. Free/Connect points) | Pass verified | restarted window = continuous run to 0.0; also with supercycling (`dtM` > `DT`, the held SeaState fields and the predictor loads checkpointed): IEA-15 VolturnUS-S, turbulent wind and JONSWAP sea, `openfast -restart` at 50 s reproduces every later OpenFAST and `.CD.out` row of the chain mooring at `dtM` = 4 `DT` (extrapolated and held loads) and `DT`, and of the chain + 248-element power-cable mooring at `dtM` = 2 `DT`. A finite-EI cable also checkpoints its committed boundary (held DOFs, end-connection directions, vessel frame): before, the rebuild took its fairlead from the restored input mesh, which differs in the last bits, and on the IEA-15 mixed deck restarted at 6 s the lazy-wave cable's `.CD.out` channels drifted by up to 9.4e-7 (relative) within 4 s; now all rows to 10 s match bit for bit at `dtM` = `DT` and 2 `DT`, `NumCrctn` 0 and 1, and with a rigid fairlead END CONNECTIONS row | | Linearisation | Pass verified (quasi-static stiffness) | quasi-static `dYdu` compared entry by entry with stock MoorDyn's zero-frequency reduction `D − C A⁻¹ B` (full-precision `.lin` output): fairlead stiffness 0.07–0.10%, transverse `H/X` term 0.29%, platform 6×6 diagonals ≤0.10%; standalone static FD 1.5e-5; transverse term equals `H/X`. Velocity/acceleration columns are zero by design ([`openfast_lin_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_lin_ab.py)) | | FAST.Farm shared moorings + clumps + channel record | Pass verified | 600 s A/B of the r-test `MD_Shared` farm against stock MoorDyn (same deck, analysis from 100 s; [`fastfarm_shared_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/fastfarm_shared_ab.py)): tension means ≤0.02%, minima and maxima ≤0.25%, platform motions within millimetres and 0.001°; shared-line tension std 2.2–2.7% lower, 1.0% at half the mooring step (CableDyn's implicit step at the 0.05 s coupling step against MoorDyn's 1e-4 s explicit step). On the shared lines, which have no Fixed end, `FairTen`/`AnchTen` name the opposite ends from MoorDyn's (see the migration guide). MoorDyn's initial settling does not converge for the anchor legs 6 and 7 (2.4 m excess length at t = 0), a start-up transient over by 100 s that most likely set the 3% end of the earlier 60 s record | | Slack-line tension convention | Pass verified | tension-only dynamics; BA on slack lines matches `MoorDyn_Line.f90` | diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index ee0a94fd..c7533c28 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -84,6 +84,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF PUBLIC :: CD_HFMF_MinSpanZ PUBLIC :: CD_HFMF_MirrorSize PUBLIC :: CD_HFMF_FrictionMirrorSize + PUBLIC :: CD_HFMF_BoundaryMirrorSize PUBLIC :: CD_HFMF_ForceMirrorSize PUBLIC :: CD_HFMF_TorsionMirrorSize PUBLIC :: CD_HFMF_PackMirror @@ -1527,16 +1528,31 @@ INTEGER FUNCTION CD_HFMF_MirrorSize(self) RESULT(n) !! carries the committed acceleration, and unlike the EI=0 side (whose acceleration !! is re-derived by CD_Recompute_System_Acceleration) the cable reloads it exactly. !! A cable on a frictional seabed appends its stick-slip friction anchors, (x, y) per - !! node (CD_HFMF_FrictionMirrorSize slots): they are committed state like q. Zero if - !! uninitialised. + !! node (CD_HFMF_FrictionMirrorSize slots): they are committed state like q. Then come + !! the committed boundary (CD_HFMF_BoundaryMirrorSize), the force-blend state and the + !! torsion state. Zero if uninitialised. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self n = 0 IF (.NOT. self%initialized) RETURN IF (ALLOCATED(self%line%freemask)) n = 3*COUNT(self%line%freemask) - n = n + CD_HFMF_FrictionMirrorSize(self) + CD_HFMF_ForceMirrorSize(self) + & - CD_HFMF_TorsionMirrorSize(self) + n = n + CD_HFMF_FrictionMirrorSize(self) + CD_HFMF_BoundaryMirrorSize(self) + & + CD_HFMF_ForceMirrorSize(self) + CD_HFMF_TorsionMirrorSize(self) END FUNCTION CD_HFMF_MirrorSize + INTEGER FUNCTION CD_HFMF_BoundaryMirrorSize(self) RESULT(n) + !! Mirror slots of the committed boundary: [q; v; a] of the held (prescribed or fixed) + !! DOFs, the end-connection directions (6) and the parent frame the coupled end was + !! committed with (orientation 9, angular velocity 3, angular acceleration 3). A restart + !! rebuild moves the coupled end to the host's restored input mesh, the glue's input at + !! the restart time, which need not carry the bits the uninterrupted run committed (with + !! NumCrctn = 0 that run stepped with the extrapolated input); reloading this block after + !! the move continues from exactly the committed state. + TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self + n = 0 + IF (.NOT. self%initialized) RETURN + n = 3*(self%line%ndof - COUNT(self%line%freemask)) + 21 + END FUNCTION CD_HFMF_BoundaryMirrorSize + INTEGER FUNCTION CD_HFMF_TorsionMirrorSize(self) RESULT(n) !! Mirror slots of the condensed torsion, last: the accepted (unwrapped) Theta, Phi and the !! four end-frame vectors (14 values); zero without torsion. @@ -1547,15 +1563,14 @@ INTEGER FUNCTION CD_HFMF_TorsionMirrorSize(self) RESULT(n) END FUNCTION CD_HFMF_TorsionMirrorSize INTEGER FUNCTION CD_HFMF_ForceMirrorSize(self) RESULT(n) - !! Mirror slots of the force-blended generalised-alpha integrator state beyond [v; q; a] of - !! the free DOFs: a validity flag and the committed force F_n (ndof values), then the - !! committed accelerations of the held DOFs; zero with the configuration blend. The - !! force blend carries F_n and a_n of the prescribed end into the next step, so a restart - !! reloads them instead of re-evaluating F_n and taking a_n from the host input mesh. + !! Mirror slots of the force-blended generalised-alpha integrator state beyond the free + !! and boundary blocks: a validity flag and the committed force F_n (ndof values); zero + !! with the configuration blend. The force blend carries F_n into the next step, so a + !! restart reloads it instead of re-evaluating it. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self n = 0 IF (.NOT. self%initialized) RETURN - IF (self%line%force_blend) n = 1 + self%line%ndof + (self%line%ndof - COUNT(self%line%freemask)) + IF (self%line%force_blend) n = 1 + self%line%ndof END FUNCTION CD_HFMF_ForceMirrorSize INTEGER FUNCTION CD_HFMF_FrictionMirrorSize(self) RESULT(n) @@ -1567,21 +1582,23 @@ INTEGER FUNCTION CD_HFMF_FrictionMirrorSize(self) RESULT(n) END FUNCTION CD_HFMF_FrictionMirrorSize SUBROUTINE CD_HFMF_PackMirror(self, buf, ErrStat, ErrMsg) - !! Write the cable's continuous state into buf as [v_free; q_free; a_free] -- the - !! layout CD_HFMF_MirrorSize sizes. The mirror is written every mooring step and - !! reloaded ONLY by a checkpoint-restart rebuild (CD_HFMF_UnpackMirror); the module - !! stays self-authoritative in normal marching. + !! Write the cable's continuous state into buf as [v_free; q_free; a_free], then the + !! friction, boundary, force-blend and torsion blocks -- the layout CD_HFMF_MirrorSize + !! sizes. The mirror is written every mooring step and reloaded ONLY by a + !! checkpoint-restart rebuild or the state-const CalcOutput restore + !! (CD_HFMF_UnpackMirror); the module stays self-authoritative in normal marching. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self REAL(wp), INTENT(OUT) :: buf(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: i, nf, k + INTEGER :: i, nf, nh, k ErrStat = CD_HFMF_OK; ErrMsg = '' buf = CD_ZERO IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_PackMirror: module not initialised'; RETURN END IF nf = COUNT(self%line%freemask) + nh = self%line%ndof - nf IF (SIZE(buf) /= CD_HFMF_MirrorSize(self)) THEN ErrStat = CD_HFMF_BADINPUT ErrMsg = 'CD_HFMF_PackMirror: buffer must be sized CD_HFMF_MirrorSize' @@ -1602,6 +1619,20 @@ SUBROUTINE CD_HFMF_PackMirror(self, buf, ErrStat, ErrMsg) buf(k + 1:k + 2*self%line%nn) = RESHAPE(self%line%fr_anchor, [2*self%line%nn]) k = k + 2*self%line%nn END IF + ! committed boundary: [q; v; a] of the held DOFs, end-connection directions, parent frame + DO i = 1, self%line%ndof + IF (self%line%freemask(i)) CYCLE + k = k + 1 + buf(k) = self%line%q(i) + buf(nh + k) = self%line%v(i) + buf(2*nh + k) = self%line%a(i) + END DO + k = k + 2*nh + buf(k + 1:k + 6) = RESHAPE(self%line%endconn_d0, [6]) + buf(k + 7:k + 15) = RESHAPE(self%parent_dcm, [9]) + buf(k + 16:k + 18) = self%parent_omega + buf(k + 19:k + 21) = self%parent_alpha + k = k + 21 ! force-blend committed force: flag (1 when the cache holds F at the committed state) IF (self%line%force_blend) THEN IF (self%line%fc_valid .AND. .NOT. (ABS(self%line%fc_t - self%line%t) > CD_ZERO)) THEN @@ -1609,11 +1640,6 @@ SUBROUTINE CD_HFMF_PackMirror(self, buf, ErrStat, ErrMsg) buf(k + 2:k + 1 + self%line%ndof) = self%line%fc_R END IF k = k + 1 + self%line%ndof - DO i = 1, self%line%ndof - IF (self%line%freemask(i)) CYCLE - k = k + 1 - buf(k) = self%line%a(i) - END DO END IF IF (self%line%torsion%active) THEN buf(k + 1) = self%line%torsion%theta @@ -1623,18 +1649,19 @@ SUBROUTINE CD_HFMF_PackMirror(self, buf, ErrStat, ErrMsg) END SUBROUTINE CD_HFMF_PackMirror SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) - !! CHECKPOINT-RESTART reload: overwrite the cable's free-DOF state from a mirror - !! written by CD_HFMF_PackMirror ([v_free; q_free; a_free]) and set the line clock - !! to the restart time. The prescribed (coupled) and fixed DOFs are untouched -- the - !! caller re-prescribes the coupled endpoint from the host mesh - !! (CD_HFMF_SetCoupledKinematics) around this call. The module must already be - !! initialised from the SAME deck (the rebuild re-runs the static build first). + !! CHECKPOINT-RESTART reload: overwrite the cable's committed state from a mirror + !! written by CD_HFMF_PackMirror and set the line clock to the restart time. The held + !! DOFs, end-connection directions and parent frame reload from the boundary block, so + !! a caller that first moved the coupled endpoint to the host's restored input mesh + !! (CD_HFMF_SetCoupledKinematics) continues from the committed boundary bit for bit. The + !! module must already be initialised from the SAME deck (the rebuild re-runs the + !! static build first). TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self REAL(wp), INTENT(IN) :: buf(:) REAL(wp), INTENT(IN) :: t INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: i, nf, k + INTEGER :: i, nf, nh, k, kb ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_UnpackMirror: module not initialised'; RETURN @@ -1666,6 +1693,14 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) END ASSOCIATE END DO END IF + ! the boundary block's parent orientation, checked before anything is written as well + nh = self%line%ndof - nf + kb = 3*nf + CD_HFMF_FrictionMirrorSize(self) + 3*nh + IF (.NOT. valid_parent_dcm(RESHAPE(buf(kb + 7:kb + 15), [3, 3]))) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'CD_HFMF_UnpackMirror: the parent orientation must be a proper orthogonal DCM' + RETURN + END IF k = 0 DO i = 1, self%line%ndof IF (self%line%freemask(i)) THEN @@ -1681,6 +1716,19 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) self%line%ws_recovery_fr = self%line%fr_anchor k = k + 2*self%line%nn END IF + DO i = 1, self%line%ndof + IF (self%line%freemask(i)) CYCLE + k = k + 1 + self%line%q(i) = buf(k) + self%line%v(i) = buf(nh + k) + self%line%a(i) = buf(2*nh + k) + END DO + k = k + 2*nh + self%line%endconn_d0 = RESHAPE(buf(k + 1:k + 6), [3, 2]) + self%parent_dcm = RESHAPE(buf(k + 7:k + 15), [3, 3]) + self%parent_omega = buf(k + 16:k + 18) + self%parent_alpha = buf(k + 19:k + 21) + k = k + 21 self%line%t = t ! The reloaded acceleration is committed history: a first held fluid field after the ! reload (the host re-sampling its field on the restored state) must keep it. @@ -1705,11 +1753,6 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) self%line%fc_valid = .TRUE. END IF k = k + 1 + self%line%ndof - DO i = 1, self%line%ndof - IF (self%line%freemask(i)) CYCLE - k = k + 1 - self%line%a(i) = buf(k) - END DO END IF IF (self%line%torsion%active) THEN self%line%torsion%theta = buf(k + 1) @@ -1718,22 +1761,8 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) self%line%torsion%torque = (self%line%torsion%phi - self%line%torsion%theta)/ & CD_HermiteTorsion_Compliance(self%line%torsion, self%line%l0) self%line%tors_drive_set = .FALSE. - ! A parent-attached torsion frame without a parent end connection: the parent orientation - ! is not in the mirror but follows from the restored end frame (its director and normal - ! in parent axes, tors_frame_parent, and in global axes), so a later step without - ! u_orientation holds it instead of turning the frame back to the static orientation. - IF (self%tors_parent .AND. .NOT. self%has_parent_endconn) THEN - BLOCK - REAL(wp) :: fp(3, 3), gg(3, 3) - fp(:, 1) = self%tors_frame_parent(:, 1) - fp(:, 2) = self%tors_frame_parent(:, 2) - fp(:, 3) = cross3(fp(:, 1), fp(:, 2)) - gg(:, 1) = frame_to_global(self, self%line%torsion%ends(:, 2*self%tors_index - 1)) - gg(:, 2) = frame_to_global(self, self%line%torsion%ends(:, 2*self%tors_index)) - gg(:, 3) = cross3(gg(:, 1), gg(:, 2)) - self%parent_dcm = MATMUL(fp, TRANSPOSE(gg)) - END BLOCK - END IF + ! (a parent-attached torsion frame turns with the parent orientation, which the boundary + ! block restored as committed, so a later step without u_orientation holds it) END IF END SUBROUTINE CD_HFMF_UnpackMirror diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index e9a89d60..2e13f9c0 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -91,8 +91,8 @@ MODULE CableDyn CD_AGG_GetInitMetadata, CD_AGG_GetInitLine, & CD_AGG_WriteStaticProfile USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_MirrorSize, CD_HFMF_PackMirror, CD_HFMF_UnpackMirror, & - CD_HFMF_FrictionMirrorSize, CD_HFMF_ForceMirrorSize, & - CD_HFMF_TorsionMirrorSize, CD_HFMF_OK + CD_HFMF_FrictionMirrorSize, CD_HFMF_BoundaryMirrorSize, & + CD_HFMF_ForceMirrorSize, CD_HFMF_TorsionMirrorSize, CD_HFMF_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Reset_Profile, & CD_HermiteCable_Dyn_Disable_Profile, & CD_HermiteCable_Dyn_Get_Profile, & @@ -1102,14 +1102,14 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ! (1e-10) if any bound ends ever disagree. The same gather runs inside every ! normal step, so a state violating the invariant cannot even advance, let alone ! be packed. The vector's real payload is the COMMITTED boundary kinematics: the - ! vessel-end accelerations the last advance committed differ at round-off from the - ! restored input mesh, and on a point deck that round-off is amplified through the - ! explicit-point window. Pure coupled decks keep the interiors-only mirror (their - ! restart is exact from the host-restored boundary alone at output precision). + ! vessel-end kinematics the last advance committed differ in the last bits from the + ! restored input mesh (the glue's input at the restart time, not the extrapolated one + ! the advance used), and on a point deck that round-off is amplified through the + ! explicit-point window. A finite-EI cable carries its committed boundary in its own + ! mirror block (CD_HFMF_BoundaryMirrorSize). IF (Inst(id)%agg%has_sys) THEN - ! the committed boundary kinematics of the EI=0 lines: a restart takes the coupled - ! endpoints' q/v from the restored input mesh, but their committed accelerations - ! (the generalised-alpha a_n) only from here + ! the committed boundary kinematics [q; v; a] of the EI=0 lines' coupled endpoints: + ! the rebuild moves them to the restored input mesh, then reloads them from here nstates = nstates + 3*CD_System_NSystemCoupledDOF( Inst(id)%agg%sys%fast%system ) END IF IF (CD_AGG_NDynamicPoints( Inst(id)%agg ) > 0 .AND. Inst(id)%agg%has_sys) THEN @@ -3332,8 +3332,9 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) csz = CD_HFMF_MirrorSize( inst_%agg%cables(ic) ) IF (csz <= 0) CYCLE ! uninitialised cable contributes no states ! free DOFs; mirror = [v_free; q_free; a_free] then the friction anchors, the - ! force-blend state and the torsion state (if any) + ! committed boundary, the force-blend state and the torsion state (if any) nf = (csz - CD_HFMF_FrictionMirrorSize( inst_%agg%cables(ic) ) - & + CD_HFMF_BoundaryMirrorSize( inst_%agg%cables(ic) ) - & CD_HFMF_ForceMirrorSize( inst_%agg%cables(ic) ) - & CD_HFMF_TorsionMirrorSize( inst_%agg%cables(ic) ))/3 LinStr = 'Cable '//TRIM(Num2LStr(ic)) @@ -3789,7 +3790,7 @@ SUBROUTINE reload_interiors_ary(inst_, m, states, t_clock, ErrStat, ErrMsg) npd = 9*CD_AGG_NDynamicPoints( inst_%agg ) IF (npd == 0 .AND. inst_%agg%has_sys) THEN ! no dynamic points: restore the committed boundary kinematics (the restored input - ! mesh carries the coupled positions and velocities, not the committed accelerations) + ! mesh carries the glue's input at the restart time, not the committed kinematics) ncd = CD_System_NSystemCoupledDOF( inst_%agg%sys%fast%system ) IF (koff + 3*ncd > SIZE(states)) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: the coupled-motion mirror extends '// & diff --git a/tests/test_hfmf_mirror.f90 b/tests/test_hfmf_mirror.f90 index d735f4c0..b6c67360 100644 --- a/tests/test_hfmf_mirror.f90 +++ b/tests/test_hfmf_mirror.f90 @@ -8,25 +8,28 @@ PROGRAM test_hfmf_mirror !! checkpoint-restart rebuild reloads. Builds a real lazy-wave coupled cable from a !! deck and checks: !! 1) MirrorSize is the free-DOF [v; q; a] layout (three blocks strictly below ndof - !! each: the coupled fairlead is prescribed) plus the force-blend block (validity - !! flag, committed force, held-DOF accelerations) of the default force blend; + !! each: the coupled fairlead is prescribed) plus the committed-boundary block ([q; v; a] + !! of the held DOFs, end-connection directions, parent frame) and the force-blend block + !! (validity flag, committed force) of the default force blend; !! 2) PackMirror fills a correctly sized buffer with finite values whose velocity !! AND acceleration blocks are zero at the static IC (rest), confirming the !! [v_free; q_free; a_free] order; !! 3) UnpackMirror ROUND-TRIPS: perturb the packed state, unpack into a second !! identically built cable, re-pack -- bit-identical buffers, and the line clock !! carries the restart time; - !! 4) wrong-sized / non-finite buffers and a non-finite time fail closed. + !! 4) wrong-sized / non-finite buffers, a non-orthogonal parent orientation and a + !! non-finite time fail closed. USE CableDyn_Precision, ONLY: wp USE CableDyn_DeckDriver, ONLY: CD_Init_Deck_HermiteCable, CD_DECKDRV_OK USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType, CD_HFMF_MirrorSize, CD_HFMF_PackMirror, & CD_HFMF_UnpackMirror, CD_HFMF_FrictionMirrorSize, CD_HFMF_ForceMirrorSize, & + CD_HFMF_BoundaryMirrorSize, & CD_HFMF_End, CD_HFMF_OK, CD_HFMF_BADINPUT USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE, IEEE_VALUE, IEEE_QUIET_NAN IMPLICIT NONE INTEGER :: nfail TYPE(CD_HFMF_ModuleType) :: cable, twin - INTEGER :: es, cn, n, nf, i, nx + INTEGER :: es, cn, n, nf, i, nx, kb CHARACTER(512) :: em REAL(wp), ALLOCATABLE :: buf(:), buf2(:), badbuf(:) @@ -39,15 +42,16 @@ PROGRAM test_hfmf_mirror END IF ! (1) size: [v; q; a] of the free DOFs (strictly below 3*ndof: the coupled node is - ! prescribed) plus the force-blend block of the default force blend + ! prescribed) plus the committed-boundary and force-blend blocks of the default force blend n = CD_HFMF_MirrorSize(cable) - nx = CD_HFMF_FrictionMirrorSize(cable) + CD_HFMF_ForceMirrorSize(cable) + nx = CD_HFMF_FrictionMirrorSize(cable) + CD_HFMF_BoundaryMirrorSize(cable) + CD_HFMF_ForceMirrorSize(cable) nf = (n - nx)/3 CALL require(n > 0, 'mirror size positive') CALL require(MOD(n - nx, 3) == 0, 'free-DOF part a multiple of three ([v; q; a])') CALL require(3*nf < 3*cable%line%ndof, 'free-DOF part below 3*ndof (some DOFs prescribed/fixed)') - CALL require(CD_HFMF_ForceMirrorSize(cable) == 1 + cable%line%ndof + (cable%line%ndof - nf), & - 'force-blend block: flag, committed force, held-DOF accelerations') + CALL require(CD_HFMF_BoundaryMirrorSize(cable) == 3*(cable%line%ndof - nf) + 21, & + 'boundary block: held-DOF [q; v; a], end-connection directions, parent frame') + CALL require(CD_HFMF_ForceMirrorSize(cable) == 1 + cable%line%ndof, 'force-blend block: flag, committed force') ! (2) pack a correctly sized buffer: finite, velocity + acceleration blocks zero at rest ALLOCATE (buf(n), buf2(n)) @@ -65,20 +69,25 @@ PROGRAM test_hfmf_mirror END IF ! (3) unpack round-trip into an identically built twin: perturbed [v; q; a] survives - ! bit-for-bit and the clock carries the restart time + ! bit-for-bit (held DOFs and parent frame included) and the clock carries the restart time CALL CD_Init_Deck_HermiteCable('hfmf_mirror.dat', 0.05_wp, twin, cn, es, em) CALL require(es == CD_DECKDRV_OK, 'init twin: '//TRIM(em)) DO i = 1, n buf(i) = buf(i) + 1.0e-3_wp*REAL(i, wp) ! a deterministic mid-flight-like state END DO - ! the force-blend validity flag is 0 or 1 (a committed force at the restored state) - IF (CD_HFMF_ForceMirrorSize(cable) > 0) buf(3*nf + CD_HFMF_FrictionMirrorSize(cable) + 1) = 1.0_wp + ! the parent orientation stays a rotation (a quarter turn about z), the force-blend validity + ! flag is 0 or 1 (a committed force at the restored state) + kb = 3*nf + CD_HFMF_FrictionMirrorSize(cable) + 3*(cable%line%ndof - nf) + buf(kb + 7:kb + 15) = [0.0_wp, 1.0_wp, 0.0_wp, -1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp] + IF (CD_HFMF_ForceMirrorSize(cable) > 0) buf(kb + 22) = 1.0_wp CALL CD_HFMF_UnpackMirror(twin, buf, 12.5_wp, es, em) CALL require(es == CD_HFMF_OK, 'unpack ok: '//TRIM(em)) CALL require(ABS(twin%line%t - 12.5_wp) <= 0.0_wp, 'restart time set on the line clock') CALL CD_HFMF_PackMirror(twin, buf2, es, em) CALL require(es == CD_HFMF_OK, 're-pack ok') CALL require(nan_max_abs(buf2 - buf) <= 0.0_wp, 'unpack -> pack round-trips bit-identically') + CALL require(nan_max_abs(twin%parent_dcm(:, 1) - [0.0_wp, 1.0_wp, 0.0_wp]) <= 0.0_wp, & + 'the parent orientation reloads from the boundary block') ! (4) fail-closed edges ALLOCATE (badbuf(n + 1)) @@ -90,6 +99,10 @@ PROGRAM test_hfmf_mirror CALL CD_HFMF_UnpackMirror(twin, buf, 1.0_wp, es, em) CALL require(es == CD_HFMF_BADINPUT, 'non-finite mirror fails closed') buf(1) = 0.0_wp + buf(kb + 7) = 2.0_wp + CALL CD_HFMF_UnpackMirror(twin, buf, 1.0_wp, es, em) + CALL require(es == CD_HFMF_BADINPUT, 'a non-orthogonal parent orientation fails closed') + buf(kb + 7) = 0.0_wp CALL CD_HFMF_UnpackMirror(twin, buf, IEEE_VALUE(1.0_wp, IEEE_QUIET_NAN), es, em) CALL require(es == CD_HFMF_BADINPUT, 'non-finite restart time fails closed')