ymf 0.3.1__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ymf-0.3.1/src/ymf.egg-info → ymf-0.3.2}/PKG-INFO +1 -1
- {ymf-0.3.1 → ymf-0.3.2}/docs/changes.md +26 -0
- {ymf-0.3.1 → ymf-0.3.2}/docs/problem-specification.md +68 -2
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/boundaries.py +2 -2
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/conditions.py +62 -5
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/names.py +3 -3
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/normalize.py +4 -2
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/references.py +37 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/schema.py +13 -1
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/stabilization.py +13 -2
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/symbolic/language.py +1 -1
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/symbolic/notation.py +32 -9
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/symbolic/printer.py +2 -2
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/symbolic/problem.py +3 -1
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/symbolic/split.py +68 -8
- {ymf-0.3.1 → ymf-0.3.2/src/ymf.egg-info}/PKG-INFO +1 -1
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf.egg-info/SOURCES.txt +6 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf.egg-info/scm_file_list.json +6 -0
- ymf-0.3.2/src/ymf.egg-info/scm_version.json +8 -0
- ymf-0.3.2/tests/fixtures/shallow_water/obstacle_inflow.ymf +38 -0
- ymf-0.3.2/tests/fixtures/shallow_water/santos_step.ymf +52 -0
- ymf-0.3.2/tests/fixtures/shallow_water/transcritical_bump.ymf +39 -0
- ymf-0.3.2/tests/test_atan.py +87 -0
- ymf-0.3.2/tests/test_boundary_parts.py +214 -0
- ymf-0.3.2/tests/test_boundary_trace.py +100 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_printer.py +1 -1
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_stabilization.py +34 -0
- ymf-0.3.1/src/ymf.egg-info/scm_version.json +0 -8
- {ymf-0.3.1 → ymf-0.3.2}/.gitignore +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/LICENSE +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/MANIFEST.in +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/README.md +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/RELEASING.md +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/docs/README.md +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/docs/archive-format.md +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/docs/design/domains-beyond-box.md +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/docs/design/time-outside-space.md +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/docs/history/schema-v0.1.md +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/docs/history/schema-v0.2-delta.md +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/docs/history/session-2026-07-29.md +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/docs/research/csdms-bmi.md +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/docs/research/data-sources.md +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/docs/research/units.md +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/docs/xdmf-model.yaml +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/README.md +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/heat_equation.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/kovasznay_flow.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/navier_stokes/navier_stokes_model.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/navier_stokes/planar_couette.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/navier_stokes/plane_poiseuille.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/navier_stokes/plane_poiseuille_re100.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/navier_stokes/plane_poiseuille_refined.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/nonlinear_diffusion.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/notebooks/COMPARISON.md +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/notebooks/YMF-original.ipynb +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/notebooks/YMF-updated.ipynb +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/notebooks/build_updated_notebook.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/poisson.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/poisson_spaces.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/poisson_v02_enriched.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/read_archive.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/validate_spec.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/examples/write_archive.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/pyproject.toml +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/setup.cfg +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/__init__.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/archive.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/cli.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/closure.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/compose.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/data_sources.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/discretizations.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/dispersion.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/domain.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/explicit.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/generated.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/mesh.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/spaces.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/state.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/symbolic/__init__.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/symbolic/adr.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/units.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/vocabulary.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf/xdmf.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf.egg-info/dependency_links.txt +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf.egg-info/entry_points.txt +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf.egg-info/requires.txt +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/src/ymf.egg-info/top_level.txt +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/_formulation.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/format1_two_spaces.xmf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/format1_two_spaces.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/proteus/hexahedron.xmf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/proteus/polyline.xmf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/proteus/quadrilateral.xmf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/proteus/tet_10.xmf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/proteus/tetrahedron.xmf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/proteus/tri_6.xmf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/proteus/triangle.xmf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/proteus_dispatch_0_2/README.md +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/proteus_dispatch_0_2/dambreak.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/proteus_dispatch_0_2/two_phase_level_set.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/shallow_water/circular_dam_dispersive.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/shallow_water/dam3bumps.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/shallow_water/dispersive.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/shallow_water/dispersive_numerics.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/shallow_water/lake_at_rest.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/shallow_water/proteus_numerics.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/shallow_water/shallow_water.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/shallow_water/torino.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/two_phase/dambreak.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/two_phase/dambreak_clsvof.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/two_phase/dambreak_formulation.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/two_phase/dambreak_porous.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/fixtures/two_phase/two_phase_level_set.ymf +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_archive.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_archive_spec_as_written.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_boundary_declaration.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_boundary_kinds.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_cells_per_axis.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_cli.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_closure.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_coefficient_roles.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_compose.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_condition_expansion.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_condition_sets.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_core_without_frontend.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_data_sources.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_decimals_as_written.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_discrete_domains.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_discretizations.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_dispersion.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_domain.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_examples.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_explicit.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_extends_initial_conditions.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_file_domains.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_gauges.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_generated.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_indicator_conditions.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_lagging.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_linear_solver.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_mesh.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_mesh_fingerprint.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_named_coefficients.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_named_equations.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_nesting.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_normalize.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_notation.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_notation_functions.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_periodic_regions.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_proteus_archive.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_references.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_removal.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_schema.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_select.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_shallow_water.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_spaces.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_split.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_stabilization_compat.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_state.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_state_coefficients.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_subproblems.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_symbolic.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_tag_regions.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_units.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_values.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_version.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_vocabulary.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_xdmf.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_xdmf_fragments.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tests/test_xdmf_model.py +0 -0
- {ymf-0.3.1 → ymf-0.3.2}/tools/check_dist.sh +0 -0
|
@@ -7,6 +7,32 @@ rediscover why a thing is the way it is. Open gaps are in
|
|
|
7
7
|
|
|
8
8
|
## 2026-11
|
|
9
9
|
|
|
10
|
+
- **2026-11-25: C42 round 7, `reference` optional at `beta` 1.** `missing()` asked for `shock_capturing.reference` of every
|
|
11
|
+
stated shock-capturing block, though a `beta: 1` kernel (the classical `factor |R|/sqrt(∇uᵀ G ∇u)`, proteus's RDLS)
|
|
12
|
+
never reads it. It no longer does when `beta` is stated as 1 (any spelling: `beta`, `sc_beta`); stating a reference
|
|
13
|
+
there is still allowed and checked (positive), and any other or unstated `beta` still needs it. Nothing is defaulted.
|
|
14
|
+
|
|
15
|
+
- **2026-11-25: C42 round 7, a boundary value from another sub-problem's trace.** NCLS's inflow penalty is written
|
|
16
|
+
against RDLS's face values (C19 gap note G8), which a condition could not say: its value was an expression. Now a
|
|
17
|
+
Dirichlet, `inflow` or `characteristic` condition may give `trace: {of, via, at}` instead of a value; `split_problem`
|
|
18
|
+
carries it to the sub-problems that solve the variable (not `via` itself) and refuses a `via` that is not in the
|
|
19
|
+
discretization or a `current_step` read of a later sub-problem. It is part of an archive's key.
|
|
20
|
+
|
|
21
|
+
- **2026-11-25: C42 round 7, `atan`.** santos_step's bed, `0.1 (0.5 + arctan(x/0.075)/π)`, could not be written (`atan`
|
|
22
|
+
was not a function of the notation). Now `atan(e)` parses, prints back (the printer's round trip), is `numpy.arctan`
|
|
23
|
+
in code, and differentiates (the bed slope in the momentum equation). Fixture `santos_step.ymf`: the deck's solitary
|
|
24
|
+
wave over the step, dispersive, with its own hw. One test that used `atan` as its example of a function with no
|
|
25
|
+
notation now uses `asin`.
|
|
26
|
+
|
|
27
|
+
- **2026-11-25: C42 round 7, a state on part of a boundary.** The SWFlow decks impose their inflow node by node on
|
|
28
|
+
part of one boundary (`X[0] == 0`) and on one Cartesian component (`x_mom`, `y_mom`), which a spec could not say: a
|
|
29
|
+
`component` was the normal or tangential part only (it needs the side's orientation), and a condition held on its
|
|
30
|
+
whole region. Now a condition may carry `part`, a predicate like a region's `where`, and there it replaces the
|
|
31
|
+
region's conditions on the same variable without a part on an overlapping component; a `component` may be `x`, `y`,
|
|
32
|
+
`z`; and predicates take comparisons (`x = 0 and 0.4 ≤ y ≤ 0.6`). `split_problem` gives `part` and `excluding`
|
|
33
|
+
(codes), so a reader applies each entry as written. Fixtures: `transcritical_bump.ymf` (the deck's three conditions)
|
|
34
|
+
and `obstacle_inflow.ymf` (obstacle_flow's boundary on its box: the outflow set with the state on x = 0).
|
|
35
|
+
|
|
10
36
|
- **2026-11-18: 0.3.1, a stabilization without a method (C42 round 6).** ymf 0.3.0 required `method` in every
|
|
11
37
|
`stabilization:` block, so proteus's RDLS block (`stabilization: {shock_capturing: {factor: 0.9, lag: false}}`, read
|
|
12
38
|
as a free map by ymf 0.2) no longer loaded, and `test/dispatch` broke on every proteus PR. Now `method: none` is a
|
|
@@ -182,6 +182,70 @@ the region exists, the variable is an unknown or a coefficient, `slip` and
|
|
|
182
182
|
a `component` are on a vector, and a kind gets a value exactly when it
|
|
183
183
|
takes one.
|
|
184
184
|
|
|
185
|
+
**A state on part of a boundary** (round 7). A condition's `part` is a
|
|
186
|
+
predicate, written like a region's `where`, that says on which points of its
|
|
187
|
+
region it holds; there it replaces the region's conditions on the same
|
|
188
|
+
variable that have no part and are on an overlapping component, and those
|
|
189
|
+
hold on the rest. A `component` may also be a Cartesian one, `x`, `y` or
|
|
190
|
+
`z` (the vector's first, second, third), with a value (dirichlet, neumann,
|
|
191
|
+
inflow, characteristic). So the SWFlow decks' inflows read as they are
|
|
192
|
+
imposed:
|
|
193
|
+
|
|
194
|
+
```yaml
|
|
195
|
+
# transcritical_bump: q's y component 0 on all of ∂Ω, its x component at x = 0, the depth at x = 25
|
|
196
|
+
boundary_regions: [{name: all, where: "∂Ω"}]
|
|
197
|
+
boundary_conditions:
|
|
198
|
+
- {region: all, variable: q, type: dirichlet, component: y, value: 0.0}
|
|
199
|
+
- {region: all, part: "x = 0", variable: q, type: dirichlet, component: x, value: 0.18}
|
|
200
|
+
- {region: all, part: "x = 25", variable: h, type: dirichlet, value: 0.28205279813802181}
|
|
201
|
+
# obstacle_flow: the whole state on x = 0, the outflow elsewhere
|
|
202
|
+
boundary_sets: [{region: all, set: outflow}]
|
|
203
|
+
boundary_conditions:
|
|
204
|
+
- {region: all, part: "x = 0", variable: h, type: dirichlet, value: 1.0}
|
|
205
|
+
- {region: all, part: "x = 0", variable: q, type: dirichlet, formula: "(1.5, 0)"}
|
|
206
|
+
# a window in a wall: the wall holds off it
|
|
207
|
+
boundary_sets: [{region: walls, set: wall}]
|
|
208
|
+
boundary_conditions:
|
|
209
|
+
- {region: walls, part: "x = 0 and 4 ≤ y ≤ 6", variable: q, type: dirichlet, formula: "(1.5, 0)"}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Components overlap unless they are two different Cartesian ones or the
|
|
213
|
+
normal and the tangential part (`ymf.conditions.overlap`): the x component
|
|
214
|
+
at x = 0 leaves the y component's condition alone there, a whole-vector
|
|
215
|
+
state replaces both parts of a wall. A part is not a region, so it replaces
|
|
216
|
+
no condition set's member (the member is the rest), and a part of a tag
|
|
217
|
+
region is found by flag and position together. `split_problem` gives a
|
|
218
|
+
condition with a part its `part` (code, beside the region's `where` or
|
|
219
|
+
`flags`), and one without whose region other conditions carve parts out of
|
|
220
|
+
its `excluding` (a list of codes): it holds where its region does, less
|
|
221
|
+
those, so a reader applies each entry as written and decides no precedence.
|
|
222
|
+
A Cartesian component's entry acts on that one component (`components:
|
|
223
|
+
[q_0]`). Refused on load: a part that is the whole region (`∂Ω`), a part on
|
|
224
|
+
a periodic condition, a Cartesian component on slip, open, robin or
|
|
225
|
+
periodic. `adr_problem` (one system) runs neither a part nor a component.
|
|
226
|
+
Parts of one region and variable should not overlap; that is not checked.
|
|
227
|
+
|
|
228
|
+
**A value from another sub-problem's trace** (round 7). In a split
|
|
229
|
+
discretization one sub-problem may impose, on a boundary, the boundary
|
|
230
|
+
values another holds (NCLS's inflow penalty against RDLS's face values):
|
|
231
|
+
`trace: {of, via, at}` in place of `value`, `formula` or `series`. `via`
|
|
232
|
+
names the sub-problem, `of` the field (default the condition's variable),
|
|
233
|
+
`at` when (`previous_step`, or `current_step` from an earlier sub-problem of
|
|
234
|
+
the step, as a lag says it).
|
|
235
|
+
|
|
236
|
+
```yaml
|
|
237
|
+
boundary_conditions:
|
|
238
|
+
- {region: top, variable: φ, type: dirichlet, imposed: weak,
|
|
239
|
+
trace: {of: φ, via: rdls, at: previous_step}}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Dirichlet, `inflow` and `characteristic` only, whole fields (no
|
|
243
|
+
`component`). `split_problem` gives the entry `trace` (with `of` filled in)
|
|
244
|
+
and no `value`, to every sub-problem that solves the variable except `via`
|
|
245
|
+
itself, which has its own values; a `via` that is no sub-problem of the
|
|
246
|
+
discretization, or is solved later than a `current_step` read, is refused.
|
|
247
|
+
`adr_problem` runs none.
|
|
248
|
+
|
|
185
249
|
**Condition sets.** What a free-slip wall or an open top means is part of
|
|
186
250
|
the model: written once there, over its own unknowns and coefficients, and
|
|
187
251
|
applied to regions by each problem.
|
|
@@ -370,13 +434,14 @@ solution_paths:
|
|
|
370
434
|
| `(a, b)` | a vector |
|
|
371
435
|
| `x² π³ x^n x**n` | powers |
|
|
372
436
|
| `2π²κt`, `κ ΔT`, `sin(πx)` | implicit multiplication |
|
|
373
|
-
| `sin cos tan exp log sqrt sinh cosh tanh abs` | functions, with parentheses |
|
|
437
|
+
| `sin cos tan atan exp log sqrt sinh cosh tanh abs` | functions, with parentheses (`atan` is the arctangent, `numpy.arctan` in code) |
|
|
374
438
|
| `hypot(a, b)` | `sqrt(a² + b²)` rounded once (C99 `hypot`, `numpy.hypot` in code): a distance that matches code computing it with `hypot`, bit for bit |
|
|
375
439
|
| `heaviside(φ)`, `sign(e)`, `min(a, b, ...)`, `max(a, b, ...)` | sharp functions; a solver needs `heaviside` and `sign` of an unknown regularized, since their derivatives are Dirac deltas |
|
|
376
440
|
| `norm(v)`, `sym(∇v)` | `sqrt(v·v)`, and the symmetric part `(A + Aᵀ)/2` of a square tensor |
|
|
377
441
|
| `grad div lap dt dx dy dz dot outer` | the operators spelled out, for ASCII-only text |
|
|
378
442
|
| `lhs = rhs in Ω` | an equation; the `in ...` clause is ignored |
|
|
379
443
|
| `y = 0 or x = 0 and y = H` | a boundary region; `∂Ω` is the whole boundary |
|
|
444
|
+
| `x = 0 and 0.4 ≤ y ≤ 0.6` | comparisons in a predicate (`≤ ≥ < >`, or `<= >=`; chained): a closed bound keeps the points on it (within `tol`), an open one drops them |
|
|
380
445
|
| `Ω = [a, b] × [c, d], t ∈ (t0, t1]` | the domain, a box, and the time interval of a transient problem |
|
|
381
446
|
|
|
382
447
|
**Decimals are kept as written.** A numeral is an IEEE double, and a
|
|
@@ -984,7 +1049,8 @@ three and adds no other key.
|
|
|
984
1049
|
*What a reader that must not guess still needs: `ymf.stabilization.missing(block)`.* It returns the dotted keys the
|
|
985
1050
|
kernel generator reads that the block does not state, and nothing is filled in: `missing("SUPG")` is `["tau", "lagged",
|
|
986
1051
|
"shock_capturing"]`; with `shock_capturing: {factor: 0.9, lagged: false}` stated it also asks for `shock_capturing.beta` and
|
|
987
|
-
`.reference` (stating `shock_capturing: none` answers the block as a whole
|
|
1052
|
+
`.reference` (stating `shock_capturing: none` answers the block as a whole; **at `beta: 1`, the classical form that never
|
|
1053
|
+
reads the reference value, `reference` is not asked for**: proteus's RDLS is `{factor: 0.9, beta: 1.0, lagged: false}`); the entropy and graph viscosities need
|
|
988
1054
|
nothing. For `none`, an unstated `shock_capturing` is not missing (the word says there is none); a `shock_capturing`
|
|
989
1055
|
block it does state must be complete, so `missing({"shock_capturing": {"factor": 0.9, "lag": False}})` is
|
|
990
1056
|
`["shock_capturing.beta", "shock_capturing.reference"]` and `missing("none")` is `[]`.
|
|
@@ -103,14 +103,14 @@ def check_condition(condition: Dict[str, Any], where: str) -> None:
|
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
def kinds(doc: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
106
|
-
"""Every boundary condition of the document, expanded, as ``{region, variable, type, [component], [only], kind,
|
|
106
|
+
"""Every boundary condition of the document, expanded, as ``{region, [part], variable, type, [component], [only], kind,
|
|
107
107
|
[penalty], [form]}`` in order: what a solver reads to choose its boundary terms."""
|
|
108
108
|
from ymf.conditions import expand
|
|
109
109
|
from ymf.normalize import boundary_conditions
|
|
110
110
|
strong = ((expand(doc).get("model") or {}).get("strong_form") or {})
|
|
111
111
|
out = []
|
|
112
112
|
for bc in boundary_conditions(strong):
|
|
113
|
-
entry = {k: bc[k] for k in ("region", "variable", "type", "component", "only") if bc.get(k) is not None}
|
|
113
|
+
entry = {k: bc[k] for k in ("region", "part", "variable", "type", "component", "only") if bc.get(k) is not None}
|
|
114
114
|
entry["kind"] = kind_of(bc)
|
|
115
115
|
for k in ("penalty", "form"):
|
|
116
116
|
if bc.get(k) is not None:
|
|
@@ -13,9 +13,12 @@ be reproducible from its record.
|
|
|
13
13
|
An expanded condition is one of the abstract forms, on
|
|
14
14
|
|
|
15
15
|
* the whole variable, or a ``component`` of a vector: its ``normal`` or
|
|
16
|
-
``tangential`` part on the boundary
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
``tangential`` part on the boundary, or a Cartesian component ``x``, ``y``,
|
|
17
|
+
``z``;
|
|
18
|
+
* the whole region, or a ``part`` of it given by a predicate (``x = 0 and
|
|
19
|
+
0.4 ≤ y ≤ 0.6``: a state imposed on part of a boundary), and ``only`` the
|
|
20
|
+
part of that where the flow enters (``inflow``) or where characteristics
|
|
21
|
+
enter (``incoming_characteristics``);
|
|
19
22
|
|
|
20
23
|
with its value (``value``, ``formula`` or ``series``), optionally how it is
|
|
21
24
|
``imposed`` (``strong`` or ``weak``: C12 makes that a property of each
|
|
@@ -26,6 +29,21 @@ from.
|
|
|
26
29
|
document; it is idempotent, and a document with no alias and no condition set
|
|
27
30
|
comes back unchanged, so the outputs it keys keep their keys.
|
|
28
31
|
|
|
32
|
+
**A part, and the rest of its region.** A condition with a ``part`` holds
|
|
33
|
+
on the points of its region where the predicate holds, and there it replaces
|
|
34
|
+
the conditions on the same region and variable that have no part and are on
|
|
35
|
+
a component that overlaps its own (:func:`overlap`: the whole variable
|
|
36
|
+
overlaps every component; ``x`` and ``y``, or ``normal`` and ``tangential``,
|
|
37
|
+
do not): those hold on the rest of the region. So ``boundary_sets: [{region: all, set: wall}]``
|
|
38
|
+
and ``{region: all, part: "x = 0", variable: q, type: dirichlet, formula:
|
|
39
|
+
"(0.75, 0)"}`` is a wall everywhere but on x = 0, where the discharge is
|
|
40
|
+
given; ``{region: all, variable: q, type: dirichlet, component: y, value:
|
|
41
|
+
0}`` with ``{region: all, part: "x = 0", variable: q, type: dirichlet,
|
|
42
|
+
component: x, value: 0.18}`` holds q's y component everywhere, x = 0
|
|
43
|
+
included. A part is not a region of its own, so a condition with a part does
|
|
44
|
+
not replace a condition set's member either: the member is the rest.
|
|
45
|
+
:func:`excluded` gives the parts a condition without one does not hold on.
|
|
46
|
+
|
|
29
47
|
This module is stdlib only, like the rest of the spec core.
|
|
30
48
|
"""
|
|
31
49
|
|
|
@@ -34,7 +52,11 @@ from __future__ import annotations
|
|
|
34
52
|
import copy
|
|
35
53
|
from typing import Any, Dict, List, Tuple
|
|
36
54
|
|
|
37
|
-
__all__ = ["ALIASES", "ABSTRACT", "expand", "expand_condition", "has_shorthand", "describe"
|
|
55
|
+
__all__ = ["ALIASES", "ABSTRACT", "AXES", "expand", "expand_condition", "has_shorthand", "describe", "parts",
|
|
56
|
+
"excluded", "overlap"]
|
|
57
|
+
|
|
58
|
+
#: the Cartesian components a condition may be on, and the index of each
|
|
59
|
+
AXES = {"x": 0, "y": 1, "z": 2}
|
|
38
60
|
|
|
39
61
|
#: the abstract forms: what an expansion is made of
|
|
40
62
|
ABSTRACT = ("dirichlet", "neumann", "robin", "periodic")
|
|
@@ -43,7 +65,7 @@ ABSTRACT = ("dirichlet", "neumann", "robin", "periodic")
|
|
|
43
65
|
_VALUE_KEYS = ("value", "formula", "series", "units")
|
|
44
66
|
|
|
45
67
|
#: the order an expanded condition's keys are written in
|
|
46
|
-
_ORDER = ("region", "variable", "type", "component", "only", "value", "formula", "series",
|
|
68
|
+
_ORDER = ("region", "part", "variable", "type", "component", "only", "value", "formula", "series",
|
|
47
69
|
"alpha", "beta", "units", "imposed", "penalty", "form", "source", "source_url", "temporal",
|
|
48
70
|
"expanded_from")
|
|
49
71
|
|
|
@@ -191,3 +213,38 @@ def expand(doc: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
191
213
|
def describe() -> List[Tuple[str, str, List[Dict[str, Any]]]]:
|
|
192
214
|
"""``(alias, what it means, its components)`` for the documentation."""
|
|
193
215
|
return [(name, a["means"], copy.deepcopy(a["components"])) for name, a in ALIASES.items()]
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def overlap(a: Any, b: Any) -> bool:
|
|
220
|
+
"""Whether conditions on components ``a`` and ``b`` of one variable (None: the whole variable) can constrain the
|
|
221
|
+
same thing: not when they are two different Cartesian components, nor the normal and the tangential part."""
|
|
222
|
+
if a is None or b is None or a == b:
|
|
223
|
+
return True
|
|
224
|
+
if a in AXES and b in AXES:
|
|
225
|
+
return False
|
|
226
|
+
return {a, b} != {"normal", "tangential"}
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def parts(conditions: List[Dict[str, Any]]) -> Dict[Tuple[Any, Any], List[Tuple[str, Any]]]:
|
|
230
|
+
"""``{(region, variable): [(part, component), ...]}``: the parts of each region that conditions on a variable claim,
|
|
231
|
+
with the component each is on, in the order written, each once."""
|
|
232
|
+
out: Dict[Tuple[Any, Any], List[Tuple[str, Any]]] = {}
|
|
233
|
+
for bc in conditions:
|
|
234
|
+
if isinstance(bc, dict) and bc.get("part") is not None:
|
|
235
|
+
claimed = out.setdefault((bc.get("region"), bc.get("variable")), [])
|
|
236
|
+
if (bc["part"], bc.get("component")) not in claimed:
|
|
237
|
+
claimed.append((bc["part"], bc.get("component")))
|
|
238
|
+
return out
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def excluded(bc: Dict[str, Any], claimed: Dict[Tuple[Any, Any], List[Tuple[str, Any]]]) -> List[str]:
|
|
242
|
+
"""The parts a condition without a part does not hold on: those of its region that conditions on the same variable,
|
|
243
|
+
on a component that overlaps its own, claim (``claimed`` is :func:`parts`). Empty for a condition with a part."""
|
|
244
|
+
if bc.get("part") is not None:
|
|
245
|
+
return []
|
|
246
|
+
out: List[str] = []
|
|
247
|
+
for part, component in claimed.get((bc.get("region"), bc.get("variable")), []):
|
|
248
|
+
if overlap(component, bc.get("component")) and part not in out:
|
|
249
|
+
out.append(part)
|
|
250
|
+
return out
|
|
@@ -28,8 +28,8 @@ class NotationError(ValueError):
|
|
|
28
28
|
|
|
29
29
|
_SUPERSCRIPTS = {"²": 2, "³": 3, "⁴": 4}
|
|
30
30
|
_ALIASES = {"−": "-", "⋅": "·", "∙": "·", "–": "-", "∆": "Δ"}
|
|
31
|
-
_OPERATORS = ["**", "^", "+", "-", "*", "/", "(", ")", "[", "]", ",", "=",
|
|
32
|
-
"·", "⊗", "∇", "Δ", "∂", "×", "∈", ";"] + list(_SUPERSCRIPTS)
|
|
31
|
+
_OPERATORS = ["**", "^", "+", "-", "*", "/", "(", ")", "[", "]", ",", "<=", ">=", "=",
|
|
32
|
+
"≤", "≥", "<", ">", "·", "⊗", "∇", "Δ", "∂", "×", "∈", ";"] + list(_SUPERSCRIPTS)
|
|
33
33
|
_NUMBER = re.compile(r"\d+(\.\d*)?([eE][+-]?\d+)?|\.\d+([eE][+-]?\d+)?")
|
|
34
34
|
|
|
35
35
|
|
|
@@ -97,7 +97,7 @@ _SUBSCRIPT_PLAIN.update({
|
|
|
97
97
|
#: the notation's function names (``ymf.symbolic.notation``'s ``_FUNCTIONS``
|
|
98
98
|
#: and the parser's own; a test checks the two agree)
|
|
99
99
|
FUNCTION_NAMES = frozenset([
|
|
100
|
-
"sin", "cos", "tan", "exp", "log", "sqrt", "sinh", "cosh", "tanh", "abs", "hypot",
|
|
100
|
+
"sin", "cos", "tan", "atan", "exp", "log", "sqrt", "sinh", "cosh", "tanh", "abs", "hypot",
|
|
101
101
|
"heaviside", "sign", "min", "max",
|
|
102
102
|
"div", "grad", "lap", "dt", "dot", "outer", "vec", "norm", "sym", "dx", "dy", "dz",
|
|
103
103
|
])
|
|
@@ -141,13 +141,15 @@ def boundary_conditions(strong_form: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
|
141
141
|
of each applied set, with the region filled in and ``set`` naming where
|
|
142
142
|
it came from. A condition written out for the same region and variable
|
|
143
143
|
as a set's member replaces it: a case can apply ``atmosphere`` and still
|
|
144
|
-
give the pressure its own value.
|
|
144
|
+
give the pressure its own value. A condition with a ``part`` holds on
|
|
145
|
+
part of its region only, so it replaces no member: the member holds on
|
|
146
|
+
the rest (ymf.conditions). Raises ``ValueError`` for a set nobody
|
|
145
147
|
defines, and for two sets that both give one region's variable a
|
|
146
148
|
condition, which nothing would choose between.
|
|
147
149
|
"""
|
|
148
150
|
sets = strong_form.get("condition_sets") or {}
|
|
149
151
|
direct = [dict(bc) for bc in strong_form.get("boundary_conditions") or []]
|
|
150
|
-
written = {(bc.get("region"), bc.get("variable")) for bc in direct}
|
|
152
|
+
written = {(bc.get("region"), bc.get("variable")) for bc in direct if bc.get("part") is None}
|
|
151
153
|
expanded: List[Dict[str, Any]] = []
|
|
152
154
|
given: Dict[Any, str] = {}
|
|
153
155
|
for applied in strong_form.get("boundary_sets") or []:
|
|
@@ -278,6 +278,13 @@ def _check_split(doc: Dict[str, Any], entry: Dict[str, Any]) -> None:
|
|
|
278
278
|
if symbol in readable:
|
|
279
279
|
raise YmfReferenceError(
|
|
280
280
|
"%s.binds.%s: %s is already a name" % (here, symbol, symbol))
|
|
281
|
+
for bc in _traces(strong):
|
|
282
|
+
trace = bc["trace"]
|
|
283
|
+
here = "model.strong_form.boundary_conditions[region=%r, variable=%r].trace" % (
|
|
284
|
+
bc.get("region"), bc.get("variable"))
|
|
285
|
+
_check(trace["via"], names, "%s.via (in %s)" % (here, where), "sub-problem")
|
|
286
|
+
_check(trace.get("of", bc.get("variable")), sorted(readable), "%s.of" % (here,),
|
|
287
|
+
"model unknown, coefficient or introduced unknown")
|
|
281
288
|
if None not in equations:
|
|
282
289
|
unsolved = [e for e in equations if e not in solved_by]
|
|
283
290
|
if unsolved:
|
|
@@ -285,6 +292,15 @@ def _check_split(doc: Dict[str, Any], entry: Dict[str, Any]) -> None:
|
|
|
285
292
|
"%s: no sub-problem solves %s" % (where, ", ".join(unsolved)))
|
|
286
293
|
|
|
287
294
|
|
|
295
|
+
def _traces(strong):
|
|
296
|
+
"""The conditions (sets expanded) whose value is another sub-problem's trace."""
|
|
297
|
+
from ymf.normalize import boundary_conditions
|
|
298
|
+
try:
|
|
299
|
+
return [bc for bc in boundary_conditions(strong) if isinstance(bc, dict) and bc.get("trace") is not None]
|
|
300
|
+
except ValueError:
|
|
301
|
+
return []
|
|
302
|
+
|
|
303
|
+
|
|
288
304
|
#: what each kind of condition needs: a value (value, formula or series),
|
|
289
305
|
#: none, or either
|
|
290
306
|
_NEEDS_VALUE = {"dirichlet": True, "neumann": True, "robin": True, "inflow": True,
|
|
@@ -323,12 +339,33 @@ def _check_conditions(doc: Dict[str, Any]) -> None:
|
|
|
323
339
|
raise YmfReferenceError("%s: %s is neither an unknown nor a coefficient"
|
|
324
340
|
% (where, variable))
|
|
325
341
|
given = any(bc.get(k) is not None for k in ("value", "formula", "series"))
|
|
342
|
+
if bc.get("trace") is not None:
|
|
343
|
+
if given:
|
|
344
|
+
raise YmfReferenceError("%s: a trace is the condition's value; it takes no value, formula or series"
|
|
345
|
+
% (where,))
|
|
346
|
+
if kind not in ("dirichlet", "inflow", "characteristic"):
|
|
347
|
+
raise YmfReferenceError("%s: a %s condition takes no trace; a trace is the value of a dirichlet, "
|
|
348
|
+
"inflow or characteristic condition" % (where, kind))
|
|
349
|
+
if bc.get("component") is not None:
|
|
350
|
+
raise YmfReferenceError("%s: a trace is a whole field's; it takes no component" % (where,))
|
|
351
|
+
given = True
|
|
326
352
|
if bc.get("component") and variable in unknowns and unknowns[variable] != 1:
|
|
327
353
|
raise YmfReferenceError("%s: a %s component is a vector's, and %s is a scalar"
|
|
328
354
|
% (where, bc["component"], variable))
|
|
329
355
|
if kind == "slip" and variable in unknowns and unknowns[variable] != 1:
|
|
330
356
|
raise YmfReferenceError("%s: slip gives the normal component of a vector, and "
|
|
331
357
|
"%s is a scalar" % (where, variable))
|
|
358
|
+
if bc.get("component") in ("x", "y", "z") and kind in ("slip", "open", "robin", "periodic"):
|
|
359
|
+
raise YmfReferenceError("%s: a %s condition on the %s component; a Cartesian component takes a "
|
|
360
|
+
"value (dirichlet, neumann, inflow, characteristic)" % (where, kind, bc["component"]))
|
|
361
|
+
if bc.get("part") is not None:
|
|
362
|
+
part = str(bc["part"]).strip()
|
|
363
|
+
if kind == "periodic":
|
|
364
|
+
raise YmfReferenceError("%s: a periodic condition identifies a region's faces, whole; it has no part"
|
|
365
|
+
% (where,))
|
|
366
|
+
if part in ("", "∂Ω", "∂ Ω", "boundary"):
|
|
367
|
+
raise YmfReferenceError("%s: part %r is the whole region; give no part, or a predicate "
|
|
368
|
+
"(\"x = 0 and 0.4 ≤ y ≤ 0.6\")" % (where, bc["part"]))
|
|
332
369
|
article = "an" if str(kind)[:1] in "aeiou" else "a"
|
|
333
370
|
if _NEEDS_VALUE.get(kind) and not given:
|
|
334
371
|
raise YmfReferenceError("%s: %s %s condition needs a value, formula or series"
|
|
@@ -398,8 +398,20 @@ _CONDITION_FIELDS = {
|
|
|
398
398
|
# Where an alias expands (ymf.conditions): which part of a vector the
|
|
399
399
|
# condition is on, which part of the region it holds on, how it is
|
|
400
400
|
# imposed (C12: a property of each condition), and what it expanded from.
|
|
401
|
-
|
|
401
|
+
# A component is the normal or tangential part on the boundary, or one
|
|
402
|
+
# Cartesian component (x, y, z: the vector's first, second, third).
|
|
403
|
+
Optional("component"): Enum(["normal", "tangential", "x", "y", "z"]),
|
|
402
404
|
Optional("only"): Enum(["inflow", "incoming_characteristics"]),
|
|
405
|
+
# The part of the region the condition holds on, a predicate like a
|
|
406
|
+
# region's where ("x = 0 and 0.4 ≤ y ≤ 0.6"): a state imposed on part of
|
|
407
|
+
# a boundary. On that part it replaces the region's conditions on the
|
|
408
|
+
# same variable that have no part; they hold on the rest (ymf.conditions).
|
|
409
|
+
Optional("part"): Str(),
|
|
410
|
+
# The value taken from another sub-problem's trace on the boundary
|
|
411
|
+
# (coupled sub-problems): instead of value, formula or series. `of` is the
|
|
412
|
+
# field read (default the condition's own variable), `via` the sub-problem
|
|
413
|
+
# whose trace it is, `at` when, as a lag says it. Dirichlet kinds only.
|
|
414
|
+
Optional("trace"): Map({Optional("of"): Str(), "via": Str(), "at": LagAtEnum}),
|
|
403
415
|
Optional("imposed"): Enum(["strong", "weak", "none"]),
|
|
404
416
|
# a weak (Nitsche) condition's penalty, over h, and its adjoint term
|
|
405
417
|
# (ymf.boundaries); checked on load against the condition's type
|
|
@@ -217,7 +217,8 @@ def missing(block: Any) -> List[str]:
|
|
|
217
217
|
|
|
218
218
|
def generator_needs(method: str, resolved: Optional[Dict[str, Any]] = None) -> List[str]:
|
|
219
219
|
"""What the kernel generator reads of a stabilization of ``method``: ``tau`` (and ``lagged`` for SUPG and ASGS),
|
|
220
|
-
and the shock-capturing block's four keys (or its explicit ``none
|
|
220
|
+
and the shock-capturing block's four keys (or its explicit ``none``; ``reference`` is not asked for when the block states
|
|
221
|
+
``beta`` 1, the classical form, which never reads it). Method ``none`` needs no statement that there
|
|
221
222
|
is no shock capturing (it says so); only a shock-capturing block it does state must be complete."""
|
|
222
223
|
takes = TAKES[method]
|
|
223
224
|
needs = [k for k in ("tau", "lagged") if k in takes]
|
|
@@ -226,10 +227,20 @@ def generator_needs(method: str, resolved: Optional[Dict[str, Any]] = None) -> L
|
|
|
226
227
|
if method != "none":
|
|
227
228
|
needs.append("shock_capturing")
|
|
228
229
|
if isinstance(sc, dict):
|
|
229
|
-
needs += ["shock_capturing." + k for k in SHOCK_CAPTURING_KEYS
|
|
230
|
+
needs += ["shock_capturing." + k for k in SHOCK_CAPTURING_KEYS
|
|
231
|
+
if not (k == "reference" and _classical(sc))]
|
|
230
232
|
return needs
|
|
231
233
|
|
|
232
234
|
|
|
235
|
+
def _classical(shock_capturing: Dict[str, Any]) -> bool:
|
|
236
|
+
"""Whether a shock-capturing block states ``beta`` 1: the classical form ``factor |R| / sqrt(∇uᵀ G ∇u)``, in which the
|
|
237
|
+
reference value of the unknown does not enter (proteus's RDLS). An unstated ``beta`` is not 1."""
|
|
238
|
+
try:
|
|
239
|
+
return float(shock_capturing["beta"]) == 1.0
|
|
240
|
+
except (KeyError, TypeError, ValueError):
|
|
241
|
+
return False
|
|
242
|
+
|
|
243
|
+
|
|
233
244
|
def _has(resolved: Dict[str, Any], dotted: str) -> bool:
|
|
234
245
|
here: Any = resolved
|
|
235
246
|
for part in dotted.split("."):
|
|
@@ -210,7 +210,7 @@ class Space:
|
|
|
210
210
|
"lap": lambda e: self.div(self.grad(e)),
|
|
211
211
|
"identity": sympy.eye(self.dim),
|
|
212
212
|
"pi": sympy.pi, "E": sympy.E,
|
|
213
|
-
"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan,
|
|
213
|
+
"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "atan": sympy.atan,
|
|
214
214
|
"exp": sympy.exp, "log": sympy.log, "sqrt": sympy.sqrt,
|
|
215
215
|
"sinh": sympy.sinh, "cosh": sympy.cosh, "tanh": sympy.tanh,
|
|
216
216
|
"abs": sympy.Abs, "Abs": sympy.Abs, "hypot": hypot,
|
|
@@ -23,8 +23,8 @@ Expressions
|
|
|
23
23
|
``² ³ ⁴``; implicit multiplication (``2π²κt``, ``κ ΔT``, ``sin(πx)``);
|
|
24
24
|
``·`` (a dot product of vectors, a product otherwise) and ``⊗``
|
|
25
25
|
(outer product, binding tighter than ``·`` and ``*``); tuples
|
|
26
|
-
``(a, b)`` are vectors; functions sin cos tan exp log sqrt sinh
|
|
27
|
-
tanh abs, the sharp ones heaviside sign min max (min and max of any
|
|
26
|
+
``(a, b)`` are vectors; functions sin cos tan atan exp log sqrt sinh
|
|
27
|
+
cosh tanh abs, the sharp ones heaviside sign min max (min and max of any
|
|
28
28
|
number of arguments), and on vectors and tensors norm(v) = sqrt(v·v)
|
|
29
29
|
and sym(A) = (A + Aᵀ)/2.
|
|
30
30
|
Differential operators, each applied to the operand that follows it
|
|
@@ -36,8 +36,9 @@ single-letter names (``πx`` is π·x) when every letter is known, and is an
|
|
|
36
36
|
error otherwise -- so a misspelt coefficient is reported, not multiplied.
|
|
37
37
|
|
|
38
38
|
Equations are ``lhs = rhs``, optionally followed by ``in <region>``, which
|
|
39
|
-
is ignored. Predicates (boundary regions
|
|
40
|
-
|
|
39
|
+
is ignored. Predicates (boundary regions, and the part of a region a
|
|
40
|
+
condition holds on) are ``a = b`` tests and comparisons ``a ≤ b``, ``a < b``
|
|
41
|
+
(``≥ >``, ``<= >=``; chained, ``0.4 ≤ y ≤ 0.6``) joined by ``and`` and ``or``. Domains are ``Ω = I × I [× I]`` with intervals
|
|
41
42
|
``[a, b]``, optionally followed by ``, t ∈ (t0, t1]``. Assignments
|
|
42
43
|
(analytical solutions) are ``name = expr`` lines; ``T(x, y, t) = ...`` is
|
|
43
44
|
accepted, and a name that is not an unknown becomes a local definition
|
|
@@ -83,7 +84,7 @@ def _sqrt(a):
|
|
|
83
84
|
|
|
84
85
|
|
|
85
86
|
_FUNCTIONS = {
|
|
86
|
-
"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "exp": sympy.exp,
|
|
87
|
+
"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "atan": sympy.atan, "exp": sympy.exp,
|
|
87
88
|
"log": sympy.log, "sqrt": _sqrt, "sinh": sympy.sinh, "cosh": sympy.cosh,
|
|
88
89
|
"tanh": sympy.tanh, "abs": sympy.Abs,
|
|
89
90
|
# sqrt(a² + b²) rounded once (C99 hypot), so that a formula can match code
|
|
@@ -113,6 +114,16 @@ def _sym(a):
|
|
|
113
114
|
return (a + a.T) / 2
|
|
114
115
|
|
|
115
116
|
|
|
117
|
+
#: a predicate's tests, as code over the difference d = lhs - rhs and the tolerance ``tol``
|
|
118
|
+
_COMPARISONS = {
|
|
119
|
+
"=": "abs(%s) <= tol",
|
|
120
|
+
"≤": "%s <= tol", "<=": "%s <= tol",
|
|
121
|
+
"≥": "-(%s) <= tol", ">=": "-(%s) <= tol",
|
|
122
|
+
"<": "%s < -tol",
|
|
123
|
+
">": "-(%s) < -tol",
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
116
127
|
class Parser:
|
|
117
128
|
"""Parse notation against a :class:`~ymf.symbolic.language.Space`."""
|
|
118
129
|
|
|
@@ -358,7 +369,13 @@ class Parser:
|
|
|
358
369
|
return [sympy.sympify(residual)]
|
|
359
370
|
|
|
360
371
|
def predicate(self, text: str) -> Optional[str]:
|
|
361
|
-
"""'x = 0 or y = H' -> numpy-free code using ``tol``; None for the whole boundary.
|
|
372
|
+
"""'x = 0 or y = H' -> numpy-free code using ``tol``; None for the whole boundary.
|
|
373
|
+
|
|
374
|
+
A test is ``a = b`` (within ``tol``) or a comparison ``a ≤ b``, ``a ≥ b`` (also ``<=``, ``>=``; within ``tol``,
|
|
375
|
+
so a closed bound keeps the points on it) or ``a < b``, ``a > b`` (by more than ``tol``, so an open bound drops
|
|
376
|
+
them); comparisons chain, ``0.4 ≤ y ≤ 0.6``. Tests join with ``and``, which binds tighter than ``or``. A part of
|
|
377
|
+
a face is ``x = 0 and 0.4 ≤ y ≤ 0.6``.
|
|
378
|
+
"""
|
|
362
379
|
stripped = text.strip()
|
|
363
380
|
if stripped in ("∂Ω", "∂ Ω", "boundary"):
|
|
364
381
|
return None
|
|
@@ -369,9 +386,15 @@ class Parser:
|
|
|
369
386
|
tests = []
|
|
370
387
|
while True:
|
|
371
388
|
lhs = self._sum()
|
|
372
|
-
self.
|
|
373
|
-
|
|
374
|
-
|
|
389
|
+
op = self._take()
|
|
390
|
+
if op[1] not in _COMPARISONS:
|
|
391
|
+
self._fail("expected '=' or a comparison (≤ ≥ < >)", op)
|
|
392
|
+
while True:
|
|
393
|
+
rhs = self._sum()
|
|
394
|
+
tests.append(_COMPARISONS[op[1]] % to_code(lhs - rhs))
|
|
395
|
+
if self._peek()[1] not in _COMPARISONS or self._peek()[1] == "=":
|
|
396
|
+
break
|
|
397
|
+
lhs, op = rhs, self._take()
|
|
375
398
|
if self._peek()[1] == "and":
|
|
376
399
|
self._take(); continue
|
|
377
400
|
break
|
|
@@ -17,7 +17,7 @@ What can be written is what the notation can read:
|
|
|
17
17
|
(``u``, ``v_0``), and any other symbol by its name;
|
|
18
18
|
* ``+ - * /`` and powers, with ``² ³ ⁴`` for small integer exponents and
|
|
19
19
|
``^`` otherwise; ``sqrt`` for a square root;
|
|
20
|
-
* the functions sin cos tan exp log sqrt sinh cosh tanh abs heaviside
|
|
20
|
+
* the functions sin cos tan atan exp log sqrt sinh cosh tanh abs heaviside
|
|
21
21
|
sign, and min and max of any number of arguments;
|
|
22
22
|
* derivatives: ``D(e, axis)`` as ``∂e/∂x``, ``Dt(e)`` as ``∂e/∂t``;
|
|
23
23
|
* a column vector as a tuple ``(a, b)``.
|
|
@@ -49,7 +49,7 @@ __all__ = ["to_notation", "equation_notation"]
|
|
|
49
49
|
_SUPERSCRIPTS = {2: "²", 3: "³", 4: "⁴"}
|
|
50
50
|
_AXES = "xyz"
|
|
51
51
|
_FUNCTIONS = {
|
|
52
|
-
sympy.sin: "sin", sympy.cos: "cos", sympy.tan: "tan", sympy.exp: "exp",
|
|
52
|
+
sympy.sin: "sin", sympy.cos: "cos", sympy.tan: "tan", sympy.atan: "atan", sympy.exp: "exp",
|
|
53
53
|
sympy.log: "log", sympy.sinh: "sinh", sympy.cosh: "cosh", sympy.tanh: "tanh",
|
|
54
54
|
sympy.Abs: "abs", sympy.Heaviside: "heaviside", sympy.sign: "sign",
|
|
55
55
|
}
|
|
@@ -605,10 +605,12 @@ def adr_problem(doc: Dict[str, Any], hamiltonian_gradients=()) -> Dict[str, Any]
|
|
|
605
605
|
"boundary condition that runs in one ADR system (%s "
|
|
606
606
|
"conditions are for a split discretization's solver)"
|
|
607
607
|
% (bc["region"], bc["type"], bc["type"]))
|
|
608
|
-
restricted = [k for k in ("component", "only") if bc.get(k) is not None]
|
|
608
|
+
restricted = [k for k in ("component", "only", "part", "trace") if bc.get(k) is not None]
|
|
609
609
|
if restricted or bc.get("imposed") == "weak":
|
|
610
610
|
what = ("on the %s component" % bc["component"] if bc.get("component") else
|
|
611
611
|
"only on %s" % bc["only"].replace("_", " ") if bc.get("only") else
|
|
612
|
+
"on the part %s" % bc["part"] if bc.get("part") is not None else
|
|
613
|
+
"with another sub-problem's trace as its value" if bc.get("trace") is not None else
|
|
612
614
|
"imposed weakly")
|
|
613
615
|
raise SymbolicError(
|
|
614
616
|
"boundary condition on %s: a %s condition %s%s runs in a split "
|