18 #include "shapeset_hc_all.h"
19 #include "shapeset_hd_all.h"
20 #include "shapeset_h1_all.h"
21 #include "shapeset_l2_all.h"
22 #include "space_hcurl.h"
23 #include "space_hdiv.h"
32 unsigned g_space_seq = 0;
37 this->default_tri_order = -1;
38 this->default_quad_order = -1;
41 this->nsize = esize = 0;
42 this->ndata_allocated = 0;
44 this->seq = g_space_seq;
45 this->was_assigned = -1;
47 this->proj_mat = NULL;
49 this->vertex_functions_count = this->edge_functions_count = this->bubble_functions_count = 0;
51 if(essential_bcs != NULL)
52 for(Hermes::vector<EssentialBoundaryCondition<double>*>::const_iterator it = essential_bcs->begin(); it != essential_bcs->end(); it++)
53 for(
unsigned int i = 0; i < (*it)->markers.size(); i++)
55 if(mesh->boundary_markers_conversion.conversion_table_inverse.find((*it)->markers.at(i)) == mesh->boundary_markers_conversion.conversion_table_inverse.end() && (*it)->markers.at(i) != HERMES_ANY)
56 throw Hermes::Exceptions::Exception(
"A boundary condition defined on a non-existent marker %s.", (*it)->markers.at(i).c_str());
59 own_shapeset = (shapeset == NULL);
63 void Space<std::complex<double> >::init()
65 this->default_tri_order = -1;
66 this->default_quad_order = -1;
69 this->nsize = esize = 0;
70 this->ndata_allocated = 0;
72 this->seq = g_space_seq;
73 this->was_assigned = -1;
75 this->proj_mat = NULL;
77 this->vertex_functions_count = this->edge_functions_count = this->bubble_functions_count = 0;
79 if(essential_bcs != NULL)
80 for(Hermes::vector<EssentialBoundaryCondition<std::complex<double> >*>::const_iterator it = essential_bcs->begin(); it != essential_bcs->end(); it++)
81 for(
unsigned int i = 0; i < (*it)->markers.size(); i++)
83 if(mesh->boundary_markers_conversion.conversion_table_inverse.find((*it)->markers.at(i)) == mesh->boundary_markers_conversion.conversion_table_inverse.end() && (*it)->markers.at(i) != HERMES_ANY)
84 throw Hermes::Exceptions::Exception(
"A boundary condition defined on a non-existent marker %s.", (*it)->markers.at(i).c_str());
87 own_shapeset = (shapeset == NULL);
91 void Space<double>::free()
94 if(nsize) { ::free(ndata); nsize = 0; ndata = NULL; }
95 if(esize) { ::free(edata); edata = 0; edata = NULL; }
100 void Space<std::complex<double> >::free()
103 if(nsize) { ::free(ndata); nsize = 0; ndata = NULL; }
104 if(esize) { ::free(edata); edata = 0; edata = NULL; }
109 Space<double>::Space() : shapeset(NULL), essential_bcs(NULL), mesh(NULL)
115 Space<std::complex<double> >::Space() : shapeset(NULL), essential_bcs(NULL), mesh(NULL)
121 Space<double>::Space(
const Mesh* mesh, Shapeset* shapeset, EssentialBCs<double>* essential_bcs)
122 : shapeset(shapeset), essential_bcs(essential_bcs), mesh(mesh)
125 throw Hermes::Exceptions::NullException(0);
130 Space<std::complex<double> >::Space(
const Mesh* mesh, Shapeset* shapeset, EssentialBCs<std::complex<double> >* essential_bcs)
131 : shapeset(shapeset), essential_bcs(essential_bcs), mesh(mesh)
134 throw Hermes::Exceptions::NullException(0);
138 template<
typename Scalar>
141 if(ndata == NULL || edata == NULL || !nsize || !esize)
145 if(this->mesh == NULL)
152 throw Hermes::Exceptions::Exception(
"NULL edata detected in Space<Scalar>::get_element_order().");
156 if(!this->is_up_to_date())
158 throw Hermes::Exceptions::Exception(
"Space is not up to date.");
170 if(this->proj_mat != NULL)
171 delete [] this->proj_mat;
172 if(this->chol_p != NULL)
173 delete [] this->chol_p;
178 Space<std::complex<double> >::~Space()
182 if(this->proj_mat != NULL)
183 delete [] this->proj_mat;
184 if(this->chol_p != NULL)
185 delete [] this->chol_p;
189 template<
typename Scalar>
190 Node* Space<Scalar>::get_mid_edge_vertex_node(Element* e,
int i,
int j)
193 return e->sons[3]->vn[e->prev_vert(i)];
194 else if(e->sons[2] == NULL)
195 return i == 1 ? e->sons[0]->vn[2] : i == 3 ? e->sons[0]->vn[3] : NULL;
196 else if(e->sons[0] == NULL)
197 return i == 0 ? e->sons[2]->vn[1] : i == 2 ? e->sons[2]->vn[2] : NULL;
198 else return e->sons[i]->vn[j];
201 template<
typename Scalar>
204 if((nsize < mesh->get_max_node_id()) || (ndata == NULL))
207 nsize = mesh->get_max_node_id();
208 if((nsize > ndata_allocated) || (ndata == NULL))
210 int prev_allocated = ndata_allocated;
211 if(ndata_allocated == 0)
212 ndata_allocated = 1024;
213 while (ndata_allocated < nsize)
214 ndata_allocated = ndata_allocated * 3 / 2;
216 for(
int i = prev_allocated; i < ndata_allocated; i++)
217 ndata[i].edge_bc_proj = NULL;
221 if((esize < mesh->get_max_element_id()) || (edata == NULL))
226 while (esize < mesh->get_max_element_id())
227 esize = esize * 3 / 2;
229 for (
int i = oldsize; i < esize; i++)
231 for (
int i = oldsize; i < esize; i++)
232 edata[i].changed_in_last_adaptation =
true;
236 template<
typename Scalar>
241 this->vertex_functions_count = this->edge_functions_count = this->bubble_functions_count = 0;
244 this->shapeset = space->shapeset->clone();
246 new_mesh->
copy(space->get_mesh());
247 this->mesh = new_mesh;
249 this->resize_tables();
252 for_all_active_elements(e, this->mesh)
257 this->seq = g_space_seq++;
259 for_all_active_elements(e, this->mesh)
261 if(space->
edata[e->
id].changed_in_last_adaptation)
262 this->edata[e->
id].changed_in_last_adaptation =
true;
264 this->edata[e->
id].changed_in_last_adaptation =
false;
268 template<
typename Scalar>
271 return this->shapeset;
274 template<
typename Scalar>
281 template<
typename Scalar>
285 return next_dof - stride;
288 template<
typename Scalar>
291 return const_cast<Mesh*
>(mesh);
294 template<
typename Scalar>
297 return was_assigned == this->seq && mesh_seq == (int) mesh->
get_seq();
300 template<
typename Scalar>
304 return essential_bcs;
307 template<
typename Scalar>
310 set_element_order_internal(
id, order);
313 template<
typename Scalar>
316 if(id < 0 || id >= mesh->get_max_element_id())
317 throw Hermes::Exceptions::Exception(
"Space<Scalar>::set_element_order_internal: Invalid element id.");
321 if(mesh->get_element(
id)->is_quad() && get_type() != HERMES_L2_SPACE && H2D_GET_V_ORDER(order) == 0)
322 order = H2D_MAKE_QUAD_ORDER(order, order);
324 edata[
id].order = order;
328 template<
typename Scalar>
331 int n = spaces.size();
332 for (
int i = 0; i < n; i++)
334 if(spaces[i]->get_essential_bcs() != NULL)
336 spaces[i]->update_essential_bc_values();
340 template<
typename Scalar>
341 void Space<Scalar>::update_essential_bc_values(Space<Scalar>*s,
double time)
343 s->get_essential_bcs()->set_current_time(time);
344 s->update_essential_bc_values();
347 template<
typename Scalar>
351 for (
unsigned int i = 0; i<spaces.size(); i++)
352 ndof += spaces[i]->get_num_dofs();
356 template<
typename Scalar>
360 for (
unsigned int i = 0; i<spaces.size(); i++)
361 ndof += spaces[i]->get_num_dofs();
365 template<
typename Scalar>
371 template<
typename Scalar>
377 template<
typename Scalar>
380 int n = spaces.size();
383 for (
int i = 0; i < n; i++) {
390 template<
typename Scalar>
395 this->warn(
"Element index %d in Space<Scalar>::get_element_order() while maximum is %d.",
id, esize);
396 throw Hermes::Exceptions::Exception(
"Wrong element index in Space<Scalar>::get_element_order().");
399 return edata[
id].order;
402 template<
typename Scalar>
405 if(marker == HERMES_ANY)
406 set_uniform_order_internal(order, -1234);
408 set_uniform_order_internal(order, mesh->element_markers_conversion.get_internal_marker(marker).marker);
411 template<
typename Scalar>
415 int quad_order = H2D_MAKE_QUAD_ORDER(order, order);
418 for_all_active_elements(e, mesh)
420 if(marker == HERMES_ANY_INT || e->
marker == marker)
426 ed->order = quad_order;
432 template<
typename Scalar>
439 for_all_elements(e, mesh)
441 assert(elem_orders_[counter] >= 0 && elem_orders_[counter] <= shapeset->get_max_order());
444 ed->order = elem_orders_[counter];
446 ed->order = H2D_MAKE_QUAD_ORDER(elem_orders_[counter], elem_orders_[counter]);
451 template<
typename Scalar>
455 for_all_active_elements(e, this->get_mesh())
458 set_element_order_internal(e->
id, std::max<int>(min_order, get_element_order(e->
id) + order_change));
461 int h_order, v_order;
468 if(H2D_GET_V_ORDER(get_element_order(e->
id)) + order_change < min_order)
471 v_order = H2D_GET_V_ORDER(get_element_order(e->
id)) + order_change;
473 set_element_order_internal(e->
id, H2D_MAKE_QUAD_ORDER(h_order, v_order));
478 template<
typename Scalar>
482 for_all_active_elements(e, this->get_mesh())
486 this->warn(
"Using quad version of Space<Scalar>::adjust_element_order(), only horizontal orders will be used.");
487 set_element_order_internal(e->
id, std::max<int>(horizontal_min_order, get_element_order(e->
id) + horizontal_order_change));
490 if(get_element_order(e->
id) == -1)
491 set_element_order_internal(e->
id, H2D_MAKE_QUAD_ORDER(horizontal_min_order, vertical_min_order));
493 set_element_order_internal(e->
id, H2D_MAKE_QUAD_ORDER(std::max<int>(
H2D_GET_H_ORDER(get_element_order(e->
id)) + horizontal_order_change, horizontal_min_order), std::max<int>(H2D_GET_V_ORDER(get_element_order(e->
id)) + vertical_order_change, vertical_min_order)));
497 template<
typename Scalar>
501 for_all_active_elements(e, this->mesh)
503 if(this->get_element_order(e->
id) < 0)
504 this->set_element_order_internal(e->
id, this->get_element_order(e->
parent->
id));
508 template<
typename Scalar>
513 Hermes::vector<int> list;
515 for_all_inactive_elements(e, this->mesh)
518 for (
unsigned int i = 0; i < 4; i++)
519 if(e->
sons[i] != NULL &&
520 (!e->
sons[i]->
active || (keep_initial_refinements && e->
sons[i]->
id < this->mesh->ninitial))
522 { found =
false;
break; }
524 if(found) list.push_back(e->
id);
528 for (
unsigned int i = 0; i < list.size(); i++)
530 unsigned int order = 0, h_order = 0, v_order = 0;
531 unsigned int num_sons = 0;
532 if(this->mesh->get_element_fast(list[i])->bsplit())
535 for (
int sons_i = 0; sons_i < 4; sons_i++)
537 if(this->mesh->get_element_fast(list[i])->sons[sons_i]->active)
539 if(this->mesh->get_element_fast(list[i])->sons[sons_i]->is_triangle())
540 order += this->get_element_order(this->mesh->get_element_fast(list[i])->sons[sons_i]->id);
543 h_order +=
H2D_GET_H_ORDER(this->get_element_order(this->mesh->get_element_fast(list[i])->sons[sons_i]->id));
544 v_order += H2D_GET_V_ORDER(this->get_element_order(this->mesh->get_element_fast(list[i])->sons[sons_i]->id));
551 if(this->mesh->get_element_fast(list[i])->hsplit())
554 if(this->mesh->get_element_fast(list[i])->sons[0]->active)
556 if(this->mesh->get_element_fast(list[i])->sons[0]->is_triangle())
557 order += this->get_element_order(this->mesh->get_element_fast(list[i])->sons[0]->id);
560 h_order +=
H2D_GET_H_ORDER(this->get_element_order(this->mesh->get_element_fast(list[i])->sons[0]->id));
561 v_order += H2D_GET_V_ORDER(this->get_element_order(this->mesh->get_element_fast(list[i])->sons[0]->id));
564 if(this->mesh->get_element_fast(list[i])->sons[1]->active)
566 if(this->mesh->get_element_fast(list[i])->sons[1]->is_triangle())
567 order += this->get_element_order(this->mesh->get_element_fast(list[i])->sons[1]->id);
570 h_order +=
H2D_GET_H_ORDER(this->get_element_order(this->mesh->get_element_fast(list[i])->sons[1]->id));
571 v_order += H2D_GET_V_ORDER(this->get_element_order(this->mesh->get_element_fast(list[i])->sons[1]->id));
578 if(this->mesh->get_element_fast(list[i])->sons[2]->active)
580 if(this->mesh->get_element_fast(list[i])->sons[2]->is_triangle())
581 order += this->get_element_order(this->mesh->get_element_fast(list[i])->sons[2]->id);
584 h_order +=
H2D_GET_H_ORDER(this->get_element_order(this->mesh->get_element_fast(list[i])->sons[2]->id));
585 v_order += H2D_GET_V_ORDER(this->get_element_order(this->mesh->get_element_fast(list[i])->sons[2]->id));
588 if(this->mesh->get_element_fast(list[i])->sons[3]->active)
590 if(this->mesh->get_element_fast(list[i])->sons[3]->is_triangle())
591 order += this->get_element_order(this->mesh->get_element_fast(list[i])->sons[3]->id);
594 h_order +=
H2D_GET_H_ORDER(this->get_element_order(this->mesh->get_element_fast(list[i])->sons[3]->id));
595 v_order += H2D_GET_V_ORDER(this->get_element_order(this->mesh->get_element_fast(list[i])->sons[3]->id));
600 order = (
unsigned int)(order / num_sons);
601 h_order = (
unsigned int)(h_order / num_sons);
602 v_order = (
unsigned int)(v_order / num_sons);
604 if(this->mesh->get_element_fast(list[i])->is_triangle())
605 edata[list[i]].order = order;
607 edata[list[i]].order = H2D_MAKE_QUAD_ORDER(h_order, v_order);
608 const_cast<Mesh*
>(this->mesh)->unrefine_element_id(list[i]);
612 for_all_active_elements(e, this->mesh)
613 this->edata[e->
id].changed_in_last_adaptation =
true;
617 template<
typename Scalar>
622 template<
typename Scalar>
626 for_all_active_elements(e, coarse_space->get_mesh())
629 int coarse_element_id = e->
id;
632 int current_order = coarse_space->get_element_order(coarse_element_id);
634 if(current_order < 0)
635 throw Hermes::Exceptions::Exception(
"Source space has an uninitialized order (element id = %d)", coarse_element_id);
642 int current_order_triangular = current_order;
646 new_order = current_order_triangular + this->order_increase;
652 int current_order_quadrilateral_horizontal =
H2D_GET_H_ORDER(current_order);
654 int current_order_quadrilateral_vertical = H2D_GET_V_ORDER(current_order);
657 int new_order_quadrilateral_horizontal = current_order_quadrilateral_horizontal + this->order_increase;
658 int new_order_quadrilateral_vertical = current_order_quadrilateral_vertical + this->order_increase;
659 new_order = H2D_MAKE_QUAD_ORDER(new_order_quadrilateral_horizontal, new_order_quadrilateral_vertical);
663 ref_space->update_orders_recurrent(ref_space->
mesh->get_element(coarse_element_id), new_order);
667 template<
typename Scalar>
673 ref_space = this->init_construction_l2();
675 ref_space = this->init_construction_h1();
677 ref_space = this->init_construction_hcurl();
679 ref_space = this->init_construction_hdiv();
681 if(ref_space == NULL)
682 throw Exceptions::Exception(
"Something went wrong in ReferenceSpaceCreator::create_ref_space().");
685 this->handle_orders(ref_space);
688 this->finish_construction(ref_space);
698 template<
typename Scalar>
702 if(this->coarse_space->own_shapeset)
705 ref_space =
new L2Space<Scalar>(this->ref_mesh, 0, this->coarse_space->get_shapeset());
709 template<
typename Scalar>
713 if(this->coarse_space->own_shapeset)
720 template<
typename Scalar>
721 HcurlSpace<Scalar>* Space<Scalar>::ReferenceSpaceCreator::init_construction_hcurl()
723 HcurlSpace<Scalar>* ref_space;
724 if(this->coarse_space->own_shapeset)
725 ref_space =
new HcurlSpace<Scalar>(this->ref_mesh, this->coarse_space->
essential_bcs, 1);
727 ref_space =
new HcurlSpace<Scalar>(this->ref_mesh, this->coarse_space->essential_bcs, 1, this->coarse_space->shapeset);
731 template<
typename Scalar>
732 HdivSpace<Scalar>* Space<Scalar>::ReferenceSpaceCreator::init_construction_hdiv()
734 HdivSpace<Scalar>* ref_space;
735 if(this->coarse_space->own_shapeset)
736 ref_space =
new HdivSpace<Scalar>(this->ref_mesh, this->coarse_space->
essential_bcs, 1);
738 ref_space =
new HdivSpace<Scalar>(this->ref_mesh, this->coarse_space->essential_bcs, 1, this->coarse_space->shapeset);
742 template<
typename Scalar>
743 void Space<Scalar>::ReferenceSpaceCreator::finish_construction(Space<Scalar>* ref_space)
745 ref_space->seq = g_space_seq++;
748 for_all_active_elements(e, coarse_space->get_mesh())
750 if(this->coarse_space->edata[e->id].changed_in_last_adaptation)
752 if(ref_space->mesh->get_element(e->id)->active)
753 ref_space->edata[e->id].changed_in_last_adaptation =
true;
755 for(
unsigned int i = 0; i < 4; i++)
756 if(ref_space->mesh->get_element(e->id)->sons[i] != NULL)
757 if(ref_space->mesh->get_element(e->id)->sons[i]->active)
758 ref_space->edata[ref_space->mesh->get_element(e->id)->sons[i]->id].changed_in_last_adaptation =
true;
763 template<
typename Scalar>
764 void Space<Scalar>::update_orders_recurrent(Element* e,
int order)
767 int mo = shapeset->get_max_order();
768 int lower_limit = (
get_type() == HERMES_L2_SPACE ||
get_type() == HERMES_HCURL_SPACE) ? 0 : 1;
770 int vo = std::max(lower_limit, std::min(H2D_GET_V_ORDER(order), mo));
771 order = e->is_triangle() ? ho : H2D_MAKE_QUAD_ORDER(ho, vo);
774 edata[e->id].order = order;
776 for (
int i = 0; i < 4; i++)
777 if(e->sons[i] != NULL)
778 update_orders_recurrent(e->sons[i], order);
781 template<
typename Scalar>
785 if(en->
id >= nsize || edge >= (
int)e->get_nvert())
return 0;
788 return get_edge_order_internal(
ndata[en->
id].base);
790 return get_edge_order_internal(en);
793 template<
typename Scalar>
796 assert(en->
type == HERMES_TYPE_EDGE);
798 int o1 = 1000, o2 = 1000;
799 assert(e[0] != NULL || e[1] != NULL);
803 if(e[0]->is_triangle() || en == e[0]->en[0] || en == e[0]->en[2])
806 o1 = H2D_GET_V_ORDER(
edata[e[0]->
id].order);
811 if(e[1]->is_triangle() || en == e[1]->en[0] || en == e[1]->en[2])
814 o2 = H2D_GET_V_ORDER(
edata[e[1]->
id].order);
817 if(o1 == 0)
return o2 == 1000 ? 0 : o2;
818 if(o2 == 0)
return o1 == 1000 ? 0 : o1;
819 return std::min(o1, o2);
822 template<
typename Scalar>
825 if(this->mesh == mesh)
829 this->mesh_seq = mesh->
get_seq();
833 template<
typename Scalar>
836 this->mesh_seq = seq;
837 const_cast<Mesh*
>(this->
mesh)->set_seq(seq);
840 template<
typename Scalar>
845 template<
typename Scalar>
850 template<
typename Scalar>
856 template<
typename Scalar>
860 int* orders =
new int[num + 1];
862 for_all_active_elements(e, mesh)
865 if(e->is_triangle() && (H2D_GET_V_ORDER(p) != 0))
869 for_all_active_elements(e, mesh)
874 template<
typename Scalar>
877 if(
ndata == NULL ||
edata == NULL || !nsize || !esize)
881 if(this->mesh == NULL)
888 throw Hermes::Exceptions::Exception(
"NULL edata detected in Space<Scalar>::get_element_order().");
893 throw Hermes::Exceptions::ValueException(
"first_dof", first_dof, 0);
895 throw Hermes::Exceptions::ValueException(
"stride", stride, 1);
902 for_all_active_elements(e, mesh)
904 if(e->
id >= esize ||
edata[e->
id].order < 0)
906 printf(
"e->id = %d\n", e->
id);
907 printf(
"esize = %d\n", esize);
908 printf(
"edata[%d].order = %d\n", e->
id,
edata[e->
id].order);
910 Hermes::Exceptions::Exception(
"Uninitialized element order in Space::assign_dofs().");
912 this->
edata[e->
id].changed_in_last_adaptation =
true;
915 this->first_dof = next_dof = first_dof;
916 this->stride = stride;
919 assign_vertex_dofs();
921 assign_bubble_dofs();
928 mesh_seq = mesh->get_seq();
929 was_assigned = this->seq;
930 this->ndof = (next_dof - first_dof) / stride;
936 template<
typename Scalar>
943 for (i = 0; i < mesh->get_max_node_id(); i++)
952 for_all_active_elements(e, mesh)
954 for (
unsigned int i = 0; i < e->get_nvert(); i++)
957 if(essential_bcs != NULL)
958 if(essential_bcs->get_boundary_condition(mesh->boundary_markers_conversion.get_user_marker(e->
en[i]->
marker).marker) != NULL)
968 template<
typename Scalar>
971 return this->vertex_functions_count;
974 template<
typename Scalar>
977 return this->edge_functions_count;
980 template<
typename Scalar>
983 return this->bubble_functions_count;
986 template<
typename Scalar>
991 if(e->
id >= esize ||
edata[e->
id].order < 0)
992 throw Hermes::Exceptions::Exception(
"Uninitialized element order in get_element_assembly_list(id = #%d).", e->
id);
994 throw Hermes::Exceptions::Exception(
"The space in get_element_assembly_list() is out of date. You need to update it with assign_dofs()"
995 " any time the mesh changes.");
999 for (
unsigned int i = 0; i < e->get_nvert(); i++)
1000 get_vertex_assembly_list(e, i, al);
1001 for (
unsigned int i = 0; i < e->get_nvert(); i++)
1002 get_boundary_assembly_list_internal(e, i, al);
1003 get_bubble_assembly_list(e, al);
1004 for(
unsigned int i = 0; i < al->cnt; i++)
1006 al->dof[i] += first_dof;
1009 template<
typename Scalar>
1014 get_vertex_assembly_list(e, surf_num, al);
1015 get_vertex_assembly_list(e, e->
next_vert(surf_num), al);
1016 get_boundary_assembly_list_internal(e, surf_num, al);
1017 for(
unsigned int i = 0; i < al->cnt; i++)
1019 al->dof[i] += first_dof;
1022 template<
typename Scalar>
1026 ElementData* ed = &
edata[e->
id];
1030 int* indices = shapeset->get_bubble_indices(ed->order, e->get_mode());
1031 for (
int i = 0, dof = ed->bdof; i < ed->n; i++, dof += stride, indices++)
1032 al->add_triplet(*indices, dof, 1.0);
1035 template<
typename Scalar>
1041 template<
typename Scalar>
1044 int n = shapeset->get_max_order() + 1 - nv;
1045 mat = new_matrix<double>(n, n);
1046 int component = (
get_type() == HERMES_HDIV_SPACE) ? 1 : 0;
1049 for (
int i = 0; i < n; i++)
1051 for (
int j = i; j < n; j++)
1054 double2* pt = quad1d.get_points(o);
1055 int ii = shapeset->get_edge_index(0, 0, i + nv, HERMES_MODE_QUAD);
1056 int ij = shapeset->get_edge_index(0, 0, j + nv, HERMES_MODE_QUAD);
1058 for (
int k = 0; k < quad1d.get_num_points(o); k++)
1060 val += pt[k][1] * shapeset->get_fn_value(ii, pt[k][0], -1.0, component, HERMES_MODE_QUAD)
1061 * shapeset->get_fn_value(ij, pt[k][0], -1.0, component, HERMES_MODE_QUAD);
1071 template<
typename Scalar>
1072 void Space<Scalar>::update_edge_bc(Element* e, SurfPos* surf_pos)
1076 Node* en = e->en[surf_pos->surf_num];
1077 NodeData* nd = &
ndata[en->id];
1078 nd->edge_bc_proj = NULL;
1081 if(essential_bcs != NULL)
1083 EssentialBoundaryCondition<Scalar> *bc = this->essential_bcs->get_boundary_condition(this->mesh->boundary_markers_conversion.get_user_marker(en->marker).marker);
1086 int order = get_edge_order_internal(en);
1087 surf_pos->marker = en->marker;
1088 nd->edge_bc_proj = get_bc_projection(surf_pos, order, bc);
1089 bc_data.push_back(nd->edge_bc_proj);
1091 int i = surf_pos->surf_num, j = e->next_vert(i);
1092 ndata[e->vn[i]->id].vertex_bc_coef = nd->edge_bc_proj + 0;
1093 ndata[e->vn[j]->id].vertex_bc_coef = nd->edge_bc_proj + 1;
1100 if(mesh->get_edge_sons(e, surf_pos->surf_num, son1, son2) == 2)
1102 double mid = (surf_pos->lo + surf_pos->hi) * 0.5, tmp = surf_pos->hi;
1104 update_edge_bc(e->sons[son1], surf_pos);
1105 surf_pos->lo = mid; surf_pos->hi = tmp;
1106 update_edge_bc(e->sons[son2], surf_pos);
1109 update_edge_bc(e->sons[son1], surf_pos);
1113 template<
typename Scalar>
1117 for_all_base_elements(e, mesh)
1119 for (
unsigned int i = 0; i < e->get_nvert(); i++)
1124 SurfPos surf_pos = {0, i, e, e->
vn[i]->
id, e->vn[j]->id, 0.0, 0.0, 1.0};
1125 update_edge_bc(e, &surf_pos);
1131 template<
typename Scalar>
1134 for (
unsigned int i = 0; i <
bc_data.size(); i++)
1139 template<
typename Scalar>
1147 case HERMES_H1_SPACE:
1150 case HERMES_HCURL_SPACE:
1153 case HERMES_HDIV_SPACE:
1156 case HERMES_L2_SPACE:
1165 for_all_elements(e, this->get_mesh())
1169 space_schema_location.append(
"/space_h2d_xml.xsd");
1175 std::ofstream out(filename);
1179 XMLSpace::space_(out, xmlspace, namespace_info_map,
"UTF-8", parsing_flags);
1185 template<
typename Scalar>
1195 parsing_flags = xml_schema::flags::dont_validate;
1197 std::auto_ptr<XMLSpace::space> parsed_xml_space (
XMLSpace::space_(filename, parsing_flags));
1199 if(!strcmp(parsed_xml_space->spaceType().get().c_str(),
"h1"))
1204 if(shapeset == NULL)
1212 throw Hermes::Exceptions::SpaceLoadFailureException(
"Wrong shapeset / Wrong spaceType in the Solution XML file %s in Space::load.", filename);
1214 space->shapeset = shapeset;
1217 space->precalculate_projection_matrix(2, space->proj_mat, space->chol_p);
1219 else if (!strcmp(parsed_xml_space->spaceType().get().c_str(),
"hcurl"))
1224 if(shapeset == NULL)
1232 throw Hermes::Exceptions::Exception(
"HcurlSpace requires a vector shapeset in Space::load.");
1234 throw Hermes::Exceptions::SpaceLoadFailureException(
"Wrong shapeset / Wrong spaceType in the Solution XML file %s in Space::load.", filename);
1236 space->shapeset = shapeset;
1239 space->precalculate_projection_matrix(0, space->proj_mat, space->chol_p);
1241 else if(!!strcmp(parsed_xml_space->spaceType().get().c_str(),
"hdiv"))
1246 if(shapeset == NULL)
1254 throw Hermes::Exceptions::Exception(
"HdivSpace requires a vector shapeset in Space::load.");
1256 throw Hermes::Exceptions::SpaceLoadFailureException(
"Wrong shapeset / Wrong spaceType in the Solution XML file %s in Space::load.", filename);
1258 space->shapeset = shapeset;
1261 space->precalculate_projection_matrix(0, space->proj_mat, space->chol_p);
1263 else if(strcmp(parsed_xml_space->spaceType().get().c_str(),
"l2"))
1268 if(shapeset == NULL)
1275 throw Hermes::Exceptions::SpaceLoadFailureException(
"Wrong shapeset / Wrong spaceType in the Solution XML file %s in Space::load.", filename);
1277 space->shapeset = shapeset;
1285 throw Exceptions::SpaceLoadFailureException(
"Wrong spaceType in the Solution XML file %s in Space::load.", filename);
1290 space->mesh_seq == space->
mesh->get_seq();
1293 if(essential_bcs != NULL && parsed_xml_space->spaceType().get().c_str() !=
"l2")
1295 for(
unsigned int i = 0; i < (*it)->markers.size(); i++)
1296 if(space->get_mesh()->boundary_markers_conversion.conversion_table_inverse.find((*it)->markers.at(i)) == space->get_mesh()->boundary_markers_conversion.conversion_table_inverse.end())
1297 throw Hermes::Exceptions::Exception(
"A boundary condition defined on a non-existent marker.");
1302 unsigned int elem_data_count = parsed_xml_space->element_data().size();
1303 for (
unsigned int elem_data_i = 0; elem_data_i < elem_data_count; elem_data_i++)
1305 space->
edata[parsed_xml_space->element_data().at(elem_data_i).e_id()].order = parsed_xml_space->element_data().at(elem_data_i).ord();
1306 space->
edata[parsed_xml_space->element_data().at(elem_data_i).e_id()].bdof = parsed_xml_space->element_data().at(elem_data_i).bd();
1307 space->
edata[parsed_xml_space->element_data().at(elem_data_i).e_id()].n = parsed_xml_space->element_data().at(elem_data_i).n();
1308 space->
edata[parsed_xml_space->element_data().at(elem_data_i).e_id()].changed_in_last_adaptation = parsed_xml_space->element_data().at(elem_data_i).chgd();
1311 space->seq = g_space_seq++;
1319 throw Hermes::Exceptions::SpaceLoadFailureException(e.what());