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;
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();
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());
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()) ...
virtual size_type nb_base(size_type cv) const
Number of basis functions.
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.
void grad_base_value(const base_node &x, base_tensor &t) const
Give the value of all gradients (on ref.
size_type convex_num() const
get the current convex number
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...
FEM associated with getfem::mesh_fem_level_set objects.
bool have_pfp() const
true if a fem_precomp_ has been supplied.
virtual pfem fem_of_element(size_type cv) const
Return the basic fem associated with an element (if no fem is associated, the function will crash! us...
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...
size_t size_type
used as the common size type in the library
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()) ...
structure passed as the argument of fem interpolation functions.
dim_type target_dim() const
dimension of the target space.
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 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...
GEneric Tool for Finite Element Methods.
pfem_precomp pfp() const
get the current fem_precomp_
Describe a finite element method linked to a mesh.
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()) ...
const base_node & xref() const
coordinates of the current point, in the reference convex.
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...
pfem_precomp fem_precomp(pfem pf, bgeot::pstored_point_tab pspt, dal::pstatic_stored_object dep)
Handles precomputations for FEM.
size_type nb_level_sets(void) const
Get number of level-sets referenced in this object.
void hess_base_value(const base_node &x, base_tensor &t) const
Give the value of all hessians (on ref.
pdof_description xfem_dof(pdof_description p, size_type ind)
Description of a special dof for Xfem.