#include "ConfigMechanicalInterface.h" #include "ConfigThermalInterface.h" int main() { fs_path output_dir(OUTPUT_DIR); fs_path config_file( ASSETS_DIR "/top/config_Lshape.json"); spdlog::info("Algo read from '{}'", config_file.string()); spdlog::info("Algo output to '{}'", output_dir.string()); std::shared_ptr sp_mech_inter = std::make_shared( config_file.string()); std::shared_ptr sp_ther_inter = std::make_shared( config_file.string()); std::string ex_name = sp_mech_inter->ex_name_; spdlog::critical("Thermoelastic TO example: {}", ex_name); // initialize Top3d auto sp_mech_top3d = sp_mech_inter->CreatTop(); auto sp_ther_top3d = sp_ther_inter->CreatTop(); spdlog::critical("start to thermoelastic top opt ..."); // init thermoelastic top3d top::ThermoelasticTop3d mech_ther_top3d(sp_mech_top3d, sp_ther_top3d); // loop top::Tensor3d t_meth_rho = mech_ther_top3d.TopOptMainLoop(); // postprocess { spdlog::critical("extract compliance and volume each iteration ..."); // extract compliance and volume each iteration fs_path compliance_path = output_dir / "txt" / ex_name / (ex_name + "_MeThTop" + "_compliance.txt"); WriteStdVector(compliance_path, mech_ther_top3d.v_compliance_); spdlog::info("write compliance txt to: {}", compliance_path.c_str()); fs_path volume_path = output_dir / "txt" / ex_name / (ex_name + "_MeThTop" + "_volume.txt"); WriteStdVector(volume_path, mech_ther_top3d.v_volume_); spdlog::info("write volume txt to: {}", volume_path.c_str()); // extract final rho (txt and vtk) fs_path rho_txt_path = output_dir / "txt" / ex_name / (ex_name + "_MeThTop" + "_rho.txt"); WriteTensor3d(rho_txt_path, t_meth_rho); spdlog::info("write density txt to: {}", rho_txt_path.c_str()); fs_path rho_vtk_path = output_dir / "vtk" / ex_name / (ex_name + "_MeThTop" + "_rho.vtk"); WriteTensorToVtk(rho_vtk_path, t_meth_rho, sp_mech_inter->sp_mesh_); spdlog::info("write density vtk to: {}", rho_vtk_path.c_str()); } }