36 GMM_ASSERT1(i <= nbpt,
"convex_structure::add_point_adaptative: "
38 if (i == nbpt) nbpt++;
40 faces[f].resize(faces[f].size() + 1);
41 (faces[f])[faces[f].size() - 1] = i;
47 std::fill(faces_struct.begin(),faces_struct.end(),
49 std::fill(faces.begin(),faces.end(), convex_ind_ct());
50 dir_points_ = convex_ind_ct();
55 (
const std::vector<short_type> &ftab)
const {
56 auto it = intersection_points.find(ftab);
57 if (it == intersection_points.end()) {
58 std::vector<size_type> cpt(
nb_points(), ftab.size());
64 if (cpt[i] == 0) ind.push_back(i);
65 it = intersection_points.emplace(ftab, ind).first;
71 o <<
"convex structure of dimension " << int(cv.
dim()) <<
" with "
79 class convex_structure_key :
virtual public dal::static_stored_object_key {
85 bool compare(
const static_stored_object_key &oo)
const override{
86 const convex_structure_key &o
87 =
dynamic_cast<const convex_structure_key &
>(oo);
88 if (type < o.type)
return true;
89 if (type > o.type)
return false;
90 if (N < o.N)
return true;
91 if (N > o.N)
return false;
92 if (K < o.K)
return true;
93 if (K > o.K)
return false;
94 if (nf < o.nf)
return true;
97 bool equal(
const static_stored_object_key &oo)
const override{
98 auto &o =
dynamic_cast<const convex_structure_key &
>(oo);
99 if (type != o.type)
return false;
100 if (N != o.N)
return false;
101 if (K != o.K)
return false;
102 if (nf != o.nf)
return false;
105 convex_structure_key(
int t, dim_type NN,
short_type KK = 0,
107 : type(t), N(NN), K(KK), nf(nnf) {}
111 if (!p1 || !p2)
return p1.get() == p2.get();
112 if (p1.get() == p2.get())
return true;
113 else return *dal::key_of_stored_object(p1) == *dal::key_of_stored_object(p2);
121 return p1.get() ==
nullptr;
125 return p2 ==
nullptr;
129 return !(p1 ==
nullptr);
133 return !(p2 ==
nullptr);
140 class simplex_structure_ :
public convex_structure
143 #ifdef GETFEM_HAVE_QDLIB
148 #ifdef GETFEM_HAVE_QDLIB
150 static bool fpu_init =
false;
153 fpu_fix_start(&old_cw);
157 dal::pstatic_stored_object_key
158 pcsk = std::make_shared<convex_structure_key>(0, nc, 1);
160 if (o)
return std::dynamic_pointer_cast<const convex_structure>(o);
162 auto p = std::make_shared<simplex_structure_>();
164 p->Nc = dim_type(nc); p->nbpt =
short_type(nc+1);
166 p->faces_struct.resize(p->nbf);
167 p->faces.resize(p->nbf);
168 p->dir_points_.resize(p->Nc + 1);
169 p->auto_basic =
true;
171 p->dir_points_[i] = i;
173 p->faces[i].resize(nc);
175 (p->faces[i])[j] = (j >= i) ?
short_type(j + 1) : j;
181 dal::PERMANENT_STATIC_OBJECT);
189 struct K_simplex_structure_ :
public convex_structure {
191 K_simplex_structure_(dim_type NN,
short_type KK) {
194 faces_struct.resize(nbf);
196 dir_points_.resize(Nc+1);
199 for (
int i = 0; i < nbf; i++) {
201 faces[i].resize(faces_struct[i]->nb_points());
204 for (
int i = 0; i < nbf; i++) {
211 std::vector<int> pf(Nc+1,0);
214 c.fill(scalar_type(1.0) / scalar_type(Nc+1));
216 for (l = 1; l <= Nc; ++l)
217 (faces[l])[(pf[l])++] = 0;
218 dir_points_[pd++] = 0;
222 c[l] += scalar_type(1) / scalar_type(KK);
225 sum -=
size_type(floor(0.5+(c[l] * KK)));
227 c[l] += scalar_type(1) / scalar_type(KK);
230 for (l = 1; l <= Nc; ++l)
231 if (c[l-1] == scalar_type(0.0))
232 (faces[l])[(pf[l])++] = r;
234 (faces[0])[(pf[0])++] = r;
235 if (*(std::max_element(c.begin(), c.end())) == scalar_type(1.0))
236 dir_points_[pd++] = r;
246 dal::pstatic_stored_object_key
247 pcsk = std::make_shared<convex_structure_key>(0, nc, K);
249 if (o)
return std::dynamic_pointer_cast<const convex_structure>(o);
253 dal::PERMANENT_STATIC_OBJECT);
261 struct polygon_structure_ :
public convex_structure {
269 dal::pstatic_stored_object_key
270 pcsk = std::make_shared<convex_structure_key>(1, dim_type(nbt));
272 if (o)
return std::dynamic_pointer_cast<const convex_structure>(o);
274 auto p = std::make_shared<polygon_structure_>();
276 p->Nc = 2; p->nbpt = nbt; p->nbf = nbt;
277 p->auto_basic =
true;
278 p->faces_struct.resize(p->nbf);
279 p->faces = std::vector< std::vector<short_type> >(p->nbf);
280 p->dir_points_ = std::vector<short_type>(p->Nc + 1);
282 for (
int i = 0; i < p->nbf; i++) {
284 p->faces[i] = std::vector<short_type>(2);
285 for (
int j = 0; j < 2; j++)
289 p->dir_points_[0] = 0;
290 p->dir_points_[1] = 1;
294 dal::PERMANENT_STATIC_OBJECT);
304 struct cv_pr_structure_ :
public convex_structure {
306 Nc = dim_type(cv1->dim() + cv2->dim());
307 prod_a = cv1; prod_b = cv2;
308 nbpt =
short_type(cv1->nb_points() * cv2->nb_points());
309 nbf =
short_type(cv1->nb_faces() + cv2->nb_faces());
315 faces_struct.resize(nbf);
316 faces = std::vector< std::vector<short_type> >(nbf);
318 if (cv1->ind_dir_points().size() && cv2->ind_dir_points().size()) {
319 dir_points_ = std::vector<short_type>(Nc + 1);
321 for (
int i = 0; i <= cv1->dim(); i++)
324 + cv2->ind_dir_points()[0] * cv1->nb_points());
325 for (
int i = 1; i <= cv2->dim(); i++)
326 dir_points_[cv1->dim()+i]
328 + cv2->ind_dir_points()[i] * cv1->nb_points());
331 for (
short_type i = 0; i < cv1->nb_faces(); i++) {
332 if (cv1->nb_points_of_face(i) == 1)
333 faces_struct[i] = cv2;
340 faces[i] = std::vector<short_type>(cv1->nb_points_of_face(i)
343 for (
short_type j = 0; j < cv1->nb_points_of_face(i); j++)
344 for (
short_type l = 0; l < cv2->nb_points(); l++) {
345 (faces[i])[l*cv1->nb_points_of_face(i)+j]
347 + l * cv1->nb_points());
350 for (
short_type i = 0; i < cv2->nb_faces(); i++) {
352 if (cv2->nb_points_of_face(i) == 1)
353 faces_struct[i+k] = cv1;
360 faces[i+k] = std::vector<short_type>(cv2->nb_points_of_face(i)
363 for (
short_type j = 0; j < cv2->nb_points_of_face(i); j++)
364 for (
short_type l = 0; l < cv1->nb_points(); l++) {
365 (faces[i+k])[j*cv1->nb_points()+l]
366 =
short_type(l + (cv2->ind_points_of_face(i))[j]
376 dal::pstatic_stored_object_key pcsk = std::make_shared<cv_pr_key_>(a, b);
378 if (o)
return std::dynamic_pointer_cast<const convex_structure>(o);
381 for (
size_type k = 0; k < p->nb_faces(); ++k) {
382 if (exists_stored_object(p->faces_structure()[k]))
395 { DAL_STORED_OBJECT_DEBUG_CREATED(
this,
"parallelepiped structure"); }
397 { DAL_STORED_OBJECT_DEBUG_DESTROYED(
this,
"parallelepiped structure"); }
400 DAL_DOUBLE_KEY(parallelepiped_key_, dim_type, dim_type);
406 dal::pstatic_stored_object_key
407 pcsk = std::make_shared<parallelepiped_key_>(nc, k);
411 return ((std::dynamic_pointer_cast<const parallelepiped_>(o))->p);
413 auto p = std::make_shared<parallelepiped_>();
417 dal::PERMANENT_STATIC_OBJECT);
427 struct Q2_incomplete_structure_ :
public convex_structure {
431 DAL_SIMPLE_KEY(Q2_incomplete_structure_key_, dim_type);
434 GMM_ASSERT1(nc == 2 || nc == 3,
"Bad parameter, expected value 2 or 3");
435 dal::pstatic_stored_object_key
436 pcsk = std::make_shared<Q2_incomplete_structure_key_>(nc);
438 if (o)
return std::dynamic_pointer_cast<const convex_structure>(o);
440 auto p = std::make_shared<Q2_incomplete_structure_>();
443 p->nbpt = (nc == 2) ? 8 : 20;
444 p->nbf = (nc == 2) ? 4 : 6;
446 p->faces_struct.resize(p->nbf);
447 p->faces = std::vector< std::vector<short_type> >(p->nbf);
448 p->dir_points_ = std::vector<short_type>(p->Nc + 1);
456 p->faces[0] = {2,4,7};
457 p->faces[1] = {0,3,5};
458 p->faces[2] = {5,6,7};
459 p->faces[3] = {0,1,2};
461 p->dir_points_[0] = 0;
462 p->dir_points_[1] = 2;
463 p->dir_points_[2] = 5;
476 p->faces[0] = {2,4,7,9,11,14,16,19};
477 p->faces[1] = {0,3,5,8,10,12,15,17};
479 p->faces[2] = {5,6,7,10,11,17,18,19};
480 p->faces[3] = {0,1,2,8,9,12,13,14};
482 p->faces[4] = {12,13,14,15,16,17,18,19};
483 p->faces[5] = {0,1,2,3,4,5,6,7};
485 p->dir_points_[0] = 0;
486 p->dir_points_[1] = 2;
487 p->dir_points_[2] = 5;
488 p->dir_points_[3] = 12;
491 for (
int i = 0; i < p->nbf; i++) {
497 dal::PERMANENT_STATIC_OBJECT);
507 struct pyramid_QK_structure_ :
public convex_structure {
511 DAL_SIMPLE_KEY(pyramid_QK_structure_key_, dim_type);
514 GMM_ASSERT1(k == 1 || k == 2,
"Sorry, pyramidal elements implemented "
515 "only for degree one or two.");
516 dal::pstatic_stored_object_key
517 pcsk = std::make_shared<pyramid_QK_structure_key_>(k);
520 return std::dynamic_pointer_cast<const convex_structure>(o);
522 auto p = std::make_shared<pyramid_QK_structure_>();
526 p->dir_points_ = std::vector<short_type>(p->Nc + 1);
531 p->auto_basic =
true;
540 p->faces_struct.resize(p->nbf);
541 p->faces = std::vector< std::vector<short_type> >(p->nbf);
542 p->faces[0] = {0,1,2,3};
543 p->faces[1] = {0,1,4};
544 p->faces[2] = {1,3,4};
545 p->faces[3] = {3,2,4};
546 p->faces[4] = {2,0,4};
548 p->dir_points_[0] = 0;
549 p->dir_points_[1] = 1;
550 p->dir_points_[2] = 2;
551 p->dir_points_[3] = 4;
554 for (
int i = 1; i < p->nbf; i++)
559 dal::PERMANENT_STATIC_OBJECT);
576 p->faces_struct.resize(p->nbf);
577 p->faces = std::vector< std::vector<short_type> >(p->nbf);
578 p->faces[0] = {0,1,2,3,4,5,6,7,8};
579 p->faces[1] = {0,1,2,9,10,13};
580 p->faces[2] = {2,5,8,10,12,13};
581 p->faces[3] = {8,7,6,12,11,13};
582 p->faces[4] = {6,3,0,11,9,13};
584 p->dir_points_[0] = 0;
585 p->dir_points_[1] = 2;
586 p->dir_points_[2] = 6;
587 p->dir_points_[3] = 13;
590 for (
int i = 1; i < p->nbf; i++)
595 dal::PERMANENT_STATIC_OBJECT);
604 struct pyramid_Q2_incomplete_structure_ :
public convex_structure {
608 DAL_SIMPLE_KEY(pyramid_Q2_incomplete_structure_key_, dim_type);
611 dal::pstatic_stored_object_key
612 pcsk = std::make_shared<pyramid_Q2_incomplete_structure_key_>(0);
615 return std::dynamic_pointer_cast<const convex_structure>(o);
617 auto p = std::make_shared<pyramid_Q2_incomplete_structure_>();
621 p->dir_points_ = std::vector<short_type>(p->Nc + 1);
637 p->faces_struct.resize(p->nbf);
638 p->faces = std::vector< std::vector<short_type> >(p->nbf);
639 p->faces[0] = {0,1,2,3,4,5,6,7};
640 p->faces[1] = {0,1,2,8,9,12};
641 p->faces[2] = {2,4,7,9,11,12};
642 p->faces[3] = {7,6,5,11,10,12};
643 p->faces[4] = {5,3,0,10,8,12};
645 p->dir_points_[0] = 0;
646 p->dir_points_[1] = 2;
647 p->dir_points_[2] = 5;
648 p->dir_points_[3] = 12;
651 for (
int i = 1; i < p->nbf; i++)
656 dal::PERMANENT_STATIC_OBJECT);
664 struct prism_incomplete_P2_structure_ :
public convex_structure {
668 DAL_SIMPLE_KEY(prism_incomplete_P2_structure_key_, dim_type);
671 dal::pstatic_stored_object_key
672 pcsk = std::make_shared<prism_incomplete_P2_structure_key_>(0);
675 return std::dynamic_pointer_cast<const convex_structure>(o);
677 auto p = std::make_shared<prism_incomplete_P2_structure_>();
681 p->dir_points_ = std::vector<short_type>(p->Nc + 1);
697 p->faces_struct.resize(p->nbf);
698 p->faces = std::vector< std::vector<short_type> >(p->nbf);
699 p->faces[0] = {2,4,5,7,8,11,13,14};
700 p->faces[1] = {0,3,5,6,8,9,12,14};
701 p->faces[2] = {0,1,2,6,7,9,10,11};
702 p->faces[3] = {9,10,11,12,13,14};
703 p->faces[4] = {0,1,2,3,4,5};
705 p->dir_points_[0] = 0;
706 p->dir_points_[1] = 2;
707 p->dir_points_[2] = 5;
708 p->dir_points_[3] = 9;
710 for (
int i = 0; i < 3; i++)
717 dal::PERMANENT_STATIC_OBJECT);
725 struct dummy_structure_ :
public convex_structure {
732 dal::pstatic_stored_object_key
733 pcsk = std::make_shared<convex_structure_key>(2, nc,
short_type(n), nf);
735 if (o)
return std::dynamic_pointer_cast<const convex_structure>(o);
736 auto p = std::make_shared<dummy_structure_>();
738 p->Nc = nc; p->nbpt =
short_type(n); p->nbf = 0;
739 p->faces_struct.resize(nf);
745 p->faces[j].resize(n);
746 for (
short_type k = 0; k < n; ++k) p->faces[j][k] = k;
748 p->dir_points_.resize(0);
749 p->auto_basic =
true;
755 dal::PERMANENT_STATIC_OBJECT);
convenient initialization of vectors via overload of "operator,".
Definition of convex structures.
const convex_ind_ct & ind_points_of_face(short_type i) const
Give an array of the indexes of the vertices of a face.
dim_type dim() const
Dimension of the convex.
const convex_ind_ct & ind_common_points_of_faces(const std::vector< short_type > &ftab) const
Give an array of the indexes of the vertices at the intersection of a set of faces.
friend pconvex_structure basic_structure(pconvex_structure cv)
Original structure (if concerned)
short_type nb_points() const
Number of vertices.
short_type nb_faces() const
Number of faces.
base class for static stored objects
A simple singleton implementation.
Stores interdependent getfem objects.
pconvex_structure prism_incomplete_P2_structure()
Give a pointer on the 3D quadratic incomplete prism structure.
pconvex_structure pyramid_Q2_incomplete_structure()
Give a pointer on the 3D quadratic incomplete pyramid structure.
gmm::uint16_type short_type
used as the common short type integer in the library
pconvex_structure pyramid_QK_structure(dim_type k)
Give a pointer on the 3D pyramid structure for a degree k = 1 or 2.
std::ostream & operator<<(std::ostream &o, const convex_structure &cv)
Print the details of the convex structure cvs to the output stream o.
std::shared_ptr< const convex_structure > pconvex_structure
Pointer on a convex structure description.
pconvex_structure parallelepiped_structure(dim_type nc, dim_type k)
Give a pointer on the structures of a parallelepiped of dimension d.
pconvex_structure generic_dummy_structure(dim_type nc, size_type n, short_type nf)
Generic convex with n global nodes.
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...
pconvex_structure Q2_incomplete_structure(dim_type nc)
Give a pointer on the structures of a incomplete Q2 quadrilateral/hexahedral of dimension d = 2 or 3.
pconvex_structure prism_P1_structure(dim_type nc)
Give a pointer on the structures of a prism of dimension d.
pconvex_structure simplex_structure(dim_type nc)
Give a pointer on the structures of a simplex of dimension d.
size_t size_type
used as the common size type in the library
pconvex_structure polygon_structure(short_type nbt)
Give a pointer on the structures of a polygon with n vertex.
pconvex_structure convex_product_structure(pconvex_structure a, pconvex_structure b)
Give a pointer on the structures of a convex which is the direct product of the convexes represented ...
pconvex_structure basic_structure(pconvex_structure cv)
Original structure (if concerned)
size_type alpha(short_type n, short_type d)
Return the value of which is the number of monomials of a polynomial of variables and degree .
void add_stored_object(pstatic_stored_object_key k, pstatic_stored_object o, permanence perm)
Add an object with two optional dependencies.
void add_dependency(pstatic_stored_object o1, pstatic_stored_object o2)
Add a dependency, object o1 will depend on object o2.
pstatic_stored_object search_stored_object(pstatic_stored_object_key k)
Gives a pointer to an object from a key pointer.