GEOUNED-org / GEOUNED

A tool to convert CAD to CSG & CSG to CAD for Monte Carlo transport codes
European Union Public License 1.2
56 stars 30 forks source link

[BUG] Missing comments #212

Closed KBGrammer closed 3 months ago

KBGrammer commented 3 months ago

Somehow my comments are coming up as empty regardless. I'm trying to convert with debug on and it seems that logger.info(m.Comments) is empty in decompose_solids.

Any ideas how that would happen and how to remedy it?

For instance, when I try to convert the BC.stp example file, geouned_general_log.log has these lines:

2024-06-05 13:27:22,171 :: INFO :: load_step_file :: 458 :: Start of step file loading phase
2024-06-05 13:27:22,177 :: INFO :: load_step_file :: 488 :: read step file : inputSTEP/BC.stp
2024-06-05 13:27:22,318 :: INFO :: load_step_file :: 500 :: End of step file loading phase
2024-06-05 13:27:22,319 :: INFO :: start :: 567 :: End of loading phase
2024-06-05 13:27:22,319 :: INFO :: start :: 569 :: 0:00:00.000061
2024-06-05 13:27:22,319 :: INFO :: _decompose_solids :: 780 :: Decomposing solid: 1/1
2024-06-05 13:27:22,319 :: INFO :: _decompose_solids :: 783 :: 
2024-06-05 13:27:27,719 :: WARNING :: remove_solids :: 865 :: remove_solids degenerated solids are produced 2.4005654491663e-09
2024-06-05 13:27:28,166 :: INFO :: start :: 590 :: End of decomposition phase
2024-06-05 13:27:28,167 :: INFO :: start :: 597 :: Building cell: 1
2024-06-05 13:27:28,179 :: WARNING :: cellDef :: 519 :: <Plane object> surface removed from cell definition. Face area < Min area (1.1378327749409462e-05 < 0.01)
2024-06-05 13:27:28,179 :: WARNING :: cellDef :: 519 :: <Plane object> surface removed from cell definition. Face area < Min area (6.19804827664639e-05 < 0.01)
2024-06-05 13:27:28,179 :: WARNING :: cellDef :: 519 :: <Plane object> surface removed from cell definition. Face area < Min area (1.1384652875957003e-05 < 0.01)
2024-06-05 13:27:28,179 :: WARNING :: cellDef :: 519 :: <Plane object> surface removed from cell definition. Face area < Min area (3.9548408631023314e-05 < 0.01)
2024-06-05 13:27:28,179 :: WARNING :: cellDef :: 519 :: <Cylinder object> surface removed from cell definition. Face area < Min area (4.2607385477967235e-05 < 0.01)
2024-06-05 13:27:28,234 :: WARNING :: cellDef :: 519 :: <Plane object> surface removed from cell definition. Face area < Min area (8.962036525995444e-05 < 0.01)
2024-06-05 13:27:28,234 :: WARNING :: gen_plane_cylinder :: 284 :: surface <Cylinder object> removed from cell definition. Face area < Min area (8.962036525995444e-05 < 0.01)
2024-06-05 13:27:28,248 :: WARNING :: gen_plane_cylinder :: 284 :: surface <Cylinder object> removed from cell definition. Face area < Min area (6.19804827664639e-05 < 0.01)
2024-06-05 13:27:28,249 :: WARNING :: cellDef :: 519 :: <Plane object> surface removed from cell definition. Face area < Min area (6.19804827664639e-05 < 0.01)
2024-06-05 13:27:28,277 :: WARNING :: cellDef :: 519 :: <Plane object> surface removed from cell definition. Face area < Min area (0.009977059372179232 < 0.01)
2024-06-05 13:27:28,289 :: INFO :: start :: 631 :: 0:00:05.970539
2024-06-05 13:27:28,289 :: INFO :: start :: 656 :: Build Void
2024-06-05 13:27:28,289 :: INFO :: start :: 657 :: []
2024-06-05 13:27:28,290 :: INFO :: void_generation :: 55 :: Build Void highest enclosure
2024-06-05 13:27:28,324 :: INFO :: get_void_def :: 131 :: Loop, Box to Split :{iloop}, {nvoid}
2024-06-05 13:27:28,324 :: INFO :: get_void_def :: 135 :: 1 1/1 40 39
2024-06-05 13:27:28,324 :: INFO :: get_void_def :: 155 :: build complementary 1 0
2024-06-05 13:27:35,831 :: INFO :: start :: 689 :: simplify cell 1
2024-06-05 13:27:43,083 :: INFO :: start :: 698 :: build Time: 2024-06-05 13:27:43.083610 - 2024-06-05 13:27:28.289781
2024-06-05 13:27:43,083 :: INFO :: start :: 700 :: 0:00:20.764813
2024-06-05 13:27:43,084 :: INFO :: start :: 760 :: Process finished
2024-06-05 13:27:43,084 :: INFO :: start :: 761 :: 0:00:20.765030
2024-06-05 13:27:43,084 :: INFO :: start :: 763 :: Translation time of solid cells 2024-06-05 13:27:28.289781 - 2024-06-05 13:27:22.319185
2024-06-05 13:27:43,084 :: INFO :: start :: 764 :: Translation time of void cells 2024-06-05 13:27:43.083610 - 2024-06-05 13:27:28.289781
2024-06-05 13:27:43,086 :: INFO :: write_input :: 88 :: write MCNP file csg_with_offshoot.mcnp
2024-06-05 13:27:43,094 :: INFO :: export_csg :: 203 :: End of Monte Carlo code translation phase
2024-06-05 13:27:43,094 :: INFO :: start :: 567 :: End of loading phase
2024-06-05 13:27:43,094 :: INFO :: start :: 569 :: 0:00:00.000052

At the decompose stage, the second line of these two should have some type of name for the object, but it doesn't:

2024-06-05 13:27:22,319 :: INFO :: _decompose_solids :: 780 :: Decomposing solid: 1/1
2024-06-05 13:27:22,319 :: INFO :: _decompose_solids :: 783 :: 

The MCNP output does not contain a comment for the cell 1, but does for the void and graveyard:

C **************************************************************
1     0      5 2 -28 -4:-28 8 9 -7 -6:5 7 9 -14 -13 -4:-28 6 9 16 -15 -7:2 -28 
           -21 -11 22 -5:2 -28 -23 11 22:2 -28 -23 -22 24:-24 -22 2 -28:-28 7 
           -23 9 11 13 24 -2:-28 5 7 13 -14 -4 -2:-28 7 9 -21 13 -11 -5 -2:-28 
           9 -18 15 -17 -7:-28 7 8 -24 -22 9 12 -2:16 18 19 -20:-19 16 17 18 -9 
           25:-18 -17 -16 15 -10 -9:-19 -16 17 -10 25:6 10 -19 17 25:-28 5 -20 
           -18 16 -14 19 -10 -9 -4:-28 5 -19 -18 16 -9 25:1 (-28 9 17 -7 25:-28 
           -20 -16 19 -10:-7 -5 14:5 10 -20 -14:5 10 -20 14 -7:-28 14 16 -10 -9 
           -7:27 (9 8 (29 2 3:38 -28 -24 -12 11 13 -2):19 (33 -20 -17:37 -20 17 
           -6:40 6 -5 10 -20 15 17 -14):31 6 10 16 -15)):(15 36 -17 10:-28 25 
           16 -9 -10) 39 27 -18 6 -5:26 -19 17 25 -6 27:30 8 -10 -9 -6 27:32 
           -18 15 -17 -6 27:34 7 27 9 -21 -13 -5:35 11 -13 21 27
           Vol=8.812167e+02
           imp:n=1.0   imp:p=1.0   
C 
C ##########################################################
C              VOID CELLS
C ##########################################################
C 
2     0      41 -42 43 -44 45 -46 (-5:-2:28:4) (28:-8:-9:7:6) (-5:-7:-9:14:13:4)
            (28:-6:-9:-16:15:7) (-2:28:21:11:-22:5) (-2:28:23:-11:-22) (-2:28:
           23:22:-24) (24:22:-2:28) (28:-7:23:-9:-11:-13:-24:2) (28:-5:-7:-13:
           14:4:2) (28:-7:-9:21:-13:11:5:2) (28:-9:18:-15:17:7) (28:-7:-8:24:22:
           -9:-12:2) (-16:-18:-19:20) (19:-16:-17:-18:9:-25) (18:17:16:-15:10:9)
            (19:16:-17:10:-25) (-6:-10:19:-17:-25) (28:-5:20:18:-16:14:-19:10:9:
           4) (28:-5:19:18:-16:9:-25) (-1:(28:-9:-17:7:-25) (28:20:16:-19:10) 
           (7:5:-14) (-5:-10:20:14) (-5:-10:20:-14:7) (28:-14:-16:10:9:7) (-27:
           (-9:-8:(-29:-2:-3) (-38:28:24:12:-11:-13:2)) (-19:(-33:20:17) (-37:
           20:-17:6) (-40:-6:5:-10:20:-15:-17:14)) (-31:-6:-10:-16:15))) ((-15:
           -36:17:-10) (28:-25:-16:9:10):-39:-27:18:-6:5) (-26:19:-17:-25:6:-27)
            (-30:-8:10:9:6:-27) (-32:18:-15:17:6:-27) (-34:-7:-27:-9:21:13:5) 
           (-35:-11:13:-21:-27)
           Vol=1.0
           imp:n=1.0   imp:p=1.0   
           $Automatic Generated Void Cell. Enclosure(-1171.243, -1152.002, 1115.585, 1135.400, -568.000, -538.000)
           $Enclosed cells : (1)
3     0      -47 (-41:42:-43:44:-45:46)
           Vol=1.0
           imp:n=1.0   imp:p=1.0   
           $Graveyard_in
4     0      47
           Vol=1.0
           imp:n=0     imp:p=0     
           $Graveyard

I'm generating it with the following json parameters and using the dev version:

{
    "load_step_file": {
        "filename": "inputSTEP/BC.stp",
        "skip_solids": []
    },
    "Options": {
        "forceCylinder": false, 
        "newSplitPlane": true, 
        "delLastNumber": false, 
        "enlargeBox": 2.0, 
        "nPlaneReverse": 0, 
        "splitTolerance": 0.0, 
        "scaleUp": true, 
        "quadricPY": false, 
        "Facets": false, 
        "prnt3PPlane": false, 
        "forceNoOverlap": false
    },
    "Tolerances": {
        "relativeTol": false, 
        "relativePrecision": 1e-06, 
        "value": 1e-06, 
        "distance": 1.0e-4, 
        "angle": 0.0001, 
        "pln_distance": 1.0e-4, 
        "pln_angle": 0.0001, 
        "cyl_distance": 1.0e-4, 
        "cyl_angle": 0.0001, 
        "sph_distance": 1.0e-4, 
        "kne_distance": 1.0e-4, 
        "kne_angle": 0.0001, 
        "tor_distance": 1.0e-4, 
        "tor_angle": 0.0001, 
        "min_area": 0.01
    },
    "NumericFormat": {
        "P_abc": "14.7e", 
        "P_d": "14.7e", 
        "P_xyz": "14.7e", 
        "S_r": "14.7e", 
        "S_xyz": "14.7e", 
        "C_r": "12f", 
        "C_xyz": "12f", 
        "K_xyz": "13.6e", 
        "K_tan2": "12f", 
        "T_r": "14.7e", 
        "T_xyz": "14.7e", 
        "GQ_1to6": "18.15f", 
        "GQ_7to9": "18.15f", 
        "GQ_10": "18.15f"
    },
    "Settings": {
        "matFile": "", 
        "voidGen": true, 
        "debug": true, 
        "compSolids": true, 
        "simplify": "full", 
        "exportSolids": "", 
        "minVoidSize": 200.0, 
        "maxSurf": 50, 
        "maxBracket": 30, 
        "voidMat": [], 
        "voidExclude": [], 
        "startCell": 1, 
        "startSurf": 1, 
        "sort_enclosure": true
    },
    "export_csg":{
        "title": "Converted with GEOUNED",
        "geometryName": "csg_with_offshoot",
        "outFormat": ["mcnp"],
        "volSDEF": false,
        "volCARD": true,
        "dummyMat": true,
        "cellCommentFile": true,
        "cellSummaryFile": true
    }
}

Originally posted by @KBGrammer in https://github.com/GEOUNED-org/GEOUNED/issues/187#issuecomment-2150378118

KBGrammer commented 3 months ago

In load_step.py, the function load_cad should loop over elements in the document. However, in the following section at line 63:

doc_objects = cad_simplificado_doc.Objects
for elem in doc_objects:

the length of doc_objects is 0, so the loop doesn't progress and the comment is not picked up at line 76.

KBGrammer commented 3 months ago

I figured it out. I had added a function in my main script calling the conversion stuff that @shimwell suggested for finding solids that have splines. That contains this line:

cad_simplificado_doc = FreeCAD.newDocument("CAD_simplificado")

It shares the same name as line 40 of load_step.py. Changing the name in my function that checks for splines fixes this issue.