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

Compiling Fail cad_to_dagmc #87

Open
gglamzn opened this issue May 13, 2024 · 5 comments
Open

Compiling Fail cad_to_dagmc #87

gglamzn opened this issue May 13, 2024 · 5 comments

Comments

@gglamzn
Copy link

gglamzn commented May 13, 2024

No description provided.

@shimwell
Copy link
Member

Thanks for making use of the package. Was there an error with the code that you wanted to share?

@gglamzn
Copy link
Author

gglamzn commented May 13, 2024

Hi,

I'm currently trying to do some simulations on .step files from my CAD Software.

I have attached my Python functions and an Image of my .step geometry:

def output_path(output_dir,output_file_name):
    """
    Useful for having the ouput_path of the h5m file in the other functions.

    Args:
        output_dir (str): The directory where the output h5m file will be saved.
        output_file_name (str) : The name of h5m output file.
    
    Returns:
            output_path (str): The path of the h5m file

   """
    
    output_path = os.path.join(output_dir, output_file_name)
    output_path
    return output_path

def cad_geometry_to_h5m(material_tags_list,input_file_path,output_dir,output_file_name):
    """
    Converts a STEP file to a DAGMC h5m file usable for simulations on OpenMC.

    Args:
        material_tags_list (list): The materials tags that will be applied to the volumes.
        input_file_path (str): The path of the step to convert 
        output_dir (str): The directory where the output h5m file will be saved.
        output_file_name (str) : The name of h5m output file.
    
    Returns:
            None
   """
    result = cq.importers.importStep(input_file_path)
    assembly = cq.Assembly()
    assembly.add(result)
    
    my_model = CadToDagmc()
    
    my_model.add_cadquery_object( 
        cadquery_object=assembly,
        material_tags=material_tags_list)
    
    # Export the DAGMC h5m file to the specified output directory
    h5m_path=output_path(output_dir,output_file_name)
    my_model.export_dagmc_h5m_file(h5m_path, min_mesh_size=5, max_mesh_size=20)
    
    return None

material_tags_list=['mat1']  #arbitrary , would be defined later , during the simulation process

#To fill according to your work directory
input_file_path=
output_dir=

output_file_name='compass_geometries.h5m'
cad_geometry_to_h5m(material_tags_list,input_file_path,output_dir,output_file_name)

Replace placeholders like input_file_path and output_dir with your actual file paths and directories.

There is an IMAGE of my .step geometry :
step_geometry

It is too bad that I can't share the file

After compiling , for actually quite some time , my machine Always freezes (i tried several times to compile), and I get this on my terminal :
problem_terminal

I am not really familiar with CAD geometry but it seems to me that my geometry I relatively basic , so I may have done some mistakes somewhere.

I would like your input in my issue .
Thanks in advance.

@shimwell
Copy link
Member

Looks like it is pausing on the gmeshing part. You could tried manually meshing with gmsh and see if that is possible.

@gglamzn
Copy link
Author

gglamzn commented May 14, 2024

Hi,

If i'm meshing with gmsh , would not the meshing still be operated by the CadtoDagMC function when I will use it ?

@shimwell
Copy link
Member

The manual meshing with gmsh is mainly to check if the step geometry has errors which mean it can't be meshed. Current Cad-To-Dagmc only offers one mesher whioch is gmsh so if gmesh cna't manually mesh the geometry then Cad-To-Dagmc also can't mesh your geometry.

If you are able to successfully mesh manually in gmsh then you have the option to save the msh file and Cad-To-Dagmc can import the msh file with its MeshToDagmc class https://github.com/fusion-energy/cad_to_dagmc/blob/5cd38e4ddb9c1db86192bace38629a341c41d8cb/src/cad_to_dagmc/core.py#L328C7-L328C18

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

No branches or pull requests

2 participants