25 #include "libmesh/libmesh_config.h" 
   26 #include "libmesh/libmesh_logging.h" 
   27 #include "libmesh/gmv_io.h" 
   28 #include "libmesh/mesh_base.h" 
   29 #include "libmesh/elem.h" 
   30 #include "libmesh/equation_systems.h" 
   31 #include "libmesh/numeric_vector.h" 
   32 #include "libmesh/enum_to_string.h" 
   33 #include "libmesh/enum_io_package.h" 
   34 #include "libmesh/enum_elem_type.h" 
   35 #include "libmesh/int_range.h" 
   36 #include "libmesh/utility.h" 
   40 #ifdef LIBMESH_HAVE_GMV 
   63 struct ElementDefinition {
 
   68   std::vector<unsigned> node_map;
 
   76 std::map<ElemType, ElementDefinition> eletypes;
 
   79 void add_eletype_entry(
ElemType libmesh_elem_type,
 
   80                        const unsigned * node_map,
 
   81                        const std::string & gmv_label,
 
   85   ElementDefinition & map_entry = eletypes[libmesh_elem_type];
 
   88   map_entry.label = gmv_label;
 
   93   std::vector<unsigned int>(node_map,
 
   94                             node_map+nodes_size).swap(map_entry.node_map);
 
  100 void init_eletypes ()
 
  102   if (eletypes.empty())
 
  111         const unsigned int node_map[] = {0,1};
 
  112         add_eletype_entry(
EDGE2, node_map, 
"line 2", 2);
 
  117         const unsigned int node_map[] = {0,1,2};
 
  118         add_eletype_entry(
EDGE3, node_map, 
"3line 3", 3);
 
  123         const unsigned int node_map[] = {0,1,2};
 
  124         add_eletype_entry(
TRI3, node_map, 
"tri3 3", 3);
 
  129         const unsigned int node_map[] = {0,1,2,3,4,5};
 
  130         add_eletype_entry(
TRI6, node_map, 
"6tri 6", 6);
 
  135         const unsigned int node_map[] = {0,1,2,3};
 
  136         add_eletype_entry(
QUAD4, node_map, 
"quad 4", 4);
 
  141         const unsigned int node_map[] = {0,1,2,3,4,5,6,7};
 
  142         add_eletype_entry(
QUAD8, node_map, 
"8quad 8", 8);
 
  150         const unsigned int node_map[] = {0,1,2,3,4,5,6,7};
 
  151         add_eletype_entry(
HEX8, node_map, 
"phex8 8", 8);
 
  157         const unsigned int node_map[] = {0,1,2,3,4,5,6,7,8,9,10,11,16,17,18,19,12,13,14,15};
 
  158         add_eletype_entry(
HEX20, node_map, 
"phex20 20", 20);
 
  168         const unsigned node_map[] = {0,2,1,3};
 
  169         add_eletype_entry(
TET4, node_map, 
"tet 4", 4);
 
  174         const unsigned int node_map[] = {0,1,2,3,4,5,6,7,8,9};
 
  175         add_eletype_entry(
TET10, node_map, 
"ptet10 10", 10);
 
  180         const unsigned int node_map[] = {0,1,2,3,4,5};
 
  181         add_eletype_entry(
PRISM6, node_map, 
"pprism6 6", 6);
 
  187         const unsigned int node_map[] = {0,1,2,3,4,5,6,7,8,12,13,14, 9,10,11};
 
  188         add_eletype_entry(
PRISM15, node_map, 
"pprism15 15", 15);
 
  211   std::map<std::string, ElemType> ret;
 
  223   ret[
"phex20"]   = 
HEX20;
 
  224   ret[
"phex27"]   = 
HEX27;
 
  226   ret[
"ptet10"]   = 
TET10;
 
  228   ret[
"8quad"]    = 
QUAD8;
 
  229   ret[
"3line"]    = 
EDGE3;
 
  245   _discontinuous          (false),
 
  246   _partitioning           (true),
 
  247   _write_subdomain_id_as_material (false),
 
  248   _subdivide_second_order (true),
 
  260   _discontinuous          (false),
 
  261   _partitioning           (true),
 
  262   _write_subdomain_id_as_material (false),
 
  263   _subdivide_second_order (true),
 
  282                               const std::vector<Number> & soln,
 
  283                               const std::vector<std::string> & names)
 
  285   LOG_SCOPE(
"write_nodal_data()", 
"GMVIO");
 
  296                                   const std::vector<Number> * v,
 
  297                                   const std::vector<std::string> * solution_names)
 
  299 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 
  301   libMesh::err << 
"WARNING:  GMVIO::write_ascii_new_impl() not infinite-element aware!" 
  320   std::ofstream out_stream (fname.c_str());
 
  325   if (!out_stream.good())
 
  326     libmesh_file_error(fname.c_str());
 
  328   unsigned int mesh_max_p_level = 0;
 
  332     out_stream << 
"gmvinput ascii\n\n";
 
  344     out_stream << 0. << 
" ";
 
  352     out_stream << 0. << 
" ";
 
  354     out_stream << 
"\n\n";
 
  359     out_stream << 
"cells " << n_active_elem << 
"\n";
 
  366         mesh_max_p_level = std::max(mesh_max_p_level,
 
  373         const ElementDefinition & ele = eletypes[elem->type()];
 
  377         libmesh_assert_less_equal (ele.node_map.size(), elem->n_nodes());
 
  379         out_stream << ele.label << 
"\n";
 
  381           out_stream << elem->node_id(ele.node_map[i])+1 << 
" ";
 
  391         libmesh_error_msg(
"Not yet supported in GMVIO::write_ascii_new_impl");
 
  395           out_stream << 
"material " 
  410             out_stream << 
"proc_" << proc << 
"\n";
 
  414             out_stream << elem->processor_id()+1 << 
"\n";
 
  423   bool write_variable = 
false;
 
  426   if (this->
p_levels() && mesh_max_p_level)
 
  427     write_variable = 
true;
 
  430   if ((solution_names != 
nullptr) && (v != 
nullptr))
 
  431     write_variable = 
true;
 
  435     write_variable = 
true;
 
  438     out_stream << 
"variable\n";
 
  445   if (this->
p_levels() && mesh_max_p_level)
 
  447       out_stream << 
"p_level 0\n";
 
  451           const ElementDefinition & ele = eletypes[elem->type()];
 
  455           libmesh_assert_less_equal (ele.node_map.size(), elem->n_nodes());
 
  457           for (std::size_t i=0, enms=ele.node_map.size(); i < enms; i++)
 
  458             out_stream << elem->p_level() << 
" ";
 
  460       out_stream << 
"\n\n";
 
  470           out_stream << pr.first << 
" 0\n";
 
  472           const std::vector<Real> * the_array = pr.second;
 
  480               libmesh_assert_less (elem->id(), the_array->size());
 
  481               const Real the_value = the_array->operator[](elem->id());
 
  484                 for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
 
  485                   out_stream << the_value << 
" ";
 
  487                 out_stream << the_value << 
" ";
 
  490           out_stream << 
"\n\n";
 
  496   if ((solution_names != 
nullptr) && (v != 
nullptr))
 
  498       const unsigned int n_vars = solution_names->size();
 
  509       for (
unsigned int c=0; c<
n_vars; c++)
 
  512 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 
  518           out_stream << 
"r_" << (*solution_names)[c] << 
" 1\n";
 
  521             out_stream << (*v)[n*
n_vars + c].real() << 
" ";
 
  523           out_stream << 
"\n\n";
 
  526           out_stream << 
"i_" << (*solution_names)[c] << 
" 1\n";
 
  529             out_stream << (*v)[n*
n_vars + c].imag() << 
" ";
 
  531           out_stream << 
"\n\n";
 
  534           out_stream << 
"a_" << (*solution_names)[c] << 
" 1\n";
 
  538           out_stream << 
"\n\n";
 
  542           out_stream << (*solution_names)[c] << 
" 1\n";
 
  545             out_stream << (*v)[n*
n_vars + c] << 
" ";
 
  547           out_stream << 
"\n\n";
 
  556     out_stream << 
"endvars\n";
 
  560   out_stream << 
"\nendgmv\n";
 
  571                                   const std::vector<Number> * v,
 
  572                                   const std::vector<std::string> * solution_names)
 
  592   std::ofstream out_stream (fname.c_str());
 
  598   if (!out_stream.good())
 
  599     libmesh_file_error(fname.c_str());
 
  613   unsigned int mesh_max_p_level = 0;
 
  623     out_stream << 
"gmvinput ascii\n\n";
 
  634     out_stream << 0. << 
" ";
 
  643     out_stream << 0. << 
" ";
 
  646     out_stream << 
'\n' << 
'\n';
 
  654     out_stream << 
"cells ";
 
  656       out_stream << n_active_sub_elem;
 
  658       out_stream << n_active_elem;
 
  662     std::vector<dof_id_type> conn;
 
  666         mesh_max_p_level = std::max(mesh_max_p_level,
 
  676                     out_stream << 
"line 2\n";
 
  677                     elem->connectivity(se, 
TECPLOT, conn);
 
  678                     for (
const auto & 
idx : conn)
 
  679                       out_stream << 
idx << 
" ";
 
  685                   out_stream << 
"line 2\n";
 
  686                   if (elem->default_order() == 
FIRST)
 
  687                     elem->connectivity(0, 
TECPLOT, conn);
 
  691                       for (
auto i : lo_elem->node_index_range())
 
  692                         lo_elem->set_node(i) = elem->node_ptr(i);
 
  693                       lo_elem->connectivity(0, 
TECPLOT, conn);
 
  695                   for (
const auto & 
idx : conn)
 
  696                     out_stream << 
idx << 
" ";
 
  710                     if ((elem->type() == 
QUAD4) ||
 
  711                         (elem->type() == 
QUAD8) || 
 
  714                         (elem->type() == 
QUAD9)
 
  715 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
 
  721                         out_stream << 
"quad 4\n";
 
  722                         elem->connectivity(se, 
TECPLOT, conn);
 
  723                         for (
const auto & 
idx : conn)
 
  724                           out_stream << 
idx << 
" ";
 
  728                     else if ((elem->type() == 
TRI3) ||
 
  729                              (elem->type() == 
TRI6))
 
  731                         out_stream << 
"tri 3\n";
 
  732                         elem->connectivity(se, 
TECPLOT, conn);
 
  733                         for (
unsigned int i=0; i<3; i++)
 
  734                           out_stream << conn[i] << 
" ";
 
  742                   if ((elem->type() == 
QUAD4)
 
  743 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
 
  748                       elem->connectivity(0, 
TECPLOT, conn);
 
  749                       out_stream << 
"quad 4\n";
 
  750                       for (
const auto & 
idx : conn)
 
  751                         out_stream << 
idx << 
" ";
 
  753                   else if ((elem->type() == 
QUAD8) ||
 
  754                            (elem->type() == 
QUAD9)
 
  755 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
 
  761                       for (
auto i : lo_elem->node_index_range())
 
  762                         lo_elem->set_node(i) = elem->node_ptr(i);
 
  763                       lo_elem->connectivity(0, 
TECPLOT, conn);
 
  764                       out_stream << 
"quad 4\n";
 
  765                       for (
const auto & 
idx : conn)
 
  766                         out_stream << 
idx << 
" ";
 
  768                   else if (elem->type() == 
TRI3)
 
  770                       elem->connectivity(0, 
TECPLOT, conn);
 
  771                       out_stream << 
"tri 3\n";
 
  772                       for (
unsigned int i=0; i<3; i++)
 
  773                         out_stream << conn[i] << 
" ";
 
  775                   else if (elem->type() == 
TRI6)
 
  778                       for (
auto i : lo_elem->node_index_range())
 
  779                         lo_elem->set_node(i) = elem->node_ptr(i);
 
  780                       lo_elem->connectivity(0, 
TECPLOT, conn);
 
  781                       out_stream << 
"tri 3\n";
 
  782                       for (
unsigned int i=0; i<3; i++)
 
  783                         out_stream << conn[i] << 
" ";
 
  798 #ifndef  LIBMESH_ENABLE_INFINITE_ELEMENTS 
  799                     if ((elem->type() == 
HEX8)   ||
 
  800                         (elem->type() == 
HEX27))
 
  802                         out_stream << 
"phex8 8\n";
 
  803                         elem->connectivity(se, 
TECPLOT, conn);
 
  804                         for (
const auto & 
idx : conn)
 
  805                           out_stream << 
idx << 
" ";
 
  808                     else if (elem->type() == 
HEX20)
 
  810                         out_stream << 
"phex20 20\n";
 
  811                         out_stream << elem->node_id(0)+1  << 
" " 
  812                                    << elem->node_id(1)+1  << 
" " 
  813                                    << elem->node_id(2)+1  << 
" " 
  814                                    << elem->node_id(3)+1  << 
" " 
  815                                    << elem->node_id(4)+1  << 
" " 
  816                                    << elem->node_id(5)+1  << 
" " 
  817                                    << elem->node_id(6)+1  << 
" " 
  818                                    << elem->node_id(7)+1  << 
" " 
  819                                    << elem->node_id(8)+1  << 
" " 
  820                                    << elem->node_id(9)+1  << 
" " 
  821                                    << elem->node_id(10)+1 << 
" " 
  822                                    << elem->node_id(11)+1 << 
" " 
  823                                    << elem->node_id(16)+1 << 
" " 
  824                                    << elem->node_id(17)+1 << 
" " 
  825                                    << elem->node_id(18)+1 << 
" " 
  826                                    << elem->node_id(19)+1 << 
" " 
  827                                    << elem->node_id(12)+1 << 
" " 
  828                                    << elem->node_id(13)+1 << 
" " 
  829                                    << elem->node_id(14)+1 << 
" " 
  830                                    << elem->node_id(15)+1 << 
" ";
 
  885 #else // LIBMESH_ENABLE_INFINITE_ELEMENTS 
  890                     if ((elem->type() == 
HEX8)     ||
 
  891                         (elem->type() == 
HEX27)    ||
 
  895                         (elem->type() == 
HEX20))
 
  897                         out_stream << 
"phex8 8\n";
 
  898                         elem->connectivity(se, 
TECPLOT, conn);
 
  899                         for (
const auto & 
idx : conn)
 
  900                           out_stream << 
idx << 
" ";
 
  904                     else if ((elem->type() == 
TET4)  ||
 
  905                              (elem->type() == 
TET10))
 
  907                         out_stream << 
"tet 4\n";
 
  912                         elem->connectivity(se, 
TECPLOT, conn);
 
  913                         out_stream << conn[0] << 
" "   
  918 #ifndef  LIBMESH_ENABLE_INFINITE_ELEMENTS 
  919                     else if ((elem->type() == 
PRISM6)  ||
 
  924                     else if ((elem->type() == 
PRISM6)     ||
 
  934                         out_stream << 
"phex8 8\n";
 
  935                         elem->connectivity(se, 
TECPLOT, conn);
 
  936                         for (
const auto & 
idx : conn)
 
  937                           out_stream << 
idx << 
" ";
 
  941                       libmesh_error_msg(
"Encountered an unrecognized element " \
 
  942                                         << 
"type: " << elem->type()  \
 
  943                                         << 
"\nPossibly a dim-1 dimensional " \
 
  944                                         << 
"element?  Aborting...");
 
  951                   for (
auto i : lo_elem->node_index_range())
 
  952                     lo_elem->set_node(i) = elem->node_ptr(i);
 
  953                   if ((lo_elem->type() == 
HEX8)
 
  954 #ifdef  LIBMESH_ENABLE_INFINITE_ELEMENTS
 
  955                       || (lo_elem->type() == 
HEX27)
 
  959                       out_stream << 
"phex8 8\n";
 
  960                       lo_elem->connectivity(0, 
TECPLOT, conn);
 
  961                       for (
const auto & 
idx : conn)
 
  962                         out_stream << 
idx << 
" ";
 
  965                   else if (lo_elem->type() == 
TET4)
 
  967                       out_stream << 
"tet 4\n";
 
  968                       lo_elem->connectivity(0, 
TECPLOT, conn);
 
  969                       out_stream << conn[0] << 
" " 
  974                   else if ((lo_elem->type() == 
PRISM6)
 
  975 #ifdef  LIBMESH_ENABLE_INFINITE_ELEMENTS
 
  982                       out_stream << 
"phex8 8\n";
 
  983                       lo_elem->connectivity(0, 
TECPLOT, conn);
 
  984                       for (
const auto & 
idx : conn)
 
  985                         out_stream << 
idx << 
" ";
 
  989                     libmesh_error_msg(
"Encountered an unrecognized element " \
 
  990                                       << 
"type.  Possibly a dim-1 dimensional " \
 
  991                                       << 
"element?  Aborting...");
 
 1000             libmesh_error_msg(
"Unsupported element dimension: " <<
 
 1023           std::map<subdomain_id_type, unsigned> sbdid_map;
 
 1027             sbdid_map.insert(std::make_pair(elem->subdomain_id(), 0));
 
 1033             for (
auto & pr : sbdid_map)
 
 1037           out_stream << 
"material " 
 1042             out_stream << 
"proc_" << sbdid << 
"\n";
 
 1047               unsigned gmv_mat_number = libmesh_map_find(sbdid_map, elem->subdomain_id());
 
 1050                 for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
 
 1051                   out_stream << gmv_mat_number+1 << 
'\n';
 
 1053                 out_stream << gmv_mat_number+1 << 
"\n";
 
 1060           out_stream << 
"material " 
 1065             out_stream << 
"proc_" << proc << 
'\n';
 
 1069               for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
 
 1070                 out_stream << elem->processor_id()+1 << 
'\n';
 
 1072               out_stream << elem->processor_id()+1 << 
'\n';
 
 1083   bool write_variable = 
false;
 
 1086   if (this->
p_levels() && mesh_max_p_level)
 
 1087     write_variable = 
true;
 
 1090   if ((solution_names != 
nullptr) && (v != 
nullptr))
 
 1091     write_variable = 
true;
 
 1095     write_variable = 
true;
 
 1098     out_stream << 
"variable\n";
 
 1102   if (this->
p_levels() && mesh_max_p_level)
 
 1104       out_stream << 
"p_level 0\n";
 
 1108           for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
 
 1109             out_stream << elem->p_level() << 
" ";
 
 1111           out_stream << elem->p_level() << 
" ";
 
 1112       out_stream << 
"\n\n";
 
 1124           out_stream << pr.first << 
" 0\n";
 
 1126           const std::vector<Real> * the_array = pr.second;
 
 1134               libmesh_assert_less (elem->id(), the_array->size());
 
 1135               const Real the_value = (*the_array)[elem->id()];
 
 1138                 for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
 
 1139                   out_stream << the_value << 
" ";
 
 1141                 out_stream << the_value << 
" ";
 
 1144           out_stream << 
"\n\n";
 
 1152   if ((solution_names != 
nullptr) &&
 
 1155       const unsigned int n_vars =
 
 1156         cast_int<unsigned int>(solution_names->size());
 
 1167       for (
unsigned int c=0; c<
n_vars; c++)
 
 1170 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 
 1176           out_stream << 
"r_" << (*solution_names)[c] << 
" 1\n";
 
 1179             out_stream << (*v)[n*
n_vars + c].real() << 
" ";
 
 1181           out_stream << 
'\n' << 
'\n';
 
 1185           out_stream << 
"i_" << (*solution_names)[c] << 
" 1\n";
 
 1188             out_stream << (*v)[n*
n_vars + c].imag() << 
" ";
 
 1190           out_stream << 
'\n' << 
'\n';
 
 1193           out_stream << 
"a_" << (*solution_names)[c] << 
" 1\n";
 
 1197           out_stream << 
'\n' << 
'\n';
 
 1201           out_stream << (*solution_names)[c] << 
" 1\n";
 
 1204             out_stream << (*v)[n*
n_vars + c] << 
" ";
 
 1206           out_stream << 
'\n' << 
'\n';
 
 1215     out_stream << 
"endvars\n";
 
 1219   out_stream << 
"\nendgmv\n";
 
 1229                           const std::vector<Number> * vec,
 
 1230                           const std::vector<std::string> * solution_names)
 
 1245   std::ofstream out_stream (fname.c_str());
 
 1249   unsigned int mesh_max_p_level = 0;
 
 1256     buffer = 
"gmvinput";
 
 1257     out_stream.write(buffer.c_str(), buffer.size());
 
 1259     buffer = 
"ieeei4r4";
 
 1260     out_stream.write(buffer.c_str(), buffer.size());
 
 1268     out_stream.write(buffer.c_str(), buffer.size());
 
 1271     out_stream.write(reinterpret_cast<char *>(&tempint), 
sizeof(
unsigned int));
 
 1276       temp[v] = static_cast<float>(
mesh.
point(v)(0));
 
 1277     out_stream.write(reinterpret_cast<char *>(temp.data()), 
sizeof(
float)*
mesh.
n_nodes());
 
 1283         temp[v] = static_cast<float>(
mesh.
point(v)(1));
 
 1288     out_stream.write(reinterpret_cast<char *>(temp.data()), 
sizeof(
float)*
mesh.
n_nodes());
 
 1294         temp[v] = static_cast<float>(
mesh.
point(v)(2));
 
 1299     out_stream.write(reinterpret_cast<char *>(temp.data()), 
sizeof(
float)*
mesh.
n_nodes());
 
 1306     out_stream.write(buffer.c_str(), buffer.size());
 
 1308     unsigned int tempint = n_active_elem;
 
 1309     out_stream.write(reinterpret_cast<char *>(&tempint), 
sizeof(
unsigned int));
 
 1313         mesh_max_p_level = std::max(mesh_max_p_level,
 
 1319         const ElementDefinition & ed = eletypes[elem->type()];
 
 1328         buffer.erase(buffer.find_first_of(
' '), std::string::npos);
 
 1331         while (buffer.size() < 8)
 
 1332           buffer.insert(buffer.end(), 
' ');
 
 1335         out_stream.write(buffer.c_str(), buffer.size());
 
 1342         tempint = cast_int<unsigned int>(ed.node_map.size());
 
 1343         out_stream.write(reinterpret_cast<char *>(&tempint), 
sizeof(
unsigned int));
 
 1346         for (
const auto & ed_id : ed.node_map)
 
 1349             out_stream.write(reinterpret_cast<char *>(&
id), 
sizeof(
dof_id_type));
 
 1360         libmesh_error_msg(
"Not yet supported in GMVIO::write_binary");
 
 1364           buffer = 
"material";
 
 1365           out_stream.write(buffer.c_str(), buffer.size());
 
 1368           out_stream.write(reinterpret_cast<char *>(&tmpint), 
sizeof(
unsigned int));
 
 1371           out_stream.write(reinterpret_cast<char *>(&tmpint), 
sizeof(
unsigned int));
 
 1378               std::ostringstream oss;
 
 1379               oss << 
"proc_" << std::setw(3) << std::left << proc;
 
 1380               out_stream.write(oss.str().c_str(), oss.str().size());
 
 1383           std::vector<unsigned int> proc_id (n_active_elem);
 
 1390             proc_id[n++] = elem->processor_id() + 1;
 
 1392           out_stream.write(reinterpret_cast<char *>(proc_id.data()),
 
 1393                            sizeof(
unsigned int)*proc_id.size());
 
 1401   bool write_variable = 
false;
 
 1404   if (this->
p_levels() && mesh_max_p_level)
 
 1405     write_variable = 
true;
 
 1408   if ((solution_names != 
nullptr) && (vec != 
nullptr))
 
 1409     write_variable = 
true;
 
 1417       buffer = 
"variable";
 
 1418       out_stream.write(buffer.c_str(), buffer.size());
 
 1422   if (this->
p_levels() && mesh_max_p_level)
 
 1424       unsigned int n_floats = n_active_elem;
 
 1428       std::vector<float> temp(n_floats);
 
 1431       out_stream.write(buffer.c_str(), buffer.size());
 
 1433       unsigned int tempint = 0; 
 
 1434       out_stream.write(reinterpret_cast<char *>(&tempint), 
sizeof(
unsigned int));
 
 1438         for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
 
 1439           temp[n++] = static_cast<float>( elem->p_level() );
 
 1441       out_stream.write(reinterpret_cast<char *>(temp.data()),
 
 1442                        sizeof(
float)*n_floats);
 
 1448     libMesh::err << 
"Cell-centered data not (yet) supported in binary I/O mode!" << std::endl;
 
 1454   if ((solution_names != 
nullptr) &&
 
 1459       const unsigned int n_vars =
 
 1460         cast_int<unsigned int>(solution_names->size());
 
 1462       for (
unsigned int c=0; c<
n_vars; c++)
 
 1465 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 
 1471           out_stream.write(buffer.c_str(), buffer.size());
 
 1473           buffer = (*solution_names)[c];
 
 1474           out_stream.write(buffer.c_str(), buffer.size());
 
 1476           unsigned int tempint = 1; 
 
 1477           out_stream.write(reinterpret_cast<char *>(&tempint), 
sizeof(
unsigned int));
 
 1480             temp[n] = static_cast<float>( (*vec)[n*
n_vars + c].
real() );
 
 1482           out_stream.write(reinterpret_cast<char *>(temp.data()), 
sizeof(
float)*
mesh.
n_nodes());
 
 1487           out_stream.write(buffer.c_str(), buffer.size());
 
 1489           buffer = (*solution_names)[c];
 
 1490           out_stream.write(buffer.c_str(), buffer.size());
 
 1492           out_stream.write(reinterpret_cast<char *>(&tempint), 
sizeof(
unsigned int));
 
 1495             temp[n] = static_cast<float>( (*vec)[n*
n_vars + c].
imag() );
 
 1497           out_stream.write(reinterpret_cast<char *>(temp.data()), 
sizeof(
float)*
mesh.
n_nodes());
 
 1501           out_stream.write(buffer.c_str(), buffer.size());
 
 1502           buffer = (*solution_names)[c];
 
 1503           out_stream.write(buffer.c_str(), buffer.size());
 
 1505           out_stream.write(reinterpret_cast<char *>(&tempint), 
sizeof(
unsigned int));
 
 1510           out_stream.write(reinterpret_cast<char *>(temp.data()), 
sizeof(
float)*
mesh.
n_nodes());
 
 1514           buffer = (*solution_names)[c];
 
 1515           out_stream.write(buffer.c_str(), buffer.size());
 
 1517           unsigned int tempint = 1; 
 
 1518           out_stream.write(reinterpret_cast<char *>(&tempint), 
sizeof(
unsigned int));
 
 1521             temp[n] = static_cast<float>((*vec)[n*
n_vars + c]);
 
 1523           out_stream.write(reinterpret_cast<char *>(temp.data()), 
sizeof(
float)*
mesh.
n_nodes());
 
 1532       buffer = 
"endvars ";
 
 1533       out_stream.write(buffer.c_str(), buffer.size());
 
 1538   out_stream.write(buffer.c_str(), buffer.size());
 
 1551                                      const bool write_partitioning,
 
 1552                                      const std::set<std::string> * system_names)
 const 
 1554   std::vector<std::string> solution_names;
 
 1555   std::vector<Number>      v;
 
 1569   std::ofstream out_stream(
name.c_str());
 
 1577     out_stream << 
"gmvinput ascii" << std::endl << std::endl;
 
 1584         tw += elem->n_nodes();
 
 1586       out_stream << 
"nodes " << tw << std::endl;
 
 1594         for (
const Node & node : elem->node_ref_range())
 
 1595           out_stream << node(0) << 
" ";
 
 1597       out_stream << std::endl;
 
 1604         for (
const Node & node : elem->node_ref_range())
 
 1606           out_stream << node(1) << 
" ";
 
 1608       out_stream << 0. << 
" ";
 
 1611       out_stream << std::endl;
 
 1618         for (
const Node & node : elem->node_ref_range())
 
 1620           out_stream << node(2) << 
" ";
 
 1622       out_stream << 0. << 
" ";
 
 1625       out_stream << std::endl << std::endl;
 
 1634     out_stream << 
"cells " << n_active_elem << std::endl;
 
 1643             for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
 
 1645                 if ((elem->type() == 
EDGE2) ||
 
 1646                     (elem->type() == 
EDGE3) ||
 
 1647                     (elem->type() == 
EDGE4)
 
 1648 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
 
 1653                     out_stream << 
"line 2" << std::endl;
 
 1654                     for (
unsigned int i=0, enn=elem->n_nodes(); i<enn; i++)
 
 1655                       out_stream << nn++ << 
" ";
 
 1661                 out_stream << std::endl;
 
 1670             for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
 
 1672                 if ((elem->type() == 
QUAD4) ||
 
 1673                     (elem->type() == 
QUAD8) || 
 
 1676                     (elem->type() == 
QUAD9)
 
 1677 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
 
 1683                     out_stream << 
"quad 4" << std::endl;
 
 1684                     for (
unsigned int i=0, enn=elem->n_nodes(); i<enn; i++)
 
 1685                       out_stream << nn++ << 
" ";
 
 1688                 else if ((elem->type() == 
TRI3) ||
 
 1689                          (elem->type() == 
TRI6))
 
 1691                     out_stream << 
"tri 3" << std::endl;
 
 1692                     for (
unsigned int i=0, enn=elem->n_nodes(); i<enn; i++)
 
 1693                       out_stream << nn++ << 
" ";
 
 1699                 out_stream << std::endl;
 
 1709             for (
unsigned int se=0, nse=elem->n_sub_elem(); se<nse; se++)
 
 1711                 if ((elem->type() == 
HEX8) ||
 
 1712                     (elem->type() == 
HEX20) ||
 
 1713                     (elem->type() == 
HEX27)
 
 1714 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
 
 1721                     out_stream << 
"phex8 8" << std::endl;
 
 1722                     for (
unsigned int i=0, enn=elem->n_nodes(); i<enn; i++)
 
 1723                       out_stream << nn++ << 
" ";
 
 1725                 else if ((elem->type() == 
PRISM6) ||
 
 1728 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
 
 1734                     out_stream << 
"pprism6 6" << std::endl;
 
 1735                     for (
unsigned int i=0, enn=elem->n_nodes(); i<enn; i++)
 
 1736                       out_stream << nn++ << 
" ";
 
 1738                 else if ((elem->type() == 
TET4) ||
 
 1739                          (elem->type() == 
TET10))
 
 1741                     out_stream << 
"tet 4" << std::endl;
 
 1742                     for (
unsigned int i=0, enn=elem->n_nodes(); i<enn; i++)
 
 1743                       out_stream << nn++ << 
" ";
 
 1748                 out_stream << std::endl;
 
 1758     out_stream << std::endl;
 
 1764   if (write_partitioning)
 
 1767         libmesh_error_msg(
"Not yet supported in GMVIO::write_discontinuous_gmv");
 
 1771           out_stream << 
"material " 
 1773                      << 
" 0"<< std::endl;
 
 1776             out_stream << 
"proc_" << proc << std::endl;
 
 1779             out_stream << elem->processor_id()+1 << std::endl;
 
 1781           out_stream << std::endl;
 
 1789       libMesh::err << 
"Cell-centered data not (yet) supported for discontinuous GMV files!" << std::endl;
 
 1796     const unsigned int n_vars =
 
 1797       cast_int<unsigned int>(solution_names.size());
 
 1801     out_stream << 
"variable" << std::endl;
 
 1804     for (
unsigned int c=0; c<
n_vars; c++)
 
 1807 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 
 1813         out_stream << 
"r_" << solution_names[c] << 
" 1" << std::endl;
 
 1815           for (
auto n : elem->node_index_range())
 
 1816             out_stream << v[(n++)*
n_vars + c].real() << 
" ";
 
 1817         out_stream << std::endl << std::endl;
 
 1821         out_stream << 
"i_" << solution_names[c] << 
" 1" << std::endl;
 
 1823           for (
auto n : elem->node_index_range())
 
 1824             out_stream << v[(n++)*
n_vars + c].imag() << 
" ";
 
 1825         out_stream << std::endl << std::endl;
 
 1828         out_stream << 
"a_" << solution_names[c] << 
" 1" << std::endl;
 
 1830           for (
auto n : elem->node_index_range())
 
 1832         out_stream << std::endl << std::endl;
 
 1836         out_stream << solution_names[c] << 
" 1" << std::endl;
 
 1841             for (
unsigned int i=0, enn=elem->n_nodes(); i<enn; i++)
 
 1842               out_stream << v[(nn++)*
n_vars + c] << 
" ";
 
 1844         out_stream << std::endl << std::endl;
 
 1850     out_stream << 
"endvars" << std::endl;
 
 1855   out_stream << std::endl << 
"endgmv" << std::endl;
 
 1863                                     const std::vector<Real> * cell_centered_data_vals)
 
 1888   libmesh_experimental();
 
 1890 #ifndef LIBMESH_HAVE_GMV 
 1892   libmesh_error_msg(
"Cannot read GMV file " << 
name << 
" without the GMV API.");
 
 1911   int ierr = GMVLib::gmvread_open_fromfileskip(const_cast<char *>(
name.c_str()));
 
 1913     libmesh_error_msg(
"GMVLib::gmvread_open_fromfileskip failed!");
 
 1920       GMVLib::gmvread_data();
 
 1923       if (GMVLib::gmv_data.keyword == GMVEND)
 
 1926           GMVLib::gmvread_close();
 
 1931       if (GMVLib::gmv_data.keyword == GMVERROR)
 
 1932         libmesh_error_msg(
"Encountered GMVERROR while reading!");
 
 1935       switch (GMVLib::gmv_data.keyword)
 
 1939             if (GMVLib::gmv_data.num2 == 
NODES)
 
 1942             else if (GMVLib::gmv_data.num2 == NODE_V)
 
 1943               libmesh_error_msg(
"Unsupported GMV data type NODE_V!");
 
 1970             if (GMVLib::gmv_data.datatype == ENDKEYWORD)
 
 1975             if (GMVLib::gmv_data.datatype == NODE)
 
 1984                              << GMVLib::gmv_data.name1
 
 1985                              << 
" which is of unsupported GMV datatype " 
 1986                              << GMVLib::gmv_data.datatype
 
 1987                              << 
".  Nodal field data is currently the only type currently supported." 
 1995           libmesh_error_msg(
"Encountered unknown GMV keyword " << GMVLib::gmv_data.keyword);
 
 2001   for (
unsigned char i=0; i!=4; ++i)
 
 2007     libmesh_error_msg(
"Cannot open dimension " \
 
 2009                       << 
" mesh file when configured without "        \
 
 2032 #ifdef LIBMESH_HAVE_GMV 
 2035   _nodal_data.insert ( std::make_pair(std::string(GMVLib::gmv_data.name1),
 
 2036                                       std::vector<Number>(GMVLib::gmv_data.doubledata1, GMVLib::gmv_data.doubledata1+GMVLib::gmv_data.num) ) );
 
 2044 #ifdef LIBMESH_HAVE_GMV 
 2047   libmesh_assert_equal_to (GMVLib::gmv_data.datatype, CELL);
 
 2056   for (
int i = 0; i < GMVLib::gmv_data.nlongdata1; i++)
 
 2058       cast_int<processor_id_type>(GMVLib::gmv_data.longdata1[i]-1);
 
 2068 #ifdef LIBMESH_HAVE_GMV 
 2070   libmesh_assert_equal_to (GMVLib::gmv_data.datatype, UNSTRUCT);
 
 2074   for (
int i = 0; i < GMVLib::gmv_data.num; i++)
 
 2078                                                   GMVLib::gmv_data.doubledata2[i],
 
 2079                                                   GMVLib::gmv_data.doubledata3[i]), i);
 
 2087 #ifdef LIBMESH_HAVE_GMV 
 2092     (GMVLib::gmv_data.datatype==REGULAR) ||
 
 2093     (GMVLib::gmv_data.datatype==ENDKEYWORD);
 
 2099   if (GMVLib::gmv_data.datatype == REGULAR)
 
 2118       const ElementDefinition & eledef = eletypes[type];
 
 2122       for (
int i=0; i<GMVLib::gmv_data.num2; i++)
 
 2125           unsigned mapped_i = eledef.node_map[i];
 
 2129             (cast_int<dof_id_type>(GMVLib::gmv_data.longdata1[mapped_i]-1));
 
 2139   if (GMVLib::gmv_data.datatype == ENDKEYWORD)
 
 2152   elemname.erase(std::remove_if(elemname.begin(), elemname.end(), isspace), elemname.end());
 
 2164       libMesh::err << 
"Unable to copy nodal solution: No nodal " 
 2165                    << 
"solution has been read in from file." << std::endl;
 
 2178   std::set<std::string> vars_copied;
 
 2191           const std::string & var_name = pr.first;
 
 2206                   libMesh::err << 
"Only FIRST-order LAGRANGE variables can be read from GMV files. " 
 2207                                << 
"Skipping variable " << var_name << std::endl;
 
 2215                    sz = cast_int<dof_id_type>(pr.second.size());
 
 2220                   const unsigned int dof_index =
 
 2226                   if ((dof_index >= system.
solution->first_local_index()) &&
 
 2227                       (dof_index <  system.solution->last_local_index()))
 
 2228                     system.
solution->set (dof_index, pr.second [i]);
 
 2232               vars_copied.insert (var_name);
 
 2245     if (vars_copied.find(pr.first) == vars_copied.end())
 
 2248                    << 
" was not copied to the EquationSystems object."