From a9d86c5b193cfdba54d5a069c052e53d99bf26ed Mon Sep 17 00:00:00 2001 From: littlemine Date: Wed, 13 Oct 2021 15:49:30 +0800 Subject: [PATCH] supplement femmesh init --- projects/gmpm/fem/Fiber.cpp | 58 +++++++++++++++++++++++++++++++++++++ projects/gmpm/zecomp | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/projects/gmpm/fem/Fiber.cpp b/projects/gmpm/fem/Fiber.cpp index 1e5bde9156..edb34d138f 100644 --- a/projects/gmpm/fem/Fiber.cpp +++ b/projects/gmpm/fem/Fiber.cpp @@ -1,4 +1,5 @@ #include "../ZensimMesh.h" +#include "zensim/omp/execution/ExecutionPolicy.hpp" #include #include #include @@ -108,4 +109,61 @@ ZENDEFNODE(AddMuscleFibers, { {"FEM"}, }); +// _elmWeight +struct SetUniformMuscleAnisotropicWeight : zeno::INode { + virtual void apply() override { + auto mesh = get_input("inputMesh"); + auto uni_weight = + get_input("weight")->get(); + using vec3 = typename ZenoFEMMesh::vec3; + zs::omp_exec()(zs::range(mesh->_mesh->quads.size()), [&](size_t i) { + mesh->_elmWeight[i] = vec3{uni_weight[0], uni_weight[1], uni_weight[2]}; + }); + // for (size_t i = 0; i != mesh->_mesh->quads.size(); ++i) + // mesh->_elmWeight[i] << uni_weight[0], uni_weight[1], uni_weight[2]; + set_output("aniMesh", mesh); + } +}; + +ZENDEFNODE(SetUniformMuscleAnisotropicWeight, { + {{"inputMesh"}, {"weight"}}, + {"aniMesh"}, + {}, + {"FEM"}, + }); + +// _elmAct +struct SetUniformActivation : zeno::INode { + virtual void apply() override { + auto mesh = get_input("inputMesh"); + auto uniform_Act = + get_input("uniform_act")->get(); + + using mat3 = typename ZenoFEMMesh::mat3; + using vec3 = typename ZenoFEMMesh::vec3; + zs::omp_exec()(zs::range(mesh->_mesh->quads.size()), [&](size_t i) { + mat3 fdir = mesh->_elmOrient[i]; + vec3 act_vec{uniform_Act[0], uniform_Act[1], uniform_Act[2]}; + mesh->_elmAct[i] = mul(diag_mul(fdir, act_vec), fdir.transpose()); + }); +#if 0 + for (size_t i = 0; i < mesh->_mesh->quads.size(); ++i) { + Mat3x3d fdir = mesh->_elmOrient[i]; + Vec3d act_vec; + act_vec << uniform_Act[0], uniform_Act[1], uniform_Act[2]; + mesh->_elmAct[i] << fdir * act_vec.asDiagonal() * fdir.transpose(); + } +#endif + + set_output("actMesh", mesh); + } +}; + +ZENDEFNODE(SetUniformActivation, { + {{"inputMesh"}, {"uniform_act"}}, + {"actMesh"}, + {}, + {"FEM"}, + }); + } // namespace zeno \ No newline at end of file diff --git a/projects/gmpm/zecomp b/projects/gmpm/zecomp index 3c3f8c34f1..4ddee62f72 160000 --- a/projects/gmpm/zecomp +++ b/projects/gmpm/zecomp @@ -1 +1 @@ -Subproject commit 3c3f8c34f1c469616b1652f89f93d835195c6f70 +Subproject commit 4ddee62f72ec5018066268ad68849447fbf175e1