29 typedef const fem<bgeot::polynomial_composite> *
ppolycompfem;
31 struct polynomial_composite_fem :
public fem<bgeot::polynomial_composite> {
33 mutable bgeot::mesh_precomposite mp;
35 mutable bgeot::pgeotrans_precomp pgp;
37 bgeot::pstored_point_tab pspt;
40 virtual void mat_trans(base_matrix &M,
const base_matrix &G,
44 polynomial_composite_fem(
const mesh &m_,
const mesh_fem &mf_)
45 : m(m_), mp(m), mf(m), pgp(0), pgt_stored(0) {
46 for (dal::bv_visitor cv(m.convex_index()); !cv.finished(); ++cv)
47 mf.set_finite_element(cv, mf_.fem_of_element(cv));
49 pspt = store_point_tab(m.points());
51 for (dal::bv_visitor cv(mf.convex_index()); !cv.finished(); ++cv) {
52 pfem pf1 = mf.fem_of_element(cv);
53 if (!(pf1->is_equivalent())) {
54 dal::bit_vector unshareable;
55 for (
const auto &i : mf.ind_basic_dof_of_element(cv))
58 for (dal::bv_visitor cv2(mf.convex_index()); !cv2.finished(); ++cv2) {
60 for (
const auto &i : mf.ind_basic_dof_of_element(cv2))
61 GMM_ASSERT1(!(unshareable.is_in(i)),
"Non equivalent elements "
62 "are allowed only if they do not share their dofs");
69 void polynomial_composite_fem::mat_trans(base_matrix &M,
const base_matrix &G,
71 dim_type N = dim_type(G.nrows());
75 if (pgt != pgt_stored) {
77 pgp = bgeot::geotrans_precomp(pgt, pspt, 0);
80 for (dal::bv_visitor cv(mf.convex_index()); !cv.finished(); ++cv) {
81 pfem pf1 = mf.fem_of_element(cv);
82 if (!(pf1->is_equivalent())) {
84 size_type ndof=mf.nb_basic_dof_of_element(cv);
85 GMM_ASSERT1(ndof == pf1->nb_base(0) && ndof == pf1->nb_dof(0),
86 "Sorry, limited implementation for the moment");
89 M1.resize(ndof, ndof);
91 gmm::copy(pgp->transform(m.ind_points_of_convex(cv)[i], G),
94 pf1->mat_trans(M1, G1, m.trans_of_convex(cv));
95 gmm::sub_index I(mf.ind_basic_dof_of_element(cv));
103 const mesh_fem &mf, bgeot::pconvex_ref cr,
106 GMM_ASSERT1(!mf.is_reduced(),
107 "Sorry, does not work for reduced mesh_fems");
108 auto p = std::make_shared<polynomial_composite_fem>(m, mf);
110 p->mref_convex() = cr;
111 p->dim() = cr->structure()->dim();
112 p->is_polynomialcomp() = p->is_equivalent() = p->is_standard() =
true;
113 p->is_polynomial() =
false;
114 p->is_lagrange() =
true;
115 p->estimated_degree() = 0;
118 std::vector<bgeot::polynomial_composite> base(mf.nb_basic_dof());
119 std::fill(base.begin(), base.end(),
120 bgeot::polynomial_composite(p->mp,
true, ff));
121 std::vector<pdof_description> dofd(mf.nb_basic_dof());
123 for (dal::bv_visitor cv(mf.convex_index()); !cv.finished(); ++cv) {
124 pfem pf1 = mf.fem_of_element(cv);
125 if (!pf1->is_lagrange()) p->is_lagrange() =
false;
126 if (!(pf1->is_equivalent())) p->is_equivalent() =
false;
128 GMM_ASSERT1(pf1->is_polynomial(),
"Only for polynomial fems.");
130 p->estimated_degree() = std::max(p->estimated_degree(),
131 pf->estimated_degree());
132 for (
size_type k = 0; k < pf->nb_dof(cv); ++k) {
133 size_type igl = mf.ind_basic_dof_of_element(cv)[k];
134 base_poly fu = pf->base()[k];
135 base[igl].set_poly_of_subelt(cv, fu);
136 dofd[igl] = pf->dof_types()[k];
139 p->base().resize(mf.nb_basic_dof());
140 for (
size_type k = 0; k < mf.nb_basic_dof(); ++k) {
141 p->add_node(dofd[k], mf.point_of_basic_dof(k));
142 p->base()[k] = base[k];
147 typedef dal::naming_system<virtual_fem>::param_list fem_param_list;
149 pfem structured_composite_fem_method(fem_param_list ¶ms,
150 std::vector<dal::pstatic_stored_object> &dependencies) {
151 GMM_ASSERT1(params.size() == 2,
"Bad number of parameters : "
152 << params.size() <<
" should be 2.");
153 GMM_ASSERT1(params[0].type() == 1 && params[1].type() == 0,
154 "Bad type of parameters");
155 pfem pf = params[0].method();
156 int k = int(::floor(params[1].num() + 0.01));
157 GMM_ASSERT1(((pf->is_polynomial()) || !(pf->is_equivalent())) && k > 0
158 && k <= 150 &&
double(k) == params[1].num(),
"Bad parameters");
159 bgeot::pbasic_mesh pm;
160 bgeot::pmesh_precomposite pmp;
166 mf.set_finite_element(pm->convex_index(), pf);
167 pfem p = composite_fe_method(m, mf, pf->ref_convex(0));
168 dependencies.push_back(p->ref_convex(0));
169 dependencies.push_back(p->node_tab(0));
173 pfem PK_composite_hierarch_fem(fem_param_list ¶ms,
174 std::vector<dal::pstatic_stored_object> &) {
175 GMM_ASSERT1(params.size() == 3,
"Bad number of parameters : "
176 << params.size() <<
" should be 3.");
177 GMM_ASSERT1(params[0].type() == 0 && params[1].type() == 0 &&
178 params[2].type() == 0,
"Bad type of parameters");
179 int n = int(::floor(params[0].num() + 0.01));
180 int k = int(::floor(params[1].num() + 0.01));
181 int s = int(::floor(params[2].num() + 0.01)), t;
182 GMM_ASSERT1(n > 0 && n < 100 && k > 0 && k <= 150 && s > 0 && s <= 150 &&
183 (!(s & 1) || (s == 1)) &&
double(s) == params[2].num() &&
184 double(n) == params[0].num() &&
double(k) == params[1].num(),
186 std::stringstream name;
188 name <<
"FEM_STRUCTURED_COMPOSITE(FEM_PK(" << n <<
"," << k <<
"),1)";
190 for (t = 2; t <= s; ++t)
if ((s % t) == 0)
break;
191 name <<
"FEM_GEN_HIERARCHICAL(FEM_PK_HIERARCHICAL_COMPOSITE(" << n
192 <<
"," << k <<
"," << s/t <<
"), FEM_STRUCTURED_COMPOSITE(FEM_PK("
193 << n <<
"," << k <<
")," << s <<
"))";
198 pfem PK_composite_full_hierarch_fem(fem_param_list ¶ms,
199 std::vector<dal::pstatic_stored_object> &) {
200 GMM_ASSERT1(params.size() == 3,
"Bad number of parameters : "
201 << params.size() <<
" should be 3.");
202 GMM_ASSERT1(params[0].type() == 0 && params[1].type() == 0 &&
203 params[2].type() == 0,
"Bad type of parameters");
204 int n = int(::floor(params[0].num() + 0.01));
205 int k = int(::floor(params[1].num() + 0.01));
206 int s = int(::floor(params[2].num() + 0.01)), t;
207 GMM_ASSERT1(n > 0 && n < 100 && k > 0 && k <= 150 && s > 0 && s <= 150 &&
208 (!(s & 1) || (s == 1)) &&
double(s) == params[2].num() &&
209 double(n) == params[0].num() &&
double(k) == params[1].num(),
211 std::stringstream name;
213 name <<
"FEM_STRUCTURED_COMPOSITE(FEM_PK_HIERARCHICAL(" << n <<
","
216 for (t = 2; t <= s; ++t)
if ((s % t) == 0)
break;
217 name <<
"FEM_GEN_HIERARCHICAL(FEM_PK_FULL_HIERARCHICAL_COMPOSITE(" << n
218 <<
"," << k <<
"," << s/t
219 <<
"), FEM_STRUCTURED_COMPOSITE(FEM_PK_HIERARCHICAL("
220 << n <<
"," << k <<
")," << s <<
"))";
230 struct P1bubbletriangle__ :
public fem<bgeot::polynomial_composite> {
232 bgeot::mesh_precomposite mp;
233 P1bubbletriangle__(
void);
236 P1bubbletriangle__::P1bubbletriangle__(
void) {
239 size_type i0 = m.add_point(base_node(1.0/3.0, 1.0/3.0));
240 size_type i1 = m.add_point(base_node(0.0, 0.0));
241 size_type i2 = m.add_point(base_node(1.0, 0.0));
242 size_type i3 = m.add_point(base_node(0.0, 1.0));
248 std::stringstream s(
"1-x-y;1-x-y;1-x-y;x;x;x;y;y;y;3-3*x-3*y;3*x;3*y;");
252 dim() = cr->structure()->dim();
253 is_polynomialcomp() =
true;
254 is_equivalent() =
true;
255 is_polynomial() =
false;
256 is_lagrange() =
false;
257 is_standard() =
true;
258 estimated_degree() = 3;
261 base()=std::vector<bgeot::polynomial_composite>
262 (4, bgeot::polynomial_composite(mp,
false));
268 base_node pt(0.0, 0.0);
269 if (i) pt[i-1] = 1.0;
273 add_node(bubble1_dof(2), base_node(1.0/3.0, 1.0/3.0));
277 pfem P1bubbletriangle_fem
278 (fem_param_list ¶ms,
279 std::vector<dal::pstatic_stored_object> &dependencies) {
280 GMM_ASSERT1(params.size() == 0,
"Bad number of parameters : "
281 << params.size() <<
" should be 0.");
282 pfem p = std::make_shared<P1bubbletriangle__>();
283 dependencies.push_back(p->ref_convex(0));
284 dependencies.push_back(p->node_tab(0));
292 struct HCT_triangle__ :
public fem<bgeot::polynomial_composite> {
293 virtual void mat_trans(base_matrix &M,
const base_matrix &G,
297 mutable bgeot::mesh_precomposite mp;
298 mutable bgeot::pgeotrans_precomp pgp;
299 mutable pfem_precomp pfp;
301 mutable base_matrix K;
303 HCT_triangle__(
void);
306 void HCT_triangle__::mat_trans(base_matrix &M,
const base_matrix &G,
309 dim_type N = dim_type(G.nrows());
311 GMM_ASSERT1(N == 2,
"Sorry, this version of HCT "
312 "element works only on dimension two.");
313 if (pgt != pgt_stored) {
315 pgp = bgeot::geotrans_precomp(pgt, node_tab(0), 0);
316 pfp =
fem_precomp(std::make_shared<HCT_triangle__>(), node_tab(0), 0);
322 if (i && !(pgt->is_linear()))
gmm::mult(G, pgp->grad(3*i), K);
323 gmm::copy(K, gmm::sub_matrix(M, gmm::sub_interval(1+3*i, 2)));
327 static base_matrix W(3, 12);
328 base_small_vector norient(M_PI, M_PI * M_PI);
330 for (
unsigned i = 9; i < 12; ++i) {
331 if (!(pgt->is_linear()))
334 gmm::mult(gmm::transposed(K), cvr->normals()[i-9], n);
338 if (ps < 0) n *= scalar_type(-1);
339 true_normals[i-9] = n;
341 if (gmm::abs(ps) < 1E-8)
342 GMM_WARNING2(
"HCT_triangle : "
343 "The normal orientation may be not correct");
345 const bgeot::base_tensor &t = pfp->grad(i);
347 for (
unsigned j = 0; j < 12; ++j)
348 W(i-9, j) = t(j, 0, 0) * v[0] + t(j, 0, 1) * v[1];
351 static base_matrix A(3, 3);
352 static bgeot::base_vector w(3), coeff(3);
353 static gmm::sub_interval SUBI(9, 3), SUBJ(0, 3);
354 gmm::copy(gmm::sub_matrix(W, SUBJ, SUBI), A);
356 gmm::copy(gmm::transposed(A), gmm::sub_matrix(M, SUBI));
358 for (
unsigned j = 0; j < 9; ++j) {
360 gmm::mult(A, gmm::scaled(w, -1.0), coeff);
361 gmm::copy(coeff, gmm::sub_vector(gmm::mat_row(M, j), SUBI));
365 HCT_triangle__::HCT_triangle__(
void) : pgt_stored(0), K(2, 2) {
368 size_type i0 = m.add_point(base_node(1.0/3.0, 1.0/3.0));
369 size_type i1 = m.add_point(base_node(0.0, 0.0));
370 size_type i2 = m.add_point(base_node(1.0, 0.0));
371 size_type i3 = m.add_point(base_node(0.0, 1.0));
379 (
"-1 + 9*x + 9*y - 15*x^2 - 30*x*y - 15*y^2 + 7*x^3 + 21*x^2*y + 21*x*y^2 + 7*y^3;"
380 "1 - 3*x^2 - 3*y^2 + 3*x^3 - 3*x^2*y + 2*y^3;"
381 "1 - 3*x^2 - 3*y^2 + 2*x^3 - 3*x*y^2 + 3*y^3;"
382 "-1/6 + 5/2*x - 9/2*x^2 - 4*x*y + 1/2*y^2 + 13/6*x^3 + 4*x^2*y + 3/2*x*y^2 - 1/3*y^3;"
383 "x - 1/2*x^2 - 3*x*y - 7/6*x^3 + 2*x^2*y + 2*x*y^2;"
384 "x - 2*x^2 - 3/2*y^2 + x^3 - 1/2*x*y^2 + 7/3*y^3;"
385 "-1/6 + 5/2*y + 1/2*x^2 - 4*x*y - 9/2*y^2 - 1/3*x^3 + 3/2*x^2*y + 4*x*y^2 + 13/6*y^3;"
386 "y - 3/2*x^2 - 2*y^2 + 7/3*x^3 - 1/2*x^2*y + y^3;"
387 "y - 3*x*y - 1/2*y^2 + 2*x^2*y + 2*x*y^2 - 7/6*y^3;"
388 "1 - 9/2*x - 9/2*y + 9*x^2 + 15*x*y + 6*y^2 - 9/2*x^3 - 21/2*x^2*y - 21/2*x*y^2 - 5/2*y^3;"
389 "3*x^2 - 5/2*x^3 + 3/2*x^2*y;"
390 "3*x^2 - 2*x^3 + 3/2*x*y^2 - 1/2*y^3;"
391 "-1/6 + 3/4*x + 3/4*y - 2*x^2 - 5/2*x*y - y^2 + 17/12*x^3 + 7/4*x^2*y + 7/4*x*y^2 + 5/12*y^3;"
392 "-x^2 + 13/12*x^3 - 1/4*x^2*y;"
393 "-x^2 + x^3 - 1/4*x*y^2 + 1/12*y^3;"
394 "2/3 - 13/4*x - 11/4*y + 9/2*x^2 + 19/2*x*y + 7/2*y^2 - 23/12*x^3 - 23/4*x^2*y - 25/4*x*y^2 - 17/12*y^3;"
395 "-1/2*x^2 + 5/12*x^3 + 9/4*x^2*y;"
396 "-x*y + 1/2*y^2 + 2*x^2*y + 7/4*x*y^2 - 13/12*y^3;"
397 "1 - 9/2*x - 9/2*y + 6*x^2 + 15*x*y + 9*y^2 - 5/2*x^3 - 21/2*x^2*y - 21/2*x*y^2 - 9/2*y^3;"
398 "3*y^2 - 1/2*x^3 + 3/2*x^2*y - 2*y^3;"
399 "3*y^2 + 3/2*x*y^2 - 5/2*y^3;"
400 "2/3 - 11/4*x - 13/4*y + 7/2*x^2 + 19/2*x*y + 9/2*y^2 - 17/12*x^3 - 25/4*x^2*y - 23/4*x*y^2 - 23/12*y^3;"
401 "1/2*x^2 - x*y - 13/12*x^3 + 7/4*x^2*y + 2*x*y^2;"
402 "-1/2*y^2 + 9/4*x*y^2 + 5/12*y^3;"
403 "-1/6 + 3/4*x + 3/4*y - x^2 - 5/2*x*y - 2*y^2 + 5/12*x^3 + 7/4*x^2*y + 7/4*x*y^2 + 17/12*y^3;"
404 "-y^2 + 1/12*x^3 - 1/4*x^2*y + y^3;"
405 "-y^2 - 1/4*x*y^2 + 13/12*y^3;"
406 "-sqrt(2)*2/3 + sqrt(2)*3*x + sqrt(2)*3*y - sqrt(2)*4*x^2 - sqrt(2)*10*x*y - sqrt(2)*4*y^2 + sqrt(2)*5/3*x^3 + sqrt(2)*7*x^2*y + sqrt(2)*7*x*y^2 + sqrt(2)*5/3*y^3;"
407 "sqrt(2)*1/3*x^3 - sqrt(2)*x^2*y;"
408 "-sqrt(2)*x*y^2 + sqrt(2)*1/3*y^3;"
409 "2/3 - 2*x - 4*y + 2*x^2 + 8*x*y + 6*y^2 - 2/3*x^3 - 4*x^2*y - 6*x*y^2 - 8/3*y^3;"
410 "2*x^2 - 4*x*y - 10/3*x^3 + 4*x^2*y + 4*x*y^2;"
411 "-2*y^2 + 2*x*y^2 + 8/3*y^3;"
412 "2/3 - 4*x - 2*y + 6*x^2 + 8*x*y + 2*y^2 - 8/3*x^3 - 6*x^2*y - 4*x*y^2 - 2/3*y^3;"
413 "-2*x^2 + 8/3*x^3 + 2*x^2*y;"
414 "-4*x*y + 2*y^2 + 4*x^2*y + 4*x*y^2 - 10/3*y^3;");
418 dim() = cr->structure()->dim();
419 is_polynomialcomp() =
true;
420 is_equivalent() =
false;
421 is_polynomial() =
false;
422 is_lagrange() =
false;
423 is_standard() =
false;
424 estimated_degree() = 5;
427 base()=std::vector<bgeot::polynomial_composite>
428 (12, bgeot::polynomial_composite(mp,
false));
434 base_node pt(0.0, 0.0);
435 if (i) pt[i-1] = 1.0;
446 pfem HCT_triangle_fem
447 (fem_param_list ¶ms,
448 std::vector<dal::pstatic_stored_object> &dependencies) {
449 GMM_ASSERT1(params.size() == 0,
"Bad number of parameters : "
450 << params.size() <<
" should be 0.");
451 pfem p = std::make_shared<HCT_triangle__>();
452 dependencies.push_back(p->ref_convex(0));
453 dependencies.push_back(p->node_tab(0));
462 struct reduced_HCT_triangle__ :
public fem<bgeot::polynomial_composite> {
463 const HCT_triangle__ *HCT;
464 virtual void mat_trans(base_matrix &M,
const base_matrix &G,
467 mutable base_matrix P, Mhct;
468 reduced_HCT_triangle__(
void);
471 void reduced_HCT_triangle__::mat_trans(base_matrix &M,
const base_matrix &G,
473 HCT->mat_trans(Mhct, G, pgt);
475 P(10, 1)=HCT->true_normals[1][0]*0.5; P(11, 1)=HCT->true_normals[2][0]*0.5;
476 P(10, 2)=HCT->true_normals[1][1]*0.5; P(11, 2)=HCT->true_normals[2][1]*0.5;
478 P( 9, 4)=HCT->true_normals[0][0]*0.5; P(11, 4)=HCT->true_normals[2][0]*0.5;
479 P( 9, 5)=HCT->true_normals[0][1]*0.5; P(11, 5)=HCT->true_normals[2][1]*0.5;
481 P( 9, 7)=HCT->true_normals[0][0]*0.5; P(10, 7)=HCT->true_normals[1][0]*0.5;
482 P( 9, 8)=HCT->true_normals[0][1]*0.5; P(10, 8)=HCT->true_normals[1][1]*0.5;
487 reduced_HCT_triangle__::reduced_HCT_triangle__(
void)
488 : P(12, 9), Mhct(12, 12) {
489 HCT =
dynamic_cast<const HCT_triangle__ *
>
494 dim() = cr->structure()->dim();
495 is_polynomialcomp() =
true;
496 is_equivalent() =
false;
497 is_polynomial() =
false;
498 is_lagrange() =
false;
499 is_standard() =
false;
500 estimated_degree() = 5;
501 base() = HCT->base();
507 base_node pt(0.0, 0.0);
508 if (i) pt[i-1] = 1.0;
516 pfem reduced_HCT_triangle_fem
517 (fem_param_list ¶ms,
518 std::vector<dal::pstatic_stored_object> &dependencies) {
519 GMM_ASSERT1(params.size() == 0,
"Bad number of parameters : "
520 << params.size() <<
" should be 0.");
521 pfem p = std::make_shared<reduced_HCT_triangle__>();
522 dependencies.push_back(p->ref_convex(0));
523 dependencies.push_back(p->node_tab(0));
532 struct quadc1p3__ :
public fem<bgeot::polynomial_composite> {
533 virtual void mat_trans(base_matrix &M,
const base_matrix &G,
536 mutable bgeot::mesh_precomposite mp;
537 mutable bgeot::pgeotrans_precomp pgp;
538 mutable pfem_precomp pfp;
540 mutable base_matrix K;
545 void quadc1p3__::mat_trans(base_matrix &M,
const base_matrix &G,
548 dim_type N = dim_type(G.nrows());
550 GMM_ASSERT1(N == 2,
"Sorry, this version of reduced HCT "
551 "element works only on dimension two.");
552 if (pgt != pgt_stored) {
554 pgp = bgeot::geotrans_precomp(pgt, node_tab(0), 0);
555 pfp =
fem_precomp(std::make_shared<quadc1p3__>(), node_tab(0), 0);
561 if (i && !(pgt->is_linear()))
gmm::mult(G, pgp->grad(3*i), K);
562 gmm::copy(K, gmm::sub_matrix(M, gmm::sub_interval(1+3*i, 2)));
566 static base_matrix W(4, 16);
567 base_small_vector norient(M_PI, M_PI * M_PI);
569 for (
unsigned i = 12; i < 16; ++i) {
570 if (!(pgt->is_linear()))
573 gmm::mult(gmm::transposed(K), cvr->normals()[i-12], n);
577 if (ps < 0) n *= scalar_type(-1);
578 true_normals[i-12] = n;
579 if (gmm::abs(ps) < 1E-8)
580 GMM_WARNING2(
"FVS_quadrilateral : "
581 "The normal orientation may be not correct");
583 const bgeot::base_tensor &t = pfp->grad(i);
584 for (
unsigned j = 0; j < 16; ++j)
585 W(i-12, j) = t(j, 0, 0) * v[0] + t(j, 0, 1) * v[1];
588 static base_matrix A(4, 4);
589 static bgeot::base_vector w(4), coeff(4);
590 static gmm::sub_interval SUBI(12, 4), SUBJ(0, 4);
591 gmm::copy(gmm::sub_matrix(W, SUBJ, SUBI), A);
593 gmm::copy(gmm::transposed(A), gmm::sub_matrix(M, SUBI));
595 for (
unsigned j = 0; j < 12; ++j) {
597 gmm::mult(A, gmm::scaled(w, -1.0), coeff);
598 gmm::copy(coeff, gmm::sub_vector(gmm::mat_row(M, j), SUBI));
602 quadc1p3__::quadc1p3__(
void) : pgt_stored(0), K(2, 2) {
605 size_type i0 = m.add_point(base_node(0.0, 0.0));
606 size_type i1 = m.add_point(base_node(1.0, 0.0));
607 size_type i2 = m.add_point(base_node(0.0, 1.0));
608 size_type i3 = m.add_point(base_node(1.0, 1.0));
609 size_type i4 = m.add_point(base_node(0.5, 0.5));
617 (
"2 - 3*x - 3*y + 6*x*y + x^3 - 3*x^2*y;"
618 "1 - 3*x^2 - 3*y^2 + x^3 + 3*x^2*y + 2*y^3;"
619 "2 - 3*x - 3*y + 6*x*y - 3*x*y^2 + y^3;"
620 "1 - 3*x^2 - 3*y^2 + 2*x^3 + 3*x*y^2 + y^3;"
621 "1/6 + 1/2*x - y - 3/2*x^2 + 2*x*y + 5/6*x^3 - x^2*y;"
622 "x - 1/2*x^2 - 3*x*y + 1/6*x^3 + x^2*y + 2*x*y^2;"
623 "1/6 + 1/2*x - y - x*y + 3/2*y^2 + 1/2*x*y^2 - 2/3*y^3;"
624 "x - 2*x^2 - 3/2*y^2 + x^3 + 3/2*x*y^2 + 2/3*y^3;"
625 "1/6 - x + 1/2*y + 3/2*x^2 - x*y - 2/3*x^3 + 1/2*x^2*y;"
626 "y - 3/2*x^2 - 2*y^2 + 2/3*x^3 + 3/2*x^2*y + y^3;"
627 "1/6 - x + 1/2*y + 2*x*y - 3/2*y^2 - x*y^2 + 5/6*y^3;"
628 "y - 3*x*y - 1/2*y^2 + 2*x^2*y + x*y^2 + 1/6*y^3;"
629 "-1 + 3*x + 3*y - 6*x*y - 3*y^2 - x^3 + 3*x^2*y + 2*y^3;"
630 "3*x^2 - x^3 - 3*x^2*y;"
631 "-1 + 3*x + 3*y - 6*x*y - 3*y^2 + 3*x*y^2 + y^3;"
632 "3*x^2 - 2*x^3 - 3*x*y^2 + y^3;"
633 "-2/3 + 1/2*x + 2*y - x*y - 2*y^2 + 1/6*x^3 - x^2*y + 2*x*y^2;"
634 "-x^2 + 5/6*x^3 + x^2*y;"
635 "-2/3 + 1/2*x + 2*y - x*y - 2*y^2 + 1/2*x*y^2 + 2/3*y^3;"
636 "-x^2 + x^3 + 3/2*x*y^2 - 2/3*y^3;"
637 "-5/6 + x + 5/2*y + 1/2*x^2 - 3*x*y - 2*y^2 - 2/3*x^3 + 3/2*x^2*y + y^3;"
638 "-1/2*x^2 + 2/3*x^3 + 1/2*x^2*y;"
639 "-5/6 + x + 5/2*y - 2*x*y - 5/2*y^2 + x*y^2 + 5/6*y^3;"
640 "-x*y + 1/2*y^2 + 2*x^2*y - x*y^2 + 1/6*y^3;"
641 "-1 + 3*x + 3*y - 3*x^2 - 6*x*y + x^3 + 3*x^2*y;"
642 "3*y^2 + x^3 - 3*x^2*y - 2*y^3;"
643 "-1 + 3*x + 3*y - 3*x^2 - 6*x*y + 2*x^3 + 3*x*y^2 - y^3;"
644 "3*y^2 - 3*x*y^2 - y^3;"
645 "-5/6 + 5/2*x + y - 5/2*x^2 - 2*x*y + 5/6*x^3 + x^2*y;"
646 "1/2*x^2 - x*y + 1/6*x^3 - x^2*y + 2*x*y^2;"
647 "-5/6 + 5/2*x + y - 2*x^2 - 3*x*y + 1/2*y^2 + x^3 + 3/2*x*y^2 - 2/3*y^3;"
648 "-1/2*y^2 + 1/2*x*y^2 + 2/3*y^3;"
649 "-2/3 + 2*x + 1/2*y - 2*x^2 - x*y + 2/3*x^3 + 1/2*x^2*y;"
650 "-y^2 - 2/3*x^3 + 3/2*x^2*y + y^3;"
651 "-2/3 + 2*x + 1/2*y - 2*x^2 - x*y + 2*x^2*y - x*y^2 + 1/6*y^3;"
652 "-y^2 + x*y^2 + 5/6*y^3;"
653 "1 - 3*x - 3*y + 3*x^2 + 6*x*y + 3*y^2 - x^3 - 3*x^2*y - 2*y^3;"
655 "1 - 3*x - 3*y + 3*x^2 + 6*x*y + 3*y^2 - 2*x^3 - 3*x*y^2 - y^3;"
657 "-2/3 + 3/2*x + 2*y - x^2 - 3*x*y - 2*y^2 + 1/6*x^3 + x^2*y + 2*x*y^2;"
659 "-2/3 + 3/2*x + 2*y - x^2 - 3*x*y - 2*y^2 + x^3 + 3/2*x*y^2 + 2/3*y^3;"
660 "1/2*x*y^2 - 2/3*y^3;"
661 "-2/3 + 2*x + 3/2*y - 2*x^2 - 3*x*y - y^2 + 2/3*x^3 + 3/2*x^2*y + y^3;"
662 "-2/3*x^3 + 1/2*x^2*y;"
663 "-2/3 + 2*x + 3/2*y - 2*x^2 - 3*x*y - y^2 + 2*x^2*y + x*y^2 + 1/6*y^3;"
665 "4/3 - 2*x - 4*y + 4*x*y + 4*y^2 + 2/3*x^3 - 4*x*y^2;"
667 "4/3 - 2*x - 4*y + 4*x*y + 4*y^2 - 2*x*y^2 - 4/3*y^3;"
668 "-2*x*y^2 + 4/3*y^3;"
669 "-2/3 + 2*x - 2*x^2 + 2/3*x^3;"
670 "2*x^2 - 4*x*y - 2/3*x^3 + 4*x*y^2;"
671 "-2/3 + 2*x - 4*x*y + 2*y^2 + 2*x*y^2 - 4/3*y^3;"
672 "-2*y^2 + 2*x*y^2 + 4/3*y^3;"
673 "4/3 - 4*x - 2*y + 4*x^2 + 4*x*y - 4/3*x^3 - 2*x^2*y;"
675 "4/3 - 4*x - 2*y + 4*x^2 + 4*x*y - 4*x^2*y + 2/3*y^3;"
677 "-2/3 + 2*y + 2*x^2 - 4*x*y - 4/3*x^3 + 2*x^2*y;"
678 "-2*x^2 + 4/3*x^3 + 2*x^2*y;"
679 "-2/3 + 2*y - 2*y^2 + 2/3*y^3;"
680 "-4*x*y + 2*y^2 + 4*x^2*y - 2/3*y^3;");
684 dim() = cr->structure()->dim();
685 is_polynomialcomp() =
true;
686 is_equivalent() =
false;
687 is_polynomial() =
false;
688 is_lagrange() =
false;
689 is_standard() =
false;
690 estimated_degree() = 5;
693 base()=std::vector<bgeot::polynomial_composite>
694 (16, bgeot::polynomial_composite(mp,
false));
700 base_node pt(0.0, 0.0);
701 if (i & 1) pt[0] = 1.0;
702 if (i & 2) pt[1] = 1.0;
716 (fem_param_list ¶ms,
717 std::vector<dal::pstatic_stored_object> &dependencies) {
718 GMM_ASSERT1(params.size() == 0,
"Bad number of parameters : "
719 << params.size() <<
" should be 0.");
720 pfem p = std::make_shared<quadc1p3__>();
721 dependencies.push_back(p->ref_convex(0));
722 dependencies.push_back(p->node_tab(0));
730 struct reduced_quadc1p3__ :
public fem<bgeot::polynomial_composite> {
731 const quadc1p3__ *HCT;
732 virtual void mat_trans(base_matrix &M,
const base_matrix &G,
735 mutable base_matrix P, Mhct;
736 reduced_quadc1p3__(
void);
739 void reduced_quadc1p3__::mat_trans(base_matrix &M,
const base_matrix &G,
741 HCT->mat_trans(Mhct, G, pgt);
743 P(13, 1)=HCT->true_normals[1][0]*0.5; P(15, 1)=HCT->true_normals[3][0]*0.5;
744 P(13, 2)=HCT->true_normals[1][1]*0.5; P(15, 2)=HCT->true_normals[3][1]*0.5;
746 P(12, 4)=HCT->true_normals[0][0]*0.5; P(15, 4)=HCT->true_normals[3][0]*0.5;
747 P(12, 5)=HCT->true_normals[0][1]*0.5; P(15, 5)=HCT->true_normals[3][1]*0.5;
749 P(13, 7)=HCT->true_normals[1][0]*0.5; P(14, 7)=HCT->true_normals[2][0]*0.5;
750 P(13, 8)=HCT->true_normals[1][1]*0.5; P(14, 8)=HCT->true_normals[2][1]*0.5;
752 P(12,10)=HCT->true_normals[0][0]*0.5; P(14,10)=HCT->true_normals[2][0]*0.5;
753 P(12,11)=HCT->true_normals[0][1]*0.5; P(14,11)=HCT->true_normals[2][1]*0.5;
758 reduced_quadc1p3__::reduced_quadc1p3__(
void)
759 : P(16, 12), Mhct(16, 16) {
760 HCT =
dynamic_cast<const quadc1p3__ *
>
765 dim() = cr->structure()->dim();
766 is_polynomialcomp() =
true;
767 is_equivalent() =
false;
768 is_polynomial() =
false;
769 is_lagrange() =
false;
770 is_standard() =
false;
771 estimated_degree() = 5;
772 base() = HCT->base();
778 base_node pt(0.0, 0.0);
779 if (i & 1) pt[0] = 1.0;
780 if (i & 2) pt[1] = 1.0;
788 pfem reduced_quadc1p3_fem
789 (fem_param_list ¶ms,
790 std::vector<dal::pstatic_stored_object> &dependencies) {
791 GMM_ASSERT1(params.size() == 0,
"Bad number of parameters : "
792 << params.size() <<
" should be 0.");
793 pfem p = std::make_shared<reduced_quadc1p3__>();
794 dependencies.push_back(p->ref_convex(0));
795 dependencies.push_back(p->node_tab(0));
810 pfem hho_method(fem_param_list ¶ms,
811 std::vector<dal::pstatic_stored_object> &dependencies) {
812 GMM_ASSERT1(params.size() >= 2,
"Bad number of parameters : "
813 << params.size() <<
" should be at least 2.");
814 GMM_ASSERT1(params[0].type() == 1 && params[1].type() == 1,
815 "Bad type of parameters");
816 pfem pf = params[0].method();
818 size_type nbf = pf->ref_convex(0)->structure()->nb_faces();
819 GMM_ASSERT1(pf->is_polynomial(),
"Only for polynomial elements");
821 std::vector<pfem> pff(nbf);
822 if (params.size() == 2)
823 std::fill(pff.begin(), pff.end(), params[1].method());
825 GMM_ASSERT1(params.size() == nbf+1,
"Bad number of parameters : "
826 << params.size() <<
" a single method for all the faces or "
827 " a method for each face.");
829 GMM_ASSERT1(params[i+1].type() == 1,
"Bad type of parameters");
830 GMM_ASSERT1(params[i+1].method()->is_polynomial(),
831 "Only for polynomial elements");
832 pff[i] = params[i+1].method();
837 bgeot::pbasic_mesh pm;
838 bgeot::pmesh_precomposite pmp;
842 bgeot::basic_mesh m0(*pm);
845 ipts=m0.ind_points_of_face_of_convex(0,i);
847 = m0.structure_of_convex(0)->faces_structure()[i];
848 m0.add_convex(bgeot::default_trans_of_cvs(cvs), ipts.begin());
853 bgeot::mesh_precomposite mp; mp.initialise(m1);
855 mf.set_finite_element(0, pf);
857 mf.set_finite_element(i+1, pff[i]);
859 pfem p = composite_fe_method(m1, mf, pf->ref_convex(0),
true);
860 dependencies.push_back(p->ref_convex(0));
861 dependencies.push_back(p->node_tab(0));
867 const polynomial_composite_fem *phho
868 =
dynamic_cast<const polynomial_composite_fem*
>(hho_method.get());
871 pfem pf0 = phho->mf.fem_of_element(0);
872 pfem pf1 = phho->mf.fem_of_element(1);
873 if (pf1 && (pf1->dim()+1 == pf0->dim()))
874 return phho->mf.fem_of_element(0);
Handle composite polynomials.
Describe a mesh (collection of convexes (elements) and points).
size_type add_triangle(size_type a, size_type b, size_type c)
Add a triangle to the mesh, given the point id of its vertices.
void clear()
Erase the mesh.
indexed array reference (given a container X, and a set of indexes I, this class provides a pseudo-co...
Integration methods (exact and approximated) on convexes.
Define the getfem::mesh_fem class.
void copy(const L1 &l1, L2 &l2)
*/
number_traits< typename linalg_traits< V >::value_type >::magnitude_type vect_norm2(const V &v)
Euclidean norm of a vector.
void mult(const L1 &l1, const L2 &l2, L3 &l3)
*/
strongest_value_type< V1, V2 >::value_type vect_sp(const V1 &v1, const V2 &v2)
*/
void lu_inverse(const DenseMatrixLU &LU, const Pvector &pvector, const DenseMatrix &AInv_)
Given an LU factored matrix, build the inverse of the matrix.
pdof_description derivative_dof(dim_type d, dim_type r)
Description of a unique dof of derivative type.
pdof_description lagrange_dof(dim_type d)
Description of a unique dof of lagrange type (value at the node).
pdof_description normal_derivative_dof(dim_type d)
Description of a unique dof of normal derivative type (normal derivative at the node,...
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
const fem< bgeot::polynomial_composite > * ppolycompfem
Polynomial composite FEM.
pfem fem_descriptor(const std::string &name)
get a fem descriptor from its string name.
pfem interior_fem_of_hho_method(pfem hho_method)
Specific function for a HHO method to obtain the method in the interior.
pfem_precomp fem_precomp(pfem pf, bgeot::pstored_point_tab pspt, dal::pstatic_stored_object dep)
Handles precomputations for FEM.
const fem< bgeot::base_poly > * ppolyfem
Classical polynomial FEM.
gmm::uint16_type short_type
used as the common short type integer in the library
base_poly read_base_poly(short_type n, std::istream &f)
read a base_poly on the stream ist.
pconvex_ref simplex_of_reference(dim_type nc, short_type K)
returns a simplex of reference of dimension nc and degree k
std::shared_ptr< const convex_structure > pconvex_structure
Pointer on a convex structure description.
void structured_mesh_for_convex(pconvex_ref cvr, short_type k, pbasic_mesh &pm, pmesh_precomposite &pmp, bool force_simplexification)
This function returns a mesh in pm which contains a refinement of the convex cvr if force_simplexific...
pconvex_ref parallelepiped_of_reference(dim_type nc, dim_type k)
parallelepiped of reference of dimension nc (and degree 1)
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.