Domain loaders¶
Build a Domain from a file path or from the valence-domains registry.
From files¶
load_domain_from_fort14¶
admesh.load_domain_from_fort14 ¶
Load a domain boundary from a fort.14 mesh file.
Extracts the outer boundary polygon from a fort.14 mesh. Uses mesh node coordinates to compute bbox and boundary vertices as fixed points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to fort.14 mesh file. |
required |
Returns:
| Type | Description |
|---|---|
Domain
|
Domain with polygon rings extracted from fort.14 boundaries. |
Source code in src/admesh/loaders.py
load_domain_from_json¶
admesh.load_domain_from_json ¶
Load a domain definition from a JSON file.
Expected JSON structure::
{
"name": "example",
"bbox": [-1.0, -1.0, 1.0, 1.0],
"rings": [
[[-1, -1], [1, -1], [1, 1], [-1, 1]],
[[-0.25, -0.25], [0.25, -0.25], [0.25, 0.25], [-0.25, 0.25]]
],
"fixed_points": [[-1, -1], [1, 1]]
}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to JSON domain file. |
required |
Returns:
| Type | Description |
|---|---|
Domain
|
Ready for admesh.triangulate(). |
Notes
The declared bbox in the file, if present, overrides the bounding box
computed from ring extent. Omit bbox to auto-compute.
Source code in src/admesh/loaders.py
load_domain_from_toml¶
admesh.load_domain_from_toml ¶
Load a domain definition from a TOML file.
Expected TOML structure::
[domain]
name = "example"
bbox = [-1.0, -1.0, 1.0, 1.0]
[[domain.rings]]
coords = [[-1, -1], [1, -1], [1, 1], [-1, 1]]
[[domain.rings]] # Optional: interior islands
coords = [[-0.25, -0.25], [0.25, -0.25], [0.25, 0.25], [-0.25, 0.25]]
[[domain.fixed_points]] # Optional: pinned vertices
coords = [[-1, -1], [1, 1]]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to TOML domain file. |
required |
Returns:
| Type | Description |
|---|---|
Domain
|
Ready for admesh.triangulate(). |
Notes
The declared bbox in the file, if present, overrides the bounding box
computed from ring extent. Omit bbox to auto-compute.
Source code in src/admesh/loaders.py
From the registry¶
Registry lookups need the valence-domains package. Manifest schemas 0.3 and
0.4 are both supported; see the
valence-domains contract.
load_domain_from_registry¶
admesh.load_domain_from_registry ¶
Fetch a domain from the ADMESH-Domains registry by name.
Requires the valence-domains package. Network downloads through
Mesh.load() additionally require the optional [registry] extra
(pip install admesh2D[registry]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Domain name in the registry (e.g. |
required |
mesh_id
|
str
|
Mesh id within the domain. Defaults to |
'default@v1'
|
Returns:
| Type | Description |
|---|---|
Domain
|
Domain ready for :func: |
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
ValueError
|
If the domain name is not in the registry. On |
Examples:
>>> from admesh import load_domain_from_registry, triangulate
>>> domain = load_domain_from_registry('BaranjaHill')
>>> mesh = triangulate(domain, h0=0.1)
Source code in src/admesh/registry.py
load_domain_with_metadata¶
admesh.load_domain_with_metadata ¶
Load a domain plus provenance metadata from the registry.
Returns the same :class:Domain as :func:load_domain_from_registry
plus a metadata dict drawn from the upstream Domain/Mesh
objects (license, contributor, bounding box, etc.; missing fields
are skipped).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Domain name in the registry. |
required |
mesh_id
|
str
|
Mesh id within the domain. |
'default@v1'
|
Returns:
| Name | Type | Description |
|---|---|---|
domain |
Domain
|
Domain ready for :func: |
metadata |
dict
|
Provenance fields extracted from the registry objects. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
ValueError
|
If the domain name is not in the registry. |
Source code in src/admesh/registry.py
list_available_domains¶
admesh.list_available_domains ¶
List domains and collections available in the Valence-Domains registry.
Requires the valence-domains package.
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Mapping of primary domain or collection name to a short description ( |
Raises:
| Type | Description |
|---|---|
ImportError
|
If |