# Thermo-elastic Topology Optimization

< b > (Optional) temperature limits, optimization of voxel mesh. < / b >
This is the implementation of the paper [Thermo-elastic topology optimization with stress
and temperature constraints.](ref%2FThermo-elastic%20topology%20optimization%20with%20stress%0Aand%20temperature%20constraints.pdf)
## Files
* `3rd/` : third-party library
* `assets/` : user-defined assets
* `examples/` : several teaching examples
* `output/` : output directory
* `ref/` : reference material
* `src/` : source code
* `cmake/` : CMake files
## Dependencies
**A inside library**:
* [mma ](3rd%2Fmma ): constrained optimization algorithm
**Most dependancies are downloaded through CMake**:
* [Eigen ](https://eigen.tuxfamily.org/ ): linear algebra
* [json ](https://github.com/nlohmann/json ): parsing input JSON scenes
* [libigl ](https://github.com/libigl/libigl ): basic geometry functions
* [spdlog ](https://github.com/gabime/spdlog ): logging information
**The remaining libraries require user installation**:
* OpenMP: CPU parallel processing. Optional
```bash
sudo apt install libomp-dev
```
* [SuiteSparse ](https://github.com/DrTimothyAldenDavis/SuiteSparse ): Linear solver. Optional, NOTE: Use of the Intel MKL BLAS is strongly recommended.
* [boost ](https://github.com/boostorg/boost ): Use filesystem
* [AMGCL ](https://github.com/ddemidov/amgcl ): Linear solver. Optional.
* [CUDA Toolkit ](https://developer.nvidia.com/cuda-toolkit ): CUDA support. Optional.
**Select a Linear solver**
If your matrix has less than **50w** of freedom, then it is recommended to choose a direct solver (e.g. SuiteSparse):
1. install SuiteSparse.
2. Set `ENABLE_AMGCL` to `OFF` and set `ENABLE_SUITESPARSE` to `ON` in
[CMakeLists.txt ](CMakeLists.txt ).
Otherwise, it is recommended to choose an iterative solver (e.g. AMGCL),in CPU:
1. install OpenMP and AMGCL.
2. Set `ENABLE_AMGCL` to `ON` , `ENABLE_AMGCL_CUDA` to `OFF` and `ENABLE_SUITESPARSE` to `OFF` in [CMakeLists.txt ](CMakeLists.txt ).
Further, CUDA can be used to speed up the iterative solver:
1. install OpenMP, CUDA Toolkit and AMGCL.
2. Set `ENABLE_AMGCL` to `ON` , `ENABLE_AMGCL_CUDA` to `ON` and `ENABLE_SUITESPARSE` to `OFF` in [CMakeLists.txt ](CMakeLists.txt ).
Finally, if all options are set to `OFF` , then the Eigen build-in iterative solver will be chosen.(not recommended).
## Build
```bash
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j4
```
## Usage
1. See `example/top-thermoelastic-BiclampedStructure` or `examples/top-thermoelastic-Lshape-condition` .
2. If CUDA version is selected, see `examples/top-thermoelastic-BiclampedStructure-cuda` as a template.
NOTE:
1. `"//*"` in `examples/*/config.json` file mean comments.
2. you can modify `CONFIG_FILE` , `OUTPUT_DIR` and `ASSETS_DIR` in `examples/*/CMAKEList.txt` .
3. you can modify the linear solver arguments `prm.solver.tol` and `prm.solver.maxiter` in `src/LinearSolver/Amgcl.h` or `src/LinearSolver/AmgclCuda.h` .