27 level_set::level_set(
const mesh &msh, dim_type deg,
30 with_secondary(with_secondary_) {
31 shift_ls = scalar_type(0);
32 primary_.resize(mf->nb_dof());
33 if (has_secondary()) secondary_.resize(mf->nb_dof());
37 void level_set::copy_from(
const level_set &ls) {
40 primary_ = ls.primary_;
41 secondary_ = ls.secondary_;
42 with_secondary = ls.with_secondary;
43 shift_ls = ls.shift_ls;
48 level_set::level_set(
const level_set &ls) : context_dependencies() {
52 level_set &level_set::operator =(
const level_set &ls) {
53 this->sup_dependency(*mf);
58 level_set::~level_set() { }
60 void level_set::reinit(
void) {
61 primary_.resize(mf->nb_dof());
62 if (has_secondary()) secondary_.resize(mf->nb_dof());
66 pmesher_signed_distance level_set::mls_of_convex(
size_type cv,
unsigned lsnum,
67 bool inverted)
const {
68 assert(
this); assert(mf);
69 GMM_ASSERT1(mf->linked_mesh().convex_index().is_in(cv),
"convex " << cv
70 <<
" is not in the level set mesh!");
71 GMM_ASSERT1(mf->fem_of_element(cv),
"Internal error");
72 GMM_ASSERT1(!mf->is_reduced(),
"Internal error");
73 std::vector<scalar_type> coeff(mf->nb_basic_dof_of_element(cv));
74 GMM_ASSERT1(values(lsnum).size() == mf->nb_dof(),
75 "Inconsistent state in the levelset: nb_dof=" <<
76 mf->nb_dof() <<
", values(" << lsnum <<
").size=" <<
77 values(lsnum).size());
78 for (
size_type i = 0; i < coeff.size(); ++i)
79 coeff[i] = (!inverted ? scalar_type(1) : scalar_type(-1)) *
80 values(lsnum)[mf->ind_basic_dof_of_element(cv)[i]];
81 return new_mesher_level_set(mf->fem_of_element(cv), coeff, shift_ls);
85 return sizeof(*this) +
86 primary_.capacity() *
sizeof(scalar_type) +
87 secondary_.capacity() *
sizeof(scalar_type);
90 void level_set::simplify(scalar_type eps) {
91 for (dal::bv_visitor cv(mf->linked_mesh().convex_index());
92 !cv.finished(); ++cv) {
93 scalar_type h = mf->linked_mesh().convex_radius_estimate(cv);
94 for (
size_type i = 0; i < mf->nb_basic_dof_of_element(cv); ++i) {
95 size_type dof = mf->ind_basic_dof_of_element(cv)[i];
96 if (gmm::abs(primary_[dof]) < h*eps) {
97 primary_[dof] = scalar_type(0);
100 if (has_secondary() && gmm::abs(secondary_[dof]) < h*eps)
101 secondary_[dof] = scalar_type(0);
109 struct dummy_level_set_ {
111 dummy_level_set_() : ls(dummy_mesh()) {}
114 const level_set &dummy_level_set()