Giter Club home page Giter Club logo

homo3d's Introduction

An Optimized, Easy-to-use, Open-source GPU Solver for Large-scale Inverse Homogenization Problems

This project aims to provide an code framework for efficiently solving the inverse homogenization problems to design microstructure.

dependency

  • OpenVDB
  • CUDA11
  • gflags
  • glm
  • Eigen3

We have packed dependencies into a conda environment (except CUDA and compilers), you can create it by:

conda env create -f environment.yml

Then you activate it by:

conda activate homo3d

Compilation

After the dependency is installed, the code can be compiled using cmake:

mkdir build
cd build
cmake ..
make -j4

If the conda environment is activated, cmake will automatically checkout the dependencies in this environment.

Usage

command line

  • -reso : the resolution of the discretized domain, e.g., -reso 128 defines an $128\times128\times128$ domain. Default value is 128.
  • -obj : the objective to be optimized, options are bulk,shear,npr and custom, which optimizes the bulk modulus, shear modulus, Poisson's ratio and custom objective respectively. Default is bulk
  • -init: the method for initializing the density field, the common and default option is randc, which set the initialization via a set of trigonometric function basis. You can set this option to manual to set the initialization from a OpenVDB file.
  • -sym: symmetry requirement on the structure, only reflect3, reflect6 and rotate3 are supported. Default is reflect6.
  • -vol: volume ratio for material usage ranging from $(0,1)$, default is 0.3
  • -E: Young's modulus of base material. Default is 1e1 (Recommanded, inappropriate value will cause numerical problem due to poor representation range of Fp16. You can rescale the elastic matrix latter).
  • -mu: Poisson's ratio of base material. Default is 0.3
  • -prefix: output path suffixed with /
  • -in: variable input determined by other options, e.g., a OpenVDB file path when the argument of -init is manual.
  • -N: maximal iteration number, default is 300.
  • -relthres: the relative residual tolerance on FEM equation, default is 1e-2. (The master branch may not work well with tolerance smaller than 1e-5. Usually, the default value is enough to produce a satisfactory result).

example

optimizing the bulk modulus :

./homo3d -reso 128 -obj bulk -init randc -sym reflect6 -vol 0.3 -mu 0.3

After the optimization finished, the optimized density field is stored in <prefix>/rho in OpenVDB format.

3rd party softwares like Rhino (with grasshopper plugin Dendro) or Blender may be used to extract the solid part.

The optimized elastic matrix is stored in <prefix>/C in binary format, which is an array of 36 float precision numbers.

custom objective

To optimizing custom objective, option -obj custom should be used and add your objective and optimization routine in Framework.cu file, where we have provide few examples:

void example_opti_bulk(cfg::HomoConfig config) {
    // ...
}
void example_opti_npr(cfg::HomoConfig config) {
    // ...
}
void example_yours(cfg::HomoConfig config) {
	// Add your routines here....
}
void runCustom(cfg::HomoConfig config) {
	//example_opti_bulk(config);
	//example_opti_npr(config);
	example_yours(cfg::HomoConfig config); // uncomment this line
}

Version illustration

If you care more about accuracy rather than performance, please checkout the branch mix-fp64 and uses a smaller tolerance on the relative residual of FEM equation:

./homo3d -reso 128 -vol 0.1 -relthres 1e-6 # set tolerence to 1e-6

Other version (branch) such as mix-fp64fp32 uses a mixed precision scheme and requires less memory.

homo3d's People

Contributors

lavenklau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

homo3d's Issues

无法安装环境

直接输入conda env create -f environment.yaml后显示报错,这大概是因为文件里没有.yaml,但输入conda env create -f environment.yml后还是无法安装,单独安装依赖项时发现openvdb也无法安装

[已解决]在给定OpenVDB文件输入下优化泊松比时代码报错

我正在尝试使用homo3d优化器,把给定模型的泊松比优化到更低水平。我已经使用OpenVDB将分辨率为128的体素文件成功转换为.vdb格式,并在Blender中导入和可视化。该模型的体积分数为5%,在给定基材料下的泊松比为-0.035。

我试图在保证体积分数不变的情况下进行优化。这是我的输入: ./homo3d -reso 128 -obj npr -init manual -vol 0.05 -mu 0.35 -prefix /mnt/d/code/homo3d/dataset -in /mnt/d/code/homo3d/dataset/input.vdb
模型input.txt(上传不了.vdb格式,只好先改成.txt了)如图:

我不确定在保持体积分数为5%不变的情况下是否能成功进行优化。目前在运行代码时出现了一些报错,请问可以帮忙看一下是什么问题吗?或者我应该将初始vdb模型的体积分数调高一些,比如20%或者30%,再优化到5%,这样就能优化模型的泊松比了?

如何保證求解精度

Hi, @lavenklau - 我閱讀了你們的文章,有一個疑惑想要請教您。你們採用了代數多网格算法來計算均質化的等效剛度,但是據我所知amg方法一般用作預處理器,還需要經過cg求解器迭代修正來保證精度,你們的文章沒有提及,不只是如何處理的。萬分感謝!

build isuue

[ 2%] Building CUDA object CMakeFiles/cubin.dir/Framework.cu.o
[ 3%] Building CXX object _deps/openvdb-build/openvdb/openvdb/CMakeFiles/openvdb_static.dir/Grid.cc.o
In file included from /home/jiangyi/11/homo3d-master/homo3d-master/AutoDiff/TensorExpression.h:2:0,
from /home/jiangyi/11/homo3d-master/homo3d-master/AutoDiff/TensorExpression.cu:1:
/home/jiangyi/11/homo3d-master/homo3d-master/AutoDiff/AutoDiff.h:15:10: fatal error: cuda/std/tuple: 没有那个文件或目录
#include <cuda/std/tuple>
^~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/cubin.dir/build.make:63:CMakeFiles/cubin.dir/AutoDiff/TensorExpression.cu.o] 错误 1
make[2]: *** 正在等待未完成的任务....
[ 5%] Building CXX object _deps/openvdb-build/openvdb/openvdb/CMakeFiles/openvdb_shared.dir/Grid.cc.o
[ 5%] Building CXX object _deps/openvdb-build/openvdb/openvdb/CMakeFiles/openvdb_static.dir/io/Archive.cc.o
In file included from /home/jiangyi/11/homo3d-master/homo3d-master/homogenization/homoExpression.h:3:0,
from /home/jiangyi/11/homo3d-master/homo3d-master/homogenization/Framework.cuh:2,
from /home/jiangyi/11/homo3d-master/homo3d-master/Framework.cu:1:
/home/jiangyi/11/homo3d-master/homo3d-master/AutoDiff/AutoDiff.h:15:10: fatal error: cuda/std/tuple: 没有那个文件或目录
#include <cuda/std/tuple>
^~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/cubin.dir/build.make:76:CMakeFiles/cubin.dir/Framework.cu.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:168:CMakeFiles/cubin.dir/all] 错误 2
make[1]: *** 正在等待未完成的任务....
[ 6%] Building CXX object _deps/openvdb-build/openvdb/openvdb/CMakeFiles/openvdb_static.dir/io/Compression.cc.o

优化后模型无法打开

image
在使用基础案例中的./homo3d -reso 128 -obj bulk -init randc -sym reflect6 -vol 0.3 -mu 0.3 -prefix ./modle/
后,没有找到.VDB文件,我无法用blender软件直接对生成的这个模型进行加载,请问该如何使用生成的文件转化为模型文件

关于多重网格法

您好,我想请问在多重网格法中,K^{l+1}=R^{l+1}{l}·K^{l}·I^{l}{l+1}这里面的R矩阵和I矩阵是三线性插值矩阵吗?以及在三维体素中,u和f都是三维的,那么K是一个6维的矩阵,所以请问一下这两个矩阵的具体的shape和数值是怎样的。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.