Skip to content

Multi subdomain support#21

Merged
jhdark merged 14 commits intomainfrom
multi_subdomain_support
May 29, 2025
Merged

Multi subdomain support#21
jhdark merged 14 commits intomainfrom
multi_subdomain_support

Conversation

@jhdark
Copy link
Collaborator

@jhdark jhdark commented Apr 17, 2025

Proposed changes

With this change we can now support cases with multiple subdomains

Types of changes

What types of changes does your code introduce to foam2dolfinx?

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code refactoring
  • Documentation Update (if none of the other choices apply)
  • New tests

Checklist

  • Unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

Comment on lines 134 to 158
if self.cell_type == 12:
shape = "hexahedron"
args_conn = np.tile(
np.array([0, 1, 3, 2, 4, 5, 7, 6]), (len(self.OF_cells[subdomain]), 1)
)

elif self.cell_type == 10:
shape = "tetrahedron"
args_conn = np.argsort(
self.OF_cells[subdomain], axis=1
) # Sort the cell connectivity

else:
raise ValueError(
f"Cell type: {self.cell_type}, not supported, please use"
" either 12 (hexahedron) or 10 (tetrahedron) cells in OF mesh"
)

# create the connectivity between the OpenFOAM and dolfinx meshes
args_conn = np.argsort(self.OF_cells, axis=1) # Sort the cell connectivity
rows = np.arange(self.OF_cells.shape[0])[:, None] # Create row indices
self.connectivity = self.OF_cells[rows, args_conn] # Reorder connectivity
rows = np.arange(self.OF_cells[subdomain].shape[0])[
:, None
] # Create row indices
self.connectivity = self.OF_cells[subdomain][
rows, args_conn
] # Reorder connectivity
Copy link
Contributor

Choose a reason for hiding this comment

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

Right this freaks me out and I have a hard time trusting it:

  • does this work on the previous meshes still?
  • why is it that @Steriva 's connectivity from pyvista doesn't work?
  • how is it possible that pyvista detects several unique connectivity args and yet we force them all to be the same?
  • what is np.tile? do I sense some ChatGPT? 😄

@codecov
Copy link

codecov bot commented Apr 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.19%. Comparing base (e8e8554) to head (b67f82f).
Report is 21 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #21      +/-   ##
==========================================
- Coverage   97.72%   97.19%   -0.54%     
==========================================
  Files           2        2              
  Lines          88      107      +19     
==========================================
+ Hits           86      104      +18     
- Misses          2        3       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jhdark jhdark merged commit 754e3c4 into main May 29, 2025
9 checks passed
@jhdark jhdark deleted the multi_subdomain_support branch May 29, 2025 15:39
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