Skip to content

Commit

Permalink
supplement femmesh init
Browse files Browse the repository at this point in the history
  • Loading branch information
littlemine committed Oct 13, 2021
1 parent 7a88b74 commit a9d86c5
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
58 changes: 58 additions & 0 deletions projects/gmpm/fem/Fiber.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "../ZensimMesh.h"
#include "zensim/omp/execution/ExecutionPolicy.hpp"
#include <zeno/ListObject.h>
#include <zeno/NumericObject.h>
#include <zeno/PrimitiveObject.h>
Expand Down Expand Up @@ -108,4 +109,61 @@ ZENDEFNODE(AddMuscleFibers, {
{"FEM"},
});

// _elmWeight
struct SetUniformMuscleAnisotropicWeight : zeno::INode {
virtual void apply() override {
auto mesh = get_input<ZenoFEMMesh>("inputMesh");
auto uni_weight =
get_input<zeno::NumericObject>("weight")->get<zeno::vec3f>();
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<ZenoFEMMesh>("inputMesh");
auto uniform_Act =
get_input<zeno::NumericObject>("uniform_act")->get<zeno::vec3f>();

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
2 changes: 1 addition & 1 deletion projects/gmpm/zecomp

0 comments on commit a9d86c5

Please sign in to comment.