Skip to content

Creating meshes from CT scan images

mlesueur edited this page Feb 27, 2016 · 27 revisions

MOOSE already possesses the functionality to read a stack of CT scan images and create the corresponding mesh through its ImageReader. But the following paragraph explains why MOOSE's module is limited.

#MOOSE ImageSubdomain Using the function ImageSubdomain, MOOSE creates a mesh of the stack of CT-scan Images with 2 blocks, the pore space and the grains.

Two parameters can be chosen by the user:

  • Type of elements meshed
  • Level of refinement (different options available)

HOWEVER one important parameter can not be changed, level of coarsening. The mesh created can not have elements coarser than the resolution of the image.

Mesh coarsening is an important aspect in simulation with CT-scan images. We want to refine the mesh at the grain's boundary because this is where the simulation is complex. But we want to coarsen the region away from these boundaries in order to reduce simulation time.

This is why I would recommend to use REDBACK Image Reader in order to get the full panel of functionalities.

#REDBACK Image Reader ##Installation The first step is to [install VTK](Installing VTK). Then you have to run REDBACK's tests to make sure that those for ImageSubdomain are not skipped and do not fail.

##Usage

###Process input files The process to create a mesh with adapative refinement from a CT-scan image is in 4steps. These are all the input files you will need to run the process:

  • your stack of images (only 1 if 2D). See [here](creating png images from raw data) some methods of creating these images from raw data.
  • mesh_generation_3D_step1.i
  • mesh_generation_3D_step2.i
  • remove_duplicates.py
  • mesh_generation_3D_step3.i

The input files .i for 2D are the same without the 3D in the file name. A sample of all these files can be found in the folder tests of REBACK's directory under the folder image_subdomains.

User parameters

In the first file, mesh_generation_3D_step1.i, is all the parameters that the user has to change in order to adapt to his stack of images.

  • elem_type
  • nx/y/z, x/y/zmax: Size of your mesh, the x/y/z ratio must be adapted to your stack of images but you have to put the smallest ratio possible (if your sample is cubic, nx=ny=nz=1).
  • uniform_refine: a uniform refinement of x means MOOSE builds a mesh of 2^x pixels size. the second step, adaptivity only coarsens the mesh, so you should take the highest refinement in this step.
  • Adaptivity: adaptative coarsening, a few parameters are modifiable in order to best adapt to your model.
  • image_func: this is where you indicate the localisation of your stack of files and their names. For 2 files in the folder stack named test_00.png and test_01.png, the code should be:

file_base = stack/test_0

file_range = '0 1'

In the second file mesh_generation_3D_step2.i the image_func paragraph should be modified like explained above.

If you are taking the files from the folder tests/image_subdomains you will have to change the path of input files in all the files because they are all pointing to gold/.... Just remove gold/ so that the files will be taken from your working directory.

2D

  • Run mesh_generation_step1.i This generates the file 1block_mesh.e containing the mesh with 1block but the level of refinement/adaptivity that we want.

  • Run mesh_generation_step2.i This generates the file idfile.txt containing the list of element ids of the subdomain.

  • Run python ~/projects/moose/modules/combined/test_image_reader_subdomain/2D/remove_duplicates.py This generates the file idfile_unique.txt containing the list of unique element ids of the subdomain.

  • Run mesh_generation_step3.i This generates the file 2blocks_mesh.e containing the mesh of 2blocks. The subdomain has been created.

  • Run simulation.i This is the simulation of Navier-Stokes using the generated mesh. There might be some convergence issues. It generates the file navier.e

3D

Same process, but the files change a bit.

  • Run mesh_generation_3D_step1.i This generates the file 1block_mesh_3D.e
  • Run mesh_generation_3D_step2.i This generates the file idfile.txt
  • Run python ~/projects/moose/modules/combined/test_image_reader_subdomain/2D/remove_duplicates.py This generates the file idfile_unique.txt
  • Run mesh_generation_3D_step3.i This generates the file 2blocks_mesh_3D.e
  • Run simulation_3D.i It generates the file navier_3D.e