One of the major advances in McCAD v1.0 concerns the conversion algorithm. The conversion algorithm from McCAD v0.5 has been completely replaced by a novel one that makes use of the new code structure and proven, through testing, to be more robust. Although McCAD v1.0 maintained the polymorphism of geometrical entities—through dedicated classes for different solids and surfaces by type—it also expanded it through the creation of a “compound solid” class. A
compound is defined in McCAD v1.0 as the original input solid to be decomposed and later converted into CSG format. This class holds the original solid details, such as its name and other geometrical properties. As the solid progresses through decomposition and conversion processes, the attributes are updated—such as the boundary surfaces, and subsolids objects. This opened the door for new capabilities in conversion. McCAD now offers the user control over the solid representation; separate cells can represent each subsolid or a single cell can represent the union of all the subsolids. McCAD also generates supplementary files for volume validation. A new void cell manager allowed for additional features in void generation, discussed in detail in
Section 4.1 and
Section 4.2.
4.1. Domain Decomposition: Conformal Void Cells
When converting CAD solids to CSG, all space not belonging to material cells must be contained within voided cells. This ensures that all regions in the problem domain belong to well defined cells with known properties for particle tracking in radiation transport. McCAD conversion algorithm can perform automatic void generation, through a user-controlled on/off input switch. Another aspect of the void cells is the complexity/length of their expression in MCNP input. Since a void cell can be thought of as the Boolean complement of all the material cells contained within, the larger the number of cells, and in turn surfaces, the longer the void cell expression. This can have detrimental effects on the radiation transport time. As a result, McCAD v1.0 introduced two user-controlled input parameters to control both the size of and the number of solids contained within a void cell. This addition gives the user more control over the number of generated void cells as well as the complexity of their expressions.
A major improvement of the new conversion algorithm is seen in the processing time and computer memory utilization for void generation. The improvement can be divided into two main processes: splitting of void cells and detection of solids and void cells intersection. When performing domain decomposition to define the void cells, McCAD starts with all solids inside a single void cell, representing the axis-aligned bounding box (AABB) for the entire CAD model. Then, based on the size of the model, number of solids, and user parameters, McCAD judges whether that “root” void cell will need to be simplified via splitting.
Concerning void cells splitting, the algorithm in McCAD v0.5 relied on uniform splitting of a void cell using three planes through its center, each perpendicular to one of the basis axes, resulting in eight quadrants. Following this method, any void cell that triggers the algorithm to perform splitting, due to the number of solids contained within, would result in eight void cells instead. Though at first glance this approach would seem to reduce the number of subsequent splittings, it creates geometry errors in MCNP as a result of void and material cells overlapping, and it is resource-intensive with respect to collision detection. In McCAD v0.5, after a void cell is split, collision detection of the newly created eight void cells and the solids is performed through the same algorithm used for decomposition. This resulted in the costly collision detection process being performed eight times for each splitting of a void cell. The overall process, then, is deemed error-prone.
In McCAD v1.0, a new approach has been adopted for void generation based on a density-informed selective splitting and 1D-based collision detection, which are first-of-a-kind in a CAD-to-CSG conversion algorithm. At the beginning of void generation, the void cell manager creates a root void cell with all solids within. This process utilizes OCCT functions to create the AABB object and obtain its extents along the three axes. After that, all solids are reduced to three maps, one for each axis, of solid IDs and their AABB extents.
McCAD v1.0 performs splitting of a void cell using only a single plane. For each axis, candidate split planes are selected and sorted to set the priority of splitting. The candidate split planes include the mid-plane of the void cell’s AABB as well as another plane based on the distribution of the centers of the AABB of each solid contained within the void cell. For narrow distributions, the plane is selected to be away from the mean—and vice versa for wide distributions. Candidate split planes are then sorted to prioritize those that (a) reduce the number of solids that the plane would cut through, (b) have the fewest subsequent splittings, and (c) would result in two void cells that are at least equal to the user-controlled minimum volume. This is judged using the internal collision detector.
Using 1D maps, it is easier to loop over all solids and quickly judge based on the extents of their AABBs whether they overlap with the cutting plane or not. Collision detection is then reduced to logical operations on numerical values—the extents of each solid’s AABB and the coordinates of the cutting plane—which is a far quicker process than utilizing OCCT functions on the CAD solids themselves. Another parameter in selecting the cutting plane is the number of solids on either side, which provides a measure of the prospective number of splittings later on. After repeating the same process along the three axes, a plane is selected. After splitting, the parent void cell results in two daughters, and the process is repeated recursively. The two resultant void cells collectively span the full extent of the parent, which makes these conformal void cells. This approach ensures a reduction of unnecessary splitting of void cells and that the generated void cells are adaptive, denser around large solids aggregates, and vice versa for less populated regions of space.
As an example, consider an arbitrary collection of CAD solids, shown in
Figure 5a. The solids represent different combinations of planes, cylinders, cones, and tori and result in a total of 63 subsolids after decomposition,
Figure 5b. The center and extent of the AABB of each subsolid along the X-, Y-, and Z-axis is plotted in
Figure 6. For each horizontal line segment, the center point represents a subsolid’s AABB center, whereas the length represents its extent along the corresponding axis. Three candidate planes—along the X-, Y-, and Z-axis—were chosen by the density-informed selector, designated with the broken vertical lines. The candidate planes would cut through 3, 4, and 15 subsolids along the X-, Y-, and Z-axis, respectively. McCAD chose the one along the X-axis. If the old splitting scheme was used—three planes through the center of the void cell, as shown as the solid lines in
Figure 6—then the plane through the Z-axis would cut though almost all solids, necessitating collision detection via OCCT functions on CAD solids.
4.2. Domain Decomposition: Hierarchical Void Cells
A first-of-a-kind capability of McCAD v1.0 is the generation of hierarchical void cells. Bounding volume hierarchy (BVH) has never been utilized for radiation transport in MC simulations, except for CAD-based codes such as DAGMC [
5]. McCAD v1.0 void cell manager has the capability, through a user-controlled on/off input switch, to generate either conformal or hierarchical void cells. Hierarchical void cells form a binary tree with the root corresponding to the AABB of the entire CAD model. Using the advanced void cell manager described in
Section 4.1, McCAD then splits the root void cell into two and progresses recursively down the tree. At each node, a void cell contains two daughter void cells, and the parent–daughter relation is captured. When splitting of void cells ceases, at which stage leaf nodes are formed, the void cells contain CAD solids from the model. This simplifies the CSG expression for most of the void cells in the model—a complement of only two rectangular prisms.
In MCNP, one of the resource-intensive processes involves the update to the state of the particle as it traverses the medium. It involves the calculation of surface crossings based on the distances to the boundary surfaces in the current cell. For a void cell, this means a calculation of the distance to all surfaces represented in the void cell definition. Thus, a complex/lengthy void cell expression would result in a slowdown of the radiation transport simulation. Hierarchical void cells provide a benefit to combat this slowdown; each void cell contains only two cells, with six planar surfaces each. This not only puts an upper bound on the number of calculations involved in determining the particle’s distance to the cell boundaries, but it also simplifies such calculations by using only planar surfaces.
To demonstrate this ability, the arbitrary collection of 63 solids referenced in
Section 4.1 was utilized in a preliminary comparison of hierarchical vs. conformal void cells. By varying the number of solids per void cell in McCAD input, several MCNP input files were generated utilizing both hierarchical and conformal void cells. This parameter controls the material cells contained in all conformal and the inner-most hierarchical void cells, which determines the overall number of void cells in the MCNP input. Using the surface source defined by McCAD for stochastic volume calculation—defined on a sphere surrounding the solids with particles directed inward—the volumes of all voided material cells were calculated. The obtained results were identical because no changes to the material cells were made, but the structure of the void cells showed differences in terms of performance. MCNP6.2 was used to simulate 2 × 10
8 histories on a single thread on 11th Gen Intel
(R) Core
(TM) i7-11850H @ 2.50 GHz.
In
Figure 7a,b, the computing time and the number of particle histories per hour, as reported by MCNP, are plotted against the number of solids per void cell, respectively. For the case with 70, a single void cell was generated in both cases, and the time and number of histories are similar. As the number of void cells increases, the number of solids per void cell decreases, demonstrating the performance gain. Both figures show that hierarchical void cells are superior to conformal ones in terms of lower computing times, which were up to 50% reduced, and higher processed particle histories per hour. Such a gain does not come at the expense of an increased number of void cells: the number is comparable in both cases, as demonstrated in
Figure 7c.
4.3. Supplementary Output
When converting CAD models to CSG, in addition to checking for lost particles, volume validation is conducted to ensure that the deviation between CSG cells and CAD solids, if any, is kept to a minimum and that adequate density modifications are applied accordingly. This validation is performed through a one-to-one comparison between the original CAD solids, the sum of its subsolids after decomposition, and the stochastic volumes calculated in MCNP. McCAD v1.0 provides the necessary output to the user for this volume validation. When executed in decomposition mode, McCAD writes a list of all input solids names and volumes, as processed by OCCT, to a text file. When executed in conversion mode, McCAD produces mapping of cell IDs and the corresponding names and volumes of solids to a text file. This serves as a mapping between the cell IDs and the original input solids and their subsolids, making it easy to perform volume validation.
For conversion to MCNP, McCAD v1.0 provides two supplementary outputs. The first is in terms of a textual material-to-void cells mapping. This is beneficial in case any modifications must be implemented in the generated MCNP input file without the user repeating the conversion process all over again, although with the new conversion algorithm this difference has greatly diminished. Also, McCAD provides, in the MCNP input, auxiliary cells as well as surface, source, and tally definitions for stochastic volumes calculation.