35 unsigned id, type, region;
37 std::vector<size_type> nodes;
41 pgt = bgeot::simplex_geotrans(1,1);
44 pgt = bgeot::simplex_geotrans(2,1);
47 pgt = bgeot::parallelepiped_geotrans(2,1);
50 pgt = bgeot::simplex_geotrans(3,1);
53 pgt = bgeot::parallelepiped_geotrans(3,1);
56 pgt = bgeot::prism_geotrans(3,1);
59 pgt = bgeot::pyramid_QK_geotrans(1);
62 pgt = bgeot::simplex_geotrans(1,2);
65 pgt = bgeot::simplex_geotrans(2,2);
68 pgt = bgeot::parallelepiped_geotrans(2,2);
71 pgt = bgeot::simplex_geotrans(3,2);
74 pgt = bgeot::parallelepiped_geotrans(3,2);
77 GMM_WARNING2(
"ignoring point element");
80 pgt = bgeot::Q2_incomplete_geotrans(2);
83 pgt = bgeot::Q2_incomplete_geotrans(3);
86 pgt = bgeot::simplex_geotrans(1,3);
89 pgt = bgeot::simplex_geotrans(2,3);
92 pgt = bgeot::simplex_geotrans(2, 4);
95 pgt = bgeot::simplex_geotrans(1, 4);
99 GMM_ASSERT1(
false,
"gmsh element type " << type <<
" is unknown.");
104 void set_nb_nodes() {
166 GMM_ASSERT1(
false,
"the gmsh element type " << type <<
" is unknown..");
171 bool operator<(
const gmsh_cv_info& other)
const {
172 unsigned this_dim = (type == 15) ? 0 : pgt->dim();
173 unsigned other_dim = (other.type == 15) ? 0 : other.pgt->dim();
174 if (this_dim == other_dim)
return region < other.region;
175 return this_dim > other_dim;
181 std::map<std::string, size_type> region_map;
182 bgeot::read_until(f,
"$PhysicalNames");
186 std::string region_name;
187 for (
size_type region_cnt=0; region_cnt < nb_regions; ++ region_cnt) {
189 std::getline(f, region_name);
191 size_t pos = region_name.find_first_of(
"\"");
192 if (pos != region_name.npos) {
193 region_name.erase(0, pos+1);
194 pos = region_name.find_last_of(
"\"");
195 region_name.erase(pos);
197 region_map[region_name] = ri;
223 static void import_gmsh_mesh_file(std::istream& f,
mesh& m,
int deprecate=0,
224 std::map<std::string, size_type> *region_map=NULL,
225 std::set<size_type> *lower_dim_convex_rg=NULL,
226 bool add_all_element_type =
false,
227 bool remove_last_dimension =
true,
228 std::map<
size_type, std::set<size_type>> *nodal_map = NULL,
229 bool remove_duplicated_nodes =
true)
231 gmm::stream_standard_locale sl(f);
233 GMM_WARNING3(
" All regions must have different number!");
237 GMM_WARNING4(
"" << endl
238 <<
" deprecate: " << endl
239 <<
" static void" << endl
240 <<
" import_gmsh_mesh_file(std::istream& f," 241 <<
" mesh& , int version)" << endl
242 <<
" replace with:" << endl
243 <<
" static void" << endl
244 <<
" import_gmsh_mesh_file(std::istream& f," 252 if (bgeot::casecmp(header,
"$MeshFormat")==0)
254 else if (bgeot::casecmp(header,
"$NOD")==0)
257 GMM_ASSERT1(
false,
"can't read Gmsh format: " << header);
260 if (region_map != NULL) {
267 bgeot::read_until(f,
"$Nodes");
272 std::map<size_type, size_type> msh_node_2_getfem_node;
273 for (
size_type node_cnt=0; node_cnt < nb_node; ++node_cnt) {
275 base_node n(3); n[0]=n[1]=n[2]=0.0;
276 f >> node_id >> n[0] >> n[1] >> n[2];
277 msh_node_2_getfem_node[node_id] = m.add_point(n, 0.0, remove_duplicated_nodes);
281 bgeot::read_until(f,
"$Endnodes");
283 bgeot::read_until(f,
"$ENDNOD");
287 bgeot::read_until(f,
"$Elements");
289 bgeot::read_until(f,
"$ELM");
293 std::vector<gmsh_cv_info> cvlst; cvlst.reserve(nb_cv);
295 unsigned id, type, region;
296 unsigned dummy, cv_nb_nodes;
299 unsigned nbtags, mesh_part;
300 f >>
id >> type >> nbtags;
301 if (nbtags == 0 || nbtags > 3)
302 GMM_ASSERT1(
false,
"Number of tags " << nbtags
303 <<
" is not managed.");
306 if (nbtags > 1) f >> dummy;
307 if (nbtags > 2) f >> mesh_part;
310 f >>
id >> type >> region >> dummy >> cv_nb_nodes;
314 cvlst.push_back(gmsh_cv_info());
315 gmsh_cv_info &ci = cvlst.back();
316 ci.id = id; ci.type = type; ci.region = region;
321 cv_nb_nodes = unsigned(ci.nodes.size());
324 ci.nodes.resize(cv_nb_nodes);
328 for (
size_type i=0; i < cv_nb_nodes; ++i) {
331 std::map<size_type, size_type>::iterator
332 it = msh_node_2_getfem_node.find(j);
333 GMM_ASSERT1(it != msh_node_2_getfem_node.end(),
334 "Invalid node ID " << j <<
" in gmsh element " 336 ci.nodes[i] = it->second;
338 if(ci.type != 15) ci.set_pgt();
341 std::vector<size_type> tmp_nodes(ci.nodes);
344 ci.nodes[2] = tmp_nodes[3];
345 ci.nodes[3] = tmp_nodes[2];
350 ci.nodes[2] = tmp_nodes[3];
351 ci.nodes[3] = tmp_nodes[2];
354 ci.nodes[6] = tmp_nodes[7];
355 ci.nodes[7] = tmp_nodes[6];
359 ci.nodes[1] = tmp_nodes[2];
360 ci.nodes[2] = tmp_nodes[1];
366 ci.nodes[1] = tmp_nodes[2];
367 ci.nodes[2] = tmp_nodes[1];
371 ci.nodes[1] = tmp_nodes[3];
372 ci.nodes[2] = tmp_nodes[1];
373 ci.nodes[3] = tmp_nodes[5];
375 ci.nodes[5] = tmp_nodes[2];
379 ci.nodes[1] = tmp_nodes[4];
380 ci.nodes[2] = tmp_nodes[1];
381 ci.nodes[3] = tmp_nodes[7];
382 ci.nodes[4] = tmp_nodes[8];
384 ci.nodes[6] = tmp_nodes[3];
385 ci.nodes[7] = tmp_nodes[6];
386 ci.nodes[8] = tmp_nodes[2];
390 ci.nodes[1] = tmp_nodes[4];
391 ci.nodes[2] = tmp_nodes[1];
392 ci.nodes[3] = tmp_nodes[6];
393 ci.nodes[4] = tmp_nodes[5];
394 ci.nodes[5] = tmp_nodes[2];
395 ci.nodes[6] = tmp_nodes[7];
396 ci.nodes[7] = tmp_nodes[9];
398 ci.nodes[9] = tmp_nodes[3];
402 ci.nodes[1] = tmp_nodes[8];
403 ci.nodes[2] = tmp_nodes[1];
404 ci.nodes[3] = tmp_nodes[9];
405 ci.nodes[4] = tmp_nodes[20];
406 ci.nodes[5] = tmp_nodes[11];
407 ci.nodes[6] = tmp_nodes[3];
408 ci.nodes[7] = tmp_nodes[13];
409 ci.nodes[8] = tmp_nodes[2];
410 ci.nodes[9] = tmp_nodes[10];
411 ci.nodes[10] = tmp_nodes[21];
412 ci.nodes[11] = tmp_nodes[12];
413 ci.nodes[12] = tmp_nodes[22];
414 ci.nodes[13] = tmp_nodes[26];
415 ci.nodes[14] = tmp_nodes[23];
417 ci.nodes[16] = tmp_nodes[24];
418 ci.nodes[17] = tmp_nodes[14];
419 ci.nodes[18] = tmp_nodes[4];
420 ci.nodes[19] = tmp_nodes[16];
421 ci.nodes[20] = tmp_nodes[5];
422 ci.nodes[21] = tmp_nodes[17];
423 ci.nodes[22] = tmp_nodes[25];
424 ci.nodes[23] = tmp_nodes[18];
425 ci.nodes[24] = tmp_nodes[7];
426 ci.nodes[25] = tmp_nodes[19];
427 ci.nodes[26] = tmp_nodes[6];
431 ci.nodes[1] = tmp_nodes[4];
432 ci.nodes[2] = tmp_nodes[1];
433 ci.nodes[3] = tmp_nodes[7];
434 ci.nodes[4] = tmp_nodes[5];
435 ci.nodes[5] = tmp_nodes[3];
436 ci.nodes[6] = tmp_nodes[6];
437 ci.nodes[7] = tmp_nodes[2];
441 ci.nodes[1] = tmp_nodes[8];
442 ci.nodes[2] = tmp_nodes[1];
443 ci.nodes[3] = tmp_nodes[9];
444 ci.nodes[4] = tmp_nodes[11];
445 ci.nodes[5] = tmp_nodes[3];
446 ci.nodes[6] = tmp_nodes[13];
447 ci.nodes[7] = tmp_nodes[2];
448 ci.nodes[8] = tmp_nodes[10];
449 ci.nodes[9] = tmp_nodes[12];
450 ci.nodes[10] = tmp_nodes[15];
451 ci.nodes[11] = tmp_nodes[14];
452 ci.nodes[12] = tmp_nodes[4];
453 ci.nodes[13] = tmp_nodes[16];
454 ci.nodes[14] = tmp_nodes[5];
455 ci.nodes[15] = tmp_nodes[17];
456 ci.nodes[16] = tmp_nodes[18];
457 ci.nodes[17] = tmp_nodes[7];
458 ci.nodes[18] = tmp_nodes[19];
459 ci.nodes[19] = tmp_nodes[6];
463 ci.nodes[1] = tmp_nodes[2];
464 ci.nodes[2] = tmp_nodes[3];
465 ci.nodes[3] = tmp_nodes[1];
469 ci.nodes[1] = tmp_nodes[3];
470 ci.nodes[2] = tmp_nodes[4];
471 ci.nodes[3] = tmp_nodes[1];
472 ci.nodes[4] = tmp_nodes[8];
473 ci.nodes[5] = tmp_nodes[9];
474 ci.nodes[6] = tmp_nodes[5];
476 ci.nodes[8] = tmp_nodes[6];
477 ci.nodes[9] = tmp_nodes[2];
481 ci.nodes[1] = tmp_nodes[3];
482 ci.nodes[2] = tmp_nodes[4];
483 ci.nodes[3] = tmp_nodes[5];
484 ci.nodes[4] = tmp_nodes[1];
485 ci.nodes[5] = tmp_nodes[11];
486 ci.nodes[6] = tmp_nodes[12];
487 ci.nodes[7] = tmp_nodes[13];
488 ci.nodes[8] = tmp_nodes[6];
489 ci.nodes[9] = tmp_nodes[10];
490 ci.nodes[10] = tmp_nodes[14];
491 ci.nodes[11] = tmp_nodes[7];
492 ci.nodes[12] = tmp_nodes[9];
493 ci.nodes[13] = tmp_nodes[8];
494 ci.nodes[14] = tmp_nodes[2];
498 ci.nodes[1] = tmp_nodes[2];
499 ci.nodes[2] = tmp_nodes[3];
500 ci.nodes[3] = tmp_nodes[4];
501 ci.nodes[4] = tmp_nodes[1];
505 nb_cv = cvlst.size();
507 std::sort(cvlst.begin(), cvlst.end());
508 if (cvlst.front().type == 15){
509 GMM_WARNING2(
"Only nodes defined in the mesh! No elements are added.");
513 unsigned N = cvlst.front().pgt->dim();
516 gmsh_cv_info &ci = cvlst[cv];
517 bool is_node = (ci.type == 15);
518 unsigned ci_dim = (is_node) ? 0 : ci.pgt->dim();
526 m.
region(ci.region).add(ic);
533 if (lower_dim_convex_rg != NULL &&
534 lower_dim_convex_rg->find(ci.region) != lower_dim_convex_rg->end() &&
537 m.
region(ci.region).add(ic);
542 for (bgeot::mesh_structure::ind_cv_ct::const_iterator
543 it = ct.begin(); it != ct.end(); ++it) {
549 m.
region(ci.region).add(*it,face);
554 if (is_node && (nodal_map != NULL)) (*nodal_map)[ci.region].insert(ci.id);
560 if (nodal_map == NULL){
561 GMM_WARNING2(
"gmsh import ignored a node id: " 562 << ci.id <<
" region :" << ci.region <<
563 " point is not added explicitly as an element.");
566 else if (add_all_element_type){
568 m.
region(ci.region).add(ic);
572 GMM_WARNING2(
"gmsh import ignored an element of type " 574 " as it does not belong to the face of another element");
588 static void import_gid_mesh_file(std::istream& f,
mesh& m) {
589 gmm::stream_standard_locale sl(f);
592 enum { LIN,TRI,QUAD,TETR, PRISM, HEX,BADELTYPE } eltype=BADELTYPE;
594 std::map<size_type, size_type> msh_node_2_getfem_node;
595 std::vector<size_type> cv_nodes, getfem_cv_nodes;
596 bool nodes_done =
false;
598 if (!f.eof()) f >> std::ws;
599 if (f.eof() || !bgeot::read_until(f,
"MESH"))
break;
600 std::string selemtype;
601 f >> bgeot::skip(
"DIMENSION") >> dim
602 >> bgeot::skip(
"ELEMTYPE") >> std::ws
604 >> bgeot::skip(
"NNODE") >> nnode;
605 if (bgeot::casecmp(selemtype,
"linear")==0) { eltype = LIN; }
606 else if (bgeot::casecmp(selemtype,
"triangle")==0) { eltype = TRI; }
607 else if (bgeot::casecmp(selemtype,
"quadrilateral")==0) { eltype = QUAD; }
608 else if (bgeot::casecmp(selemtype,
"tetrahedra")==0) { eltype = TETR; }
609 else if (bgeot::casecmp(selemtype,
"prisma")==0) { eltype = PRISM; }
610 else if (bgeot::casecmp(selemtype,
"hexahedra")==0) { eltype = HEX; }
611 else GMM_ASSERT1(
false,
"unknown element type '"<< selemtype <<
"'");
612 GMM_ASSERT1(!f.eof(),
"File ended before coordinates");
613 f >> bgeot::skip(
"COORDINATES");
616 dal::bit_vector gid_nodes_used;
622 if (bgeot::casecmp(ls,
"END COORDINATES", 15)==0)
break;
623 std::stringstream s; s << ls;
627 gid_nodes[id].resize(dim); gid_nodes_used.add(
id);
628 for (
size_type i=0; i < dim; ++i) s >> gid_nodes[id][i];
632 GMM_ASSERT1(gid_nodes_used.card() != 0,
"no nodes in the mesh!");
635 std::vector<bool> direction_useless(3,
true);
636 base_node first_pt = gid_nodes[gid_nodes_used.first()];
637 for (dal::bv_visitor ip(gid_nodes_used); !ip.finished(); ++ip) {
638 for (
size_type j=0; j < first_pt.size(); ++j) {
639 if (direction_useless[j] && (gmm::abs(gid_nodes[ip][j]-first_pt[j]) > 1e-13))
640 direction_useless[j] =
false;
644 for (
size_type j=0; j < dim; ++j)
if (!direction_useless[j]) dim2++;
645 for (dal::bv_visitor ip(gid_nodes_used); !ip.finished(); ++ip) {
647 for (
size_type j=0, cnt=0; j < dim; ++j)
if (!direction_useless[j]) n[cnt++]=gid_nodes[ip][j];
648 msh_node_2_getfem_node[ip] = m.add_point(n);
652 bgeot::read_until(f,
"ELEMENTS");
654 std::vector<size_type> order(nnode);
655 for (
size_type i=0; i < nnode; ++i) order[i]=i;
659 if (nnode == 2) pgt = bgeot::simplex_geotrans(1,1);
660 else if (nnode == 3) {
661 pgt = bgeot::simplex_geotrans(1,2);
662 std::swap(order[1],order[2]);
666 if (nnode == 3) pgt = bgeot::simplex_geotrans(2,1);
667 else if (nnode == 6) {
668 static size_type lorder[6] = {0,3,1,5,4,2};
669 pgt = bgeot::simplex_geotrans(2,2);
670 std::copy(lorder,lorder+nnode,order.begin());
674 if (nnode == 4) pgt = bgeot::parallelepiped_geotrans(2,1);
675 else if (nnode == 9) {
676 static size_type lorder[9] = {0,4,1, 7,8,5, 3,6,2};
677 pgt = bgeot::parallelepiped_geotrans(2,2);
678 std::copy(lorder,lorder+nnode,order.begin());
682 if (nnode == 4) pgt = bgeot::simplex_geotrans(3,1);
683 else if (nnode == 10) {
684 static size_type lorder[10] = {0,4,1, 7,8, 3, 6, 5, 9, 2};
685 pgt = bgeot::simplex_geotrans(3,2);
686 std::copy(lorder,lorder+nnode,order.begin());
690 if (nnode == 6) pgt = bgeot::prism_geotrans(3,1);
693 if (nnode == 8) pgt = bgeot::parallelepiped_geotrans(3,1);
694 else if (nnode == 27) {
695 static size_type lorder[27] = {0,8,1, 12,21,13, 4,16,5,
696 11,20,9, 22,26,24, 19,25,17,
697 3,10,2, 15,23,14, 7,18,6};
698 pgt = bgeot::parallelepiped_geotrans(3,2);
699 std::copy(lorder,lorder+nnode,order.begin());
702 default: GMM_ASSERT1(
false,
"");
break;
704 GMM_ASSERT1(pgt != NULL,
"unknown element type " << selemtype
705 <<
" with " << nnode <<
"nodes");
710 if (bgeot::casecmp(ls,
"END ELEMENTS", 12)==0)
break;
711 std::stringstream s; s << ls;
714 cv_nodes.resize(nnode);
718 std::map<size_type, size_type>::iterator
719 it = msh_node_2_getfem_node.find(j);
720 GMM_ASSERT1(it != msh_node_2_getfem_node.end(),
721 "Invalid node ID " << j <<
" in GiD element " << cv_id);
722 cv_nodes[i] = it->second;
724 getfem_cv_nodes.resize(nnode);
726 getfem_cv_nodes[i] = cv_nodes[order[i]];
744 static void import_cdb_mesh_file(std::istream& f,
mesh& m,
747 std::map<size_type, size_type> cdb_node_2_getfem_node;
748 std::vector<size_type> getfem_cv_nodes;
749 std::vector<std::string> elt_types;
750 std::vector<size_type> elt_cnt;
751 std::vector<dal::bit_vector> regions;
756 std::getline(f,line);
757 pos = line.find_first_not_of(
" ");
758 if (bgeot::casecmp(line.substr(pos,2),
"ET") == 0) {
760 std::string type_name;
761 pos = line.find_first_of(
",")+1;
762 pos2 = line.find_first_of(
",", pos);
763 itype = std::stol(line.substr(pos, pos2-pos));
764 pos = line.find_first_not_of(
" ,\n\r\t", pos2);
765 pos2 = line.find_first_of(
" ,\n\r\t", pos);
766 type_name = line.substr(pos, pos2-pos);
768 = (type_name.find_first_not_of(
"0123456789") == std::string::npos);
769 const std::locale loc;
770 for (
auto&& c : type_name) c = std::toupper(c, loc);
772 if (elt_types.size() < itype+1)
773 elt_types.resize(itype+1);
775 elt_types[itype] =
"";
777 size_type type_num = std::stol(type_name);
778 if (type_num == 42 || type_num == 82 ||
779 type_num == 182 || type_num == 183)
780 elt_types[itype] =
"PLANE";
781 else if (type_num == 45 || type_num == 73 || type_num == 87 ||
782 type_num == 90 || type_num == 92 || type_num == 95 ||
783 type_num == 162 || type_num == 185 || type_num == 186 ||
784 type_num == 187 || type_num == 191)
785 elt_types[itype] =
"SOLID";
786 else if (type_num == 89)
787 elt_types[itype] =
"VISCO";
789 elt_types[itype].append(type_name);
791 else if (bgeot::casecmp(line.substr(pos,5),
"KEYOP") == 0) {
793 pos = line.find_first_of(
",")+1;
794 pos2 = line.find_first_of(
",", pos);
795 itype = std::stol(line.substr(pos, pos2-pos));
797 pos2 = line.find_first_of(
",", pos);
798 knum = std::stol(line.substr(pos+1, pos2-pos));
799 keyval = std::stol(line.substr(pos2+1));
800 if (knum == 1 && itype < elt_types.size() &&
801 elt_types[itype].size() == 7 &&
802 bgeot::casecmp(elt_types[itype].substr(0,7),
"MESH200") == 0) {
803 std::stringstream ss(
"MESH200");
805 elt_types[itype] = ss.str();
808 else if (bgeot::casecmp(line.substr(pos,6),
"NBLOCK") == 0)
813 elt_cnt.resize(elt_types.size());
816 size_type fields1, fieldwidth1, fields2, fieldwidth2;
818 std::string fortran_fmt;
819 std::getline(f,fortran_fmt);
820 pos = fortran_fmt.find_first_of(
"(")+1;
821 pos2 = fortran_fmt.find_first_of(
"iI", pos);
822 fields1 = std::stol(fortran_fmt.substr(pos, pos2-pos));
824 pos2 = fortran_fmt.find_first_of(
",", pos);
825 fieldwidth1 = std::stol(fortran_fmt.substr(pos, pos2-pos));
827 pos2 = fortran_fmt.find_first_of(
"eE", pos);
828 fields2 = std::stol(fortran_fmt.substr(pos, pos2-pos));
830 pos2 = fortran_fmt.find_first_of(
".", pos);
831 fieldwidth2 = std::stol(fortran_fmt.substr(pos, pos2-pos));
832 GMM_ASSERT1(fields1 >= 1 && fields2 >= 3 ,
833 "Ansys mesh import routine requires NBLOCK entries with at least " 834 "1 integer field and 3 float number fields");
840 std::getline(f,line);
841 if (line.compare(0,1,
"N") == 0)
844 nodeid = std::stol(line.substr(0, fieldwidth1));
845 pos = fields1*fieldwidth1;
846 for (size_type j=0; j < 3; ++j, pos += fieldwidth2)
847 pt[j] = std::stod(line.substr(pos, fieldwidth2));
849 cdb_node_2_getfem_node[nodeid] = m.add_point(pt, 0.,
false);
852 while (bgeot::casecmp(line.substr(0,6),
"EBLOCK") != 0) {
855 std::getline(f,line);
860 size_type fieldsno, fieldwidth;
862 std::string fortran_fmt;
863 std::getline(f,fortran_fmt);
865 pos = fortran_fmt.find_first_of(
"(")+1;
866 pos2 = fortran_fmt.find_first_of(
"iI", pos);
867 fieldsno = std::stol(fortran_fmt.substr(pos, pos2-pos));
869 pos2 = fortran_fmt.find_first_of(
")\n", pos);
870 fieldwidth = std::stol(fortran_fmt.substr(pos, pos2-pos));
871 GMM_ASSERT1(fieldsno == 19,
"Ansys mesh import routine requires EBLOCK " 872 "entries with 19 fields");
875 size_type II,JJ,KK,LL,MM,NN,OO,PP,QQ,RR,SS,TT,UU,VV,WW,XX,YY,ZZ,AA,BB;
876 for (size_type i=0; i <
size_type(-1); ++i) {
877 GMM_ASSERT1(!f.eof(),
"File ended before all elements could be read");
878 size_type imat, itype, nodesno(0);
879 std::getline(f,line);
881 long int ii = std::stol(line.substr(0,fieldwidth));
887 itype = std::stol(line.substr(fieldwidth,fieldwidth));
888 nodesno = std::stol(line.substr(8*fieldwidth,fieldwidth));
889 line = line.substr(11*fieldwidth);
891 if (imat_filt !=
size_type(-1) && imat != imat_filt) {
893 std::getline(f,line);
897 if (nodesno >= 1) II = std::stol(line.substr(0,fieldwidth));
898 if (nodesno >= 2) JJ = std::stol(line.substr(1*fieldwidth,fieldwidth));
899 if (nodesno >= 3) KK = std::stol(line.substr(2*fieldwidth,fieldwidth));
900 if (nodesno >= 4) LL = std::stol(line.substr(3*fieldwidth,fieldwidth));
901 if (nodesno >= 5) MM = std::stol(line.substr(4*fieldwidth,fieldwidth));
902 if (nodesno >= 6) NN = std::stol(line.substr(5*fieldwidth,fieldwidth));
903 if (nodesno >= 7) OO = std::stol(line.substr(6*fieldwidth,fieldwidth));
904 if (nodesno >= 8) PP = std::stol(line.substr(7*fieldwidth,fieldwidth));
906 std::getline(f,line);
907 if (nodesno >= 9) QQ = std::stol(line.substr(0,fieldwidth));
908 if (nodesno >= 10) RR = std::stol(line.substr(1*fieldwidth,fieldwidth));
909 if (nodesno >= 11) SS = std::stol(line.substr(2*fieldwidth,fieldwidth));
910 if (nodesno >= 12) TT = std::stol(line.substr(3*fieldwidth,fieldwidth));
911 if (nodesno >= 13) UU = std::stol(line.substr(4*fieldwidth,fieldwidth));
912 if (nodesno >= 14) VV = std::stol(line.substr(5*fieldwidth,fieldwidth));
913 if (nodesno >= 15) WW = std::stol(line.substr(6*fieldwidth,fieldwidth));
914 if (nodesno >= 16) XX = std::stol(line.substr(7*fieldwidth,fieldwidth));
915 if (nodesno >= 17) YY = std::stol(line.substr(8*fieldwidth,fieldwidth));
916 if (nodesno >= 18) ZZ = std::stol(line.substr(9*fieldwidth,fieldwidth));
917 if (nodesno >= 19) AA = std::stol(line.substr(10*fieldwidth,fieldwidth));
918 if (nodesno >= 20) BB = std::stol(line.substr(11*fieldwidth,fieldwidth));
921 if (imat+1 > regions.size())
922 regions.resize(imat+1);
927 else if (nodesno == 4) {
930 std::string eltname(
"MESH200_6");
931 if (elt_types.size() > itype && elt_types[itype].size() > 0)
932 eltname = elt_types[itype];
934 if (eltname.compare(
"MESH200_6") == 0 ||
935 eltname.compare(
"PLANE42") == 0 ||
936 eltname.compare(
"PLANE182") == 0) {
937 getfem_cv_nodes.resize(4);
938 getfem_cv_nodes[0] = cdb_node_2_getfem_node[II];
939 getfem_cv_nodes[1] = cdb_node_2_getfem_node[JJ];
940 getfem_cv_nodes[2] = cdb_node_2_getfem_node[LL];
941 getfem_cv_nodes[3] = cdb_node_2_getfem_node[KK];
942 regions[imat].add(m.
add_convex(bgeot::parallelepiped_geotrans(2,1),
943 getfem_cv_nodes.begin()));
944 if (itype < elt_cnt.size())
947 else if (eltname.compare(
"MESH200_8") == 0 ||
948 eltname.compare(
"SOLID72") == 0) {
949 getfem_cv_nodes.resize(4);
950 getfem_cv_nodes[0] = cdb_node_2_getfem_node[II];
951 getfem_cv_nodes[1] = cdb_node_2_getfem_node[JJ];
952 getfem_cv_nodes[2] = cdb_node_2_getfem_node[KK];
953 getfem_cv_nodes[3] = cdb_node_2_getfem_node[LL];
954 regions[imat].add(m.
add_convex(bgeot::simplex_geotrans(3,1),
955 getfem_cv_nodes.begin()));
956 if (itype < elt_cnt.size())
960 else if (nodesno == 6) {
963 else if (nodesno == 8) {
966 std::string eltname(
"MESH200_10");
967 if (elt_types.size() > itype && elt_types[itype].size() > 0)
968 eltname = elt_types[itype];
970 if (eltname.compare(
"MESH200_7") == 0 ||
971 eltname.compare(
"PLANE82") == 0 ||
972 eltname.compare(
"PLANE183") == 0) {
973 getfem_cv_nodes.resize(8);
974 getfem_cv_nodes[0] = cdb_node_2_getfem_node[II];
975 getfem_cv_nodes[1] = cdb_node_2_getfem_node[MM];
976 getfem_cv_nodes[2] = cdb_node_2_getfem_node[JJ];
977 getfem_cv_nodes[3] = cdb_node_2_getfem_node[PP];
978 getfem_cv_nodes[4] = cdb_node_2_getfem_node[NN];
979 getfem_cv_nodes[5] = cdb_node_2_getfem_node[LL];
980 getfem_cv_nodes[6] = cdb_node_2_getfem_node[OO];
981 getfem_cv_nodes[7] = cdb_node_2_getfem_node[KK];
982 regions[imat].add(m.
add_convex(bgeot::Q2_incomplete_geotrans(2),
983 getfem_cv_nodes.begin()));
984 if (itype < elt_cnt.size())
987 else if (eltname.compare(
"MESH200_10") == 0 ||
988 eltname.compare(
"SOLID45") == 0 ||
989 eltname.compare(
"SOLID185") == 0) {
990 if (KK == LL && OO == PP) {
991 if (MM == NN && NN == OO) {
992 getfem_cv_nodes.resize(4);
993 getfem_cv_nodes[0] = cdb_node_2_getfem_node[II];
994 getfem_cv_nodes[1] = cdb_node_2_getfem_node[JJ];
995 getfem_cv_nodes[2] = cdb_node_2_getfem_node[KK];
996 getfem_cv_nodes[3] = cdb_node_2_getfem_node[MM];
997 regions[imat].add(m.
add_convex(bgeot::simplex_geotrans(3,1),
998 getfem_cv_nodes.begin()));
1001 getfem_cv_nodes.resize(6);
1002 getfem_cv_nodes[0] = cdb_node_2_getfem_node[II];
1003 getfem_cv_nodes[1] = cdb_node_2_getfem_node[JJ];
1004 getfem_cv_nodes[2] = cdb_node_2_getfem_node[KK];
1005 getfem_cv_nodes[3] = cdb_node_2_getfem_node[MM];
1006 getfem_cv_nodes[4] = cdb_node_2_getfem_node[NN];
1007 getfem_cv_nodes[5] = cdb_node_2_getfem_node[OO];
1008 regions[imat].add(m.
add_convex(bgeot::prism_geotrans(3,1),
1009 getfem_cv_nodes.begin()));
1013 getfem_cv_nodes.resize(8);
1014 getfem_cv_nodes[0] = cdb_node_2_getfem_node[II];
1015 getfem_cv_nodes[1] = cdb_node_2_getfem_node[JJ];
1016 getfem_cv_nodes[2] = cdb_node_2_getfem_node[LL];
1017 getfem_cv_nodes[3] = cdb_node_2_getfem_node[KK];
1018 getfem_cv_nodes[4] = cdb_node_2_getfem_node[MM];
1019 getfem_cv_nodes[5] = cdb_node_2_getfem_node[NN];
1020 getfem_cv_nodes[6] = cdb_node_2_getfem_node[PP];
1021 getfem_cv_nodes[7] = cdb_node_2_getfem_node[OO];
1022 regions[imat].add(m.
add_convex(bgeot::parallelepiped_geotrans(3,1),
1023 getfem_cv_nodes.begin()));
1025 if (itype < elt_cnt.size())
1026 elt_cnt[itype] += 1;
1029 else if (nodesno == 10) {
1032 std::string eltname(
"MESH200_9");
1033 if (elt_types.size() > itype && elt_types[itype].size() > 0)
1034 eltname = elt_types[itype];
1036 if (eltname.compare(
"MESH200_9") == 0 ||
1037 eltname.compare(
"SOLID87") == 0 ||
1038 eltname.compare(
"SOLID92") == 0 ||
1039 eltname.compare(
"SOLID162") == 0 ||
1040 eltname.compare(
"SOLID187") == 0) {
1041 getfem_cv_nodes.resize(10);
1042 getfem_cv_nodes[0] = cdb_node_2_getfem_node[II];
1043 getfem_cv_nodes[1] = cdb_node_2_getfem_node[MM];
1044 getfem_cv_nodes[2] = cdb_node_2_getfem_node[JJ];
1045 getfem_cv_nodes[3] = cdb_node_2_getfem_node[OO];
1046 getfem_cv_nodes[4] = cdb_node_2_getfem_node[NN];
1047 getfem_cv_nodes[5] = cdb_node_2_getfem_node[KK];
1048 getfem_cv_nodes[6] = cdb_node_2_getfem_node[PP];
1049 getfem_cv_nodes[7] = cdb_node_2_getfem_node[QQ];
1050 getfem_cv_nodes[8] = cdb_node_2_getfem_node[RR];
1051 getfem_cv_nodes[9] = cdb_node_2_getfem_node[LL];
1052 regions[imat].add(m.
add_convex(bgeot::simplex_geotrans(3,2),
1053 getfem_cv_nodes.begin()));
1054 if (itype < elt_cnt.size())
1055 elt_cnt[itype] += 1;
1058 else if (nodesno == 20) {
1061 std::string eltname(
"MESH200_11");
1062 if (elt_types.size() > itype && elt_types[itype].size() > 0)
1063 eltname = elt_types[itype];
1065 if (eltname.compare(
"MESH200_11") == 0 ||
1066 eltname.compare(
"VISCO89") == 0 ||
1067 eltname.compare(
"SOLID90") == 0 ||
1068 eltname.compare(
"SOLID95") == 0 ||
1069 eltname.compare(
"SOLID186") == 0 ||
1070 eltname.compare(
"SOLID191") == 0) {
1071 if (KK == LL && MM == NN && NN == OO && OO == PP) {
1072 getfem_cv_nodes.resize(10);
1073 getfem_cv_nodes[0] = cdb_node_2_getfem_node[II];
1074 getfem_cv_nodes[1] = cdb_node_2_getfem_node[QQ];
1075 getfem_cv_nodes[2] = cdb_node_2_getfem_node[JJ];
1076 getfem_cv_nodes[3] = cdb_node_2_getfem_node[TT];
1077 getfem_cv_nodes[4] = cdb_node_2_getfem_node[RR];
1078 getfem_cv_nodes[5] = cdb_node_2_getfem_node[KK];
1079 getfem_cv_nodes[6] = cdb_node_2_getfem_node[YY];
1080 getfem_cv_nodes[7] = cdb_node_2_getfem_node[ZZ];
1081 getfem_cv_nodes[8] = cdb_node_2_getfem_node[AA];
1082 getfem_cv_nodes[9] = cdb_node_2_getfem_node[MM];
1083 regions[imat].add(m.
add_convex(bgeot::simplex_geotrans(3,2),
1084 getfem_cv_nodes.begin()));
1085 if (itype < elt_cnt.size())
1086 elt_cnt[itype] += 1;
1087 }
else if (MM == NN && NN == OO && OO == PP) {
1088 getfem_cv_nodes.resize(13);
1089 getfem_cv_nodes[0] = cdb_node_2_getfem_node[II];
1090 getfem_cv_nodes[1] = cdb_node_2_getfem_node[QQ];
1091 getfem_cv_nodes[2] = cdb_node_2_getfem_node[JJ];
1092 getfem_cv_nodes[3] = cdb_node_2_getfem_node[TT];
1093 getfem_cv_nodes[4] = cdb_node_2_getfem_node[RR];
1094 getfem_cv_nodes[5] = cdb_node_2_getfem_node[LL];
1095 getfem_cv_nodes[6] = cdb_node_2_getfem_node[SS];
1096 getfem_cv_nodes[7] = cdb_node_2_getfem_node[KK];
1097 getfem_cv_nodes[8] = cdb_node_2_getfem_node[YY];
1098 getfem_cv_nodes[9] = cdb_node_2_getfem_node[ZZ];
1099 getfem_cv_nodes[10] = cdb_node_2_getfem_node[BB];
1100 getfem_cv_nodes[11] = cdb_node_2_getfem_node[AA];
1101 getfem_cv_nodes[12] = cdb_node_2_getfem_node[MM];
1102 regions[imat].add(m.
add_convex(bgeot::pyramid_Q2_incomplete_geotrans(),
1103 getfem_cv_nodes.begin()));
1104 if (itype < elt_cnt.size())
1105 elt_cnt[itype] += 1;
1107 }
else if (KK == LL && OO == PP) {
1108 getfem_cv_nodes.resize(15);
1109 getfem_cv_nodes[0] = cdb_node_2_getfem_node[II];
1110 getfem_cv_nodes[1] = cdb_node_2_getfem_node[QQ];
1111 getfem_cv_nodes[2] = cdb_node_2_getfem_node[JJ];
1112 getfem_cv_nodes[3] = cdb_node_2_getfem_node[TT];
1113 getfem_cv_nodes[4] = cdb_node_2_getfem_node[RR];
1114 getfem_cv_nodes[5] = cdb_node_2_getfem_node[LL];
1115 getfem_cv_nodes[6] = cdb_node_2_getfem_node[YY];
1116 getfem_cv_nodes[7] = cdb_node_2_getfem_node[ZZ];
1117 getfem_cv_nodes[8] = cdb_node_2_getfem_node[AA];
1118 getfem_cv_nodes[9] = cdb_node_2_getfem_node[MM];
1119 getfem_cv_nodes[10] = cdb_node_2_getfem_node[UU];
1120 getfem_cv_nodes[11] = cdb_node_2_getfem_node[NN];
1121 getfem_cv_nodes[12] = cdb_node_2_getfem_node[XX];
1122 getfem_cv_nodes[13] = cdb_node_2_getfem_node[VV];
1123 getfem_cv_nodes[14] = cdb_node_2_getfem_node[OO];
1125 (bgeot::prism_incomplete_P2_geotrans(),
1126 getfem_cv_nodes.begin()));
1127 if (itype < elt_cnt.size())
1128 elt_cnt[itype] += 1;
1130 getfem_cv_nodes.resize(20);
1131 getfem_cv_nodes[0] = cdb_node_2_getfem_node[II];
1132 getfem_cv_nodes[1] = cdb_node_2_getfem_node[QQ];
1133 getfem_cv_nodes[2] = cdb_node_2_getfem_node[JJ];
1134 getfem_cv_nodes[3] = cdb_node_2_getfem_node[TT];
1135 getfem_cv_nodes[4] = cdb_node_2_getfem_node[RR];
1136 getfem_cv_nodes[5] = cdb_node_2_getfem_node[LL];
1137 getfem_cv_nodes[6] = cdb_node_2_getfem_node[SS];
1138 getfem_cv_nodes[7] = cdb_node_2_getfem_node[KK];
1139 getfem_cv_nodes[8] = cdb_node_2_getfem_node[YY];
1140 getfem_cv_nodes[9] = cdb_node_2_getfem_node[ZZ];
1141 getfem_cv_nodes[10] = cdb_node_2_getfem_node[BB];
1142 getfem_cv_nodes[11] = cdb_node_2_getfem_node[AA];
1143 getfem_cv_nodes[12] = cdb_node_2_getfem_node[MM];
1144 getfem_cv_nodes[13] = cdb_node_2_getfem_node[UU];
1145 getfem_cv_nodes[14] = cdb_node_2_getfem_node[NN];
1146 getfem_cv_nodes[15] = cdb_node_2_getfem_node[XX];
1147 getfem_cv_nodes[16] = cdb_node_2_getfem_node[VV];
1148 getfem_cv_nodes[17] = cdb_node_2_getfem_node[PP];
1149 getfem_cv_nodes[18] = cdb_node_2_getfem_node[WW];
1150 getfem_cv_nodes[19] = cdb_node_2_getfem_node[OO];
1151 regions[imat].add(m.
add_convex(bgeot::Q2_incomplete_geotrans(3),
1152 getfem_cv_nodes.begin()));
1153 if (itype < elt_cnt.size())
1154 elt_cnt[itype] += 1;
1160 int nonempty_regions=0;
1161 for (size_type i=0; i < regions.size(); ++i)
1162 if (regions[i].card() > 0)
1165 if (nonempty_regions > 1)
1166 for (size_type i=0; i < regions.size(); ++i)
1167 if (regions[i].card() > 0)
1168 m.
region(i).add(regions[i]);
1170 for (size_type i=1; i < elt_types.size(); ++i)
1172 cout <<
"Imported " << elt_cnt[i] <<
" " << elt_types[i] <<
" elements." << endl;
1173 cout <<
"Imported " << m.
convex_index().card() <<
" elements in total." << endl;
1178 static double round_to_nth_significant_number(
double x,
int ndec) {
1180 double s = (x < 0 ? -1 : 1);
1181 double pdec = pow(10.,
double(ndec));
1182 if (x == 0)
return 0.;
1184 while (x > 1) { x /= 10.0; p*=10; }
1185 while (x < 0.1) { x *= 10.0; p/=10; }
1187 x = s * (floor(x * pdec + 0.5) / pdec) * p;
1193 static void import_noboite_mesh_file(std::istream& f,
mesh& m) {
1195 using namespace std;
1196 gmm::stream_standard_locale sl(f);
1198 ofstream fichier_GiD(
"noboite_to_GiD.gid", ios::out | ios::trunc );
1200 fichier_GiD <<
"MESH dimension 3 ElemType Tetrahedra Nnode 4"<<endl;
1203 int i,NE,NP,ligne_debut_NP;
1211 ligne_debut_NP=NE*4/6+3;
1216 for (i=1; i<=ligne_debut_NP; i++){
1217 getline(f, contenu);
1224 fichier_GiD <<
"Coordinates" <<endl;
1226 for (i=1; i<=NP; i++){
1227 float coor_x,coor_y,coor_z;
1229 fichier_GiD << i<<
" ";
1231 f>>coor_x >>coor_y >>coor_z;
1232 fichier_GiD<<coor_x<<
" " <<coor_y <<
" "<<coor_z <<endl;
1236 fichier_GiD <<
"end coordinates" <<endl<<endl;
1243 f.seekg(0, ios::beg);
1244 for (i=1; i<=3; i++){
1245 getline(f, contenu);
1249 fichier_GiD <<
"Elements" <<endl;
1251 for (i=1; i<=NE; i++){
1252 float elem_1,elem_2,elem_3,elem_4;
1254 fichier_GiD << i<<
" ";
1255 f>>elem_1>>elem_2>>elem_3>>elem_4;
1256 fichier_GiD<<elem_1<<
" " <<elem_2 <<
" "<<elem_3<<
" "<<elem_4<<
" 1"<<endl;
1259 fichier_GiD <<
"end elements" <<endl<<endl;
1264 fichier_GiD.close();
1267 cerr <<
"Erreur à l'ouverture !" << endl;
1275 cerr <<
"Erreur à l'ouverture !" << endl;
1279 ifstream fichier1_GiD(
"noboite_to_GiD.gid", ios::in);
1280 import_gid_mesh_file(fichier1_GiD, m);
1289 static void import_am_fmt_mesh_file(std::istream& f,
mesh& m) {
1290 gmm::stream_standard_locale sl(f);
1292 std::vector<size_type> tri;
1295 f >> nbs >> nbt; bgeot::read_until(f,
"\n");
1297 for (
size_type i=0; i < nbt*3; ++i) f >> tri[i];
1301 P[0]=round_to_nth_significant_number(P[0],6);
1302 P[1]=round_to_nth_significant_number(P[1],6);
1304 GMM_ASSERT1(jj == j,
"ouch");
1314 static void import_emc2_mesh_file(std::istream& f,
mesh& m) {
1315 gmm::stream_standard_locale sl(f);
1317 std::vector<size_type> tri;
1320 bgeot::read_until(f,
"Vertices");
1323 f >> P[0] >> P[1] >> dummy;
1325 GMM_ASSERT1(jj == j,
"ouch");
1331 if (ls.find(
"Triangles")+1) {
1334 f >> ip[0] >> ip[1] >> ip[2] >> dummy; ip[0]--; ip[1]--; ip[2]--;
1337 }
else if (ls.find(
"Quadrangles")+1) {
1340 f >> ip[0] >> ip[1] >> ip[2] >> ip[3] >> dummy; ip[0]--; ip[1]--; ip[2]--; ip[3]--;
1343 }
else if (ls.find(
"End")+1)
break;
1347 void import_mesh(
const std::string& filename,
const std::string& format,
1352 if (bgeot::casecmp(format,
"structured")==0)
1354 else if (bgeot::casecmp(format,
"structured_ball")==0)
1357 std::ifstream f(filename.c_str());
1358 GMM_ASSERT1(f.good(),
"can't open file " << filename);
1360 f.exceptions(std::ifstream::badbit | std::ifstream::failbit);
1364 catch (std::logic_error& exc) {
1368 catch (std::ios_base::failure& exc) {
1370 GMM_ASSERT1(
false,
"error while importing " << format
1371 <<
" mesh file \"" << filename <<
"\" : " << exc.what());
1373 catch (std::runtime_error& exc) {
1380 std::map<std::string, size_type> ®ion_map,
1381 bool remove_last_dimension,
1382 std::map<
size_type, std::set<size_type>> *nodal_map,
1383 bool remove_duplicated_nodes)
1385 import_gmsh_mesh_file(f, m, 0, ®ion_map,
nullptr,
false, remove_last_dimension, nodal_map,
1386 remove_duplicated_nodes);
1390 bool add_all_element_type,
1391 std::set<size_type> *lower_dim_convex_rg,
1392 std::map<std::string, size_type> *region_map,
1393 bool remove_last_dimension,
1394 std::map<
size_type, std::set<size_type>> *nodal_map,
1395 bool remove_duplicated_nodes)
1397 import_gmsh_mesh_file(f, m, 0, region_map, lower_dim_convex_rg, add_all_element_type,
1398 remove_last_dimension, nodal_map, remove_duplicated_nodes);
1402 bool add_all_element_type,
1403 std::set<size_type> *lower_dim_convex_rg,
1404 std::map<std::string, size_type> *region_map,
1405 bool remove_last_dimension,
1406 std::map<
size_type, std::set<size_type>> *nodal_map,
1407 bool remove_duplicated_nodes)
1411 std::ifstream f(filename.c_str());
1412 GMM_ASSERT1(f.good(),
"can't open file " << filename);
1414 f.exceptions(std::ifstream::badbit | std::ifstream::failbit);
1415 import_gmsh_mesh_file(f, m, 0, region_map, lower_dim_convex_rg, add_all_element_type,
1416 remove_last_dimension, nodal_map, remove_duplicated_nodes);
1419 catch (std::logic_error& exc) {
1423 catch (std::ios_base::failure& exc) {
1425 GMM_ASSERT1(
false,
"error while importing " <<
"gmsh" 1426 <<
" mesh file \"" << filename <<
"\" : " << exc.what());
1428 catch (std::runtime_error& exc) {
1435 mesh& m, std::map<std::string, size_type> ®ion_map,
1436 bool remove_last_dimension,
1437 std::map<
size_type, std::set<size_type>> *nodal_map,
1438 bool remove_duplicated_nodes) {
1439 import_mesh_gmsh(filename, m,
false, NULL, ®ion_map, remove_last_dimension, nodal_map,
1440 remove_duplicated_nodes);
1443 void import_mesh(std::istream& f,
const std::string& format,
1445 if (bgeot::casecmp(format,
"gmsh")==0)
1446 import_gmsh_mesh_file(f,m);
1447 else if (bgeot::casecmp(format,
"gmshv2")==0)
1448 import_gmsh_mesh_file(f,m,2);
1449 else if (bgeot::casecmp(format,
"gid")==0)
1450 import_gid_mesh_file(f,m);
1451 else if (bgeot::casecmp(format,
"noboite")==0)
1452 import_noboite_mesh_file(f,m);
1453 else if (bgeot::casecmp(format,
"am_fmt")==0)
1454 import_am_fmt_mesh_file(f,m);
1455 else if (bgeot::casecmp(format,
"emc2_mesh")==0)
1456 import_emc2_mesh_file(f,m);
1457 else if (bgeot::casecmp(format,
"cdb")==0)
1458 import_cdb_mesh_file(f,m);
1459 else if (bgeot::casecmp(format.substr(0,4),
"cdb:")==0) {
1464 imat = std::stol(format.substr(4), &sz);
1465 success = (sz == format.substr(4).size() && imat !=
size_type(-1));
1466 }
catch (
const std::invalid_argument&) {
1468 }
catch (
const std::out_of_range&) {
1472 import_cdb_mesh_file(f,m,imat);
1473 else GMM_ASSERT1(
false,
"cannot import " 1474 << format <<
" mesh type : wrong cdb mesh type input");
1476 else GMM_ASSERT1(
false,
"cannot import " 1477 << format <<
" mesh type : unknown mesh type");
1481 size_type pos = filename.find_last_of(
":");
1482 if (pos != std::string::npos)
1489 bool is_flat =
true;
1490 unsigned N = m.dim();
if (N < 1)
return;
1491 for (dal::bv_visitor i(m.points().index()); !i.finished(); ++i)
1492 if (m.points()[i][N-1] != 0) is_flat = 0;
1494 base_matrix M(N-1,N);
1495 for (
unsigned i=0; i < N-1; ++i) M(i,i) = 1;
size_type add_parallelepiped(dim_type di, const ITER &ipts)
Add a parallelepiped to the mesh.
void maybe_remove_last_dimension(mesh &msh)
for gmsh and gid meshes, the mesh nodes are always 3D, so for a 2D mesh the z-component of nodes shou...
Define a getfem::getfem_mesh object.
void read_from_file(const std::string &name)
Load the mesh from a file.
Describe a mesh (collection of convexes (elements) and points).
pconvex_structure structure_of_convex(size_type ic) const
Return the pconvex_structure of the convex ic.
size_type add_convex(bgeot::pgeometric_trans pgt, ITER ipts)
Add a convex to the mesh.
void clear()
Erase the mesh.
Import mesh files from various formats.
const ind_cv_ct & convex_to_point(size_type ip) const
Return a container of the convexes attached to point ip.
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 regular_mesh(mesh &m, const std::string &st)
Build a regular mesh parametrized by the string st.
void import_mesh(const std::string &filename, const std::string &format, mesh &m)
imports a mesh file.
size_t size_type
used as the common size type in the library
GEneric Tool for Finite Element Methods.
gmm::uint16_type short_type
used as the common short type integer in the library
std::string name_of_geometric_trans(pgeometric_trans p)
Get the string name of a geometric transformation.
void import_mesh_gmsh(const std::string &filename, mesh &m, std::map< std::string, size_type > ®ion_map, bool remove_last_dimension=true, std::map< size_type, std::set< size_type >> *nodal_map=NULL, bool remove_duplicated_nodes=true)
Import a mesh file in format generated by Gmsh.
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 transformation(const base_matrix &)
apply the given matrix transformation to each mesh node.
const mesh_region region(size_type id) const
Return the region of index 'id'.
void regular_ball_mesh(mesh &m, const std::string &st)
Build a regular mesh on a ball, parametrized by the string st.
const dal::bit_vector & convex_index() const
Return the list of valid convex IDs.
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation
std::map< std::string, size_type > read_region_names_from_gmsh_mesh_file(std::istream &f)
for gmsh meshes, create table linking region name to region_id.