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

Added cells supporting unions #134

Merged
merged 3 commits into from
Jan 21, 2025

Conversation

ChasingNeutrons
Copy link
Collaborator

There is a new cell type which supports unions, complements, and parentheses. It uses infix notation, inspired by the results of Paul Romano et al.'s recent paper.

There are several style/code structure questions that should be resolved here.

First, this cell essentially supercedes the simpleCell. Do we want to get rid of the simpleCell? It might be code duplication otherwise and I can't think of a very good case for keeping it. Maybe we wait a little while until we're comfortable with this one.

Second, for the operators necessary, reading them in alongside the surfaces required a deviation in input parsing/reading. Currently lists do not allow mixed number/character arrays. Hence I created the 'tokenArray' to contain arbitrary white-space separated characters of any format. These are read into a character array - I convert the numbers back to integers inside unionCell. It is denoted by using square brackets. Is this acceptable? Is there a nicer way of doing this? This also requires that surfaces and operators be delimited by spaces - maybe this isn't strictly necessary if I put some more logic inside the unionCell itself, for example. I would especially like to resolve this quickly because it will affect the input format and it would be great to settle that quickly so that we can start using this, e.g., with csg2csg.

I have also written a unit test and changed some comments in other nearby files.

Required a change to dictionary reading to allow mixed character/number
reading. Also fixed some comments in nearby files.
Copy link
Member

@valeriaRaffuzzi valeriaRaffuzzi left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the development, it's very exciting to finally have unions!
Just a couple of comments but then it can be merged for me.

character(*), parameter :: EASYCELL_DEF = "&
& id 2; type unionCell; surfaces [-13 -15 ]; filltype outside; "
character(*), parameter :: COMPLEXCELL_DEF = "&
& id 3; type simpleCell; surfaces [< -13 -15 > # < -4 : -5 : -6 > ]; filltype outside; "
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be unionCell too?

Copy link
Member

Choose a reason for hiding this comment

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

The cell % init procedure doesn't read type, so that could be removed actually.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Very good spot. I will remove it from the equivalent simpleCell test for now too.

Comment on lines 40 to 47
call charToDict(dict, SURF_DEF)
call surfs % init(dict)
call dict % kill()
call charToDict(dict, EASYCELL_DEF)
call easyCell % init(dict, surfs)
call dict % kill()
call charToDict(dict, COMPLEXCELL_DEF)
call complexCell % init(dict, surfs)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
call charToDict(dict, SURF_DEF)
call surfs % init(dict)
call dict % kill()
call charToDict(dict, EASYCELL_DEF)
call easyCell % init(dict, surfs)
call dict % kill()
call charToDict(dict, COMPLEXCELL_DEF)
call complexCell % init(dict, surfs)
call charToDict(dict, SURF_DEF)
call surfs % init(dict)
call dict % kill()
call charToDict(dict, EASYCELL_DEF)
call easyCell % init(dict, surfs)
call dict % kill()
call charToDict(dict, COMPLEXCELL_DEF)
call complexCell % init(dict, surfs)

What about adding spaces to make it more legible?



!!
!! CSG cell defined by intersections and unions of halfspaces
Copy link
Member

Choose a reason for hiding this comment

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

And complements?

@valeriaRaffuzzi
Copy link
Member

To answer the questions in the description:

  • if the new union cell includes all the functionalities of the simple cell and it's not any slower, then I agree there is no reason to keep the simpleCell
  • After reviewing the code I thought the tokenArray parser was neat enough. I see why it's convenient to read everything as characters!

@ChasingNeutrons
Copy link
Collaborator Author

Thanks for the comments.

I think, at least for this PR, I will keep simple cells and open an issue to remove them. In part this is because getting rid of it means changing all of the inputs which use them!

@valeriaRaffuzzi
Copy link
Member

Thanks for the comments.

I think, at least for this PR, I will keep simple cells and open an issue to remove them. In part this is because getting rid of it means changing all of the inputs which use them!

That's ok, we can make an issue. Merge?

@valeriaRaffuzzi valeriaRaffuzzi merged commit 21daeb9 into CambridgeNuclear:main Jan 21, 2025
5 checks passed
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