Skip to content

Improve Geometry class#527

Open
yguclu wants to merge 55 commits intodevelfrom
yguclu-improve-Geometry
Open

Improve Geometry class#527
yguclu wants to merge 55 commits intodevelfrom
yguclu-improve-Geometry

Conversation

@yguclu
Copy link
Copy Markdown
Member

@yguclu yguclu commented Oct 7, 2025

  • Add new factory class method from_file
  • Use __init__ method in all factory class methods (from_file, from_discrete_mapping, and from_topological_domain)
  • Discourage direct use of __init__ (factory class methods should be preferred)
  • Add mandatory pdim parameter (number of dimensions of physical domain) to __init__
  • Clean up and document (with docstrings) the factory class methods
  • Add Pytest mark @pytest.mark.xdist_group('h5py') to all tests in psydac.cad.tests.test_geometry, because h5py is not thread-safe

Moreover:

  • Use SymPDE branch clean-multipatch-domain, which will become version 0.20.0
  • Always provide interface orientation to the join constructor of Domain objects (from sympde.topology.domain)
  • Add interface orientation to multipatch geometry files (in the folder psydac/cad/mesh/multipatch)

yguclu and others added 28 commits September 18, 2025 15:27
- 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
@yguclu yguclu marked this pull request as draft January 27, 2026 19:49
@yguclu yguclu marked this pull request as ready for review January 27, 2026 19:49
@yguclu yguclu force-pushed the yguclu-improve-Geometry branch from 4694c33 to 001e592 Compare January 27, 2026 22:20
@yguclu yguclu marked this pull request as draft January 27, 2026 22:24
@yguclu yguclu marked this pull request as ready for review February 11, 2026 10:50
Use the custom action `ubuntu_install` for installing non-Python dependencies, like in the `testing` workflow. Add a separate step to install the packages `graphviz` and `pandoc` required for documentation.
Comment thread psydac/cad/geometry.py
Comment on lines +46 to 51
The Geometry object can be created in four ways:
- case 0 : providing a `Domain` to `__init__` with detailed parameters for each patch.
- case 1 : passing the path to a geometry file to `from_file`.
- case 2 : passing a `SplineMapping` to `from_discrete_mapping` (single patch).
- case 3 : passing a `Domain`, ncells, and periodicity to `from_topological_domain` (single or multi-patch).

Copy link
Copy Markdown
Collaborator

@campospinto campospinto Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's very nice to list these cases!
Maybe we should also specify here which cases should be suggested to users ?
My feeling is that case 0 should only be used "internally", i.e. called by existing functions

edit 1: ok I see now that this is also explained in the PR description. then I suggest to specify it in this docstring as well.

edit2: it would be useful to indicate also here that case 1 and 3 are called by the discretize_domain interface (or just discretize called on a SymPDE Domain)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular, I would suggest to remove or rewrite the direct constructions of Geometry objects in cad/cad.py, to avoid giving bad ideas

Comment thread psydac/cad/geometry.py
#--------------------------------------------------------------------------
@classmethod
def from_topological_domain(cls, domain, ncells, *, periodic=None, comm=None, mpi_dims_mask=None):
interior = domain.interior
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here I suggest checking that domain is of correct type (a symPDE Domain I guess)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 349eee8

Comment on lines +581 to 582
return Geometry.from_file(filename, comm=comm, mpi_dims_mask=mpi_dims_mask)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 21, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 10 complexity · 0 duplication

Metric Results
Complexity 10
Duplication 0

View in Codacy

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. Give us feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CAD Geometric operations on NURBS, geometry files, etc... Next Release Must be in next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants