Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions python/tests/test_deck_native_parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2713,3 +2713,36 @@ def test_route_rules_match_the_driver(text, tmp_path):
)
assert completed.returncode in (0, 1), completed.stderr[-600:]
assert _accepted(deck) == (completed.returncode == 0), completed.stderr[-600:]


@pytest.mark.skipif(
not _PARITY_DRIVER or not Path(_PARITY_DRIVER).is_file(),
reason="set CABLEDYN_TEST_DRIVER to a built native driver to run the refinement-stop check",
)
def test_a_compression_refinement_leaves_where_it_was_stops_the_refinement(tmp_path):
# the power cable with its sections given twice: too long to hang clear of the seabed, it is
# held in axial compression by its bending stiffness, a compression of the equilibrium that
# no mesh removes; the axial refinement stops once two passes leave it where it was instead
# of splitting elements to the element budget (6 passes, 32768 elements)
tail = "1 bare 52.101 256\n"
text = _example(
"lozon_gomex80_power_cable.dat",
(tail, tail + "1 bare 68.114 448\n1 buoy 50.000 320\n" + tail),
)
deck = tmp_path / "long.dat"
deck.write_text(text, encoding="utf-8")
completed = subprocess.run(
[_PARITY_DRIVER, str(deck), str(tmp_path / "long")],
capture_output=True,
text=True,
errors="replace",
cwd=tmp_path,
timeout=900,
env={**os.environ, "OMP_NUM_THREADS": "1", "OPENBLAS_NUM_THREADS": "1"},
check=False,
)
assert completed.returncode == 2, completed.stderr[-600:]
assert "two passes left the compression where it was" in completed.stderr, completed.stderr[
-900:
]
assert _accepted(deck)
17 changes: 16 additions & 1 deletion src/CableDyn_HermiteCableStatic.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6565,7 +6565,9 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs
! move toward the compression, so it is given two more.
INTEGER :: max_axial_stall_passes
INTEGER, PARAMETER :: AXIAL_BUDGET_FLOOR = 2048
INTEGER :: axial_budget, axial_stall, wios
INTEGER :: axial_budget, axial_stall, axial_flat, wios
! A violation within this share of the previous pass's is flat: refinement does not move it.
REAL(wp), PARAMETER :: AXIAL_FLAT_REL = 1.0e-3_wp
REAL(wp) :: axial_prev, end_res_prev
LOGICAL :: end_min, end_prev, end_settled
CHARACTER(400) :: axial_stop
Expand All @@ -6576,6 +6578,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs
applied_scale = 1
local_passes = 0
axial_stall = 0
axial_flat = 0
axial_prev = CD_ZERO
end_prev = .FALSE.
end_res_prev = CD_ZERO
Expand Down Expand Up @@ -6870,6 +6873,14 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs
ELSE
axial_stall = axial_stall + 1
END IF
! A compression that two successive passes leave where it was (to 0.1 %) is the
! equilibrium's, not the mesh's: splitting the elements around it further only grows
! the mesh to its budget. (A mesh compression falls as its elements are split.)
IF (ABS(diag_out%axial_violation - axial_prev) <= AXIAL_FLAT_REL*axial_prev) THEN
axial_flat = axial_flat + 1
ELSE
axial_flat = 0
END IF
END IF
needs_refinement = (must_be_tensile .AND. diag_out%axial_compression) .OR. &
(refine_other .AND. refinable(diag_out))
Expand All @@ -6879,6 +6890,10 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs
axial_stop = 'the minimum axial strain stopped improving'
EXIT
END IF
IF (needs_refinement .AND. local_axial .AND. axial_flat >= 2) THEN
axial_stop = 'two passes left the compression where it was: it is the equilibrium''s, not the mesh''s'
EXIT
END IF
IF (needs_refinement .AND. local_axial .AND. end_settled) THEN
axial_stop = 'the compression is the reaction of a held end, which refinement does not change'
EXIT
Expand Down
Loading