Skip to content

Improve Geometry class - #527

Open
yguclu wants to merge 61 commits into
develfrom
yguclu-improve-Geometry
Open

yguclu wants to merge 61 commits into
develfrom
yguclu-improve-Geometry

Conversation

@yguclu

@yguclu yguclu commented Oct 7, 2025

Copy link
Copy Markdown
Member
  • 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 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)
  • Use ubuntu_installations action in documentation workflow
  • Fix module name in documentation sources: cmd.mesh >> cmd.psydac_mesh

TO DO:

  • In from_file, make sure that the domain argument (an instance of sympde.topology.Domain) is compatible with the topological domain defined in the .yml section of the HDF5 file.
  • Update unit tests in cad.tests.test_geometry:
    • Add some 1D unit tests
    • Add proper asserts statements to test_geometry_2d_1 and test_geometry_2d_2
    • Remove obsolete test function test_geometry_1
    • Test functions from cad.cad in new module cad.tests.test_cad
  • After release of SymPDE version 0.20.0, update pyproject.toml and run all unit tests once again on all platforms
  • Mention SymPDE 0.20.0 in PR description
  • Mention SymPDE 0.20.0 in CHANGELOG.md

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 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).

@campospinto campospinto Feb 12, 2026

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.

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

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.

Do you mean the script-like code on the bottom of cad/cad.py? I believe that code does not work right now, so we could either remove it or try to create a unit test out of it

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.

yes, I guess I was referring to these calls to the Geometry constructor. Since these are not advised the best is probably to remove them

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.

Excluding some unit tests (which naturally have to test also the __init__ function), I can find those calls only at the bottom of cad/cad.py. That is why I was asking

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

codacy-production Bot commented Apr 21, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 18 complexity · 0 duplication

Metric Results
Complexity 18
Duplication 0

View in Codacy

🟢 Coverage 81.91% diff coverage

Metric Results
Coverage variation Report missing for 41a0cd71
Diff coverage 81.91% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (41a0cd7) Report Missing Report Missing Report Missing
Head commit (2cb2971) 49506 32929 66.52%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#527) 199 163 81.91%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

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.

@yguclu
yguclu marked this pull request as draft September 9, 2026 13:31
@yguclu
yguclu marked this pull request as ready for review September 9, 2026 13:32
@yguclu
yguclu marked this pull request as draft September 11, 2026 16:22
@yguclu
yguclu marked this pull request as ready for review September 11, 2026 16:22
@yguclu
yguclu marked this pull request as draft September 11, 2026 16:36
@yguclu
yguclu marked this pull request as ready for review September 11, 2026 16:36
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