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;
44 this->add_dependency(*mf);
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);
70 <<
" is not in the level set mesh!");
72 GMM_ASSERT1(!mf->
is_reduced(),
"Internal error");
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)) *
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) {
92 !cv.finished(); ++cv) {
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()
virtual size_type nb_basic_dof_of_element(size_type cv) const
Return the number of degrees of freedom attached to a given convex.
virtual size_type nb_dof() const
Return the total number of degrees of freedom.
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...
static T & instance()
Instance from the current thread.
size_t size_type
used as the common size type in the library
virtual scalar_type convex_radius_estimate(size_type ic) const
Return an estimate of the convex largest dimension.
void add_dependency(pstatic_stored_object o1, pstatic_stored_object o2)
Add a dependency, object o1 will depend on object o2.
bool is_reduced() const
Return true if a reduction matrix is applied to the dofs.
GEneric Tool for Finite Element Methods.
const mesh & linked_mesh() const
Return a reference to the underlying mesh.
virtual ind_dof_ct ind_basic_dof_of_element(size_type cv) const
Give an array of the dof numbers a of convex.
const dal::bit_vector & convex_index() const
Return the list of valid convex IDs.
const mesh_fem & classical_mesh_fem(const mesh &mesh, dim_type degree, dim_type qdim=1, bool complete=false)
Gives the descriptor of a classical finite element method of degree K on mesh.