Skip to content

Feature: Grain Boundaries#387

Open
jplauzie wants to merge 2 commits intomumax:3.11.2from
jplauzie:Grainboundaries
Open

Feature: Grain Boundaries#387
jplauzie wants to merge 2 commits intomumax:3.11.2from
jplauzie:Grainboundaries

Conversation

@jplauzie
Copy link

This PR adds a new function that adds boundaries to existing regions, given user input of: (startregion, numgrains, offset, boundarythickness, zeroflag). Zeroflag: 1 = region0 is normal, 0 = region0 acts as edge but no boundary itself, -1 = ignore region0 entirely.

  • Meant to be used after ext_makegrains or ext_make3dgrains, to give grains boundaries, but will of course work with any arbitrary shape. One can also assign all boundaries the same material parameters to have grains embedded into a single material, instead of each grain having individual boundaries.
  • kind of region-intensive, since it will double the amount of regions used.
  • can be called repeatedly if one wants multiple layers
  • works in both 2D and 3D
  • 1 major flaw: Since it works on the output of ext_makegrains, it currently cannot detect if you happen to have 2 grains that belong to the same region touching. There will be no boundary. The only way I can think to fix this is to have ext_grainboundaries call a modified ext_makegrains internally that uses only unique values but is unlimited to 256 regions, and then reduce (using modulo 256) back down to 256 after boundaries have been added (this is doable, but I have not implemented it yet, I figured I'd get feedback first). A bit unfortunate, since ideally you want to use a low number of regions to begin with since they get doubled.
  • does not yet work with shift/moving frame stuff, where new grains will be introduced as the frame moves at the edges.

For instance, if one had called
ext_make3dgrains(200e-9, 1, 50, ellipsoid(5e-9512,5e-9256,5e-9*100), 12345678)

and you wanted 2 boundary layers each with thickness of 3 cells, you might do:
ext_grainboundaries(0,50,51,3,1)
ext_grainboundaries(0,50,102,3,1)

@JonathanMaes JonathanMaes changed the base branch from master to 3.11.2 March 18, 2026 15:26
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