Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement alternating division schemes between adjacent hexahedra and wedges #172

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

connoramoreno
Copy link
Collaborator

@connoramoreno connoramoreno commented Nov 1, 2024

Modifies the source mesh workflow to alternate the scheme by which hexahedra and wedges are split into tetrahedra. The alternating schemes ensure that the faces of adjacent tetrahedra, but not belonging to the same hexahedron or wedge, match one another. This avoids gaps and overlaps between adjacent non-planar hexahedron and wedge faces. This alignment is ensured for adjacent wedge-wedge, wedge-hexahedron, and hexahedron-hexahedron pairs. Code changes are as follows:

  • Introduces alternate_scheme, toroidal_alt_scheme, and cfs_alt_scheme boolean parameters to control whether an alternate division scheme should be used for a given element
  • Introduces an alternate division scheme, in the form of MOAB canonical indices defining the tetrahedral division of a given element, for both hexahedra and wedges

The alternate splitting schemes are illustrated below. Plots will follow to demonstrate expected behavior of total volume and total source strength as a function of mesh discretization.

(a)Screenshot 2024-11-01 at 2 59 13 PM
(b)Screenshot 2024-11-01 at 3 07 21 PM

Figure 1. Alternate schemes for adjacent hexahedra. (a) Original and (b) alternate.

(a)Screenshot 2024-11-01 at 3 24 55 PM
(b)Screenshot 2024-11-01 at 3 22 00 PM

Figure 2. Alternate schemes for adjacent wedges. (a) Original and (b) alternate.

Closes #168

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix @connoramoreno

parastell/source_mesh.py Outdated Show resolved Hide resolved
@connoramoreno
Copy link
Collaborator Author

connoramoreno commented Nov 3, 2024

Below are plots demonstrating that total source strength (in the form of fusion power, calculated for four periods even though only one period of the source mesh is modeled) and total mesh volume scale as expected with mesh discretization.

Expected behavior:

  • For increasing CFS discretization, total source strength converges to some value and total volume remains constant
  • For changing poloidal discretization, total source strength changes are small and trend similarly to those for total volume. Total volume converges to some value.
  • For changing toroidal discretization, total source strength changes are small and trend similarly to those for total volume. Total volume converges to some value.

(a) Screenshot 2024-11-03 at 9 08 51 AM
(b) Screenshot 2024-11-03 at 9 09 15 AM
Figure 1. Behavior of total source strength and volume as a function of CFS discretization. Numbers of poloidal and toroidal grid points are kept constant at 121 each. (a) Total source strength. Total relative change is 3.15%. (b) Total mesh volume. Total relative change is 0%.

(a) Screenshot 2024-11-03 at 9 09 05 AM
(b) Screenshot 2024-11-03 at 9 09 19 AM
Figure 2. Behavior of total source strength and volume as a function of poloidal discretization. Numbers of CFS and toroidal grid points are kept constant at 16 and 121, respectively. (a) Total source strength. Total relative change is 0.39%. (b) Total mesh volume. Total relative change is 0.41%.

(a) Screenshot 2024-11-03 at 9 09 10 AM
(b) Screenshot 2024-11-03 at 9 09 24 AM
Figure 3. Behavior of total source strength and volume as a function of toroidal discretization. Numbers of CFS and poloidal grid points are kept constant at 16 and 121, respectively. (a) Total source strength. Total relative change is 0.40%. (b) Total mesh volume. Total relative change is 0.23%.

@connoramoreno connoramoreno marked this pull request as ready for review November 3, 2024 15:33
@connoramoreno
Copy link
Collaborator Author

I have another PR lined up once this is merged that will allow users to input their own grids, rather than us enforce uniformly spaced grids. I'd like to include checks on inputs (such as warnings for when grid sizes are not even) in that subsequent PR, since it touches a lot of that part of the code.

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

do we need to keep these different alternative scheme variables? For me it's hard to follow. If we require even numbers of poloidal voxels, I think there may be a cleaner way to do it.

@gonuke
Copy link
Member

gonuke commented Nov 3, 2024

Can we just determine the meshing scheme from whether s_idx + theta_idx + phi_idx is even or odd?

For the very first wedge of the first toroidal plane it's 0+0+0 =0 even. Then it alternates until we get to the last wedge which must be odd if we have an even number of poloidal voxels. Then the first hex on the next cfs layer is 1+0+0 =1 odd and alternates... and so on.

The first wedge on the next toroidal slice is 0+1+0 =1 odd - which is what we need it to be... and so on.

So within each hex generation method you can have

alternate_scheme = (s_idx + phi_idx + theta_idx) % 2

@gonuke
Copy link
Member

gonuke commented Nov 3, 2024

Could then have canonical ordering indexed in a list with index 0 and 1 and directly use the one you want indexed by the alternate scheme variable.

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.

Source mesh total source strength scaling incorrectly with mesh discretization
2 participants