You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
5.1 KiB

2 years ago
# Thermo-elastic Topology Optimization
![Screenshot from 2023-07-02 13-57-29.png](docs%2Fimgs%2FScreenshot%20from%202023-07-02%2013-57-29.png)
<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
* [Eigen](https://eigen.tuxfamily.org/): linear algebra
* [libigl](https://github.com/libigl/libigl): basic geometry functions
*
**The following dependencies require user installation**:
* [json](https://github.com/nlohmann/json): parsing input JSON scenes
2 years ago
* [spdlog](https://github.com/gabime/spdlog): logging information
* OpenMP: CPU parallel processing.
2 years ago
```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):
2 years ago
1. install SuiteSparse.
2 years ago
2. Set `ENABLE_AMGCL` to `OFF` and set `ENABLE_SUITESPARSE` to `ON` in
2 years ago
[CMakeLists.txt](CMakeLists.txt).
2 years ago
Otherwise, it is recommended to choose an iterative solver (e.g. AMGCL),in CPU:
2 years ago
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).
2 years ago
Further, CUDA can be used to speed up the iterative solver:
2 years ago
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).
2 years ago
2 years ago
Finally, if all options are set to `OFF`, then the Eigen build-in iterative solver will be chosen.(not recommended).
2 years ago
## Build
1. set path in
[CMakeLists.txt](CMakeLists.txt).
```cmake
set(CMAKE_CUDA_COMPILER "/path/to/nvcc") # set path to nvcc
```
2.
2 years ago
```bash
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j 16
2 years ago
```
## Usage
1 year ago
### 3/28 update
1. Use `example/top-thermolastic-compare-3d` to run mechanical(Me)/mechanical thermal(MeTh) topology optimization(Top) and simulation(Sim).
The procedure run in following order:
1. Me Top & MeTh Top -> density(*_MeTop_rho.vtk & *_MethTop_rho.vtk) and compliance/volume each iteration(*_MeTop_compliance.txt *_MeTop_volume.txt & ...)
2. clamp density by different threshold(.XX) -> 0/1 density(*_MeSim_threshXX_rho.vtk & *_MeThSim_threshXX_rho.vtk)
3. MeTh Sim -> temperature(*_T.vtk), displacement(*_U.vtk), Von Mise Stress(*_von_stress.vtk).
Note: open .vtk via Paraview software.
2. Input
1. Set parameters in *.json. see comments in `example/top-thermoelastic-*.json`(see comments in `examples/top-thermoelastic-BiclampedStructure/config.json` and ref paper for MeTh parameters; see comments in `examples/top-thermoelastic-compare-3d/config_beam.json`)
2. Redirect in `main.cpp` or `main.cu` if ENABLE_AMGCL_CUDA is ON:
```c++
top::fs_path config_file(
CMAKE_SOURCE_DIR "/examples/top-thermoelastic-compare-3d/${your_config_file}.json");
```
3. For irregular voxel model(e.g. Lshape), you can define the initial density in `main.cpp` or `main.cu`:
```c++
// NOTE: USER DEFINE GRID HERE!!!
std::shared_ptr<top::Mesh> sp_mech_mesh;
std::shared_ptr<top::HeatMesh> sp_thermal_mesh;
if (ex_name=="Lshape") {
// L-shape condition
spdlog::critical("Using User Defined density!");
top::Tensor3d L_shape_model(len_x, len_y, len_z);
L_shape_model.setConstant(1);
// set the initial voxel model
for (int k = 0; k < len_z; ++k) {
for (int j = 0; j < len_y; ++j) {
for (int i = 0; i < len_x; ++i) {
if (j > len_y* 0.6 & k >len_z * 0.5) {
L_shape_model(i, j, k) = 0;
}
}
}
}
//...
}
```
3. Output see `output/txt/${example_name}/${example_name}_*` and `output/vtk/${example_name}/${example_name}_*`.
---
2 years ago
1. See `example/top-thermoelastic-BiclampedStructure` or `examples/top-thermoelastic-Lshape-condition`.
2 years ago
NOTE:
1. `"//*"` in `examples/*/config.json` file mean comments.
2. you can modify `CONFIG_FILE`, `OUTPUT_DIR` and `ASSETS_DIR` in `examples/*/CMAKEList.txt`.
2 years ago
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`.
1 year ago
4. you should modify example content in `*.cpp` rather than `*.cu`, the latter is copied from the former by cmake.