LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
gmsh_file_v2.cc
1
10#include "gmsh_file_v2.h"
11
12#include <boost/fusion/include/adapt_struct.hpp>
13#include <boost/fusion/include/adapt_struct_named.hpp>
14#include <boost/fusion/include/boost_array.hpp>
15#include <boost/fusion/include/io.hpp>
16#include <boost/fusion/include/std_pair.hpp>
17#include <boost/fusion/iterator.hpp>
18#include <boost/fusion/support/category_of.hpp>
19#include <boost/fusion/support/iterator_base.hpp>
20#include <boost/fusion/support/tag_of.hpp>
21#include <boost/fusion/support/tag_of_fwd.hpp>
22#include <boost/mpl/minus.hpp>
23#include <boost/phoenix/core.hpp>
24#include <boost/phoenix/function/adapt_function.hpp>
25#include <boost/phoenix/object.hpp>
26#include <boost/phoenix/operator.hpp>
27#include <boost/phoenix/stl.hpp>
28#include <boost/spirit/include/qi.hpp>
29#include <boost/spirit/include/qi_binary.hpp>
30
31#include "eigen_fusion_adapter.h"
32
33using size_type = lf::mesh::Mesh::size_type;
34
35namespace lf::io {
36
38std::ostream& operator<<(std::ostream& stream, GMshFileV2::ElementType et) {
39 switch (et) {
40 default:
41 break;
43 stream << "EDGE2";
44 break;
46 stream << "TRIA3";
47 break;
49 stream << "QUAD4";
50 break;
52 stream << "TET4";
53 break;
55 stream << "HEX8";
56 break;
58 stream << "PRISM6";
59 break;
61 stream << "PYRAMID5";
62 break;
64 stream << "EDGE3";
65 break;
67 stream << "TRIA6";
68 break;
70 stream << "QUAD9";
71 break;
73 stream << "TET10";
74 break;
76 stream << "HEX27";
77 break;
79 stream << "PRISM18";
80 break;
82 stream << "PYRAMID14";
83 break;
85 stream << "POINT";
86 break;
88 stream << "QUAD8";
89 break;
91 stream << "HEX20";
92 break;
94 stream << "PRISM15";
95 break;
97 stream << "PYRAMID13";
98 break;
100 stream << "TRIA9";
101 break;
103 stream << "TRIA10";
104 break;
106 stream << "TRIA12";
107 break;
109 stream << "TRIA15";
110 break;
112 stream << "TRIA15_5";
113 break;
115 stream << "TRIA21";
116 break;
118 stream << "EDGE4";
119 break;
121 stream << "EDGE5";
122 break;
124 stream << "EDGE6";
125 break;
127 stream << "TET20";
128 break;
130 stream << "TET35";
131 break;
133 stream << "TET56";
134 break;
136 stream << "HEX64";
137 break;
139 stream << "HEX125";
140 break;
141 }
142 return stream;
143}
144
146std::ostream& operator<<(std::ostream& stream, const GMshFileV2& mf) {
147 stream << "GMSH FILE: Ver. " << mf.VersionNumber
148 << (mf.IsBinary ? "(Binary)" : "(Text)")
149 << ", size of double = " << mf.DoubleSize << std::endl;
150 stream << "======================================================="
151 << std::endl;
152 stream << "PHYSICAL ENTITIES (Dimension, Number, Name):" << std::endl;
153 for (const auto& pe : mf.PhysicalEntities) {
154 stream << " " << pe.Dimension << "\t , " << pe.Number << "\t , " << pe.Name
155 << std::endl;
156 }
157 stream << "NODES (Number, coords)" << std::endl;
158 for (const auto& n : mf.Nodes) {
159 stream << " " << n.first << "\t , " << n.second.transpose() << std::endl;
160 }
161 stream << "ELEMENTS (Number, Type, PhysicalEntity Nr, ElementaryEntityNr, "
162 "Mesh partitions to which it belongs, Node numbers in it)"
163 << std::endl;
164 for (const auto& e : mf.Elements) {
165 stream << " " << e.Number << "\t " << e.Type << '\t' << e.PhysicalEntityNr
166 << "\t" << e.ElementaryEntityNr << "\t";
167 for (auto p : e.MeshPartitions) {
168 stream << p << ", ";
169 }
170 stream << '\t';
171 for (auto n : e.NodeNumbers) {
172 stream << n << ", ";
173 }
174 stream << std::endl;
175 }
176 stream << std::endl;
177 stream << "PERIODIC ENTITIES:" << std::endl;
178 for (const auto& pe : mf.Periodic) {
179 std::cout << " dim=" << pe.Dimension
180 << ", slaveNr=" << pe.ElementarySlaveNr
181 << ", masterNr=" << pe.ElementaryMasterNr << std::endl;
182 for (auto nm : pe.NodeMapping) {
183 std::cout << " " << nm.first << " <-> " << nm.second << std::endl;
184 }
185 }
186 return stream;
187}
188
191 switch (et) {
192 default:
193 break;
195 return 2;
197 return 3;
200 return 4;
202 return 8;
204 return 6;
206 return 5;
208 return 3;
210 return 6;
212 return 9;
214 return 10;
216 return 27;
218 return 18;
220 return 14;
222 return 1;
224 return 8;
226 return 20;
228 return 15;
230 return 13;
232 return 9;
234 return 10;
236 return 12;
239 return 15;
241 return 21;
243 return 4;
245 return 5;
247 return 6;
249 return 20;
251 return 35;
253 return 56;
255 return 64;
257 return 125;
258 }
259 LF_VERIFY_MSG(false, "unknown Gmsh element type");
260 // Make compiler happy:
261 return 0;
262}
263
265 switch (et) {
267 return base::RefEl::kPoint();
268
274 return base::RefEl::kSegment();
275
284 return base::RefEl::kTria();
285
289 return base::RefEl::kQuad();
290
307 default:
308 LF_VERIFY_MSG(
309 false, "Reference element not supported for GmshElement type " << et);
310 }
311}
312
315 switch (et) {
317 return 0;
323 return 1;
335 return 2;
352 return 3;
353 default:
354 LF_VERIFY_MSG(false, "Unknown GmshElement Type.");
355 }
356 // Make compiler happy:
357 return -1;
358}
359} // namespace lf::io
360
361// Boost Fusion Adaptions (needed so boost spirit can parse directly into
362// GMshFileV2 struct)
364BOOST_FUSION_ADAPT_STRUCT(lf::io::GMshFileV2::PhysicalEntity,
365 (int, Dimension)(int, Number)(std::string, Name));
366
367BOOST_FUSION_ADAPT_STRUCT(
369 (size_type, Number)(lf::io::GMshFileV2::ElementType,
370 Type)(int, PhysicalEntityNr)(int, ElementaryEntityNr)(
371 std::vector<int>, MeshPartitions)(std::vector<size_type>, NodeNumbers));
372
374using nodeMapping_t = std::pair<size_type, size_type>;
375
376BOOST_FUSION_ADAPT_STRUCT(lf::io::GMshFileV2::PeriodicEntity,
377 (int, Dimension)(int, ElementarySlaveNr)(
378 int,
379 ElementaryMasterNr)(std::vector<nodeMapping_t>,
380 NodeMapping));
381
383using nodePair_t = std::pair<size_type, Eigen::Vector3d>;
384
387// NOLINTNEXTLINE
388BOOST_FUSION_ADAPT_STRUCT_NAMED(
389 lf::io::GMshFileV2, MshFileAdapted,
390 //(double, VersionNumber)
391 //(bool, IsBinary)
392 //(int, DoubleSize)
393 (std::vector<lf::io::GMshFileV2::PhysicalEntity>,
394 PhysicalEntities)(std::vector<nodePair_t>, Nodes)(
395 std::vector<lf::io::GMshFileV2::Element>,
396 Elements)(std::vector<lf::io::GMshFileV2::PeriodicEntity>, Periodic));
397
399namespace boost::spirit::traits {
400/*template<>
401struct transform_attribute<hydi::io::MshFile::ElementType, int, qi::domain> {
402 using type = int&;
403 static int& pre(hydi::io::MshFile::ElementType& d) { return (int&)d; }
404 static void post(hydi::io::MshFile::ElementType& dval, const int& attr) {}
405 static void fail(hydi::io::MshFile::ElementType&) {}
406};*/
407
408template <typename Enum, typename RawValue>
409struct assign_to_attribute_from_value<
410 Enum, RawValue,
411 typename std::enable_if<std::is_enum<Enum>::value &&
412 std::is_same<Enum, RawValue>::value ==
413 false>::type> {
414 static void call(RawValue const& raw, Enum& cat) {
415 cat = static_cast<Enum>(raw);
416 }
417};
418
419} // namespace boost::spirit::traits
421
422namespace lf::io {
423namespace /*Anonymous*/ {
424
425namespace qi = boost::spirit::qi;
426namespace ascii = boost::spirit::ascii;
427namespace phoenix = boost::phoenix;
428
430struct gmshElementType : qi::symbols<char, unsigned> {
431 gmshElementType() {
432 for (const auto& et : GMshFileV2::AllElementTypes) {
433 add(std::to_string(static_cast<int>(et)), static_cast<int>(et));
434 }
435 }
436};
437
438// NOLINTNEXTLINE
439BOOST_PHOENIX_ADAPT_FUNCTION(int, numNodesAdapted, NumNodes, 1);
440
442template <class ITERATOR>
443struct MshGrammarText
444 : qi::grammar<ITERATOR, boost::fusion::adapted::MshFileAdapted(),
445 ascii::space_type> {
446 MshGrammarText(
447 qi::rule<ITERATOR, std::pair<size_type, Eigen::Vector3d>()> nodeRule,
448 qi::rule<ITERATOR, std::vector<GMshFileV2::Element>(),
449 qi::locals<size_type, int, int, int, size_type>>
450 elementGroup)
451 : MshGrammarText::base_type(start_, "Msh File"),
452 node_(nodeRule),
453 elementGroup_(elementGroup) {
454 using phoenix::push_back;
455 using phoenix::reserve;
456 using phoenix::val;
457 using qi::_val;
458 using qi::char_;
459 using qi::double_;
460 using qi::eps;
461 using qi::int_;
462 using qi::lexeme;
463 using qi::lit;
464 using qi::omit;
465 using qi::repeat;
466 using qi::labels::_1;
467 using qi::labels::_2;
468 using qi::labels::_3;
469 using qi::labels::_4;
470 using qi::labels::_a;
471
472 // General Parsers:
473 quotedString_ %= lexeme['"' >> +(char_ - '"') >> '"'];
474 quotedString_.name("string");
475 startComment_ %= !lit("$PhysicalNames") >> !lit("$Nodes") >>
476 !lit("$Elements") >> !lit("$Periodic") >>
477 (lit('$') >> (+(char_ - qi::eol)));
478 startComment_.name("Start of Comment");
479 comment_ %=
480 startComment_[_a = qi::_1] > *(char_ - '$') >> "$End" >> qi::string(_a);
481 comment_.name("comment");
482 qi::on_error<qi::fail>(comment_,
483 errorHandler_(qi::_1, qi::_2, qi::_3, qi::_4));
484
485 // Physical Entities:
486 physicalEntity_ %= int_ > int_ > quotedString_; // NOLINT
487 physicalEntity_.name("Physical Entity Entry");
488 qi::on_error<qi::fail>(physicalEntity_,
489 errorHandler_(qi::_1, qi::_2, qi::_3, qi::_4));
490 physicalEntityGroup_ %= "$PhysicalNames" >
491 omit[int_[reserve(_val, qi::_1), _a = qi::_1]] >
492 repeat(_a)[physicalEntity_] > "$EndPhysicalNames";
493 physicalEntityGroup_.name("$Physical Entity Section");
494 qi::on_error<qi::fail>(physicalEntityGroup_,
495 errorHandler_(qi::_1, qi::_2, qi::_3, qi::_4));
496
497 // Nodes:
498 nodeGroup_ %= "$Nodes" > qi::eol >
499 omit[qi::uint_[reserve(_val, qi::_1), _a = qi::_1]] >
500 qi::eol > repeat(_a)[node_] > -qi::eol > "$EndNodes";
501 nodeGroup_.name("$Node Section");
502 qi::on_error<qi::fail>(node_,
503 errorHandler_(qi::_1, qi::_2, qi::_3, qi::_4));
504 qi::on_error<qi::fail>(nodeGroup_,
505 errorHandler_(qi::_1, qi::_2, qi::_3, qi::_4));
506
507 // Elements:
508 qi::on_error<qi::fail>(elementGroup_,
509 errorHandler_(qi::_1, qi::_2, qi::_3, qi::_4));
510
511 // Periodic entities:
512 periodicEntityNodeMapping_ =
513 omit[qi::uint_[reserve(_val, qi::_1), _a = qi::_1]] >
514 repeat(_a)[qi::uint_ > qi::uint_]; // NOLINT
515 periodicEntityNodeMapping_.name("slave-master node mapping");
516 qi::on_error<qi::fail>(periodicEntityNodeMapping_,
517 errorHandler_(qi::_1, qi::_2, qi::_3, qi::_4));
518 periodicEntity_ =
519 int_ > int_ > int_ > periodicEntityNodeMapping_; // NOLINT
520 periodicEntity_.name("periodic entity");
521 qi::on_error<qi::fail>(periodicEntity_,
522 errorHandler_(qi::_1, qi::_2, qi::_3, qi::_4));
523 periodicEntityGroup_ = "$Periodic" >
524 omit[qi::uint_[reserve(_val, qi::_1), _a = qi::_1]] >
525 repeat(_a)[periodicEntity_] > "$EndPeriodic";
526 periodicEntityGroup_.name("periodic entity section");
527 qi::on_error<qi::fail>(periodicEntityGroup_,
528 errorHandler_(qi::_1, qi::_2, qi::_3, qi::_4));
529
530 // The whole file:
531 start_ %= *comment_ >> -(physicalEntityGroup_ >> *comment_) >> nodeGroup_ >>
532 *comment_ >> elementGroup_ >> *comment_ >>
533 -(periodicEntityGroup_ >> *comment_);
534 start_.name("beginning of file");
535 qi::on_error<qi::fail>(start_,
536 errorHandler_(qi::_1, qi::_2, qi::_3, qi::_4));
537 }
538
539 private:
540 qi::rule<ITERATOR, std::string(), ascii::space_type> quotedString_;
541 qi::rule<ITERATOR, std::string()> startComment_;
542 qi::rule<ITERATOR, qi::locals<std::string>, ascii::space_type> comment_;
543
544 qi::rule<ITERATOR, GMshFileV2::PhysicalEntity(), ascii::space_type>
545 physicalEntity_;
546 qi::rule<ITERATOR, std::vector<GMshFileV2::PhysicalEntity>(),
547 qi::locals<size_type>, ascii::space_type>
548 physicalEntityGroup_;
549
550 qi::rule<ITERATOR, std::pair<size_type, Eigen::Vector3d>()> node_;
551 qi::rule<ITERATOR, std::vector<std::pair<size_type, Eigen::Vector3d>>(),
552 qi::locals<size_type>>
553 nodeGroup_;
554
557 qi::rule<ITERATOR, std::vector<GMshFileV2::Element>(),
558 qi::locals<size_type, int, int, int, size_type>>
559 elementGroup_;
560
561 qi::rule<ITERATOR, std::vector<std::pair<size_type, size_type>>(),
562 qi::locals<size_type>, ascii::space_type>
563 periodicEntityNodeMapping_;
564 qi::rule<ITERATOR, GMshFileV2::PeriodicEntity(), ascii::space_type>
565 periodicEntity_;
566 qi::rule<ITERATOR, std::vector<GMshFileV2::PeriodicEntity>(),
567 qi::locals<size_type>, ascii::space_type>
568 periodicEntityGroup_;
569
570 qi::rule<ITERATOR, boost::fusion::adapted::MshFileAdapted(),
571 ascii::space_type>
572 start_;
573
574 struct ErrorHandler {
575 template <class, class, class, class>
576 struct result {
577 using type = void;
578 };
579
580 template <class FIRST, class LAST, class ERROR_POS, class WHAT>
581 void operator()(FIRST first, LAST last, ERROR_POS /*errorPos*/,
582 WHAT what) const {
583 std::string input(first, last);
584 if (input.length() > 40) {
585 input = input.substr(0, 40);
586 }
587 std::cout << "Error in MshFile! Expecting " << what << " here: \""
588 << input << "\"" << std::endl;
589 }
590 };
591 phoenix::function<ErrorHandler> errorHandler_;
592};
593
594} // namespace
595
596const std::vector<GMshFileV2::ElementType> GMshFileV2::AllElementTypes{
597 ElementType::EDGE2, ElementType::TRIA3, ElementType::QUAD4,
598 ElementType::TET4, ElementType::HEX8, ElementType::PRISM6,
599 ElementType::PYRAMID5, ElementType::EDGE3, ElementType::TRIA6,
600 ElementType::QUAD9, ElementType::TET10, ElementType::HEX27,
601 ElementType::PRISM18, ElementType::PYRAMID14, ElementType::POINT,
602 ElementType::QUAD8, ElementType::HEX20, ElementType::PRISM15,
603 ElementType::PYRAMID13, ElementType::TRIA9, ElementType::TRIA10,
604 ElementType::TRIA12, ElementType::TRIA15, ElementType::TRIA15_5,
605 ElementType::TRIA21, ElementType::EDGE4, ElementType::EDGE5,
606 ElementType::EDGE6, ElementType::TET20, ElementType::TET35,
607 ElementType::TET56, ElementType::HEX64, ElementType::HEX125};
608
609GMshFileV2 readGmshFileV2(std::string::const_iterator begin,
610 std::string::const_iterator end,
611 const std::string& version, bool is_binary,
612 int size_t_size, int one,
613 const std::string& filename) {
614 LF_VERIFY_MSG(version == "2.2",
615 "Version " << version << " not supported by readGmshFileV2");
616 LF_ASSERT_MSG(size_t_size == 8, "Size of std::size_t must be 8.");
617
618 GMshFileV2 result;
619 result.IsBinary = is_binary;
620 result.VersionNumber = version;
621 result.DoubleSize = size_t_size;
622
623 // Parse the rest of the document
625
626 // Setup parsers for node/element sections (which are different depending on
627 // binary/non-binary files):
628 //
629 // Note vec3 has no skipper because it may be used inside lexeme and lexeme
630 // can only use parsers without skippers!
631 // http://boost-spirit.com/home/2010/02/24/parsing-skippers-and-skipping-parsers/
632 // (see comment section)
633 using iterator_t = std::string::const_iterator;
634 qi::rule<iterator_t, Eigen::Vector3d> vec3;
635 qi::rule<iterator_t, std::pair<size_type, Eigen::Vector3d>()> node;
636 qi::rule<iterator_t, GMshFileV2::Element(), qi::locals<int>> elementText;
637 qi::rule<iterator_t, GMshFileV2::Element(GMshFileV2::ElementType, int, int)>
638 elementBin;
639 qi::rule<iterator_t, std::vector<GMshFileV2::Element>(),
640 qi::locals<size_type, int, int, int, size_type>>
641 elementGroup;
642
643 using phoenix::reserve;
644 using qi::omit;
645 using qi::repeat;
646 using qi::labels::_a;
647 using qi::labels::_b;
648 using qi::labels::_c;
649 using qi::labels::_d;
650 using qi::labels::_e;
651 using qi::labels::_r1;
652 using qi::labels::_r2;
653 using qi::labels::_r3;
654 using qi::labels::_val;
655
656 if (!is_binary) {
657 // Text file
658 vec3 = qi::double_ >> ' ' >> qi::double_ >> ' ' >> qi::double_;
659 node = qi::uint_ >> ' ' >> vec3 >> qi::eol;
660 elementText %= qi::int_ > ' ' > qi::int_ > ' ' >
661 qi::omit[qi::int_[qi::_a = qi::_1]] > ' ' > qi::int_ > ' ' >
662 qi::int_ > ' ' >
663 ((qi::eps(_a > 2) >> omit[qi::int_] >> ' ') || qi::eps) >
664 qi::repeat(qi::_a - 3)[qi::int_ >> ' '] > (qi::uint_ % ' ') >
665 *(qi::blank) > qi::eol;
666 elementGroup %= "$Elements" > qi::eol >
667 qi::omit[qi::uint_[phoenix::reserve(qi::_val, qi::_1),
668 qi::_a = qi::_1]] > qi::eol >
669 qi::repeat(qi::_a)[elementText] > "$EndElements";
670 } else if (is_binary && one == 1) {
671 // Binary File Little Endian
672 // std::cout << "little endian" << std::endl;
673 vec3 %=
674 qi::little_bin_double >> qi::little_bin_double >> qi::little_bin_double;
675 node %= qi::no_skip[qi::little_dword >> vec3];
676 elementBin %= qi::little_dword >> qi::attr(_r1) >> qi::little_dword >>
677 qi::little_dword >>
678 ((qi::eps(_r2 > 2) >> omit[qi::little_dword]) || qi::eps) >>
679 qi::repeat(_r2 - 3)[qi::little_dword] >>
680 qi::repeat(_r3)[qi::little_dword];
681 elementGroup %=
682 "$Elements" >> qi::eol >> qi::eps[_e = 0] >>
683 omit[qi::uint_[reserve(_val, qi::_1), _a = qi::_1]] >>
684 qi::eol // # Elements in total
685 >>
686 omit[*((qi::eps(_e < _a) >> qi::little_dword[_b = qi::_1] >>
687 qi::little_dword[_c = qi::_1] >>
688 qi::little_dword[_d = qi::_1] // elements-header-binary
689 >> repeat(_c)[elementBin(
690 phoenix::static_cast_<GMshFileV2::ElementType>(_b), _d,
691 numNodesAdapted(
692 phoenix::static_cast_<GMshFileV2::ElementType>(
693 _b)))[phoenix::push_back(_val, qi::_1)]]) >>
694 qi::eps[_e += _c])] // elements-binary
695 >> qi::eol >> "$EndElements";
696 } else {
697 // std::cout << "big endian" << std::endl;
698 // Binary File Big Endian
699 vec3 %= qi::big_bin_double >> qi::big_bin_double >> qi::big_bin_double;
700 node %= qi::no_skip[qi::big_dword >> vec3];
701 elementBin %=
702 qi::big_dword >> qi::attr(_r1) >> qi::big_dword >> qi::big_dword >>
703 ((qi::eps(_r2 > 2) >> omit[qi::big_dword]) || qi::eps) >>
704 qi::repeat(_r2 - 3)[qi::big_dword] >> qi::repeat(_r3)[qi::big_dword];
705 elementGroup %=
706 "$Elements" >> qi::eol >> qi::eps[_e = 0] >>
707 omit[qi::uint_[reserve(_val, qi::_1), _a = qi::_1]] >>
708 qi::eol // # Elements in total
709 >>
710 omit[*((qi::eps(_e < _a) >> qi::big_dword[_b = qi::_1] >>
711 qi::big_dword[_c = qi::_1] >>
712 qi::big_dword[_d = qi::_1] // elements-header-binary
713 >> repeat(_c)[elementBin(
714 phoenix::static_cast_<GMshFileV2::ElementType>(_b), _d,
715 numNodesAdapted(
716 phoenix::static_cast_<GMshFileV2::ElementType>(
717 _b)))[phoenix::push_back(_val, qi::_1)]]) >>
718 qi::eps[_e += _c])] // elements-binary
719 >> qi::eol >> "$EndElements";
720 }
721
723 vec3.name("vec3");
724 node.name("node");
725 elementText.name("element");
726 elementBin.name("element");
727 elementGroup.name("ElementSection");
728
729 // Finally parse everything:
730 MshGrammarText<iterator_t> mshGrammar(node, elementGroup);
731 bool r = qi::phrase_parse(begin, end, mshGrammar, ascii::space, result);
732
733 // if (r && iter == end) std::cout << "Parsing succeeded" << std::endl;
734 // else if (r) std::cout << "Parsing partially succeeded" << std::endl;
735 // std::cout << result << std::endl;
736
737 LF_VERIFY_MSG(r, "Could not parse file " << filename);
738 LF_VERIFY_MSG(begin == end, "Could not parse all of file " << filename);
739
740 return result;
741}
742
743} // namespace lf::io
Represents a reference element with all its properties.
Definition: ref_el.h:106
static constexpr RefEl kSegment()
Returns the (1-dimensional) reference segment.
Definition: ref_el.h:150
static constexpr RefEl kPoint()
Returns the (0-dimensional) reference point.
Definition: ref_el.h:141
static constexpr RefEl kTria()
Returns the reference triangle.
Definition: ref_el.h:158
static constexpr RefEl kQuad()
Returns the reference quadrilateral.
Definition: ref_el.h:166
lf::base::size_type size_type
Mesh input (from file) and output (in various formats) facilities.
Definition: gmsh_file_v2.cc:35
GMshFileV2 readGmshFileV2(std::string::const_iterator begin, std::string::const_iterator end, const std::string &version, bool is_binary, int size_t_size, int one, const std::string &filename)
Read a *.msh file from disk and copy it's contents into the MshFile Datastructure.
int DimOf(GMshFileV2::ElementType et)
Dimension of the GmshElement type.
base::RefEl RefElOf(GMshFileV2::ElementType et)
Reference element type of a GmshElementType.
std::ostream & operator<<(std::ostream &stream, GMshFileV2::ElementType et)
Output the element type onto the console:
Definition: gmsh_file_v2.cc:38
size_type NumNodes(GMshFileV2::ElementType et)
Number of nodes that this element type has.
Represents a mesh volume/surface/line/point.
Definition: gmsh_file_v2.h:151
Describes how 2 elementary entities are identified with each to represent periodic boundaries.
Definition: gmsh_file_v2.h:207
Represents a physical entity as defined in gmsh. In GMSH a Physical entity is created through one of ...
Definition: gmsh_file_v2.h:40
A representation of a .msh file (V2) in a c++ data structure.
Definition: gmsh_file_v2.h:18
std::string VersionNumber
The version of GMSH of the msh file, equals usually 2.2.
Definition: gmsh_file_v2.h:21
int DoubleSize
how many bytes is a double?
Definition: gmsh_file_v2.h:25
std::vector< PhysicalEntity > PhysicalEntities
A list of all Physical entities that have a name.
Definition: gmsh_file_v2.h:62
std::vector< Element > Elements
A list of all Elements (Points,Lines,Surfaces or Volumes) present in the *.msh file.
Definition: gmsh_file_v2.h:196
ElementType
All possible element types (see GMSH documentation)
Definition: gmsh_file_v2.h:75
std::vector< std::pair< size_type, Eigen::Vector3d > > Nodes
The nodes that make up this mesh.
Definition: gmsh_file_v2.h:72
bool IsBinary
Is it a binary file?
Definition: gmsh_file_v2.h:23
std::vector< PeriodicEntity > Periodic
Definition: gmsh_file_v2.h:228
static const std::vector< ElementType > AllElementTypes
Contains a list of all element types that are possible.
Definition: gmsh_file_v2.h:144