An open API service indexing awesome lists of open source software.

https://github.com/insigneo/microfe


https://github.com/insigneo/microfe

finite-elements mesh-generation

Last synced: 11 months ago
JSON representation

Awesome Lists containing this project

README

          

# microFE

[![TUoS](https://img.shields.io/badge/-The%20University%20of%20Sheffield-blue.svg?colorA=ffffff&colorB=009fe3&logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAABsFBMVEUAAABmZplVVYBLPHheUYZJPXlSR3pCOnNgWIdoYI9FPnVMQXc0JGM0KmhEOXI0MW8xMW2Ph6yYkrOWj6%2BOiayinLqWkbIcWJkdWJezrsW2sciclrWmoL0cWpkbXJuCfqQVba4Vba2tqsKBgKWXkbGgm7ioo7%2Bln7umobyppcClob0RdrgSd7ikoLuXkbEeeKwieqmYkrKkn7sAneAAn%2BMBnN8Dn%2BIEj9IEkNQEoOMFi88GicwHnuAInuAVaqkVgrEWa6sWiskYj84ek88mk8wmqOInqOIqhrA4qd45qd87kaA8q988q%2BA9qN0%2Fk51Aqd1CqdxCqd1JnqtNnc9OnKVPnItSmsZUmqZVlsFVnYZVns1bst9ds99ftN9isNtitN9joa1msdtnveZqoaRqrNZqvuZsrdZvk2lylWR0nKZ2oJx%2BfKOBf6WEn5eGr3iIr3eduNWfmbifmrifudWim6mjnKmloLymrz2psTuuqb6uqsOwq8C0taG2tqS4tqy4tra6uTC6ui6%2FsCK%2FsCPBvdHDv9LFwtfGwtjOy9rPzdvUlaHmkpb%2B%2FPz%2B%2Fv7%2F%2FPz%2F%2F%2F9OZpcfAAAAM3RSTlMABQYRExUZHyAgJS8xMTFTVFleZmiJkpOTmp2oqba9wsTFxcfO0dPX3OLj5%2Bf19v39%2Fv4kncL4AAAAvElEQVR4AWNgYBIQV9Q20NdRkOBnZGBg4DExTQ9taIzMMDbhA3PdzMqbmyosXaHc4kCvvHy%2FgAIINzElvL%2B%2FvzcoLQ7E5bX1TOhq624P8bDhBnLZTEwye%2Fr7%2BpNNTFgYgMApJreuprY%2BK94RyOGSlEv19XZx9vFPkpViZ1BRZ7WKdq%2Bsto%2B1ZtZQYhAp1FS2iCopDTaX1yoSZmDgkNHrsAuLcOjUleZkAAGxqtbsnJYyUQYoEFIzMlQVBLEA%2FZgsl9iPrB4AAAAASUVORK5CYII%3D)](https://www.sheffield.ac.uk)
[![INSIGNEO](https://img.shields.io/badge/-INSIGNEO-red.svg?colorA=ffffff&colorB=cf2020&logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAABC1BMVEUAAAD%2FAAC%2FAADMGhrRFxfSHh7VHBzJGxvTISHKICDMHx%2FOHR3RJCTTIyPOISHPICDMHR3NIyPNICDRISHQHx%2FQHx%2FOHx%2FQISHOICDQICDQHx%2FOHx%2FPISHQISHQICDOICDQISHOICDQICDPISHPICDQISHPICDPICDOHx%2FPISHPISHQISHPICDPISHPISHQICDOICDOICDPHx%2FPICDPICDOICDPICDPICDPICDPHx%2FPICDPICDQICDPICDPHx%2FQISHOICDPICDPICDPICDPICDPHx%2FMISHOICDPICDQICDPICDPISHPHx%2FPICDPICDPICDPICDPICDPICDOICDPHx%2FPICDPICDPICDPICDi8V76AAAAWHRSTlMAAgQKCxESExcYGRocHR8gIyRITVFSU1ZYYWJjZGZnaWxucXV5fH%2BAg4SFjI%2BUlZeYqKuusbK2ubrDxcbHycvMzdHU2Nrb4uLl5%2Bnq6%2Bzt7u%2F09vf7%2FP3%2B%2FHERCQAAAKVJREFUeAEdx%2BVCg2AAhtHHAANDMQRD7ECwO7DDjViM7b3%2FK9n4zr9Dxdk6jjc4s02si46kK7tMLGDuW%2Fq%2FvdxZlt5shh7VWhsGTqWvTVYll0q4PjMyy7VuYHQ7nIL98oVMAey183sI9EtNPpzXfz7BV8aHIpi%2Fe3ch1iuHysYxnFxHTDf1bD7xpMKBxa6Kk6WVKFXPY8BLZTQWMMYOHvK%2FZHcS6AOapR0V%2FpSSVQAAAABJRU5ErkJggg%3D%3D)](https://insigneo.org/)
[![CompBioMed](https://img.shields.io/badge/-CompBioMed-yellow.svg?colorA=grey&colorB=f4b540&logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAAoAAAAQCAMAAAAYoR5yAAAA81BMVEUAAAD%2F%2F%2F%2Bqqqr%2F%2F8z%2FzLP%2FyKT%2F1ar%2F4KP%2F9dj%2F5L%2Fm1bP%2F3bv%2Fx4Dw4eHbzJn%2F26%2F52Zn%2FzobQypT%2F6LveyLH%2FyID63d3%2F05P%2Fx3nt19fZzbT%2Fv2Dx0sHk0NDPtX7%2Fxln207D53abEr3f8vFjx1Jz%2FxWP%2FvmL%2FwWT%2Fw0f8vk7t0aj12aLBsnzz0qbTvZritmTAq3vWtF6%2FrIHHr4rJsor6vGPYu3vCsIft17rewJLCq3nw267KtYn%2Fv1vKtJL%2FvFPzz5v547H536P9uE%2FLrG7LsnHGsHbyvmXexIzWq130qkP3y3%2F8tUr3yYD6s0T8sz78tETsoiaWAAAAUXRSTlMAAgMFCg4YGRocHh4gIiMjKCorLS4uNDQ3OT1ISkxPUFFTVldYXV5eYWJkZWdnaGlqamttbW9wcXN1dnh5e35%2Bf3%2BAgYSFio6Sl5ydn6GkqK2fR9KlAAAAd0lEQVQI1zXGRQKCABRAwWdhY3d3t9iJ3d7%2FNC74zmo4H%2FH4AGBxoWIzetKUnDFu321c2vtUrdLx0y5j8oj9u3sPzFL9Ps9K86%2FmSho5FK77sgmglGKamLUA6gH6rkzHDzTcBDfe6BJYO6A4DKdDFmpOQG2PuskfKZ4MqTH%2F64gAAAAASUVORK5CYII%3D)](http://www.compbiomed.eu/)

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

## Installation (ShARC)

Log in and create conda environment

```bash
$ qrshx
$ module load apps/python/conda
$ cd /microFE/
$ conda env create -f environment.yml
```

Compile matlab code as

```bash
$ cd m_files/
$ module load apps/matlab/R2016a
$ ./compile.sh
```

In case you want to run the workflow in Windows, compile `m_files/main_win.m` file.

## Usage

The entire pipeline is run by

```bash
$ python microFE.py -c config.ini
```

where `config.ini` is a generic configuration file. Meshing and FE solver are run by submitting a batch job. See `microFE.sh` for an example file which you can run as `qsub microFE.sh` in ShARC. All the parameters are specified in the `.ini` configuration file.

### Configuration file

The meshing process requires the definition of a number of paths and variables. These are defined in a `.ini` configuration file

```
[directories]
CT_IMAGE_FOLDER =
OUTPUT_DIR =
MESHER_SRC =
LD_LIB_PATH =

[images]
img_name =

[mesher]
threshold =
resolution =

[fem]
boundary_condition = <`displacement` or `load`>
units = <`mm` or `percent` for `displacement`, `N` for `load`>
direction = <`x`, `y`, or `z`>
sign = <`positive` or `negative`>
amount =
constrain = <`full` or `free`>
E =
yield_stress =
Et =

[job]
name =
np =
```
The element used in ANSYS APDL is the 8-nodes [SOLID185](https://www.sharcnet.ca/Software/Ansys/16.2.3/en-us/help/ans_elem/Hlp_E_SOLID185.html)

By specifying only the Young's modulus `E`, the analysis will be [linear elastic](https://www.sharcnet.ca/Software/Ansys/16.2.3/en-us/help/ans_mat/ann8sq39eldm.html#ELlinmatstressstrain), whereas including also `yield_stress` and `Et` (the tangent Young's modulus) the analysis will be [elastic-perfectly-plastic](https://www.sharcnet.ca/Software/Ansys/16.2.3/en-us/help/ans_mat/amp8sq21dldm.html#miso).

## Matlab mesher

In `m_files\` there is the code for generating FE models with cartesian mesh and homogeneous material properties. The original mesher code is in `/m_files/mesher.m`.

The following inputs are required:

- greyscale images (`.tiff` format);
- voxel size (`Image_Resolution`);
- threshold for defining bone tissue;

The `m_files/main.m` file executes the mesher.

The script in `m_files/compile.sh` compiles the matlab scripts with the matlab compiler. Compiled files can be run with the matlab runtime environment.

## Outputs

After executing microFE.py, the results will be saved in `OUTPUT_DIR/` folder as specified in the `.ini` configuration file. The folder structure will be

```
/
|- elementdata.txt (mesh elements list)
|- nodedata.txt (mesh nodes list)
|- fe_model.txt (Ansys model script)
|- microFE.py.log (log file)
|- Binary/ (Binary slices from microCT image)
| |- binary0001.tif
| |- binary0002.tif
| |- ...
|- tiff/ (microCT slices converted to tiff from DICOM)
| |- _0001.tif
| |- _0002.tif
| |- ...
|- NodalDisplacements.txt (nodal displacement from FEM solution as: node, x, y, z)
|- .db (Ansys output files)
|- .err
|- .esav
|- .log
|- .mntr
|- .PCS
|- .rst
|- .stat
```

## Citation

The Matlab code was developed by Y. Chen as part of his PhD project:

- _Chen Y, Pani M, Taddei F, Mazzà C, Li X, Viceconti M. [Large-scale finite element analysis of human cancellous bone tissue micro computer tomography data: a convergence study](http://biomechanical.asmedigitalcollection.asme.org/article.aspx?articleid=1892759). Journal of biomechanical engineering. 2014 Oct 1;136(10):101013._

- _Chen Y, Dall'Ara E, Sales E, Manda K, Wallace R, Pankaj P, Viceconti M. [Micro-CT based finite element models of cancellous bone predict accurately displacement once the boundary condition is well replicated: A validation study](http://www.sciencedirect.com/science/article/pii/S1751616116303204). Journal of the mechanical behavior of biomedical materials. 2017 Jan 31;65:644-51._