48 #ifndef GETFEM_MESH_SLICERS_H
49 #define GETFEM_MESH_SLICERS_H
64 typedef std::bitset<32> faces_ct;
69 slice_node(
const base_node& pt_,
const base_node& pt_ref_)
70 : pt(pt_), pt_ref(pt_ref_) {}
71 void swap(slice_node &other) {
72 std::swap(faces,other.faces); pt.swap(other.pt);
73 pt_ref.swap(other.pt_ref);
82 struct slice_simplex {
83 std::vector<size_type> inodes;
84 size_type dim()
const {
return inodes.size()-1; }
86 slice_simplex() : inodes(4) {}
88 {
return inodes == o.inodes; }
89 bool operator!=(
const slice_simplex& o)
const
90 {
return inodes != o.inodes; }
94 class stored_mesh_slice;
104 std::deque<slicer_action*> action;
106 typedef std::vector<slice_node> cs_nodes_ct;
107 typedef std::vector<slice_simplex> cs_simplexes_ct;
117 cs_simplexes_ct simplexes;
121 dal::bit_vector simplex_index, nodes_index, splx_in;
123 bgeot::pconvex_ref cvr, prev_cvr;
131 void update_nodes_index();
138 void push_back_action(
slicer_action &a) { action.push_back(&a); }
139 void push_front_action(
slicer_action &a) { action.push_front(&a); }
141 size_type add_simplex(
const slice_simplex& s,
bool isin) {
143 simplexes.push_back(s); splx_in[i] = isin; simplex_index.add(i);
147 splx_in.sup(i); simplex_index.sup(i);
150 if (nodes.size())
return nodes[0].pt.size();
151 else GMM_ASSERT1(
false,
"internal_error");
153 void simplex_orientation(slice_simplex& s);
161 void exec(
const std::vector<short_type> &nrefine,
const mesh_region& cvlst);
173 void exec(
const std::vector<base_node>& pts);
178 const mesh& refined_simplex_mesh_for_convex_cut_by_level_set
179 (
const mesh &cvm,
unsigned nrefine);
181 refined_simplex_mesh_for_convex_faces_cut_by_level_set(
short_type f);
185 void apply_slicers();
191 class mesh_slice_cv_dof_data_base {
194 virtual void copy(
size_type cv, base_vector& coeff)
const = 0;
195 virtual scalar_type maxval()
const = 0;
196 virtual ~mesh_slice_cv_dof_data_base() {}
197 virtual std::unique_ptr<mesh_slice_cv_dof_data_base> clone()
const = 0;
205 :
public mesh_slice_cv_dof_data_base {
206 typedef typename gmm::linalg_traits<VEC>::value_type T;
217 virtual void copy(
size_type cv, base_vector& coeff)
const {
218 coeff.resize(pmf->nb_basic_dof_of_element(cv));
219 const mesh_fem::ind_dof_ct &dof = pmf->ind_basic_dof_of_element(cv);
220 base_vector::iterator out = coeff.begin();
221 for (mesh_fem::ind_dof_ct::iterator it=dof.begin(); it != dof.end();
225 scalar_type maxval()
const {
return gmm::vect_norminf(u); }
226 virtual std::unique_ptr<mesh_slice_cv_dof_data_base> clone()
const
227 {
return std::make_unique<mesh_slice_cv_dof_data<VEC>>(*this); }
239 static const float EPS;
255 std::vector<slice_node::faces_ct> convex_faces;
256 bool test_bound(
const slice_simplex& s, slice_node::faces_ct& fmask,
257 const mesh_slicer::cs_nodes_ct& nodes)
const;
269 mesh_slice_cv_dof_data_base *defdata;
272 std::vector<base_node> ref_pts;
274 slicer_apply_deformation(mesh_slice_cv_dof_data_base &defdata_)
275 : defdata(&defdata_), pf(0) {
277 defdata->pmf->get_qdim() != defdata->pmf->linked_mesh().dim())
278 GMM_ASSERT1(
false,
"wrong Q(=" <<
int(defdata->pmf->get_qdim())
279 <<
") dimension for slice deformation: should be equal to "
280 "the mesh dimension which is "
281 <<
int(defdata->pmf->linked_mesh().dim()));
283 void exec(mesh_slicer &ms);
292 enum {VOLIN=-1, VOLBOUND=0, VOLOUT=+1, VOLSPLIT=+2};
303 dal::bit_vector pt_in, pt_bin;
308 const mesh_slicer::cs_nodes_ct& nodes,
309 const dal::bit_vector& nodes_index) {
310 pt_in.clear(); pt_bin.clear();
311 for (dal::bv_visitor i(nodes_index); !i.finished(); ++i) {
312 bool in, bin; test_point(nodes[i].pt, in, bin);
313 if (bin || ((
orient > 0) ? !in : in)) pt_in.add(i);
314 if (bin) pt_bin.add(i);
317 virtual void test_point(
const base_node&,
bool& in,
bool& bound)
const
318 { in=
true; bound=
true; }
322 const mesh_slicer::cs_nodes_ct& )
const = 0;
327 static scalar_type
trinom(scalar_type a, scalar_type b, scalar_type c);
332 std::bitset<32> spbin);
341 const base_node x0, n;
342 void test_point(
const base_node& P,
bool& in,
bool& bound)
const;
344 const mesh_slicer::cs_nodes_ct& nodes)
const;
358 void test_point(
const base_node& P,
bool& in,
bool& bound)
const;
360 const mesh_slicer::cs_nodes_ct& nodes)
const;
376 void test_point(
const base_node& P,
bool& in,
bool& bound)
const;
378 const mesh_slicer::cs_nodes_ct& nodes)
const;
380 slicer_cylinder(base_node x0_, base_node x1_,scalar_type R_,
int orient_) :
382 d /= gmm::vect_norm2(d);
391 std::unique_ptr<const mesh_slice_cv_dof_data_base> mfU;
393 scalar_type val_scaling;
394 std::vector<scalar_type> Uval;
395 void prepare(
size_type cv,
const mesh_slicer::cs_nodes_ct& nodes,
396 const dal::bit_vector& nodes_index);
398 const mesh_slicer::cs_nodes_ct&)
const;
402 scalar_type val_,
int orient_) :
404 GMM_ASSERT1(mfU->pmf->get_qdim() == 1,
405 "can't compute isovalues of a vector field !");
406 val_scaling = mfU->maxval();
468 scalar_type area()
const {
return a; }
480 dal::bit_vector *pslice_edges;
484 : edges_m(edges_m_), pslice_edges(0) {}
492 : edges_m(edges_m_), pslice_edges(&bv) {}
region-tree for window/point search on a set of rectangles.
Mesh structure definition.
Balanced tree of n-dimensional rectangles.
Describe a finite element method linked to a mesh.
const EXTENSION_MATRIX & extension_matrix() const
Return the extension matrix corresponding to reduction applied (RE=I).
virtual size_type nb_basic_dof() const
Return the total number of basic degrees of freedom (before the optional reduction).
bool is_reduced() const
Return true if a reduction matrix is applied to the dofs.
Keep informations about a mesh crossed by level-sets.
structure used to hold a set of convexes and/or convex faces.
Use this structure to specify that the mesh must be deformed before the slicing operation (with a mes...
Apply a serie a slicing operations to a mesh.
void exec(size_type nrefine, const mesh_region &cvlst)
build a new mesh_slice.
mesh_slicer(const mesh &m_)
mesh_slicer constructor.
Describe a mesh (collection of convexes (elements) and points).
Extraction of the boundary of a slice.
Slicer whose side-effect is to build the list of edges (i.e.
slicer_build_edges_mesh(mesh &edges_m_, dal::bit_vector &bv)
slicer_build_edges_mesh(mesh &edges_m_)
Slicer whose side-effect is to build a mesh from the slice simplexes.
Build the complementary of a slice.
Slicer whose side-effect is to compute the area of the slice.
Slices a mesh with a cylinder (or its boundary).
Contract or expand each convex with respect to its gravity center.
slicer_explode(scalar_type c)
Slice a mesh with a half-space (or its boundary).
Build the intersection of two slices.
Slices a mesh with another mesh.
This slicer does nothing.
Slices a mesh with a sphere (or its boundary).
Base class for general slices of a mesh (planar, sphere, cylinder,isosurface)
virtual void prepare(size_type, const mesh_slicer::cs_nodes_ct &nodes, const dal::bit_vector &nodes_index)
Overload either 'prepare' or 'test_point'.
int orient
orient defines the kind of slicing : VOLIN -> keep the inside of the volume, VOLBOUND -> its boundary...
virtual scalar_type edge_intersect(size_type, size_type, const mesh_slicer::cs_nodes_ct &) const =0
edge_intersect should always be overloaded
static scalar_type trinom(scalar_type a, scalar_type b, scalar_type c)
Utility function.
The output of a getfem::mesh_slicer which has been recorded.
Define the getfem::mesh_fem class.
Include the base gmm files.
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
gmm::uint16_type short_type
used as the common short type integer in the library
bool operator==(const pconvex_structure &p1, const pconvex_structure &p2)
Stored objects must be compared by keys, because there is a possibility that they are duplicated in s...
size_t size_type
used as the common size type in the library
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation
GEneric Tool for Finite Element Methods.