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.

55 lines
2.2 KiB

12 months ago
#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());
}
}