37 GMM_ASSERT1(i <= nbpt,
"convex_structure::add_point_adaptative: " 39 if (i == nbpt) nbpt++;
41 faces[f].resize(faces[f].size() + 1);
42 (faces[f])[faces[f].size() - 1] = i;
48 std::fill(faces_struct.begin(),faces_struct.end(),
50 std::fill(faces.begin(),faces.end(), convex_ind_ct());
51 dir_points_ = convex_ind_ct();
56 (
const std::vector<short_type> &ftab)
const {
57 auto it = intersection_points.find(ftab);
58 if (it == intersection_points.end()) {
59 std::vector<size_type> cpt(
nb_points(), ftab.size());
65 if (cpt[i] == 0) ind.push_back(i);
66 it = intersection_points.emplace(ftab, ind).first;
72 o <<
"convex structure of dimension " << int(cv.
dim()) <<
" with " 80 class convex_structure_key :
virtual public dal::static_stored_object_key {
86 virtual bool compare(
const static_stored_object_key &oo)
const {
87 const convex_structure_key &o
88 =
dynamic_cast<const convex_structure_key &
>(oo);
89 if (type < o.type)
return true;
90 if (type > o.type)
return false;
91 if (N < o.N)
return true;
92 if (N > o.N)
return false;
93 if (K < o.K)
return true;
94 if (K > o.K)
return false;
95 if (nf < o.nf)
return true;
98 convex_structure_key(
int t, dim_type NN,
short_type KK = 0,
100 : type(t), N(NN), K(KK), nf(nnf) {}
110 #ifdef GETFEM_HAVE_QDLIB 115 #ifdef GETFEM_HAVE_QDLIB 117 static bool fpu_init =
false;
120 fpu_fix_start(&old_cw);
124 dal::pstatic_stored_object_key
125 pcsk = std::make_shared<convex_structure_key>(0, nc, 1);
129 auto p = std::make_shared<simplex_structure_>();
131 p->Nc = dim_type(nc); p->nbpt =
short_type(nc+1);
133 p->faces_struct.resize(p->nbf);
134 p->faces.resize(p->nbf);
135 p->dir_points_.resize(p->Nc + 1);
136 p->auto_basic =
true;
138 p->dir_points_[i] = i;
140 p->faces[i].resize(nc);
142 (p->faces[i])[j] = (j >= i) ?
short_type(j + 1) : j;
148 dal::PERMANENT_STATIC_OBJECT);
158 K_simplex_structure_(dim_type NN,
short_type KK) {
161 faces_struct.resize(nbf);
163 dir_points_.resize(Nc+1);
165 for (
int i = 0; i < nbf; i++) {
168 faces[i].resize(faces_struct[i]->
nb_points());
177 std::vector<int> pf(Nc+1); std::fill(pf.begin(), pf.end(), 0);
179 if (KK == 0) c.fill(scalar_type(1.0) / scalar_type(Nc+1));
181 for (l = 1; l <= Nc; ++l) (faces[l])[(pf[l])++] = 0;
182 dir_points_[pd++] = 0;
187 c[l] += scalar_type(1.0) / scalar_type(KK); ++sum;
189 sum -=
size_type(floor(0.5+(c[l] * KK)));
190 c[l] = 0.0; ++l; c[l] += scalar_type(1.0) / scalar_type(KK);
193 for (l = 1; l <= Nc; ++l)
194 if (c[l-1] == scalar_type(0.0)) (faces[l])[(pf[l])++] = r;
196 (faces[0])[(pf[0])++] = r;
197 if (*(std::max_element(c.begin(), c.end())) == scalar_type(1.0))
198 dir_points_[pd++] = r;
207 dal::pstatic_stored_object_key
208 pcsk = std::make_shared<convex_structure_key>(0, nc, K);
214 dal::PERMANENT_STATIC_OBJECT);
230 dal::pstatic_stored_object_key
231 pcsk = std::make_shared<convex_structure_key>(1, dim_type(nbt));
235 auto p = std::make_shared<polygon_structure_>();
237 p->Nc = 2; p->nbpt = nbt; p->nbf = nbt;
238 p->auto_basic =
true;
239 p->faces_struct.resize(p->nbf);
240 p->faces = std::vector< std::vector<short_type> >(p->nbf);
241 p->dir_points_ = std::vector<short_type>(p->Nc + 1);
243 for (
int i = 0; i < p->nbf; i++) {
245 p->faces[i] = std::vector<short_type>(2);
246 for (
int j = 0; j < 2; j++)
250 p->dir_points_[0] = 0;
251 p->dir_points_[1] = 1;
255 dal::PERMANENT_STATIC_OBJECT);
267 Nc = dim_type(cv1->dim() + cv2->dim());
268 prod_a = cv1; prod_b = cv2;
269 nbpt =
short_type(cv1->nb_points() * cv2->nb_points());
270 nbf =
short_type(cv1->nb_faces() + cv2->nb_faces());
276 faces_struct.resize(nbf);
277 faces = std::vector< std::vector<short_type> >(nbf);
279 if (cv1->ind_dir_points().size() && cv2->ind_dir_points().size()) {
280 dir_points_ = std::vector<short_type>(Nc + 1);
282 for (
int i = 0; i <= cv1->dim(); i++)
285 + cv2->ind_dir_points()[0] * cv1->nb_points());
286 for (
int i = 1; i <= cv2->dim(); i++)
287 dir_points_[cv1->dim()+i]
289 + cv2->ind_dir_points()[i] * cv1->nb_points());
292 for (
short_type i = 0; i < cv1->nb_faces(); i++) {
293 if (cv1->nb_points_of_face(i) == 1)
294 faces_struct[i] = cv2;
301 faces[i] = std::vector<short_type>(cv1->nb_points_of_face(i)
304 for (
short_type j = 0; j < cv1->nb_points_of_face(i); j++)
305 for (
short_type l = 0; l < cv2->nb_points(); l++) {
306 (faces[i])[l*cv1->nb_points_of_face(i)+j]
308 + l * cv1->nb_points());
311 for (
short_type i = 0; i < cv2->nb_faces(); i++) {
313 if (cv2->nb_points_of_face(i) == 1)
314 faces_struct[i+k] = cv1;
321 faces[i+k] = std::vector<short_type>(cv2->nb_points_of_face(i)
324 for (
short_type j = 0; j < cv2->nb_points_of_face(i); j++)
325 for (
short_type l = 0; l < cv1->nb_points(); l++) {
326 (faces[i+k])[j*cv1->nb_points()+l]
327 =
short_type(l + (cv2->ind_points_of_face(i))[j]
337 dal::pstatic_stored_object_key pcsk = std::make_shared<cv_pr_key_>(a, b);
342 for (
size_type k = 0; k < p->nb_faces(); ++k) {
343 if (exists_stored_object(p->faces_structure()[k]))
356 { DAL_STORED_OBJECT_DEBUG_CREATED(
this,
"parallelepiped structure"); }
358 { DAL_STORED_OBJECT_DEBUG_DESTROYED(
this,
"parallelepiped structure"); }
361 DAL_DOUBLE_KEY(parallelepiped_key_, dim_type, dim_type);
367 dal::pstatic_stored_object_key
368 pcsk = std::make_shared<parallelepiped_key_>(nc, k);
372 return ((std::dynamic_pointer_cast<const parallelepiped_>(o))->p);
374 auto p = std::make_shared<parallelepiped_>();
378 dal::PERMANENT_STATIC_OBJECT);
392 DAL_SIMPLE_KEY(Q2_incomplete_structure_key_, dim_type);
395 GMM_ASSERT1(nc == 2 || nc == 3,
"Bad parameter, expected value 2 or 3");
396 dal::pstatic_stored_object_key
397 pcsk = std::make_shared<Q2_incomplete_structure_key_>(nc);
401 auto p = std::make_shared<Q2_incomplete_structure_>();
404 p->nbpt = (nc == 2) ? 8 : 20;
405 p->nbf = (nc == 2) ? 4 : 6;
407 p->faces_struct.resize(p->nbf);
408 p->faces = std::vector< std::vector<short_type> >(p->nbf);
409 p->dir_points_ = std::vector<short_type>(p->Nc + 1);
417 p->faces[0] = {2,4,7};
418 p->faces[1] = {0,3,5};
419 p->faces[2] = {5,6,7};
420 p->faces[3] = {0,1,2};
422 p->dir_points_[0] = 0;
423 p->dir_points_[1] = 2;
424 p->dir_points_[2] = 5;
437 p->faces[0] = {2,4,7,9,11,14,16,19};
438 p->faces[1] = {0,3,5,8,10,12,15,17};
440 p->faces[2] = {5,6,7,10,11,17,18,19};
441 p->faces[3] = {0,1,2,8,9,12,13,14};
443 p->faces[4] = {12,13,14,15,16,17,18,19};
444 p->faces[5] = {0,1,2,3,4,5,6,7};
446 p->dir_points_[0] = 0;
447 p->dir_points_[1] = 2;
448 p->dir_points_[2] = 5;
449 p->dir_points_[3] = 12;
452 for (
int i = 0; i < p->nbf; i++) {
458 dal::PERMANENT_STATIC_OBJECT);
472 DAL_SIMPLE_KEY(pyramid_QK_structure_key_, dim_type);
475 GMM_ASSERT1(k == 1 || k == 2,
"Sorry, pyramidal elements implemented " 476 "only for degree one or two.");
477 dal::pstatic_stored_object_key
478 pcsk = std::make_shared<pyramid_QK_structure_key_>(k);
483 auto p = std::make_shared<pyramid_QK_structure_>();
487 p->dir_points_ = std::vector<short_type>(p->Nc + 1);
492 p->auto_basic =
true;
501 p->faces_struct.resize(p->nbf);
502 p->faces = std::vector< std::vector<short_type> >(p->nbf);
503 p->faces[0] = {0,1,2,3};
504 p->faces[1] = {0,1,4};
505 p->faces[2] = {1,3,4};
506 p->faces[3] = {3,2,4};
507 p->faces[4] = {2,0,4};
509 p->dir_points_[0] = 0;
510 p->dir_points_[1] = 1;
511 p->dir_points_[2] = 2;
512 p->dir_points_[3] = 4;
515 for (
int i = 1; i < p->nbf; i++)
520 dal::PERMANENT_STATIC_OBJECT);
537 p->faces_struct.resize(p->nbf);
538 p->faces = std::vector< std::vector<short_type> >(p->nbf);
539 p->faces[0] = {0,1,2,3,4,5,6,7,8};
540 p->faces[1] = {0,1,2,9,10,13};
541 p->faces[2] = {2,5,8,10,12,13};
542 p->faces[3] = {8,7,6,12,11,13};
543 p->faces[4] = {6,3,0,11,9,13};
545 p->dir_points_[0] = 0;
546 p->dir_points_[1] = 2;
547 p->dir_points_[2] = 6;
548 p->dir_points_[3] = 13;
551 for (
int i = 1; i < p->nbf; i++)
556 dal::PERMANENT_STATIC_OBJECT);
569 DAL_SIMPLE_KEY(pyramid_Q2_incomplete_structure_key_, dim_type);
572 dal::pstatic_stored_object_key
573 pcsk = std::make_shared<pyramid_Q2_incomplete_structure_key_>(0);
578 auto p = std::make_shared<pyramid_Q2_incomplete_structure_>();
582 p->dir_points_ = std::vector<short_type>(p->Nc + 1);
598 p->faces_struct.resize(p->nbf);
599 p->faces = std::vector< std::vector<short_type> >(p->nbf);
600 p->faces[0] = {0,1,2,3,4,5,6,7};
601 p->faces[1] = {0,1,2,8,9,12};
602 p->faces[2] = {2,4,7,9,11,12};
603 p->faces[3] = {7,6,5,11,10,12};
604 p->faces[4] = {5,3,0,10,8,12};
606 p->dir_points_[0] = 0;
607 p->dir_points_[1] = 2;
608 p->dir_points_[2] = 5;
609 p->dir_points_[3] = 12;
612 for (
int i = 1; i < p->nbf; i++)
617 dal::PERMANENT_STATIC_OBJECT);
629 DAL_SIMPLE_KEY(prism_incomplete_P2_structure_key_, dim_type);
632 dal::pstatic_stored_object_key
633 pcsk = std::make_shared<prism_incomplete_P2_structure_key_>(0);
638 auto p = std::make_shared<prism_incomplete_P2_structure_>();
642 p->dir_points_ = std::vector<short_type>(p->Nc + 1);
658 p->faces_struct.resize(p->nbf);
659 p->faces = std::vector< std::vector<short_type> >(p->nbf);
660 p->faces[0] = {2,4,5,7,8,11,13,14};
661 p->faces[1] = {0,3,5,6,8,9,12,14};
662 p->faces[2] = {0,1,2,6,7,9,10,11};
663 p->faces[3] = {9,10,11,12,13,14};
664 p->faces[4] = {0,1,2,3,4,5};
666 p->dir_points_[0] = 0;
667 p->dir_points_[1] = 2;
668 p->dir_points_[2] = 5;
669 p->dir_points_[3] = 9;
671 for (
int i = 0; i < 3; i++)
678 dal::PERMANENT_STATIC_OBJECT);
693 dal::pstatic_stored_object_key
694 pcsk = std::make_shared<convex_structure_key>(2, nc,
short_type(n), nf);
697 auto p = std::make_shared<dummy_structure_>();
699 p->Nc = nc; p->nbpt =
short_type(n); p->nbf = 0;
700 p->faces_struct.resize(nf);
706 p->faces[j].resize(n);
707 for (
short_type k = 0; k < n; ++k) p->faces[j][k] = k;
709 p->dir_points_.resize(0);
710 p->auto_basic =
true;
716 dal::PERMANENT_STATIC_OBJECT);
friend pconvex_structure basic_structure(pconvex_structure cv)
Original structure (if concerned)
base class for static stored objects
Stores interdependent getfem objects.
container for small vectors of POD (Plain Old Data) types.
std::ostream & operator<<(std::ostream &o, const convex_structure &cv)
Print the details of the convex structure cvs to the output stream o.
Definition of convex structures.
pconvex_structure prism_P1_structure(dim_type nc)
Give a pointer on the structures of a prism of dimension d.
pstatic_stored_object search_stored_object(pstatic_stored_object_key k)
Gives a pointer to an object from a key pointer.
std::shared_ptr< const convex_structure > pconvex_structure
Pointer on a convex structure description.
size_t size_type
used as the common size type 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.
void add_stored_object(pstatic_stored_object_key k, pstatic_stored_object o, permanence perm)
Add an object with two optional dependencies.
pconvex_structure prism_incomplete_P2_structure()
Give a pointer on the 3D quadratic incomplete prism structure.
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 ...
A simple singleton implementation.
short_type nb_points() const
Number of vertices.
void add_dependency(pstatic_stored_object o1, pstatic_stored_object o2)
Add a dependency, object o1 will depend on object o2.
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.
pconvex_structure generic_dummy_structure(dim_type nc, size_type n, short_type nf)
Generic convex with n global nodes.
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...
convenient initialization of vectors via overload of "operator,".
pconvex_structure simplex_structure(dim_type nc)
Give a pointer on the structures of a simplex of dimension d.
dim_type dim() const
Dimension of the convex.
short_type nb_faces() const
Number of faces.
const convex_ind_ct & ind_points_of_face(short_type i) const
Give an array of the indexes of the vertices of a face.
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.
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 ...
pconvex_structure polygon_structure(short_type nbt)
Give a pointer on the structures of a polygon with n vertex.
pconvex_structure pyramid_Q2_incomplete_structure()
Give a pointer on the 3D quadratic incomplete pyramid structure.