17 changed files with 271 additions and 275 deletions
@ -0,0 +1,16 @@ |
|||
set(SUB_PROJECT_NAME sim_mechanical) |
|||
if (ENABLE_AMGCL_CUDA) |
|||
# cp main.cpp to main.cu |
|||
configure_file( |
|||
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp |
|||
${CMAKE_CURRENT_SOURCE_DIR}/main.cu |
|||
COPYONLY |
|||
) |
|||
add_executable(${SUB_PROJECT_NAME} main.cu) |
|||
# # OpenMP Required! |
|||
target_compile_options(${SUB_PROJECT_NAME} PRIVATE -Xcompiler -fopenmp) |
|||
target_link_libraries(${SUB_PROJECT_NAME} PUBLIC ${PROJECT_NAME}_cuda_lib) |
|||
else () |
|||
add_executable(${SUB_PROJECT_NAME} main.cpp) |
|||
target_link_libraries(${SUB_PROJECT_NAME} ${PROJECT_NAME}_lib) |
|||
endif () |
@ -0,0 +1,55 @@ |
|||
#include "ConfigMechanicalInterface.h" |
|||
#include "ConfigThermalInterface.h" |
|||
|
|||
int main() { |
|||
// INPUT ARGS
|
|||
fs_path config_file(ASSETS_DIR "/top/config_Lshape.json"); |
|||
fs_path model_file( |
|||
ASSETS_DIR "/voxel_model/Clamped_Lshape_model_thresh35.txt"); |
|||
// END INPUT
|
|||
|
|||
std::string model_name = model_file.filename().replace_extension(); |
|||
Tensor3d tr_model = ReadTensor3d(model_file); |
|||
fs_path output_dir(OUTPUT_DIR); |
|||
spdlog::info("Read config from '{}'", config_file.string()); |
|||
spdlog::info("Read model from '{}'", model_file.string()); |
|||
spdlog::info("Output to '{}'", output_dir.string()); |
|||
|
|||
// Config interface
|
|||
std::shared_ptr<ConfigMechanicalInterface> sp_mech_inter = std::make_shared<ConfigMechanicalInterface>( |
|||
config_file, tr_model); |
|||
std::string ex_name = sp_mech_inter->ex_name_; |
|||
spdlog::critical("Mechancial SIM example: {}, model: {}", ex_name,model_name); |
|||
|
|||
// initialize Top3d
|
|||
auto sp_mech_top3d = sp_mech_inter->CreatTop(); |
|||
|
|||
spdlog::critical("start to mechanical simulation ..."); |
|||
// loop
|
|||
sp_mech_top3d->TopOptMainLoop(true); |
|||
// postprocess
|
|||
{ |
|||
// extract displacement (vtk)
|
|||
fs_path U_vtk_path = |
|||
output_dir / "vtk" / ex_name / model_name / |
|||
"Me_displacement.vtk"; |
|||
WriteNodeToVtk(U_vtk_path, sp_mech_top3d->GetNormedDisplacement(), |
|||
tr_model); |
|||
spdlog::info("write displacement norm vtk to: {}", U_vtk_path.string()); |
|||
|
|||
// extract stress field (vtk)
|
|||
fs_path von_stress_vtk_path = |
|||
output_dir / "vtk" / ex_name / model_name / |
|||
"Me_Von_Mises_stress.vtk"; |
|||
WriteNodeToVtk(von_stress_vtk_path, sp_mech_top3d->GetVonStress(), |
|||
tr_model); |
|||
spdlog::info("write von stress vtk to: {}", |
|||
von_stress_vtk_path.string()); |
|||
|
|||
// extract compliance of the model (txt)
|
|||
fs_path compliance_path = |
|||
output_dir / "txt" / ex_name / model_name / "Me_compliance.txt"; |
|||
WriteStdVector(compliance_path, sp_mech_top3d->v_compliance_); |
|||
spdlog::info("write compliance txt to: {}", compliance_path.string()); |
|||
} |
|||
} |
@ -1,67 +0,0 @@ |
|||
{ |
|||
"TopologyOptimizationExample": "Lshape","//": "user defined project name", |
|||
"material": { |
|||
"E": 2.1e11, |
|||
"poisson_ratio": 0.3, |
|||
"thermal_conductivity":43, "//unit": "W/(m*K)", |
|||
"thermal_expansion_coefficient": 1.21e-5, "//unit": "1/K" |
|||
}, |
|||
"topology": { |
|||
"max_loop": 100, |
|||
"volfrac": 0.5, |
|||
"penal": 3.0, |
|||
"r_min": 1.05, |
|||
"T_ref": 312, |
|||
"T_limit": 3996.52, |
|||
"R_E": 28, |
|||
"R_lambda": 28, |
|||
"R_beta":0 |
|||
}, |
|||
"model": { |
|||
"regular_model": { |
|||
"lx":1, |
|||
"ly": 30, |
|||
"lz": 20 |
|||
} |
|||
}, |
|||
"mechanical_boundary_condition":{ |
|||
"NBC": [ |
|||
{ |
|||
"min": [0, 1, 0], |
|||
"max": [1, 1, 0], |
|||
"val": [0.0,0.0 , -1e8] |
|||
} |
|||
|
|||
], |
|||
"DBC": [ |
|||
{ |
|||
"min": [0, 0, 1], |
|||
"max": [1, 0.5, 1], |
|||
"dir": [1, 1, 1] |
|||
} |
|||
|
|||
] |
|||
}, |
|||
"thermal_boundary_condition": { |
|||
"NBC": [ |
|||
{ |
|||
"min": [0.5, 0.2, 0.2], |
|||
"max": [0.5, 0.2, 0.2], |
|||
"heat_flux": 3.5, "//unit": "W" |
|||
}, |
|||
{ |
|||
"min": [0.5, 0.8, 0.2], |
|||
"max": [0.5, 0.8, 0.2], |
|||
"heat_flux": 3.5, "//unit": "W" |
|||
} |
|||
|
|||
], |
|||
"DBC": [ |
|||
{ |
|||
"min": [0, 0, 1], |
|||
"max": [1, 0.5, 1], |
|||
"temperature": 312, "//unit": "K" |
|||
} |
|||
] |
|||
} |
|||
} |
@ -1,67 +0,0 @@ |
|||
{ |
|||
"TopologyOptimizationExample": "beam","//": "user defined project name", |
|||
"material": { |
|||
"E": 2.1e11, |
|||
"poisson_ratio": 0.3, |
|||
"thermal_conductivity":43, "//unit": "W/(m*K)", |
|||
"thermal_expansion_coefficient": 1.21e-5, "//unit": "1/K" |
|||
}, |
|||
"topology": { |
|||
"max_loop":20, |
|||
"volfrac": 0.5, |
|||
"penal": 3.0, "//": "1-6, only work for Mechanical Top Opt, the higher the value, the density tends to be 0/1", |
|||
"r_min": 1.2, |
|||
"T_ref": 312, |
|||
"T_limit": 3996.52, |
|||
"R_E": 28, |
|||
"R_lambda": 28, |
|||
"R_beta":0 |
|||
}, |
|||
"model": { |
|||
"regular_model": { |
|||
"lx": 1, |
|||
"ly": 30, |
|||
"lz": 10 |
|||
} |
|||
}, |
|||
"mechanical_boundary_condition":{ |
|||
"DBC": [ |
|||
{ |
|||
"min": [0, 0, 0], |
|||
"max": [1, 0, 1], |
|||
"dir": [1, 1, 1] |
|||
} |
|||
|
|||
], |
|||
"NBC": [ |
|||
{ |
|||
"min": [0, 1, 0], |
|||
"max": [1, 1, 0], |
|||
"val": [0.0,0.0 , -1e8] |
|||
} |
|||
|
|||
] |
|||
}, |
|||
"thermal_boundary_condition": { |
|||
"NBC": [ |
|||
{ |
|||
"min": [0.5, 0.2, 0.2], |
|||
"max": [0.5, 0.2, 0.2], |
|||
"heat_flux": 3.5, "//unit": "W" |
|||
}, |
|||
{ |
|||
"min": [0.5, 0.8, 0.2], |
|||
"max": [0.5, 0.8, 0.2], |
|||
"heat_flux": 3.5, "//unit": "W" |
|||
} |
|||
|
|||
], |
|||
"DBC": [ |
|||
{ |
|||
"min": [0, 0, 1], |
|||
"max": [1, 0.5, 1], |
|||
"temperature": 312, "//unit": "K" |
|||
} |
|||
] |
|||
} |
|||
} |
Loading…
Reference in new issue