Runs structural checks against a domain_decomposition object and
returns a list of valid (logical) and issues (character vector
of human-readable problem descriptions).
Value
list with elements valid (logical scalar) and issues
(character vector — empty when valid is TRUE).
Details
Structural checks, run in order:
Outlet count — each basin's
domain_connectivityoverlay resolves to exactly one outlet sub-network viasort_network()withsplit = TRUE. Domains may have multiple outlets by design and are not checked.Coverage / partition — every
source_networkid appears in exactly one domain'scatchmentsslot.Connectivity membership — each domain's rows that carry the reserved outlet
toidvalue (other than genuine basin outlets, whosesource_networktoidcarries the same reserved value) appear, withtoids intact, in some basin'sdomain_connectivityoverlay. Seehy_domain()for the dual-ownership rule behind this duplication.Inter-domain cycle — the derived domain graph (
get_domain_graph()withrelations = "flow") is acyclic; checked by delegating tocheck_hy_graph().Nexus existence — every
nexus_idreferenced by a flow row in the derived inter-domain edge list is registered innexus_registry. Containment relationships are not checked here because no flow crosses a hydro nexus between contained and containing domains.Containment resolution — every non-NA
containing_domain_idresolves to a key ofdecomposition$domains, no domain is contained by itself, and the sequence of containers (A inside B inside C, ...) does not loop back on itself. The acyclic check runscheck_hy_graph()on the containment relationships pulled from each domain.Override references — every row in
overrides(when present) names a known source/sink domain viaid/toidand a known source/sink nexus viasource_nexus_id/sink_nexus_id.
See also
domain_decomposition for the object's slots,
hy_domain() for the per-domain object, decompose_network().
Examples
lev <- hy(data.frame(
id = 1:3, toid = c(2L, 3L, 0L),
topo_sort = 3:1, levelpath = c(1L, 1L, 1L),
levelpath_outlet_id = c(3L, 3L, 3L)))
domain <- hy_domain(
domain_id = "T1",
outlet_nexus_id = "n_out",
inlet_nexus_ids = character(0),
containing_domain_id = NA_character_,
catchments = lev)
d <- structure(
list(
domains = list(T1 = domain),
domain_connectivity = list(),
overrides = NULL,
catchment_domain_index = setNames(rep("T1", 3), c("1", "2", "3")),
nexus_registry = data.frame(nexus_id = "n_out"),
source_network = lev),
class = "domain_decomposition")
validate_decomposition(d)
#> $valid
#> [1] TRUE
#>
#> $issues
#> character(0)
#>
