Skip to content

CSG Transformations#32403

Open
kkiesling wants to merge 28 commits intoidaholab:nextfrom
kkiesling:csg-transform
Open

CSG Transformations#32403
kkiesling wants to merge 28 commits intoidaholab:nextfrom
kkiesling:csg-transform

Conversation

@kkiesling
Copy link
Collaborator

refs / closes #32308

Reason

Design

Impact

@kkiesling
Copy link
Collaborator Author

@shikhar413

@moosebuild
Copy link
Contributor

moosebuild commented Feb 27, 2026

Job Documentation, step Docs: sync website on 6210b19 wanted to post the following:

View the site here

This comment will be updated on new commits.

@moosebuild
Copy link
Contributor

moosebuild commented Mar 2, 2026

Job Coverage, step Generate coverage on 6210b19 wanted to post the following:

Framework coverage

aec0a3 #32403 6210b1
Total Total +/- New
Rate 85.79% 85.80% +0.01% 100.00%
Hits 128628 128751 +123 150
Misses 21303 21311 +8 0

Diff coverage report

Full coverage report

Modules coverage

Coverage did not change

Full coverage reports

Reports

This comment will be updated on new commits.

@moosebuild
Copy link
Contributor

Job Coverage, step Verify coverage on c07e899 wanted to post the following:

The following coverage requirement(s) failed:

  • Failed to generate chemical_reactions coverage rate (required: 92.0%)
  • Failed to generate combined coverage rate (required: 37.0%)
  • Failed to generate contact coverage rate (required: 87.0%)
  • Failed to generate electromagnetics coverage rate (required: 94.0%)
  • Failed to generate external_petsc_solver coverage rate (required: 84.0%)
  • Failed to generate fluid_properties coverage rate (required: 84.0%)
  • Failed to generate fsi coverage rate (required: 85.0%)
  • Failed to generate functional_expansion_tools coverage rate (required: 81.0%)
  • Failed to generate geochemistry coverage rate (required: 96.0%)
  • Failed to generate heat_transfer coverage rate (required: 87.0%)
  • Failed to generate level_set coverage rate (required: 85.0%)
  • Failed to generate misc coverage rate (required: 32.0%)
  • Failed to generate navier_stokes coverage rate (required: 77.0%)
  • Failed to generate optimization coverage rate (required: 86.0%)
  • Failed to generate peridynamics coverage rate (required: 77.0%)
  • Failed to generate phase_field coverage rate (required: 85.0%)
  • Failed to generate porous_flow coverage rate (required: 95.0%)
  • Failed to generate ray_tracing coverage rate (required: 93.0%)
  • Failed to generate rdg coverage rate (required: 63.0%)
  • Failed to generate reactor coverage rate (required: 90.0%)
  • Failed to generate richards coverage rate (required: 93.0%)
  • Failed to generate scalar_transport coverage rate (required: 81.0%)
  • Failed to generate solid_mechanics coverage rate (required: 84.0%)
  • Failed to generate solid_properties coverage rate (required: 83.0%)
  • Failed to generate stochastic_tools coverage rate (required: 88.0%)
  • Failed to generate subchannel coverage rate (required: 87.0%)
  • Failed to generate thermal_hydraulics coverage rate (required: 88.0%)
  • Failed to generate xfem coverage rate (required: 80.0%)

@GiudGiud GiudGiud self-assigned this Mar 2, 2026
Copy link
Contributor

@GiudGiud GiudGiud 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 apply transformations to surfaces?

and do you envision that transformations applied to a universe should be propagated to all cells they contain?
To know the real location of the cell we need to get or gather the full list of transformations

|---------------------|----------------------------------------------|--------------------|
| `TRANSLATION` | $\{$ x-distance, y-distance, z-distance $\}$ | none |
| `ROTATION` | $\{ \phi, \theta, \psi \}$ | none |
| `SCALE` | $\{$ x-scale, y-scale, z-scale $\}$ | non-zero |
Copy link
Contributor

Choose a reason for hiding this comment

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

positive no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So I had this as a positive, non-zero restriction initially, but @shikhar413 pointed out that negative values were allowed in the TransformGenerator. I did look the source code there and did not see a restriction on any of the values for scaling, including the fact that the values could be zero. We decided to allow negative values to be consistent with that generator, but restrict zero values because that wouldn't make any sense from a CSG/MC standpoint. I am fine with going back to restricting it to positive values only if we think it makes most sense even though the TransformGenerator allows negative.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok seems fine.
TransformGenerator negative scaling needs an extra step to flip the elements back to a positive volume.

I guess it's a way to do a central symmetry


!alert! note title=CSGRegion Transformations

If applying a transformation to a `CSGRegion` object, the `CSGRegion` object will not store the transformation information.Rather, the transformation will be applied to each `CSGSurface` associated with that `CSGRegion`. This means that if one `CSGSurface` object is used in multiple `CSGRegion` objects, all regions with that surface may be affected by the transformation. If the intention is to apply a transformation to just one use case of the shared `CSGSurface`, then a clone of that surface should be made prior to applying the transformation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
If applying a transformation to a `CSGRegion` object, the `CSGRegion` object will not store the transformation information.Rather, the transformation will be applied to each `CSGSurface` associated with that `CSGRegion`. This means that if one `CSGSurface` object is used in multiple `CSGRegion` objects, all regions with that surface may be affected by the transformation. If the intention is to apply a transformation to just one use case of the shared `CSGSurface`, then a clone of that surface should be made prior to applying the transformation.
If applying a transformation to a `CSGRegion` object, the `CSGRegion` object will not store the transformation information. Rather, the transformation will be applied to each `CSGSurface` associated with that `CSGRegion`. This means that if one `CSGSurface` object is used in multiple `CSGRegion` objects, all regions with that surface may be affected by the transformation. If the intention is to apply a transformation to just one use case of the shared `CSGSurface`, then a clone of that surface should be made prior to applying the transformation.

seems like something that is easy to miss. Could check in dbg mode? (in between #ifndef NDEBUG)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What exactly are you recommending to check here with debug mode?

std::vector<std::pair<TransformationType, std::tuple<Real, Real, Real>>> transformations = {
{TransformationType::TRANSLATION, {1.0, 2.0, 3.0}},
{TransformationType::ROTATION, {45.0, 30.0, 60.0}},
{TransformationType::SCALE, {-2.0, 2.0, 2.0}}};
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe use a valid one for the test in case the checking moves around

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

assuming you are referring to the negative value in the SCALE one, that was intentional given the fact that negatives are valid there, so I will leave this.

@kkiesling
Copy link
Collaborator Author

do we need to apply transformations to surfaces?

We decided against this because it seems like most of the MC codes actually have methods in place to apply transformations to surfaces (or other entities) and so it would be more reliable for the codes to use their own methods.

and do you envision that transformations applied to a universe should be propagated to all cells they contain? To know the real location of the cell we need to get or gather the full list of transformations

yes I envision this would be iteratively applied to each cell within a universe

getTransformations() const
{
return _transformations;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

right my question is more that transformations are not usually applied to surfaces in MC codes?
At least in OpenMC if I recall correctly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Surfaces are the primary entities that can have transformations applied to them across all MC codes, various codes allow for cells and universes too under different circumstances (these are less consistent across codes). But pretty much all codes support surface transformations directly with built-in methods.

At the end of the day, it is really all the surfaces that need to be transformed to alter the geometry with a transformation.

@kkiesling
Copy link
Collaborator Author

kkiesling commented Mar 3, 2026

Just realized that I need to add a check for transformations in the equality operator overloads for each of these object types. Making note here so I don't forget to do that. EDIT: done

@kkiesling kkiesling requested a review from GiudGiud March 6, 2026 21:18
@shikhar413
Copy link
Contributor

@kkiesling now that we have transformations defined here, do we want to update the documentation for hexagonal lattices to mention that x-type lattices should be implemented by applying a rotation to a y-type lattice?

@kkiesling
Copy link
Collaborator Author

now that we have transformations defined here, do we want to update the documentation for hexagonal lattices to mention that x-type lattices should be implemented by applying a rotation to a y-type lattice?

good idea. Just added a note in the docs.

@moosebuild
Copy link
Contributor

Job Test, step Results summary on 6210b19 wanted to post the following:

Framework test summary

Compared against aec0a32 in job civet.inl.gov/job/3640883.

No added tests

Run time changes

Test Base (s) Head (s) +/- Base (MB) Head (MB)
executioners/multisys-ss-detection.multi-sys-ss 4.99 7.51 +50.60% 136.29 136.47

Modules test summary

Compared against aec0a32 in job civet.inl.gov/job/3640883.

No added tests

Run time changes

Test Base (s) Head (s) +/- Base (MB) Head (MB)
solid_mechanics/test:ad_anisotropic_creep.jac_ad 19.06 30.29 +58.96% 145.60 178.71
stochastic_tools/test:transfers/sampler_reporter.transfer/distributed 3.42 5.43 +58.62% 476.23 475.47
solid_mechanics/test:rate_independent_cyclic_hardening.nonlin_isoharden_symmetric_strain_controlled 3.86 5.86 +51.83% 126.80 129.98
solid_mechanics/test:smeared_cracking.rz_exponential 12.39 18.72 +51.10% 134.13 124.25
solid_mechanics/test:crystal_plasticity/cp_eigenstrains.thermal_eigenstrain 4.66 7.04 +51.01% 119.34 122.35

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.

CSG Transformations Support

4 participants