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

Immediately resolve complement operators for regions #3145

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

paulromano
Copy link
Contributor

Description

This PR changes how the the ~ operator works on regions. By implementing the __invert__ method on the Intersection and Union classes, De Morgan's laws are always immediately applied, which means that you won't end up with ~ inside an XML file.

Along with this change, I've simplified the handling of the unary - and + operators on some composite surfaces. For example, for XConeOneSided the __neg__ and __pos__ methods were both implemented. However, CompositeSurface has a default __pos__ method that just takes the complement of whatever __neg__ returns. With the improvement in how complements are handled, this means that we don't need to implement __pos__ for composite surfaces and we still end up with an expression that doesn't have ~ in it.

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 15) on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

@shimwell
Copy link
Member

def test_filter_mesh_translations(model): is failing with this error

 Input differences:
--- inputs_true.dat
+++ inputs_test.dat
@@ -12,7 +12,7 @@
   </materials>
   <geometry>
     <cell id="1" material="1" region="1 -2 3 -4 10 -9" universe="1"/>
-    <cell id="2" material="2" region="~(1 -2 3 -4) (5 -6 7 -8) 10 -9" universe="1"/>
+    <cell id="2" material="2" region="(-1 | 2 | -3 | 4) (5 -6 7 -8) 10 -9" universe="1"/>

Perhaps this is just a case of updating the dat file

@paulromano
Copy link
Contributor Author

@shimwell Yes, looks like I missed that one update. It should be fixed now.

@pshriwise
Copy link
Contributor

Great idea @paulromano! Much easier to handle this in Python than with the current C++ algorithm. I suppose we can't do away with the C++ version for a bit, but I think roundtripping the XML through the Python interface should do the trick for users trying to update old files when the time comes.

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.

3 participants