GetFEM  5.5
getfem_level_set.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 1999-2026 Yves Renard, Julien Pommier
5 
6  This file is a part of GetFEM
7 
8  GetFEM is free software; you can redistribute it and/or modify it
9  under the terms of the GNU Lesser General Public License as published
10  by the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version along with the GCC Runtime Library
12  Exception either version 3.1 or (at your option) any later version.
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  License and GCC Runtime Library Exception for more details.
17  You should have received a copy of the GNU Lesser General Public License
18  along with this program. If not, see https://www.gnu.org/licenses/.
19 
20  As a special exception, you may use this file as it is a part of a free
21  software library without restriction. Specifically, if other files
22  instantiate templates or use macros or inline functions from this file,
23  or you compile this file and link it with other files to produce an
24  executable, this file does not by itself cause the resulting executable
25  to be covered by the GNU Lesser General Public License. This exception
26  does not however invalidate any other reasons why the executable file
27  might be covered by the GNU Lesser General Public License.
28 
29 ===========================================================================*/
30 
31 /**@file getfem_level_set.h
32  @author Yves Renard <Yves.Renard@insa-lyon.fr>, Julien Pommier <Julien.Pommier@insa-toulouse.fr>
33  @date January 31, 2005.
34  @brief Define level-sets.
35 */
36 #ifndef GETFEM_LEVEL_SET_H__
37 #define GETFEM_LEVEL_SET_H__
38 
39 #include "getfem_mesh_fem.h"
40 #include "getfem_mesher.h"
41 
42 namespace getfem {
43  /** @brief Define a level-set.
44 
45  In getfem, a levelset is one or two scalar functions, defined on
46  a lagrange polynomial mesh_fem.
47 
48  The (optional) second function is a way to limit the level-set
49  to handle cracks for example.
50  */
51 
52  class level_set : public context_dependencies, virtual public dal::static_stored_object {
53 
54  protected :
55  dim_type degree_;
56  const mesh_fem *mf;
57  std::vector<scalar_type> primary_, secondary_;
58  bool with_secondary;
59  scalar_type shift_ls; // for the computation of a gap on a level_set.
60  // shift the level set on the ref element for mesher_level_set call
61  // Deprecated.
62 
63  void copy_from(const level_set &ls); // WARNING : to be updated if
64  // some components are added
65 
66  public :
67 
68  void set_shift(scalar_type shift_ls_) // Deprecated
69  { shift_ls = shift_ls_; }
70  scalar_type get_shift(void) const { return shift_ls; } // Deprecated
71  void simplify(scalar_type eps = 0.01);
72  void update_from_context(void) const { }
73  void reinit(void);
74  std::vector<scalar_type> &values(unsigned i = 0)
75  { return (i == 0) ? primary_ : secondary_; }
76  const std::vector<scalar_type> &values(unsigned i = 0) const
77  { return (i == 0) ? primary_ : secondary_; }
78 
79  pmesher_signed_distance mls_of_convex(size_type cv, unsigned lsnum = 0,
80  bool inverted = false) const;
81  bool has_secondary(void) const { return with_secondary; }
82  const mesh_fem &get_mesh_fem(void) const { return *mf; }
83  const mesh &linked_mesh() const { return mf->linked_mesh(); }
84  dim_type degree() const { return degree_; }
85  level_set(const mesh &msh, dim_type deg = dim_type(1),
86  bool with_secondary_ = false);
87  level_set(const level_set &ls);
88  level_set &operator =(const level_set &ls);
89 
90  ~level_set();
91  size_type memsize() const;
92  };
93 
94  /* Dummy level_set for default parameter of functions. */
95  const level_set &dummy_level_set();
96 
97 } /* end of namespace getfem. */
98 
99 
100 #endif /* GETFEM_LEVEL_SET_H__ */
base class for static stored objects
Deal with interdependencies of objects.
Define a level-set.
void update_from_context(void) const
this function has to be defined and should update the object when the context is modified.
Describe a finite element method linked to a mesh.
const mesh & linked_mesh() const
Return a reference to the underlying mesh.
Define the getfem::mesh_fem class.
An experimental mesher.
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:48
GEneric Tool for Finite Element Methods.