From c6a5d27f180848abd9633b6384ba33e0d803c5fa Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 21 Oct 2026 11:45:45 +0900 Subject: [PATCH] perf(profile): split the cable assembly, CalcOutput and wave sampling The first coupled profile showed that, on a mooring with a finite-EI power cable, CalcOutput and the SeaState sampling cost as much as the mooring step itself, and that the cable step is dominated by its residual and tangent assemblies. Choosing what to optimise first needs the inside of each. The residual and tangent assembly of a finite-EI cable now times its sections (band zeroing, tangent element kernels, tangent scatter, structural residual, weight, attachments, dry buoyancy, seabed contact, axial damping, drag, end connections, wave and held Froude-Krylov loads, torsion). The OpenFAST module splits CalcOutput into the overlay of the current kinematics, the output channels and the restore of the committed state, and the SeaState sampling into the node queries, the grid checks and the hand-over of the fields. The standalone driver and the OpenFAST module report them. Unprofiled, each new timer is skipped after one test; outputs are byte-identical with and without the profile. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 4 ++ CMakeLists.txt | 2 +- app/cabledyn.f90 | 13 ++++- doc/cli.rst | 26 ++++++---- doc/faq.rst | 6 ++- src/CableDyn_HermiteCableDynamic.f90 | 64 +++++++++++++++++++++++- src/openfast/CableDyn_OF.f90 | 74 +++++++++++++++++++++++++++- 7 files changed, 174 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13887388..8aed8135 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ All notable changes to CableDyn are recorded in this file. The format follows factorisations and back-substitutions, with their counts and times, and separates the factorisations of finite-EI cables from their back-substitutions (which now include the force-blend correction that ends each step). Results do not change. +- The run-time profile also splits the residual and tangent assemblies of finite-EI cables into + their sections and, in OpenFAST, `CalcOutput` into the kinematics overlay, the output channels + and the restore, and the SeaState sampling into the node queries, the grid checks and the + hand-over of the fields. Results do not change. ## [0.2.0] - 2026-10-20 diff --git a/CMakeLists.txt b/CMakeLists.txt index c8915904..ac225bca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2055,7 +2055,7 @@ add_test( -DDRIVER=$ -DDECK=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/held_start_gomex80_power_cable.dat -DOUTPUT_ROOT=${CMAKE_CURRENT_BINARY_DIR}/driver_profile_finite_ei - "-DEXPECT=\n Finite-EI cable steps: [1-9][0-9]*, residual evaluations: [1-9][0-9]*, tangent assemblies: [1-9][0-9]*, factorisations: [1-9][0-9]*, linear solves: [1-9][0-9]*, force-blend corrections: [0-9]+[^\n]*\n Finite-EI cable step time \\(s\\): residual [0-9.]+, tangent [0-9.]+, effective matrix [0-9.]+, factorisation [0-9.]+, back-substitution [0-9.]+, added mass [0-9.]+, other [0-9.]+\\." + "-DEXPECT=\n Finite-EI cable steps: [1-9][0-9]*, residual evaluations: [1-9][0-9]*, tangent assemblies: [1-9][0-9]*, factorisations: [1-9][0-9]*, linear solves: [1-9][0-9]*, force-blend corrections: [0-9]+[^\n]*\n Finite-EI cable step time \\(s\\): residual [0-9.]+, tangent [0-9.]+, effective matrix [0-9.]+, factorisation [0-9.]+, back-substitution [0-9.]+, added mass [0-9.]+, other [0-9.]+\\.\n Finite-EI cable assembly time \\(s\\): band zeroing [0-9.]+, tangent element kernels [0-9.]+, tangent scatter [0-9.]+, structural residual [0-9.]+, weight [0-9.]+, attachments [0-9.]+, dry buoyancy [0-9.]+, seabed contact [0-9.]+, axial damping [0-9.]+, drag [0-9.]+, end connections [0-9.]+, wave Froude-Krylov [0-9.]+, held Froude-Krylov [0-9.]+, torsion [0-9.]+\\." -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_profile.cmake) add_test( NAME driver_profile_failure diff --git a/app/cabledyn.f90 b/app/cabledyn.f90 index ad8dedec..bcb9978c 100644 --- a/app/cabledyn.f90 +++ b/app/cabledyn.f90 @@ -41,7 +41,8 @@ PROGRAM cabledyn CD_Profile_Kernels, CD_PROF_K_RESIDUAL, CD_PROF_K_TANGENT, CD_PROF_K_FACTOR, & CD_PROF_K_SOLVE, CD_PROF_NKERNEL USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Reset_Profile, CD_HermiteCable_Dyn_Get_Profile, & - CD_HermiteCable_Dyn_Recovery_Reset, CD_HermiteCable_Dyn_Recovery_Count + CD_HermiteCable_Dyn_Recovery_Reset, CD_HermiteCable_Dyn_Recovery_Count, & + CD_HermiteCable_Dyn_Get_Assembly_Profile, HC_ASM_NSEC, HC_ASM_NAMES USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: error_unit, output_unit, int64 IMPLICIT NONE TYPE :: StandaloneProgress @@ -860,7 +861,8 @@ SUBROUTINE print_profile() !! the finite-EI cable steps. Printed once, on stdout, at the end of the run. LOGICAL, SAVE :: printed = .FALSE. REAL(wp) :: seconds(CD_PROF_NPHASE), total, march, t_step, t_resid, t_eff, t_solve, t_am, t_tan, t_factor - REAL(wp) :: kernel_seconds(CD_PROF_NKERNEL) + REAL(wp) :: kernel_seconds(CD_PROF_NKERNEL), asm_seconds(HC_ASM_NSEC) + CHARACTER(:), ALLOCATABLE :: asm_line INTEGER(int64) :: march_steps, line_steps, line_iterations, kernel_calls(CD_PROF_NKERNEL) INTEGER :: line_max_iterations, n_step, n_resid, n_solve, n_am, n_alloc, n_tan, n_factor, n_correct, k IF (printed .OR. .NOT. CD_Profile_Armed()) RETURN @@ -908,6 +910,13 @@ SUBROUTINE print_profile() ', tangent ', fixed(t_tan, 3), ', effective matrix ', fixed(t_eff, 3), ', factorisation ', & fixed(t_factor, 3), ', back-substitution ', fixed(t_solve, 3), ', added mass ', fixed(t_am, 3), ', other ', & fixed(MAX(0.0_wp, t_step - (t_resid + t_tan + t_eff + t_factor + t_solve + t_am)), 3), '.' + CALL CD_HermiteCable_Dyn_Get_Assembly_Profile(asm_seconds) + asm_line = ' Finite-EI cable assembly time (s):' + DO k = 1, HC_ASM_NSEC + asm_line = asm_line//' '//TRIM(HC_ASM_NAMES(k))//' '//fixed(asm_seconds(k), 3) + IF (k < HC_ASM_NSEC) asm_line = asm_line//',' + END DO + WRITE (output_unit, '(A)') asm_line//'.' ELSE IF (.NOT. profile_cable_detail .AND. n_finite_ei > 0) THEN WRITE (output_unit, '(A)') ' Finite-EI cable steps: not counted on the mixed EI = 0 + finite-EI route, '// & 'whose cables step concurrently.' diff --git a/doc/cli.rst b/doc/cli.rst index 27a5db31..affb914c 100644 --- a/doc/cli.rst +++ b/doc/cli.rst @@ -158,20 +158,21 @@ breakdown such as: Run-time profile (CABLEDYN_PROFILE), wall-clock time: input parsing 0.002 s 0.1 % - initialisation and statics 0.237 s 8.8 % - dynamic march 2.444 s 91.1 % - fluid sampled by the driver 0.050 s 1.9 % - line, cable and object steps 2.379 s 88.6 % + initialisation and statics 0.238 s 8.7 % + dynamic march 2.496 s 91.2 % + fluid sampled by the driver 0.051 s 1.9 % + line, cable and object steps 2.430 s 88.8 % checks and line failures 0.002 s 0.1 % - outputs 0.012 s 0.5 % + outputs 0.013 s 0.5 % progress and bookkeeping 0.000 s 0.0 % finalisation 0.000 s 0.0 % - total 2.684 s 100.0 % - March: 600 committed step(s), 4.0735 ms per step. + total 2.736 s 100.0 % + March: 600 committed step(s), 4.1596 ms per step. EI = 0 line steps: 3621 (substeps and retries included), Newton iterations: 4739 (1.309 per line step, at most 2). - EI = 0 line step kernels: residual 6947 (0.039 s), residual and tangent 3322 (0.064 s), factorisation 3322 (0.013 s), back-substitution 5126 (0.009 s). + EI = 0 line step kernels: residual 6947 (0.040 s), residual and tangent 3322 (0.064 s), factorisation 3322 (0.013 s), back-substitution 5126 (0.009 s). Finite-EI cable steps: 1423, residual evaluations: 6140, tangent assemblies: 2914, factorisations: 2914, linear solves: 2914, force-blend corrections: 1423, intervals recovered by substeps: 0. - Finite-EI cable step time (s): residual 0.412, tangent 0.883, effective matrix 0.039, factorisation 0.211, back-substitution 0.075, added mass 0.049, other 0.085. + Finite-EI cable step time (s): residual 0.420, tangent 0.913, effective matrix 0.039, factorisation 0.213, back-substitution 0.076, added mass 0.050, other 0.086. + Finite-EI cable assembly time (s): band zeroing 0.033, tangent element kernels 0.809, tangent scatter 0.065, structural residual 0.173, weight 0.003, attachments 0.000, dry buoyancy 0.024, seabed contact 0.007, axial damping 0.147, drag 0.240, end connections 0.001, wave Froude-Krylov 0.000, held Froude-Krylov 0.126, torsion 0.000. The phases add up to the total, which runs from the start of the deck parse to the report. If the run stops with an error, the time up to the stop counts to the phase in which it stopped, and @@ -206,6 +207,13 @@ The counts follow the march: matrix, the factorisations, the back-substitutions (of the Newton solves and of the force-blend correction that ends each step), the added mass and the rest; the rarely used torsion and consistent-acceleration solves count to the rest. +* **Finite-EI cable assembly time** splits the residual and tangent assemblies into their + sections. The tangent element kernels evaluate the structural, damping, drag and wave + tangents of each element together; the other sections are the element residuals, the weight + and supports, the attachments, the dry-part buoyancy, the seabed contact, the axial damping, + the drag, the end connections, the wave and held Froude-Krylov loads and the torsion. The + sections also count the assemblies made outside the step (reactions, end moments and + consistent accelerations), so they can add up to more than the residual and tangent times. An unset or empty variable, or ``0``, leaves the profile off. The driver reads the variable once, when it starts. diff --git a/doc/faq.rst b/doc/faq.rst index 33ad71c7..e8f035f8 100644 --- a/doc/faq.rst +++ b/doc/faq.rst @@ -106,7 +106,11 @@ OpenFAST coupling ``CABLEDYN_PROFILE=1`` before running ``openfast.exe`` to separate CableDyn solve, SeaState sampling, output-probe, and native-I/O time, and to split the steps of ``EI = 0`` lines and finite-EI cables into residual, tangent, factorisation and back-substitution time (with - ``OMP_NUM_THREADS=1`` the line times add up to the solve time); the standalone driver reads + ``OMP_NUM_THREADS=1`` the line times add up to the solve time). The ``profile parts`` line + splits ``CalcOutput`` further, into the overlay and restore of the current kinematics (at + ``nsuper = 1``) and the output channels, and splits the SeaState sampling into the node + queries, the grid checks and the hand-over of the fields; the ``Hermite assembly`` line splits + the cable assemblies into their sections (:ref:`cli-profile`). The standalone driver reads the same variable and prints its own breakdown (:ref:`cli-profile`). Keep ``ModCoupling`` fixed while comparing configurations. Do not switch to loose coupling merely to meet a wall-clock target; on the IEA-15MW reference model it materially changed platform and tension responses. Test diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index d92621ad..4b7cf7b4 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -136,7 +136,7 @@ MODULE CableDyn_HermiteCableDynamic LOGICAL, PARAMETER, PUBLIC :: CD_HC_FORCE_BLEND_DEFAULT = .TRUE. PUBLIC :: CD_HermiteCable_Dyn_End PUBLIC :: CD_HermiteCable_Dyn_Reset_Profile, CD_HermiteCable_Dyn_Disable_Profile, & - CD_HermiteCable_Dyn_Get_Profile + CD_HermiteCable_Dyn_Get_Profile, CD_HermiteCable_Dyn_Get_Assembly_Profile PUBLIC :: CD_HermiteCable_Dyn_Profile_Enabled INTEGER, PARAMETER, PUBLIC :: CD_HCDYN_OK = 0, CD_HCDYN_BADINPUT = 1, CD_HCDYN_NOCONVERGE = 2 INTEGER, PARAMETER, PUBLIC :: CD_HCDYN_TENSILE_OFF = 0 @@ -182,6 +182,29 @@ MODULE CableDyn_HermiteCableDynamic REAL(wp), SAVE :: prof_t_solve = 0.0_wp ! back-substitution wall (Newton solves and force-blend corrections) REAL(wp), SAVE :: prof_t_factor = 0.0_wp ! LU factorisation wall of the effective tangent REAL(wp), SAVE :: prof_t_am = 0.0_wp ! frozen added-mass assembly wall (band) + ! assemble_residual split into its sections (asm_mark), summed over every assembly while the + ! profile is armed: the residual and tangent assemblies above, and those made outside the step + ! (committed force, reactions, end moments, consistent accelerations). The tangent element + ! kernels evaluate the structural, damping, drag and wave tangents of each element together, + ! in parallel. + INTEGER, PARAMETER, PUBLIC :: HC_ASM_ZERO = 1, HC_ASM_TAN_KERNELS = 2, HC_ASM_SCATTER = 3, & + HC_ASM_STRUCT = 4, HC_ASM_WEIGHT = 5, HC_ASM_ATTACH = 6, HC_ASM_BUOY = 7, & + HC_ASM_CONTACT = 8, HC_ASM_DAMP = 9, HC_ASM_DRAG = 10, HC_ASM_ENDCONN = 11, & + HC_ASM_WAVE = 12, HC_ASM_HELD = 13, HC_ASM_TORSION = 14, HC_ASM_NSEC = 14 + CHARACTER(*), PARAMETER, PUBLIC :: HC_ASM_NAMES(HC_ASM_NSEC) = [CHARACTER(24) :: & + 'band zeroing', 'tangent element kernels', & + 'tangent scatter', 'structural residual', & + 'weight', 'attachments', 'dry buoyancy', & + 'seabed contact', 'axial damping', 'drag', & + 'end connections', 'wave Froude-Krylov', & + 'held Froude-Krylov', 'torsion'] + ! the same sections as one-word report keys (the OpenFAST module's key=value profile lines) + CHARACTER(*), PARAMETER, PUBLIC :: HC_ASM_KEYS(HC_ASM_NSEC) = [CHARACTER(12) :: & + 'zero', 'tan_kernels', 'tan_scatter', & + 'structural', 'weight', 'attachments', & + 'buoyancy', 'contact', 'damping', 'drag', & + 'end_conn', 'wave_fk', 'held_fk', 'torsion'] + REAL(wp), SAVE :: prof_t_asm(HC_ASM_NSEC) = 0.0_wp ! Number of coupling intervals completed by internal generalised-alpha substeps after the nominal ! interval was too large for the prescribed boundary motion or environmental load. This counter is @@ -506,6 +529,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Reset_Profile() prof_t_step = 0.0_wp; prof_t_resid = 0.0_wp; prof_t_eff = 0.0_wp prof_t_tan = 0.0_wp; prof_t_factor = 0.0_wp prof_t_solve = 0.0_wp; prof_t_am = 0.0_wp + prof_t_asm = 0.0_wp END SUBROUTINE CD_HermiteCable_Dyn_Reset_Profile SUBROUTINE CD_HermiteCable_Dyn_Disable_Profile() @@ -515,6 +539,26 @@ SUBROUTINE CD_HermiteCable_Dyn_Disable_Profile() prof_enabled = .FALSE. END SUBROUTINE CD_HermiteCable_Dyn_Disable_Profile + SUBROUTINE CD_HermiteCable_Dyn_Get_Assembly_Profile(seconds) + !! Time of each assemble_residual section (HC_ASM_*, names HC_ASM_NAMES) since the last + !! CD_HermiteCable_Dyn_Reset_Profile; zero unless the profile is armed. + REAL(wp), INTENT(OUT) :: seconds(HC_ASM_NSEC) + seconds = prof_t_asm + END SUBROUTINE CD_HermiteCable_Dyn_Get_Assembly_Profile + + SUBROUTINE asm_mark(section, last) + !! Add the time since last to section and restart from now (profiled runs only). Called on + !! the thread that runs assemble_residual, outside its parallel loop; a profiled run steps + !! its cables one at a time, so the plain update is safe. + INTEGER, INTENT(IN) :: section + INTEGER(INT64), INTENT(INOUT) :: last + INTEGER(INT64) :: now, rate + IF (.NOT. prof_enabled) RETURN + CALL SYSTEM_CLOCK(now, rate) + IF (rate > 0_INT64) prof_t_asm(section) = prof_t_asm(section) + REAL(now - last, wp)/REAL(rate, wp) + last = now + END SUBROUTINE asm_mark + SUBROUTINE CD_HermiteCable_Dyn_Get_Profile(n_step, n_resid, n_solve, n_am, n_alloc, & t_step, t_resid, t_eff, t_solve, t_am, n_tan, t_tan, & n_factor, t_factor, n_correct) @@ -6439,6 +6483,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta REAL(wp), INTENT(IN), OPTIONAL :: endconn_direction_eval(3, 2) REAL(wp), POINTER :: R(:), Kb(:, :), Kvb(:, :) INTEGER :: ne, e, a, gi, es, omp_threads + INTEGER(INT64) :: asm_t ! clock at the last section mark (asm_mark; profiled runs only) LOGICAL :: tangent_only REAL(wp) :: qe(12), ve(12), Ee, fe(12), Ke(12, 12), pen REAL(wp) :: fdrag(12), djq(12, 12), djv(12, 12), ffk(12), fjq(12, 12) @@ -6467,10 +6512,13 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta Kvb => model%ws_Kvb endconn_d0_eval = model%endconn_d0 IF (PRESENT(endconn_direction_eval)) endconn_d0_eval = endconn_direction_eval + asm_t = 0_INT64 + IF (prof_enabled) CALL SYSTEM_CLOCK(asm_t) IF (want_residual) R = CD_ZERO IF (want_tangent) THEN Kb = CD_ZERO; Kvb = CD_ZERO END IF + CALL asm_mark(HC_ASM_ZERO, asm_t) ! Tangent-only element kernels are independent. Evaluate them in parallel into persistent ! buffers, then validate and scatter serially in the original element order. Residual and @@ -6488,12 +6536,14 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta END DO !$OMP END DO !$OMP END PARALLEL + CALL asm_mark(HC_ASM_TAN_KERNELS, asm_t) DO e = 1, ne IF (model%ws_elem_es(e) /= CD_HCABLE_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'element: '//TRIM(model%ws_elem_em(e)); RETURN END IF CALL scatter12_band(Kb, model%ws_elem_K(:, :, e), e) END DO + CALL asm_mark(HC_ASM_SCATTER, asm_t) ELSE DO e = 1, ne qe(1:3) = q_cfg(6*(e - 1) + 1:6*(e - 1) + 3) @@ -6521,6 +6571,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta END IF IF (want_tangent) CALL scatter12_band(Kb, Ke, e) END DO + CALL asm_mark(HC_ASM_STRUCT, asm_t) END IF IF (want_residual) THEN @@ -6541,12 +6592,14 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta R(6*ne + 4:6*ne + 6) = R(6*ne + 4:6*ne + 6) + (model%w(ne)*model%l0(ne)*model%l0(ne)/12.0_wp)*support END IF END IF + CALL asm_mark(HC_ASM_WEIGHT, asm_t) IF (model%has_attach) THEN CALL assemble_attachments(model, q_cfg, v_cfg, want_residual, want_tangent, R, Kb, Kvb, es, em2) IF (es /= CD_HCDYN_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = TRIM(em2); RETURN END IF END IF + CALL asm_mark(HC_ASM_ATTACH, asm_t) ! Dry-part buoyancy recovery. w is the submerged weight; the part of an element above the ! free surface of the drag configuration regains its displaced-water buoyancy. The surface @@ -6582,6 +6635,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta END DO END IF + CALL asm_mark(HC_ASM_BUOY, asm_t) ! Standalone production contact uses the same nodal C1 normal/damper/friction ! law as the deck compatibility path, including structured-bed slope terms. ! Retain the scalar flat penalty for existing direct API callers. @@ -6621,6 +6675,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta END IF END IF + CALL asm_mark(HC_ASM_CONTACT, asm_t) ! Scatter the element-private hydrodynamic tangents in the same phase and element ! order as the serial formulation, retaining its floating-point accumulation order. IF (tangent_only .AND. (model%has_drag .OR. model%has_axial_damping)) THEN @@ -6640,6 +6695,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta END DO END IF + CALL asm_mark(HC_ASM_SCATTER, asm_t) ! Axial Kelvin-Voigt damping is an internal constitutive force. It uses the same ! reference-arc Hermite interpolation and axial quadrature as the elastic resultant. IF (model%has_axial_damping .AND. .NOT. tangent_only) THEN @@ -6682,6 +6738,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta END DO END IF + CALL asm_mark(HC_ASM_DAMP, asm_t) ! Consistent Morison quadratic drag on the submerged cable, distributed over the full cubic- ! Hermite shape functions (so the material-tangent DOFs, which move the element interior, also ! carry drag). The element returns the 12-DOF generalized drag LOAD fdrag (f_ext) and its force @@ -6765,6 +6822,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta END DO END IF + CALL asm_mark(HC_ASM_DRAG, asm_t) ! ---- rotational line-end connections ---- ! A node-local generalized load on the end tangents: the 3x3 tangent block sits on the ! band diagonal (|gi - gj| <= 2 against KU_D = 11), so it cannot widen the band. The @@ -6787,6 +6845,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta END IF END IF + CALL asm_mark(HC_ASM_ENDCONN, asm_t) ! Froude-Krylov + fluid-inertia wave load (from the wave ACCELERATION), with the added-mass ! configuration's coefficients. An external load: R -= ffk, K -= fjq (geometric tangent chain; ! the wave-field spatial gradient is neglected in K -- see the element note). @@ -6840,6 +6899,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta END DO END IF + CALL asm_mark(HC_ASM_WAVE, asm_t) ! HELD-FIELD Froude-Krylov + fluid-inertia load: the host-sampled fluid acceleration ! (per-element two-node average, frozen over the step) with the added-mass ! configuration's coefficients -- the held-mode twin of the wave FK block above. @@ -6883,6 +6943,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta END DO END IF + CALL asm_mark(HC_ASM_HELD, asm_t) ! Condensed torsion: R <- R - M_t dTheta/dq and Kb <- Kb - M_t d2Theta/dq2 at q_cfg (the ! rank-one g g^T / C joins the solve by Sherman-Morrison; g is kept in tors_g). IF (model%torsion%active .AND. (want_residual .OR. want_tangent)) THEN @@ -6891,6 +6952,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta ErrStat = es; ErrMsg = TRIM(em2); RETURN END IF END IF + CALL asm_mark(HC_ASM_TORSION, asm_t) END SUBROUTINE assemble_residual SUBROUTINE assemble_torsion(model, q_cfg, want_residual, want_tangent, ErrStat, ErrMsg) diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index e56a93f5..ccbac0e9 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -95,6 +95,7 @@ MODULE CableDyn USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Reset_Profile, & CD_HermiteCable_Dyn_Disable_Profile, & CD_HermiteCable_Dyn_Get_Profile, & + CD_HermiteCable_Dyn_Get_Assembly_Profile, HC_ASM_NSEC, HC_ASM_KEYS, & CD_HermiteCable_Dyn_Recovery_Count, & CD_HermiteCable_Dyn_Recovery_Reset USE CableDyn_Profile, ONLY: CD_Profile_Arm, CD_Profile_Disarm, CD_Profile_Kernels, CD_PROF_K_RESIDUAL, & @@ -216,6 +217,13 @@ MODULE CableDyn REAL(wp) :: prof_t_wave = 0.0_wp, prof_t_step = 0.0_wp REAL(wp) :: prof_t_calcout = 0.0_wp, prof_t_loads = 0.0_wp REAL(wp) :: prof_t_native = 0.0_wp + ! parts of calcout_s (the overlay and restore of the current kinematics, at nsuper = 1, and + ! the channels of a fresh evaluation) and of wave_s (the SeaState node queries with the + ! current decomposition, the grid checks, the hand-over of the fields to the aggregate) + REAL(wp) :: prof_t_overlay = 0.0_wp, prof_t_channels = 0.0_wp + REAL(wp) :: prof_t_restore = 0.0_wp + REAL(wp) :: prof_t_wave_kin = 0.0_wp, prof_t_wave_check = 0.0_wp + REAL(wp) :: prof_t_wave_set = 0.0_wp END TYPE CD_OF_Instance TYPE(CD_OF_Instance), ALLOCATABLE, SAVE :: Inst(:) @@ -1744,7 +1752,8 @@ SUBROUTINE sample_wavefield( inst_e, p, m, t_sample, ErrStat, ErrMsg, at_init ) character(*), parameter :: RoutineName = 'sample_wavefield' INTEGER(IntKi) :: i, l, es, nodeInWater, n_current_nodes - LOGICAL :: init_call + INTEGER(IntKi) :: prof_c0, prof_c1, prof_rate + LOGICAL :: init_call, timed REAL(SiKi) :: zeta1, zeta2, zeta, pdyn, fv(3), fa(3), famcf(3) REAL(SiKi) :: wave_zeta1, wave_zeta2, wave_zeta, wave_pdyn REAL(SiKi) :: wave_fv(3), wave_fa(3), wave_famcf(3) @@ -1763,6 +1772,9 @@ SUBROUTINE sample_wavefield( inst_e, p, m, t_sample, ErrStat, ErrMsg, at_init ) ErrMsg = '' init_call = .FALSE. IF (PRESENT(at_init)) init_call = at_init + ! the parts of wave_s, timed like it outside the Init seeding call (a checkpoint restart + ! re-sampling once is counted in the parts only) + timed = inst_e%prof_enabled .AND. .NOT. init_call IF (.NOT. ASSOCIATED(p%WaveField)) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: the WaveField pointer is null but '// & 'SeaState kinematics were requested at Init.', ErrStat, ErrMsg, RoutineName ) @@ -1794,6 +1806,7 @@ SUBROUTINE sample_wavefield( inst_e, p, m, t_sample, ErrStat, ErrMsg, at_init ) RETURN END IF IF (.NOT. inst_e%grid_warned) ALLOCATE (wl_sampled(inst_e%nfluid)) + IF (timed) CALL SYSTEM_CLOCK(prof_c0, prof_rate) DO i = 1, inst_e%nfluid IF (.NOT. inst_e%agg%host_wave_enabled .AND. .NOT. inst_e%agg%host_current_enabled) THEN ! An explicit WaterKin file may disable both host components even @@ -1889,6 +1902,11 @@ SUBROUTINE sample_wavefield( inst_e, p, m, t_sample, ErrStat, ErrMsg, at_init ) inst_e%fx_pd(i) = 0.0_wp IF (inst_e%agg%host_wave_enabled) inst_e%fx_pd(i) = REAL(pdyn, wp) END DO + IF (timed) THEN + CALL SYSTEM_CLOCK(prof_c1) + inst_e%prof_t_wave_kin = inst_e%prof_t_wave_kin + REAL(prof_c1 - prof_c0, wp)/REAL(prof_rate, wp) + prof_c0 = prof_c1 + END IF ! Grid coverage: checked on the positions just sampled (with their free-surface ! elevations), at Init (the static equilibrium) and then every mooring step until the one ! warning has been issued. @@ -1897,8 +1915,17 @@ SUBROUTINE sample_wavefield( inst_e, p, m, t_sample, ErrStat, ErrMsg, at_init ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) END IF IF (.NOT. inst_e%curr_grid_warned) CALL check_current_field_grid( inst_e, p%WaveField, t_sample ) + IF (timed) THEN + CALL SYSTEM_CLOCK(prof_c1) + inst_e%prof_t_wave_check = inst_e%prof_t_wave_check + REAL(prof_c1 - prof_c0, wp)/REAL(prof_rate, wp) + prof_c0 = prof_c1 + END IF CALL CD_AGG_SetFluidFields( inst_e%agg, inst_e%fx_vel, inst_e%fx_acc, inst_e%fx_wl, es, em, & dynamic_pressure=inst_e%fx_pd ) + IF (timed) THEN + CALL SYSTEM_CLOCK(prof_c1) + inst_e%prof_t_wave_set = inst_e%prof_t_wave_set + REAL(prof_c1 - prof_c0, wp)/REAL(prof_rate, wp) + END IF IF (es /= CD_AGG_OK) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: '//TRIM(em), ErrStat, ErrMsg, RoutineName ) END IF @@ -2228,6 +2255,10 @@ SUBROUTINE CD_CalcOutput( t, u, p, x, xd, z, other, y, m, ErrStat, ErrMsg ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) RETURN END IF + IF (Inst(id)%prof_enabled) THEN + CALL SYSTEM_CLOCK(prof_c1) + Inst(id)%prof_t_overlay = Inst(id)%prof_t_overlay + REAL(prof_c1 - prof_c0, wp)/REAL(prof_rate, wp) + END IF ELSE ! Supercycled: the committed state changes only when a mooring step completes, so the ! held loads/channels are re-evaluated only then (serving the cache is bit-identical @@ -2277,6 +2308,7 @@ SUBROUTINE CD_CalcOutput( t, u, p, x, xd, z, other, y, m, ErrStat, ErrMsg ) ! Deck OUTPUTS channels are evaluated at the same aggregate state as the returned ! loads: with supercycling the last committed zero-order-hold mooring state, at ! nsuper = 1 the state including the current coupled kinematics. + IF (Inst(id)%prof_enabled) CALL SYSTEM_CLOCK(prof_phase0) DO i = 1, p%NumOuts CALL CD_AGG_EvalChannel( Inst(id)%agg, i, cval, es, em ) IF (es /= CD_AGG_OK) THEN @@ -2290,6 +2322,11 @@ SUBROUTINE CD_CalcOutput( t, u, p, x, xd, z, other, y, m, ErrStat, ErrMsg ) END IF Inst(id)%ws_chan(i) = cval END DO + IF (Inst(id)%prof_enabled) THEN + CALL SYSTEM_CLOCK(prof_c1) + Inst(id)%prof_t_channels = Inst(id)%prof_t_channels + & + REAL(prof_c1 - prof_phase0, wp)/REAL(prof_rate, wp) + END IF Inst(id)%loads_cached = .TRUE. Inst(id)%loads_at_n = Inst(id)%last_solve_n END IF @@ -2299,7 +2336,13 @@ SUBROUTINE CD_CalcOutput( t, u, p, x, xd, z, other, y, m, ErrStat, ErrMsg ) ! re-derived interior accelerations, and only the mirror carries the committed ! gen-alpha values. IF (state_overlaid) THEN + IF (Inst(id)%prof_enabled) CALL SYSTEM_CLOCK(prof_phase0) CALL restore_calcoutput_probe( Inst(id), m, ErrStat2, ErrMsg2 ) + IF (Inst(id)%prof_enabled) THEN + CALL SYSTEM_CLOCK(prof_c1) + Inst(id)%prof_t_restore = Inst(id)%prof_t_restore + & + REAL(prof_c1 - prof_phase0, wp)/REAL(prof_rate, wp) + END IF CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF (ErrStat >= AbortErrLev) RETURN END IF @@ -2441,6 +2484,8 @@ SUBROUTINE CD_End(u, p, x, xd, z, other, y, m, ErrStat , ErrMsg) INTEGER(int64) :: k_calls(CD_PROF_NKERNEL) REAL(wp) :: k_seconds(CD_PROF_NKERNEL), ht_factor CHARACTER(24) :: k_txt(CD_PROF_NKERNEL) + REAL(wp) :: ht_asm(HC_ASM_NSEC) + CHARACTER(:), ALLOCATABLE :: asm_txt INTEGER :: k_i INTEGER :: sb_max, sb_ios CHARACTER(24) :: sb_txt(5) @@ -2480,6 +2525,13 @@ SUBROUTINE CD_End(u, p, x, xd, z, other, y, m, ErrStat , ErrMsg) TRIM(Num2LStr(REAL(Inst(m%CDInst)%prof_t_calcout, DbKi)))// & ' loads_s='//TRIM(Num2LStr(REAL(Inst(m%CDInst)%prof_t_loads, DbKi)))// & ' native_io_s='//TRIM(Num2LStr(REAL(Inst(m%CDInst)%prof_t_native, DbKi))) ) + CALL WrScr( ' CableDyn profile parts: overlay_s='// & + TRIM(Num2LStr(REAL(Inst(m%CDInst)%prof_t_overlay, DbKi)))// & + ' channels_s='//TRIM(Num2LStr(REAL(Inst(m%CDInst)%prof_t_channels, DbKi)))// & + ' restore_s='//TRIM(Num2LStr(REAL(Inst(m%CDInst)%prof_t_restore, DbKi)))// & + ' wave_kin_s='//TRIM(Num2LStr(REAL(Inst(m%CDInst)%prof_t_wave_kin, DbKi)))// & + ' wave_check_s='//TRIM(Num2LStr(REAL(Inst(m%CDInst)%prof_t_wave_check, DbKi)))// & + ' wave_set_s='//TRIM(Num2LStr(REAL(Inst(m%CDInst)%prof_t_wave_set, DbKi))) ) CALL WrScr( ' CableDyn profile counts: update='// & TRIM(Num2LStr(Inst(m%CDInst)%prof_n_update))// & ' solve='//TRIM(Num2LStr(Inst(m%CDInst)%prof_n_solve))// & @@ -2523,6 +2575,14 @@ SUBROUTINE CD_End(u, p, x, xd, z, other, y, m, ErrStat , ErrMsg) ' alloc='//TRIM(Num2LStr(hn_alloc)) ) CALL WrScr( ' CableDyn Hermite recoveries: intervals='// & TRIM(Num2LStr(CD_HermiteCable_Dyn_Recovery_Count())) ) + ! the residual and tangent assemblies split into their sections + CALL CD_HermiteCable_Dyn_Get_Assembly_Profile(ht_asm) + asm_txt = ' CableDyn Hermite assembly:' + DO k_i = 1, HC_ASM_NSEC + asm_txt = asm_txt//' '//TRIM(HC_ASM_KEYS(k_i))//'_s='// & + TRIM(Num2LStr(REAL(ht_asm(k_i), DbKi))) + END DO + CALL WrScr( asm_txt ) END IF END IF ! Propagate a teardown failure as SEVERE (not fatal): the glue's End path @@ -4257,6 +4317,12 @@ SUBROUTINE reset_instance_profile( id, enabled, init_seconds, reset_global ) Inst(id)%prof_t_calcout = 0.0_wp Inst(id)%prof_t_loads = 0.0_wp Inst(id)%prof_t_native = 0.0_wp + Inst(id)%prof_t_overlay = 0.0_wp + Inst(id)%prof_t_channels = 0.0_wp + Inst(id)%prof_t_restore = 0.0_wp + Inst(id)%prof_t_wave_kin = 0.0_wp + Inst(id)%prof_t_wave_check = 0.0_wp + Inst(id)%prof_t_wave_set = 0.0_wp IF (reset_global) THEN CALL CD_HermiteCable_Dyn_Recovery_Reset() IF (enabled) THEN @@ -4286,6 +4352,12 @@ SUBROUTINE copy_instance_profile( destination, source ) Inst(destination)%prof_t_calcout = Inst(source)%prof_t_calcout Inst(destination)%prof_t_loads = Inst(source)%prof_t_loads Inst(destination)%prof_t_native = Inst(source)%prof_t_native + Inst(destination)%prof_t_overlay = Inst(source)%prof_t_overlay + Inst(destination)%prof_t_channels = Inst(source)%prof_t_channels + Inst(destination)%prof_t_restore = Inst(source)%prof_t_restore + Inst(destination)%prof_t_wave_kin = Inst(source)%prof_t_wave_kin + Inst(destination)%prof_t_wave_check = Inst(source)%prof_t_wave_check + Inst(destination)%prof_t_wave_set = Inst(source)%prof_t_wave_set END SUBROUTINE copy_instance_profile !> Validate an instance handle (fails closed on 0 / stale handles, e.g. after a