Skip to content

Allow coordinate swap in polar CONGA projections - #634

Merged
yguclu merged 46 commits into
develfrom
coordinate_swap_2d
Nov 23, 2026
Merged

yguclu merged 46 commits into
develfrom
coordinate_swap_2d

Conversation

@alisa-kirkinskaia

@alisa-kirkinskaia alisa-kirkinskaia commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Add the option to swap the order of the radial and angular coordinates to the broken-FEEC conforming projection operators in 2D polar domains, which were introduced in PR #576. The polar CONGA projections in psydac/feec/polar/conga_projections.py assumed the logical coordinates are ordered $(x_1, x_2) = (s, \theta)$. Here we add the keyword radial_dim (default 0) so the projections also work on spaces built on $(\theta, s)$.

Background

Swapping coordinates preserves the physical fields, geometry, and pole. The mapping becomes $F'=F\circ S$, where $S(\theta,s)=(s,\theta)$, so $\det DF'=-(\det DF)\circ S$.

Let $\Pi$ transpose a coefficient array, i.e. map the flat index $i n_\theta + j$ to $j n_s + i$. Then

  • 0- and 2-forms: $P' = \Pi P \Pi^T$;
  • 1-forms: the components also swap, so $P^{\prime} = Q P Q^T$ with
$$Q = \begin{pmatrix} 0 & \Pi_\theta \\ \Pi_s & 0 \end{pmatrix}$$

Warning: pull-backs and push-forwards implementations are not consistent about the sign of $\det DF$, see issue #636.

Changes

  • Add the new parameter radial_dim (which can take the value 0 or 1) to all projections. Assert that W.periodic[radial_dim] is False and W.periodic[1 - radial_dim] is True.
  • dot: all regions (pole, rings, inner, outer boundary) are built with the helper polar_index(radial_dim, radial_index, angular_index).
  • tosparse: assembles in (radial, angular) flat indices as before. If radial_dim == 1, it remaps rows and columns at the end with transpose_flat_index().
  • 1-form blocks are renamed by meaning instead of position: C0PolarProjection_V1_00/_10/_11 become _s_s, _theta_s and _theta_theta, and C1PolarProjection_U1_00/_10 become _s_s and _theta_s. The s-component of $W^1$ is coeff_space[radial_dim], so C0PolarProjection_V1 and C1PolarProjection_U1 place the blocks at [rdim, rdim], [adim, adim], and [adim, rdim] (or [rdim, adim] if transposed=True).
  • Add the classes TransposedTargetMapping and TransposedCzarnyMapping to psydac.feec.multipatch_domain_utilities, used by the examples when radial_dim == 1.
  • Update Poisson and Maxwell examples with command line argument --radial_dim. In the Poisson example, --radial_dim 1 is supported by all test cases (disk, target, czarny) with the smooth methods None, C0conga and C1conga; it raises a NotImplementedError with the smooth methods polar-std and polar-spec, which rely on psydac.polar.C1Projector.

Tests

Tests are parametrized over radial_dim. The (θ, s) case uses TransposedPolarMapping from psydac.feec.multipatch_domain_utilities. The new file psydac/feec/tests/test_multipatch_domain_utilities.py checks that TransposedPolarMapping, TransposedTargetMapping and TransposedCzarnyMapping equal PolarMapping, TargetMapping and CzarnyMapping with swapped logical coordinates, and that the determinant of their Jacobian changes sign.

@codacy-production

codacy-production Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 32 complexity · 45 duplication

Metric Results
Complexity 32
Duplication 45

View in Codacy

🟢 Coverage 9.10% diff coverage

Metric Results
Coverage variation Report missing for a73780e1
Diff coverage ✅ 9.10% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (a73780e) Report Missing Report Missing Report Missing
Head commit (ac21648) 105150 67348 64.05%

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 (#634) 648 59 9.10%

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.

@alisa-kirkinskaia alisa-kirkinskaia changed the title Coordinate swap 2d Coordinate swap in CONGA projections (2D) Oct 22, 2026
@alisa-kirkinskaia
alisa-kirkinskaia marked this pull request as ready for review October 30, 2026 11:40
@alisa-kirkinskaia
alisa-kirkinskaia marked this pull request as draft October 30, 2026 11:40
@alisa-kirkinskaia
alisa-kirkinskaia marked this pull request as ready for review October 30, 2026 11:40
@yguclu
yguclu self-requested a review October 30, 2026 14:36
@yguclu

yguclu commented Nov 2, 2026

Copy link
Copy Markdown
Member

Hi @alisa-kirkinskaia,

The two failing jobs are caused by issue #637, not by your changes.

I am going to create a small PR which fixes the issue ASAP, and ask for your review.

@yguclu
yguclu marked this pull request as draft November 3, 2026 09:43
@yguclu
yguclu marked this pull request as ready for review November 3, 2026 09:43

@yguclu yguclu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good job! I have a few remarks

Comment thread psydac/feec/polar/conga_projections.py Resolved
Comment thread psydac/feec/polar/conga_projections.py Resolved
Comment thread psydac/feec/polar/conga_projections.py Resolved
Comment thread psydac/feec/polar/conga_projections.py Resolved
Comment thread psydac/feec/polar/conga_projections.py Resolved
@yguclu
yguclu marked this pull request as draft November 13, 2026 16:00
@yguclu
yguclu marked this pull request as ready for review November 13, 2026 16:00
@yguclu
yguclu marked this pull request as draft November 17, 2026 18:34
@yguclu
yguclu marked this pull request as ready for review November 17, 2026 18:34

@yguclu yguclu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Last round of comments!

Comment thread psydac/feec/polar/conga_projections.py Resolved
@alisa-kirkinskaia
alisa-kirkinskaia marked this pull request as draft November 19, 2026 13:29
@alisa-kirkinskaia
alisa-kirkinskaia marked this pull request as ready for review November 19, 2026 13:30
@alisa-kirkinskaia
alisa-kirkinskaia marked this pull request as draft November 20, 2026 09:25
@alisa-kirkinskaia
alisa-kirkinskaia marked this pull request as ready for review November 20, 2026 09:25

@yguclu yguclu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Excellent! Let's merge this!

@yguclu yguclu changed the title Coordinate swap in CONGA projections (2D) Allow coordinate swap in polar CONGA projections Nov 20, 2026
@yguclu
yguclu marked this pull request as draft November 23, 2026 18:31
@yguclu
yguclu marked this pull request as ready for review November 23, 2026 18:31
@yguclu
yguclu merged commit 2f50395 into devel Nov 23, 2026
9 checks passed
@yguclu
yguclu deleted the coordinate_swap_2d branch November 23, 2026 22:45
FrederikSchnack added a commit that referenced this pull request Nov 24, 2026
Import SymPDE objects from sympde.api and refer to the defining SymPDE
modules in docstrings in the files changed by #634.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants