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.

69 lines
2.9 KiB

#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::shared_ptr<ConfigThermalInterface> sp_ther_inter = std::make_shared<ConfigThermalInterface>(
config_file, tr_model);
std::string ex_name = sp_mech_inter->ex_name_;
spdlog::critical("Thermoelastic SIM example: {}, model: {}", ex_name,model_name);
// initialize Top3d
auto sp_mech_top3d = sp_mech_inter->CreatTop();
auto sp_ther_top3d = sp_ther_inter->CreatTop();
spdlog::critical("start to thermoelastic simulation ...");
// init thermoelastic top3d
auto sp_MeTh_top3d = std::make_shared<ThermoelasticTop3d>(sp_mech_top3d,
sp_ther_top3d);
// loop
sp_MeTh_top3d->TopOptMainLoop(true);
// postprocess
{
// extract temperature (vtk)
fs_path T_vtk_path =
output_dir / "vtk" / ex_name / model_name /
"MeTh_temperature.vtk";
WriteNodeToVtk(T_vtk_path, sp_MeTh_top3d->GetTemperature(),
tr_model);
spdlog::info("write temperature vtk to: {}", T_vtk_path.string());
// extract displacement (vtk)
fs_path U_vtk_path =
output_dir / "vtk" / ex_name / model_name /
"MeTh_displacement.vtk";
WriteNodeToVtk(U_vtk_path, sp_MeTh_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 /
"MeTh_Von_Mises_stress.vtk";
WriteNodeToVtk(von_stress_vtk_path, sp_MeTh_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 / "MeTh_compliance.txt";
WriteStdVector(compliance_path, sp_MeTh_top3d->v_compliance_);
spdlog::info("write compliance txt to: {}", compliance_path.string());
}
}