27 void fem_level_set::init() {
28 cvr = bfem->ref_convex(0);
29 dim_ = cvr->structure()->dim();
30 is_equiv =
true; real_element_defined =
true;
31 is_polycomp = is_pol = is_lag = is_standard_fem =
false;
33 ntarget_dim = bfem->target_dim();
36 nm <<
"FEM_LEVEL_SET(" << bfem->debug_name() <<
")";
37 debug_name_ = nm.str();
45 for (
size_type k=0; k < bfem->nb_dof(0); ++k) {
46 const mesh_level_set::zoneset *ze = dofzones[k];
48 for (mesh_level_set::zoneset::const_iterator itz = ze->begin();
49 itz != ze->end(); ++itz) {
50 const mesh_level_set::zone *z = *itz;
51 for (mesh_level_set::zone::const_iterator it = z->begin();
52 it != z->end(); ++it) {
56 else if (c != d) { ls_index.add(i);
break; }
61 common_ls_zones[i] = c;
65 for (
size_type k = 0; k < bfem->nb_dof(0); ++k) {
67 add_node(bfem->dof_types()[k], bfem->node_of_dof(0,k));
69 for (
size_type j = 0; j < dofzones[k]->size(); ++j) {
72 bfem->node_of_dof(0,k));
79 { GMM_ASSERT1(
false,
"No base values, real only element."); }
82 { GMM_ASSERT1(
false,
"No base values, real only element."); }
85 { GMM_ASSERT1(
false,
"No base values, real only element."); }
87 static bool are_zones_compatible_(
const std::string a,
const std::string b) {
88 if (a.size() != b.size())
return false;
90 if (a[i] !=
'0' && a[i] != b[i])
return false;
94 void fem_level_set::find_zone_id(
const fem_interpolation_context &c,
95 std::vector<bool> &ids,
int side)
const {
97 for (
size_type i = 0; i < dofzones.size(); ++i)
98 if (dofzones[i]) s += dofzones[i]->size();
99 ids.resize(0); ids.resize(s,
false);
100 std::string z(common_ls_zones);
101 base_vector coeff(32);
103 mesher_level_set eval;
105 for (dal::bv_visitor i(ls_index); !i.finished(); ++i) {
106 const level_set *ls = mls.get_level_set(i);
107 const mesh_fem &mf = ls->get_mesh_fem();
109 eval.init_base(mf.fem_of_element(cv), coeff);
110 eval.set_shift(ls->get_shift());
114 scalar_type v = eval(c.xref());
116 if (gmm::abs(v) < vclosest) { vclosest = gmm::abs(v); iclosest = i; }
121 if (side != 0 && iclosest !=
size_type(-1))
123 z[iclosest] = (side > 0) ?
'+' :
'-';
127 for (
unsigned d = 0; d < dofzones.size(); ++d) {
128 if (!dofzones[d])
continue;
129 for (mesh_level_set::zoneset::const_iterator it = dofzones[d]->begin();
130 it != dofzones[d]->end(); ++it, ++cnt) {
132 for (mesh_level_set::zone::const_iterator it2 = (*it)->begin();
133 it2 != (*it)->end(); ++it2) {
134 if (are_zones_compatible_(z,*(*it2))) { ids[cnt] =
true;
break; }
141 base_tensor &t,
bool)
const {
145 base_tensor::iterator it = t.begin();
149 else c0.set_pf(bfem);
151 base_tensor::const_iterator itf = tt.begin();
153 std::vector<bool> zid;
154 find_zone_id(c, zid, c.xfem_side());
157 for (
size_type d = 0; d < bfem->nb_dof(0); ++d, ++itf) {
159 for (
size_type k = 0; k < dofzones[d]->size(); ++k, ++cnt)
160 *it++ = zid[cnt] ? *itf : 0;
164 assert(it == t.end());
168 base_tensor &t,
bool)
const {
176 else c0.set_pf(bfem);
179 base_tensor::iterator it = t.begin();
180 base_tensor::const_iterator itf = tt.begin();
182 std::vector<bool> zid;
183 find_zone_id(c, zid, c.xfem_side());
185 for (dim_type i = 0; i < c.N() ; ++i) {
188 for (
size_type d = 0; d < bfem->nb_dof(0); ++d, ++itf) {
190 for (
size_type k = 0; k < dofzones[d]->size(); ++k, ++cnt)
191 *it++ = zid[cnt] ? *itf : 0;
196 assert(it == t.end());
200 base_tensor &t,
bool)
const {
205 else c0.set_pf(bfem);
208 base_tensor::iterator it = t.begin();
209 base_tensor::const_iterator itf = tt.begin();
211 std::vector<bool> zid;
212 find_zone_id(c, zid, c.xfem_side());
214 dim_type NNdim = dim_type(gmm::sqr(c.N())*
target_dim());
215 for (dim_type ijq = 0; ijq < NNdim ; ++ijq) {
217 for (
size_type d = 0; d < bfem->nb_dof(0); ++d, ++itf) {
219 for (
size_type k = 0; k < dofzones[d]->size(); ++k, ++cnt)
220 *it++ = zid[cnt] ? *itf : 0;
225 assert(it == t.end());
structure passed as the argument of fem interpolation functions.
void real_hess_base_value(const fem_interpolation_context &c, base_tensor &t, bool=true) const
Give the hessian of all components of the base functions at the current point of the fem_interpolatio...
void real_base_value(const fem_interpolation_context &c, base_tensor &t, bool=true) const
Give the value of all components of the base functions at the current point of the fem_interpolation_...
void base_value(const base_node &x, base_tensor &t) const
Give the value of all components of the base functions at the point x of the reference element.
void real_grad_base_value(const fem_interpolation_context &c, base_tensor &t, bool=true) const
Give the gradient of all components of the base functions at the current point of the fem_interpolati...
void grad_base_value(const base_node &x, base_tensor &t) const
Give the value of all gradients (on ref.
void hess_base_value(const base_node &x, base_tensor &t) const
Give the value of all hessians (on ref.
size_type nb_level_sets(void) const
Get number of level-sets referenced in this object.
FEM associated with getfem::mesh_fem_level_set objects.
pdof_description xfem_dof(pdof_description p, size_type ind)
Description of a special dof for Xfem.
void add_node(const pdof_description &d, const base_node &pt, const dal::bit_vector &faces)
internal function adding a node to an element for the creation of a finite element method.
dim_type target_dim() const
dimension of the target space.
bool have_pfp() const
true if a fem_precomp_ has been supplied.
virtual size_type nb_base(size_type cv) const
Number of basis functions.
void hess_base_value(base_tensor &t, bool withM=true) const
fill the tensor with the hessian of the base functions (taken at point this->xref())
void grad_base_value(base_tensor &t, bool withM=true) const
fill the tensor with the gradient of the base functions (taken at point this->xref())
void base_value(base_tensor &t, bool withM=true) const
fill the tensor with the values of the base functions (taken at point this->xref())
pfem_precomp fem_precomp(pfem pf, bgeot::pstored_point_tab pspt, dal::pstatic_stored_object dep)
Handles precomputations for FEM.
pfem_precomp pfp() const
get the current fem_precomp_
size_t size_type
used as the common size type in the library
GEneric Tool for Finite Element Methods.
void slice_vector_on_basic_dof_of_element(const mesh_fem &mf, const VEC1 &vec, size_type cv, VEC2 &coeff, size_type qmult1=size_type(-1), size_type qmult2=size_type(-1))
Given a mesh_fem.