30 dal::bit_vector res = convex_tab.index();
31 for (dal::bv_visitor cv(convex_tab.index()); !cv.finished(); ++cv)
38 mesh_convex_structure::ind_pt_ct::const_iterator it;
40 for (it=convex_tab[ic].pts.begin();
41 it != convex_tab[ic].pts.end() && (*it) != ip; ++it) ++ind;
42 GMM_ASSERT1(it != convex_tab[ic].pts.end(),
43 "This point does not exist on this convex.");
49 std::vector<size_type> doubles;
53 for (
size_type l = 0; l < convex_tab[cv].pts.size(); ++l) {
55 if (ind == i) ind = j;
56 else if (ind == j) { ind = i; doubles.push_back(cv); }
61 if (std::find(doubles.begin(), doubles.end(), cv) == doubles.end()) {
62 for (
size_type l = 0; l < convex_tab[cv].pts.size(); ++l)
63 if (convex_tab[cv].pts[l] == j) convex_tab[cv].pts[l] = i;
71 std::vector<size_type> doubles;
74 for (
size_type k = 0; k < convex_tab[i].pts.size(); ++k) {
78 if (ind == i) ind = j;
79 else if (ind == j) { ind = i; doubles.push_back(ip); }
83 for (
size_type k = 0; k < convex_tab[j].pts.size(); ++k) {
85 if (std::find(doubles.begin(), doubles.end(), ip) == doubles.end()) {
87 if (points_tab[ip][l] == j) points_tab[ip][l] = i;
102 for (
size_type l = 0; l < convex_tab[ic].pts.size(); ++l) {
104 std::vector<size_type>::iterator it1= points_tab[ind].
begin(), it2 = it1;
105 std::vector<size_type>::iterator ite= points_tab[ind].
end();
106 for (; it2 != ite; ++it2) { *it1 = *it2;
if (*it1 != ic) ++it1; }
107 points_tab[ind].pop_back();
119 for (
short_type iff = 0; iff < ps->nb_faces(); ++iff)
126 for (dal::bv_visitor i(nn); !i.finished(); ++i)
127 if (convex_tab[i].cstruct->dim() == n)
134 for (dal::bv_visitor i(nn); !i.finished(); ++i)
135 dmax = std::max(dmax, convex_tab[i].cstruct->dim());
136 for ( ; dmax > 1; --dmax)
to_faces(dmax);
143 for (
size_type l = 0; l < convex_tab[cv].pts.size(); ++l)
144 if (convex_tab[cv].pts[l] == i2) { ++nb;
break; }
150 std::vector<size_type> &ipt)
const {
154 for (
size_type l = 0; l < convex_tab[cv].pts.size(); ++l)
155 if (convex_tab[cv].pts[l] == i2) { ipt.push_back(cv);
break; }
164 for (
size_type l = 0; l < convex_tab[cv].pts.size(); ++l)
165 if (ip != convex_tab[cv].pts[l]) {
167 if (std::find(s.begin(), s.end(), ind) != s.end()) s.push_back(ind);
175 const mesh_convex_structure *q = &(convex_tab[ic]);
176 std::vector<size_type>::const_iterator r = q->pts.begin();
177 const convex_ind_ct *p = &(q->cstruct->ind_points_of_face(iff));
181 size_type mesh_structure::memsize(
void)
const {
183 + convex_tab.memsize();
184 for (
size_type i = 0; i < convex_tab.size(); ++i)
185 mems += convex_tab[i].pts.size() *
sizeof(
size_type);
187 mems += points_tab[i].size() *
sizeof(
size_type);
193 for (i = 0; i < j; i++)
194 if (!convex_tab.index_valid(i))
197 if (points_tab.
size())
198 for (i=0, j = (points_tab.
end()-points_tab.
begin())-1; i < j; ++i, --j){
199 while (i < j && !(points_tab[i].empty())) ++i;
200 while (i < j && points_tab[j].empty()) --j;
206 points_tab = dal::dynamic_tas<ind_cv_ct, 8>();
207 convex_tab = dal::dynamic_tas<mesh_convex_structure, 8>();
211 void mesh_structure::stat(
void) {
212 cout <<
"mesh structure with " <<
nb_convex() <<
" valid convex, " 213 <<
"for a total memory size of " << memsize() <<
" bytes.\n";
226 && (convex_tab[ic].cstruct->dim()==convex_tab[icv].cstruct->dim()))
233 const std::vector<short_type> &ftab,
236 std::vector<size_type> ipts;
238 switch (ftab.size()) {
242 ipts.resize(pt.size());
243 std::copy(pt.begin(), pt.end(), ipts.begin());
250 ipts.resize(pt.size());
251 std::copy(pt.begin(), pt.end(), ipts.begin());
257 const mesh_convex_structure &q = convex_tab[ic];
258 const convex_ind_ct &ind = q.cstruct->ind_common_points_of_faces(ftab);
260 ipts.resize(ind.size());
261 auto it = ind.cbegin();
262 for (
size_type &ipt : ipts) ipt = q.pts[*it++];
267 if (ipts.size() == 0) {
271 auto ipt0 = ipts.cbegin();
272 auto ipt1 = ipt0 + 1;
274 for (
size_type icv : points_tab[*ipt0]) {
290 && (convex_tab[ic].cstruct->dim()==convex_tab[icv].cstruct->dim()))
291 if (std::find(s.begin(), s.end(), icv) == s.end())
305 && (convex_tab[ic].cstruct->dim()==convex_tab[icv].cstruct->dim()))
313 if (neighbour_element ==
size_type(-1))
return convex_face::invalid_face();
316 auto nNeighbourElementFaces = pcs->nb_faces();
317 for (
short_type iff = 0; iff < nNeighbourElementFaces; ++iff) {
318 auto nPointsOnFace = pcs->nb_points_of_face(iff);
320 nPointsOnFace, face_points.begin()))
321 return {neighbour_element, iff};
323 GMM_ASSERT2(
false,
"failed to determine neighbouring face");
324 return convex_face::invalid_face();
330 ind_cv_ct::const_iterator it = std::find(ct.begin(), ct.end(), ip);
331 return (it != ct.end()) ? (it - ct.begin()):
size_type(-1);
340 void mesh_edge_list_convex(
pconvex_structure cvs, std::vector<size_type> points_of_convex,
341 size_type cv_id, edge_list &el,
bool merge_convex)
343 dim_type n = cvs->dim();
345 size_type ncv = merge_convex ? 0 : cv_id;
348 for (dim_type k = 0; k < n; ++k)
349 for (dim_type l = dim_type(k+1); l <= n; ++l)
350 el.add(edge_list_elt(points_of_convex[k],
351 points_of_convex[l], ncv));
356 for (dim_type j = 0; j < n; ++j)
357 if ((k & (1 << j)) == 0)
358 el.add(edge_list_elt(points_of_convex[k],
359 points_of_convex[k | (1 << j)], ncv));
362 for (dim_type k = 0; k < n - 1; ++k)
363 for (dim_type l = dim_type(k+1); l < n; ++l) {
364 el.add(edge_list_elt(points_of_convex[k],
365 points_of_convex[l], ncv));
366 el.add(edge_list_elt(points_of_convex[k+n],
367 points_of_convex[l+n], ncv));
369 for (dim_type k = 0; k < n; ++k)
370 el.add(edge_list_elt(points_of_convex[k],
371 points_of_convex[k+n], ncv));
378 indpttab[0].resize(cvstab[0]->nb_points());
379 std::copy(points_of_convex.begin(),
380 points_of_convex.end(), indpttab[0].
begin());
389 std::vector< size_type > pts = indpttab[ncs];
390 if (cvs->dim() == 1) {
392 for (
size_type j = 1; j < cvs->nb_points(); ++j) {
394 el.add(edge_list_elt((indpttab[ncs])[j-1],(indpttab[ncs])[j],ncv));
401 cvstab[ncs+f] = (cvs->faces_structure())[f];
402 indpttab[ncs+f].resize(cvs->nb_points_of_face(f));
411 for (
size_type k = 0; k < cvs->nb_points_of_face(f); ++k)
412 (indpttab[ncs+f])[k] = pts[cvs->ind_points_of_face(f)[k]];
426 std::vector<size_type> p;
427 for (dal::bv_visitor cv(m.
convex_index()); !cv.finished(); ++cv) {
439 std::vector<size_type> &cmk) {
441 cmk.reserve(cvlst.card()); cmk.resize(0);
443 std::deque<int> pile;
444 std::vector<size_type> tab, connectivity(cvlst.last_true()+1),
445 temp(cvlst.last_true()+1);
449 std::fill(connectivity.begin(), connectivity.end(),
size_type(-1));
453 for (dal::bv_visitor j(cvlst); !j.finished(); ++j) {
455 mesh_structure::ind_cv_ct::const_iterator itp = ct.begin(),
459 for (; itp != itpe; ++itp) {
461 mesh_structure::ind_cv_ct::const_iterator
464 for ( ; it != ite; ++it)
465 if (temp[*it] != j+1) { temp[*it] = j+1; nei++; }
467 connectivity[j] = nei-1;
468 if (nei < connectivity[cv]) cv = j;
479 mesh_structure::ind_cv_ct::const_iterator
482 for ( ; it != ite; ++it)
483 if (connectivity[*it] !=
size_type(-1)) {
485 pile.push_front(
int(*it));
490 cv = std::min_element(connectivity.begin(), connectivity.end()) - connectivity.begin();
491 if (connectivity[cv] ==
size_type(-1))
break;
493 else { cv = pile.back(); pile.pop_back(); }
void swap_convex(size_type cv1, size_type cv2)
Exchange two convex IDs.
indexed array reference (given a container X, and a set of indexes I, this class provides a pseudo-co...
short_type nb_points_of_convex(size_type ic) const
Return the number of points of convex ic.
ind_pt_face_ct ind_points_of_face_of_convex(size_type ic, short_type f) const
Return a container of the (global) point number for face f or convex ic.
void to_faces(dim_type n)
build a new mesh, such that its convexes are the faces of the convexes of the previous one ...
void to_edges()
build a new mesh, such that its convexes are the edges of the convexes of the previous one ...
void optimize_structure()
Reorder the convex IDs and point IDs, such that there is no hole in their numbering.
pconvex_structure prism_P1_structure(dim_type nc)
Give a pointer on the structures of a prism of dimension d.
convex_face adjacent_face(size_type ic, short_type f) const
Return a face of the neighbouring element that is adjacent to the given face.
pconvex_structure structure_of_convex(size_type ic) const
Return the pconvex_structure of the convex ic.
const ind_cv_ct & convex_to_point(size_type ip) const
Return a container of the convexes attached to point ip.
void swap_points(size_type i, size_type j)
Exchange two point IDs.
void clear()
erase the mesh
bool is_convex_face_having_points(size_type ic, short_type face_num, short_type nb, ITER pit) const
Return true if the face of the convex contains the given list of points.
void ind_points_to_point(size_type, ind_set &) const
Return a container of the points attached (via an edge) to point ip.
std::shared_ptr< const convex_structure > pconvex_structure
Pointer on a convex structure description.
size_type nb_convex() const
The total number of convexes in the mesh.
size_t size_type
used as the common size type in the library
bool is_convex_having_points(size_type ic, short_type nb, ITER pit) const
Return true if the convex contains the listed points.
size_type memsize(void) const
Gives the total memory occupied by the array.
size_type add_face_of_convex(size_type ic, short_type f)
Insert a new convex corresponding to face f of the convex ic.
Mesh structure definition.
size_type neighbour_of_convex(size_type ic, short_type f) const
Return a neighbour convex of a given convex face.
size_type size(void) const
Number of allocated elements.
size_type local_ind_of_convex_point(size_type ic, size_type ip) const
Return the "local" index for point ip of the mesh.
gmm::uint16_type short_type
used as the common short type integer in the library
pconvex_structure parallelepiped_structure(dim_type nc, dim_type k)
Give a pointer on the structures of a parallelepiped of dimension d.
size_type add_convex(pconvex_structure cs, ITER ipts, bool *present=0)
Insert a new convex in the mesh_structure.
pconvex_structure simplex_structure(dim_type nc)
Give a pointer on the structures of a simplex of dimension d.
iterator end(void)
Iterator on the last + 1 element.
Mesh structure definition.
size_type ind_in_convex_of_point(size_type ic, size_type ip) const
Find the local index of the point of global index ip with respect to the convex cv.
bool is_convex_valid(size_type i)
Return true if i is in convex_index()
void cuthill_mckee_on_convexes(const bgeot::mesh_structure &ms, std::vector< size_type > &cmk)
Return the cuthill_mc_kee ordering on the convexes.
const ind_cv_ct & ind_points_of_convex(size_type ic) const
Return a container to the list of points attached to convex ic.
void sup_convex(size_type ic)
Remove the convex ic.
iterator begin(void)
Iterator on the first element.
short_type nb_faces_of_convex(size_type ic) const
Return the number of faces of convex ic.
void neighbours_of_convex(size_type ic, short_type f, ind_set &s) const
Return in s a list of neighbours of a given convex face.
void add_faces_of_convex(size_type ic)
Insert new convexes corresponding to the faces of the convex ic.
const dal::bit_vector & convex_index() const
Return the list of valid convex IDs.