Repository navigation
New mapping class hierarchy (psydac part) - #600
Draft
campospinto wants to merge 93 commits into
Draft
campospinto wants to merge 93 commits into
campospinto wants to merge 93 commits into
Conversation
- Write 3D geometry in parallel without `mpi_dims_mask` - Read 3D geometry in parallel with `mpi_dims_mask` - Verify correct distribution of domain for any number of MPI processes
Add parameter `mpi_dims_mask` to class method `from_discrete_mapping` and bound method `read`.
Use new variable for dictionary with number of cells for each patch.
test methods from_discrete_mapping and from_topological_domain with mpi_dims_mask
- Add new constructor Geometry.from_file - Remove `filename` from __init__ parameters
commit ccbd6e3 Author: Yaman Güçlü <yaman.guclu@gmail.com> Date: Wed Oct 1 06:25:42 2025 +0200 Allow `mpi_dims_mask` with geometry file (#526) Add the optional parameter `mpi_dims_mask` to the constructor of class `Geometry`, as well as its class methods `from_discrete_mapping` and `from_topological_domain`. Add unit tests to verify that the domain is correctly decomposed. --------- Co-authored-by: Alisa Kirkinskaia <alisa.kirkinskaia@tum.de> Co-authored-by: Alisa Kirkinskaia <alisa.kirkinsk@gmail.com>
- Add function `get_available_mappings` - Clean up function `discrete_mapping` and add docstring to it
…rove from_discrete_mapping
Tests only, ahead of WP15-1 re-keying Geometry.mappings/ncells/periodic by interior name. Four pins, all of current behaviour: - test_geometry_fixture_export_is_byte_identical: from_file -> export reproduces geometry.yml/topology.yml byte for byte on the 11 readable fixtures, with per-patch points/knots/degree/periodic/weights preserved; the 3 plate_with_hole_mp* fixtures as strict xfail(raises=ValueError). - test_geometry_export_names_in_memory_constructors: the exact geometry.yml byte strings for from_discrete_mapping and from_discrete_domain, read -> export as a fixed point, and no WP10 double-wrap of interior names. - test_geometry_mappings_order_matches_interiors: dict order tracks interior order on all four construction paths. - test_geometry_legacy_patch_key_access: today's legacy patch-name keying and list-valued periodic on a multipatch file. This is the one pin WP15-1 deliberately flips. test_geometry.py 56 passed / 4 xfailed (was 42 / 1), unchanged under -n 4 --dist loadgroup; with test_build_derham_mapping.py + mapping/tests, 264 passed (was 250). No production code touched; zero sympde edits. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 505 |
| Duplication | 73 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is the psydac side of the new sympde mapping hierarchy
(pyccel/sympde#196). The class diagram, a worked example and the migration
table are in that PR.
For psydac users, the main change is that a spline geometry is now a
first-class symbolic mapping. A
SplineCallableMapping(the formerSplineMapping) can be wrapped as a sympdeDiscreteMappingwithF_h.to_defined_mapping(name). Domains built from such mappings arediscretized directly with
discretize(domain), in single-patch and multipatchcases alike, with no geometry file and no
ncells.Geometryno longermodifies the sympde mappings it receives: the
set_callable_mappingcalls aregone.
Dependencies
pyproject.tomlmust pin sympde to that branchwhile it is under review, then to the release that contains it.
Geometryclass #527 (ImproveGeometryclass). Until that PR is merged, thisdiff also contains its commits.
Main changes
Spline mappings (
psydac/mapping/discrete.py)SplineMappingis renamedSplineCallableMapping, andNurbsMappingisrenamed
NurbsCallableMapping(see the class diagram in the description of New mapping class hierarchy (sympde part) sympde#196). The old names still import, with aDeprecationWarning, and refer to the same classes. The HDF5typetag isunchanged, so existing geometry files are read and written as before.
to_defined_mapping(name), which returns a sympdeDiscreteMappingwrapping the spline.from_mappingchanges tofrom_mapping(mapping, space=None, *, ncells=, degree=, periodic=, bounds=, comm=):spaceis not given;AnalyticMappingor aDiscreteMappingcan be passed directly;from_mapping(space, mapping)raises aTypeErrorthat names the new call.
__call__,jacobian,jacobian_inv,metricandmetric_detnow acceptarrays as well as scalars, like
AnalyticMappingdoes. On a tensor grid in aserial run, they use a faster evaluation through
build_mesh/jac_mat_grid.Other inputs fall back to point-by-point evaluation.
Geometry (
psydac/cad/geometry.py,psydac/api/discretization.py)Geometry.from_discrete_domain(domain)for single-patch and multipatchdomains whose patches are all spline
DiscreteMappings. It rebuilds eachspline on a space that is aware of the interfaces and connects the ghost
regions, so interface integrals can be assembled. It runs in serial only.
discretize(domain)withoutfilenameorncellsnow usesfrom_discrete_domain. If the domain does not qualify, the error explainswhy, patch by patch.
from_file/read(), the patches ofgeometry.domainare now splineDiscreteMappings.read()no longer callsset_callable_mappingon themappings returned by
Domain.from_file.from_discrete_mappingbuilds aDiscreteMappingpatch. It takes anoptional
domain_log=, which is checked against the spline's parametric box.mappings,ncellsandperiodicare keyed bydomain.interior_namesinevery constructor. The old keys (on-disk patch names, integer indices) still
work, with a
DeprecationWarning. The HDF5 output does not change.read()matched the patches in the file to the domain's interiors byposition. sympde sorts the interiors by name, so with 11 or more patches
(
patch_10sorts beforepatch_2) some patches got the wrong spline.Patches are now matched by name.
logical_ncube, and infem/partitioning.py,construct_join_connectivityand
connectivity_to_join_tuples. This also fixes two bugs in the multipatchexporters (
cad/multipatch.py): 1-D NURBS export raisedTypeError, and itnow works;
dim > 3raised anIndexError, and it now raises a clearNotImplementedError.Call sites migrated to the new sympde classes
MappingbecomesSymbolicMapping, andCallableMappingbecomes
AnalyticMapping. This touchesapi/ast,fem_bilinear_form,postprocessing,feec/pushforwardand others..jacobian_symbolinstead of.jacobian.Collela3D, and the mappings in testsand examples) now derive from
AnalyticMapping.PostProcessManageranddiscretize_spacelook mappings up by interior namedirectly, without the two-branch fallback.
Examples (
examples/notebooks/)poisson_2d_analytic_vs_spline_mapping.ipynb: the same two-patch Poissonproblem, solved once on analytic mappings and once on spline mappings.
feec_timedomain_maxwell_scattering.ipynb: time-domain Maxwell scattering ona multipatch domain.
feec_potential_hollowtorus.ipynb, withexamples/feec/feec_potential_hollowtorus.py:harmonic vector potentials in a shaped hollow torus.
Tests
mapping/tests/test_spline_callable_mapping_point_eval.pyfeec/tests/test_spline_mapping_2d.pyfem/tests/test_partitioning.pyfem/tests/test_integral.pycad/tests/test_geometry.pyis much extended: key conventions, exportround-trips,
from_discrete_domain, and the ≥11-patch case.api/tests/test_discretize_dispatch.py,test_grid.py,test_mapping_jacobian_pullback.py,test_runtime_assemble.py,test_fem_bilinear_form_codegen.py,test_ast_general_path_codegen.py,test_ast_parallel_block.py,test_compile_backend_equivalence.py.pytest -n auto --pyargs psydac -m "not mpi and not petsc"gives15742 passed, 24 skipped, 15 xfailed.
Usage
To read a geometry file, nothing changes:
discretize(domain, filename=f). Thespline of each patch is available as
domain_h.mappings[interior_name], andalso as
domain_h.domain.mapping.get_callable_mapping().Breaking changes
from_mapping(space, mapping)becomesfrom_mapping(mapping, space). The oldorder raises a
TypeErrorthat names the new call.Domain.from_file(f).mapping.get_callable_mapping()raisesValueError,even after
discretize(domain, filename=f). Read the spline from thegeometry instead, as described above. The same applies to building a
PostProcessManager(domain=Domain.from_file(f))and a separatediscretize(domain, filename=f): usePostProcessManager(geometry_file=f).