28 void fem_level_set::init() {
29 cvr = bfem->ref_convex(0);
30 dim_ = cvr->structure()->dim();
31 is_equiv =
true; real_element_defined =
true;
32 is_polycomp = is_pol = is_lag = is_standard_fem =
false;
34 ntarget_dim = bfem->target_dim();
37 nm <<
"FEM_LEVEL_SET(" << bfem->debug_name() <<
")";
38 debug_name_ = nm.str();
46 for (
size_type k=0; k < bfem->nb_dof(0); ++k) {
47 const mesh_level_set::zoneset *ze = dofzones[k];
49 for (mesh_level_set::zoneset::const_iterator itz = ze->begin();
50 itz != ze->end(); ++itz) {
51 const mesh_level_set::zone *z = *itz;
52 for (mesh_level_set::zone::const_iterator it = z->begin();
53 it != z->end(); ++it) {
57 else if (c != d) { ls_index.add(i);
break; }
62 common_ls_zones[i] = c;
66 for (
size_type k = 0; k < bfem->nb_dof(0); ++k) {
68 add_node(bfem->dof_types()[k], bfem->node_of_dof(0,k));
70 for (
size_type j = 0; j < dofzones[k]->size(); ++j) {
73 bfem->node_of_dof(0,k));
80 { GMM_ASSERT1(
false,
"No base values, real only element."); }
83 { GMM_ASSERT1(
false,
"No base values, real only element."); }
86 { GMM_ASSERT1(
false,
"No base values, real only element."); }
88 static bool are_zones_compatible_(
const std::string a,
const std::string b) {
89 if (a.size() != b.size())
return false;
91 if (a[i] !=
'0' && a[i] != b[i])
return false;
95 void fem_level_set::find_zone_id(
const fem_interpolation_context &c,
96 std::vector<bool> &ids,
int side)
const {
98 for (
size_type i = 0; i < dofzones.size(); ++i)
99 if (dofzones[i]) s += dofzones[i]->size();
100 ids.resize(0); ids.resize(s,
false);
101 std::string z(common_ls_zones);
102 base_vector coeff(32);
104 mesher_level_set eval;
106 for (dal::bv_visitor i(ls_index); !i.finished(); ++i) {
107 const level_set *ls = mls.get_level_set(i);
108 const mesh_fem &mf = ls->get_mesh_fem();
110 eval.init_base(mf.fem_of_element(cv), coeff);
111 eval.set_shift(ls->get_shift());
115 scalar_type v = eval(c.xref());
117 if (gmm::abs(v) < vclosest) { vclosest = gmm::abs(v); iclosest = i; }
122 if (side != 0 && iclosest !=
size_type(-1))
124 z[iclosest] = (side > 0) ?
'+' :
'-';
128 for (
unsigned d = 0; d < dofzones.size(); ++d) {
129 if (!dofzones[d])
continue;
130 for (mesh_level_set::zoneset::const_iterator it = dofzones[d]->begin();
131 it != dofzones[d]->end(); ++it, ++cnt) {
133 for (mesh_level_set::zone::const_iterator it2 = (*it)->begin();
134 it2 != (*it)->end(); ++it2) {
135 if (are_zones_compatible_(z,*(*it2))) { ids[cnt] =
true;
break; }
142 base_tensor &t,
bool)
const {
146 base_tensor::iterator it = t.begin();
150 else c0.set_pf(bfem);
152 base_tensor::const_iterator itf = tt.begin();
154 std::vector<bool> zid;
155 find_zone_id(c, zid, c.xfem_side());
158 for (
size_type d = 0; d < bfem->nb_dof(0); ++d, ++itf) {
160 for (
size_type k = 0; k < dofzones[d]->size(); ++k, ++cnt)
161 *it++ = zid[cnt] ? *itf : 0;
165 assert(it == t.end());
169 base_tensor &t,
bool)
const {
177 else c0.set_pf(bfem);
180 base_tensor::iterator it = t.begin();
181 base_tensor::const_iterator itf = tt.begin();
183 std::vector<bool> zid;
184 find_zone_id(c, zid, c.xfem_side());
186 for (dim_type i = 0; i < c.N() ; ++i) {
189 for (
size_type d = 0; d < bfem->nb_dof(0); ++d, ++itf) {
191 for (
size_type k = 0; k < dofzones[d]->size(); ++k, ++cnt)
192 *it++ = zid[cnt] ? *itf : 0;
197 assert(it == t.end());
201 base_tensor &t,
bool)
const {
206 else c0.set_pf(bfem);
209 base_tensor::iterator it = t.begin();
210 base_tensor::const_iterator itf = tt.begin();
212 std::vector<bool> zid;
213 find_zone_id(c, zid, c.xfem_side());
215 dim_type NNdim = dim_type(gmm::sqr(c.N())*
target_dim());
216 for (dim_type ijq = 0; ijq < NNdim ; ++ijq) {
218 for (
size_type d = 0; d < bfem->nb_dof(0); ++d, ++itf) {
220 for (
size_type k = 0; k < dofzones[d]->size(); ++k, ++cnt)
221 *it++ = zid[cnt] ? *itf : 0;
226 assert(it == t.end());