libMesh
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
libMesh::UNVIO Class Reference

The UNVIO class implements the Ideas UNV universal file format. More...

#include <unv_io.h>

Inheritance diagram for libMesh::UNVIO:
[legend]

Public Member Functions

 UNVIO (MeshBase &mesh)
 Constructor. More...
 
 UNVIO (const MeshBase &mesh)
 Constructor. More...
 
virtual ~UNVIO ()
 Destructor. More...
 
virtual void read (const std::string &) override
 This method implements reading a mesh from a specified file. More...
 
virtual void write (const std::string &) override
 This method implements writing a mesh to a specified file. More...
 
bool & verbose ()
 Set the flag indicating if we should be verbose. More...
 
void read_dataset (std::string file_name)
 Read a UNV data file containing a dataset of type "2414". More...
 
const std::vector< Number > * get_data (Node *node) const
 
bool is_parallel_format () const
 Returns true iff this mesh file format and input class are parallelized, so that all processors can read their share of the data at once. More...
 
virtual void write_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
 This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems object. More...
 
virtual void write_discontinuous_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
 This method implements writing a mesh with discontinuous data to a specified file where the data is taken from the EquationSystems object. More...
 
virtual void write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
 This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are provided. More...
 
virtual void write_nodal_data (const std::string &, const NumericVector< Number > &, const std::vector< std::string > &)
 This method may be overridden by "parallel" output formats for writing nodal data. More...
 
virtual void write_nodal_data (const std::string &, const EquationSystems &, const std::set< std::string > *)
 This method should be overridden by "parallel" output formats for writing nodal data. More...
 
virtual void write_nodal_data_discontinuous (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
 This method implements writing a mesh with discontinuous data to a specified file where the nodal data and variables names are provided. More...
 
unsigned intascii_precision ()
 Return/set the precision to use when writing ASCII files. More...
 

Protected Member Functions

MeshBasemesh ()
 
void set_n_partitions (unsigned int n_parts)
 Sets the number of partitions in the mesh. More...
 
void skip_comment_lines (std::istream &in, const char comment_start)
 Reads input from in, skipping all the lines that start with the character comment_start. More...
 
const MeshBasemesh () const
 
virtual bool get_add_sides ()
 

Protected Attributes

std::vector< bool > elems_of_dimension
 A vector of bools describing what dimension elements have been encountered when reading a mesh. More...
 
const bool _is_parallel_format
 Flag specifying whether this format is parallel-capable. More...
 
const bool _serial_only_needed_on_proc_0
 Flag specifying whether this format can be written by only serializing the mesh to processor zero. More...
 

Private Member Functions

void read_implementation (std::istream &in_stream)
 The actual implementation of the read function. More...
 
void write_implementation (std::ostream &out_stream)
 The actual implementation of the write function. More...
 
void nodes_in (std::istream &in_file)
 Read nodes from file. More...
 
void elements_in (std::istream &in_file)
 Method reads elements and stores them in std::vector<Elem *> _elements in the same order as they come in. More...
 
void groups_in (std::istream &in_file)
 Reads the "groups" section of the file. More...
 
void nodes_out (std::ostream &out_file)
 Outputs nodes to the file out_file. More...
 
void elements_out (std::ostream &out_file)
 Outputs the element data to the file out_file. More...
 
unsigned char max_elem_dimension_seen ()
 
bool need_D_to_e (std::string &number)
 Replaces "1.1111D+00" with "1.1111e+00" if necessary. More...
 

Private Attributes

bool _verbose
 should be be verbose? More...
 
std::map< dof_id_type, Node * > _unv_node_id_to_libmesh_node_ptr
 Maps UNV node IDs to libMesh Node*s. More...
 
std::map< unsigned, unsigned > _unv_elem_id_to_libmesh_elem_id
 Map UNV element IDs to libmesh element IDs. More...
 
std::map< Node *, std::vector< Number > > _node_data
 Map from libMesh Node* to data at that node, as read in by the read_dataset() function. More...
 

Static Private Attributes

static const std::string _nodes_dataset_label = "2411"
 label for the node dataset More...
 
static const std::string _elements_dataset_label = "2412"
 label for the element dataset More...
 
static const std::string _groups_dataset_label = "2467"
 label for the groups dataset More...
 

Detailed Description

The UNVIO class implements the Ideas UNV universal file format.

This class enables both reading and writing UNV files.

Author history

Author
Tammo Kaschner
Daniel Dreyer
Benjamin S. Kirk
John W. Peterson
Date
2003, 2004, 2014

Definition at line 52 of file unv_io.h.

Constructor & Destructor Documentation

◆ UNVIO() [1/2]

libMesh::UNVIO::UNVIO ( MeshBase mesh)

Constructor.

Takes a writable reference to a mesh object. This is the constructor required to read a mesh.

Definition at line 70 of file unv_io.C.

70  :
71  MeshInput<MeshBase> (mesh),
73  _verbose (false)
74 {
75 }
bool _verbose
should be be verbose?
Definition: unv_io.h:182
template class LIBMESH_EXPORT MeshOutput< MeshBase >
Definition: mesh_output.C:180

◆ UNVIO() [2/2]

libMesh::UNVIO::UNVIO ( const MeshBase mesh)

Constructor.

Takes a reference to a constant mesh object. This constructor will only allow us to write the mesh.

Definition at line 79 of file unv_io.C.

79  :
81  _verbose (false)
82 {
83 }
bool _verbose
should be be verbose?
Definition: unv_io.h:182
template class LIBMESH_EXPORT MeshOutput< MeshBase >
Definition: mesh_output.C:180

◆ ~UNVIO()

libMesh::UNVIO::~UNVIO ( )
virtualdefault

Destructor.

Member Function Documentation

◆ ascii_precision()

unsigned int & libMesh::MeshOutput< MeshBase >::ascii_precision ( )
inlineinherited

Return/set the precision to use when writing ASCII files.

By default we use numeric_limits<Real>::max_digits10, which should be enough to write out to ASCII and get the exact same Real back when reading in.

Definition at line 269 of file mesh_output.h.

Referenced by nodes_out(), libMesh::FroIO::write(), libMesh::MEDITIO::write_ascii(), libMesh::TecplotIO::write_ascii(), libMesh::GMVIO::write_ascii_new_impl(), and libMesh::GMVIO::write_ascii_old_impl().

270 {
271  return _ascii_precision;
272 }
unsigned int _ascii_precision
Precision to use when writing ASCII files.
Definition: mesh_output.h:207

◆ elements_in()

void libMesh::UNVIO::elements_in ( std::istream &  in_file)
private

Method reads elements and stores them in std::vector<Elem *> _elements in the same order as they come in.

Within UNVIO, element labels are ignored.

Definition at line 585 of file unv_io.C.

References _unv_elem_id_to_libmesh_elem_id, _unv_node_id_to_libmesh_node_ptr, libMesh::MeshBase::add_elem(), libMesh::Elem::build(), libMesh::EDGE2, libMesh::MeshInput< MeshBase >::elems_of_dimension, libMesh::HEX20, libMesh::HEX8, libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), n_nodes, libMesh::out, libMesh::PRISM6, libMesh::QUAD4, libMesh::QUAD8, libMesh::QUAD9, libMesh::TET10, libMesh::TET4, libMesh::TRI3, libMesh::TRI6, and verbose().

Referenced by read_implementation().

586 {
587  LOG_SCOPE("elements_in()","UNVIO");
588 
589  if (this->verbose())
590  libMesh::out << " Reading elements" << std::endl;
591 
592  MeshBase & mesh = MeshInput<MeshBase>::mesh();
593 
594  // node label, we use an int here so we can read in a -1
595  int element_label;
596 
597  unsigned
598  n_nodes, // number of nodes on element
599  fe_descriptor_id, // FE descriptor id
600  phys_prop_tab_num, // physical property table number (not supported yet)
601  mat_prop_tab_num, // material property table number (not supported yet)
602  color; // color (not supported yet)
603 
604  // vector that temporarily holds the node labels defining element
605  std::vector<unsigned int> node_labels (21);
606 
607  // vector that assigns element nodes to their correct position
608  // for example:
609  // 44:plane stress | QUAD4
610  // linear quadrilateral |
611  // position in UNV-file | position in libmesh
612  // assign_elem_node[1] = 0
613  // assign_elem_node[2] = 3
614  // assign_elem_node[3] = 2
615  // assign_elem_node[4] = 1
616  //
617  // UNV is 1-based, we leave the 0th element of the vectors unused in order
618  // to prevent confusion, this way we can store elements with up to 20 nodes
619  unsigned int assign_elem_nodes[21];
620 
621  // Read elements until there are none left
622  unsigned ctr = 0;
623  while (true)
624  {
625  // read element label, break out when we read -1
626  in_file >> element_label;
627 
628  if (element_label == -1)
629  break;
630 
631  in_file >> fe_descriptor_id // read FE descriptor id
632  >> phys_prop_tab_num // (not supported yet)
633  >> mat_prop_tab_num // (not supported yet)
634  >> color // (not supported yet)
635  >> n_nodes; // read number of nodes on element
636 
637  // For "beam" type elements, the next three numbers are:
638  // .) beam orientation node number
639  // .) beam fore-end cross section number
640  // .) beam aft-end cross section number
641  // which we discard in libmesh. The "beam" type elements:
642  // 11 Rod
643  // 21 Linear beam
644  // 22 Tapered beam
645  // 23 Curved beam
646  // 24 Parabolic beam
647  // all have fe_descriptor_id < 25.
648  // http://www.sdrl.uc.edu/universal-file-formats-for-modal-analysis-testing-1/file-format-storehouse/unv_2412.htm
649  if (fe_descriptor_id < 25)
650  {
651  unsigned dummy;
652  in_file >> dummy >> dummy >> dummy;
653  }
654 
655  // read node labels (1-based)
656  for (unsigned int j=1; j<=n_nodes; j++)
657  in_file >> node_labels[j];
658 
659  // element pointer, to be allocated
660  std::unique_ptr<Elem> elem;
661 
662  switch (fe_descriptor_id)
663  {
664  case 11: // Rod
665  {
666  elem = Elem::build(EDGE2);
667 
668  assign_elem_nodes[1]=0;
669  assign_elem_nodes[2]=1;
670  break;
671  }
672 
673  case 41: // Plane Stress Linear Triangle
674  case 91: // Thin Shell Linear Triangle
675  {
676  elem = Elem::build(TRI3); // create new element
677 
678  assign_elem_nodes[1]=0;
679  assign_elem_nodes[2]=2;
680  assign_elem_nodes[3]=1;
681  break;
682  }
683 
684  case 42: // Plane Stress Quadratic Triangle
685  case 92: // Thin Shell Quadratic Triangle
686  {
687  elem = Elem::build(TRI6); // create new element
688 
689  assign_elem_nodes[1]=0;
690  assign_elem_nodes[2]=5;
691  assign_elem_nodes[3]=2;
692  assign_elem_nodes[4]=4;
693  assign_elem_nodes[5]=1;
694  assign_elem_nodes[6]=3;
695  break;
696  }
697 
698  case 43: // Plane Stress Cubic Triangle
699  libmesh_error_msg("ERROR: UNV-element type 43: Plane Stress Cubic Triangle not supported.");
700 
701  case 44: // Plane Stress Linear Quadrilateral
702  case 94: // Thin Shell Linear Quadrilateral
703  {
704  elem = Elem::build(QUAD4); // create new element
705 
706  assign_elem_nodes[1]=0;
707  assign_elem_nodes[2]=3;
708  assign_elem_nodes[3]=2;
709  assign_elem_nodes[4]=1;
710  break;
711  }
712 
713  case 45: // Plane Stress Quadratic Quadrilateral
714  case 95: // Thin Shell Quadratic Quadrilateral
715  {
716  elem = Elem::build(QUAD8); // create new element
717 
718  assign_elem_nodes[1]=0;
719  assign_elem_nodes[2]=7;
720  assign_elem_nodes[3]=3;
721  assign_elem_nodes[4]=6;
722  assign_elem_nodes[5]=2;
723  assign_elem_nodes[6]=5;
724  assign_elem_nodes[7]=1;
725  assign_elem_nodes[8]=4;
726  break;
727  }
728 
729  case 300: // Thin Shell Quadratic Quadrilateral (nine nodes)
730  {
731  elem = Elem::build(QUAD9); // create new element
732 
733  assign_elem_nodes[1]=0;
734  assign_elem_nodes[2]=7;
735  assign_elem_nodes[3]=3;
736  assign_elem_nodes[4]=6;
737  assign_elem_nodes[5]=2;
738  assign_elem_nodes[6]=5;
739  assign_elem_nodes[7]=1;
740  assign_elem_nodes[8]=4;
741  assign_elem_nodes[9]=8;
742  break;
743  }
744 
745  case 46: // Plane Stress Cubic Quadrilateral
746  libmesh_error_msg("ERROR: UNV-element type 46: Plane Stress Cubic Quadrilateral not supported.");
747 
748  case 111: // Solid Linear Tetrahedron
749  {
750  elem = Elem::build(TET4); // create new element
751 
752  assign_elem_nodes[1]=0;
753  assign_elem_nodes[2]=1;
754  assign_elem_nodes[3]=2;
755  assign_elem_nodes[4]=3;
756  break;
757  }
758 
759  case 112: // Solid Linear Prism
760  {
761  elem = Elem::build(PRISM6); // create new element
762 
763  assign_elem_nodes[1]=0;
764  assign_elem_nodes[2]=1;
765  assign_elem_nodes[3]=2;
766  assign_elem_nodes[4]=3;
767  assign_elem_nodes[5]=4;
768  assign_elem_nodes[6]=5;
769  break;
770  }
771 
772  case 115: // Solid Linear Brick
773  {
774  elem = Elem::build(HEX8); // create new element
775 
776  assign_elem_nodes[1]=0;
777  assign_elem_nodes[2]=4;
778  assign_elem_nodes[3]=5;
779  assign_elem_nodes[4]=1;
780  assign_elem_nodes[5]=3;
781  assign_elem_nodes[6]=7;
782  assign_elem_nodes[7]=6;
783  assign_elem_nodes[8]=2;
784  break;
785  }
786 
787  case 116: // Solid Quadratic Brick
788  {
789  elem = Elem::build(HEX20); // create new element
790 
791  assign_elem_nodes[1]=0;
792  assign_elem_nodes[2]=12;
793  assign_elem_nodes[3]=4;
794  assign_elem_nodes[4]=16;
795  assign_elem_nodes[5]=5;
796  assign_elem_nodes[6]=13;
797  assign_elem_nodes[7]=1;
798  assign_elem_nodes[8]=8;
799 
800  assign_elem_nodes[9]=11;
801  assign_elem_nodes[10]=19;
802  assign_elem_nodes[11]=17;
803  assign_elem_nodes[12]=9;
804 
805  assign_elem_nodes[13]=3;
806  assign_elem_nodes[14]=15;
807  assign_elem_nodes[15]=7;
808  assign_elem_nodes[16]=18;
809  assign_elem_nodes[17]=6;
810  assign_elem_nodes[18]=14;
811  assign_elem_nodes[19]=2;
812  assign_elem_nodes[20]=10;
813  break;
814  }
815 
816  case 117: // Solid Cubic Brick
817  libmesh_error_msg("Error: UNV-element type 117: Solid Cubic Brick not supported.");
818 
819  case 118: // Solid Quadratic Tetrahedron
820  {
821  elem = Elem::build(TET10); // create new element
822 
823  assign_elem_nodes[1]=0;
824  assign_elem_nodes[2]=4;
825  assign_elem_nodes[3]=1;
826  assign_elem_nodes[4]=5;
827  assign_elem_nodes[5]=2;
828  assign_elem_nodes[6]=6;
829  assign_elem_nodes[7]=7;
830  assign_elem_nodes[8]=8;
831  assign_elem_nodes[9]=9;
832  assign_elem_nodes[10]=3;
833  break;
834  }
835 
836  default: // Unrecognized element type
837  libmesh_error_msg("ERROR: UNV-element type " << fe_descriptor_id << " not supported.");
838  }
839 
840  // nodes are being stored in element
841  for (dof_id_type j=1; j<=n_nodes; j++)
842  {
843  // Map the UNV node ID to the libmesh node ID
844  auto & node_ptr =
845  libmesh_map_find(_unv_node_id_to_libmesh_node_ptr, node_labels[j]);
846 
847  elem->set_node(assign_elem_nodes[j]) = node_ptr;
848  }
849 
850  elems_of_dimension[elem->dim()] = true;
851 
852  // Set the element's ID
853  elem->set_id(ctr);
854 
855  // Maintain a map from the libmesh (0-based) numbering to the
856  // UNV numbering.
857  _unv_elem_id_to_libmesh_elem_id[element_label] = ctr;
858 
859  // Add the element to the Mesh
860  mesh.add_elem(std::move(elem));
861 
862  // Increment the counter for the next iteration
863  ctr++;
864  } // end while (true)
865 }
bool & verbose()
Set the flag indicating if we should be verbose.
Definition: unv_io.C:91
std::map< dof_id_type, Node * > _unv_node_id_to_libmesh_node_ptr
Maps UNV node IDs to libMesh Node*s.
Definition: unv_io.h:188
std::vector< bool > elems_of_dimension
A vector of bools describing what dimension elements have been encountered when reading a mesh...
Definition: mesh_input.h:107
const dof_id_type n_nodes
Definition: tecplot_io.C:67
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition: elem.C:273
std::map< unsigned, unsigned > _unv_elem_id_to_libmesh_elem_id
Map UNV element IDs to libmesh element IDs.
Definition: unv_io.h:208
OStreamProxy out
uint8_t dof_id_type
Definition: id_types.h:67

◆ elements_out()

void libMesh::UNVIO::elements_out ( std::ostream &  out_file)
private

Outputs the element data to the file out_file.

Do not use this directly, but through the proper write method.

Definition at line 934 of file unv_io.C.

References _elements_dataset_label, libMesh::Utility::enum_to_string(), libMesh::HEX20, libMesh::HEX8, libMesh::DofObject::id(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::out, libMesh::PRISM6, libMesh::QUAD4, libMesh::QUAD8, libMesh::QUAD9, libMesh::TET10, libMesh::TET4, libMesh::TRI3, libMesh::TRI6, and verbose().

Referenced by write_implementation().

935 {
936  if (this->verbose())
937  libMesh::out << " Writing elements" << std::endl;
938 
939  // Write beginning of dataset
940  out_file << " -1\n"
941  << " "
943  << "\n";
944 
945  unsigned
946  fe_descriptor_id = 0, // FE descriptor id
947  phys_prop_tab_dummy = 2, // physical property (not supported yet)
948  mat_prop_tab_dummy = 1, // material property (not supported yet)
949  color_dummy = 7; // color (not supported yet)
950 
951  // vector that assigns element nodes to their correct position
952  // currently only elements with up to 20 nodes
953  //
954  // Example:
955  // QUAD4 | 44:plane stress
956  // | linear quad
957  // position in libMesh | UNV numbering
958  // (note: 0-based) | (note: 1-based)
959  //
960  // assign_elem_node[0] = 0
961  // assign_elem_node[1] = 3
962  // assign_elem_node[2] = 2
963  // assign_elem_node[3] = 1
964  unsigned int assign_elem_nodes[20];
965 
966  unsigned int n_elem_written=0;
967 
968  // A reference to the parent class's mesh
969  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
970 
971  for (const auto & elem : mesh.element_ptr_range())
972  {
973  switch (elem->type())
974  {
975 
976  case TRI3:
977  {
978  fe_descriptor_id = 41; // Plane Stress Linear Triangle
979  assign_elem_nodes[0] = 0;
980  assign_elem_nodes[1] = 2;
981  assign_elem_nodes[2] = 1;
982  break;
983  }
984 
985  case TRI6:
986  {
987  fe_descriptor_id = 42; // Plane Stress Quadratic Triangle
988  assign_elem_nodes[0] = 0;
989  assign_elem_nodes[1] = 5;
990  assign_elem_nodes[2] = 2;
991  assign_elem_nodes[3] = 4;
992  assign_elem_nodes[4] = 1;
993  assign_elem_nodes[5] = 3;
994  break;
995  }
996 
997  case QUAD4:
998  {
999  fe_descriptor_id = 44; // Plane Stress Linear Quadrilateral
1000  assign_elem_nodes[0] = 0;
1001  assign_elem_nodes[1] = 3;
1002  assign_elem_nodes[2] = 2;
1003  assign_elem_nodes[3] = 1;
1004  break;
1005  }
1006 
1007  case QUAD8:
1008  {
1009  fe_descriptor_id = 45; // Plane Stress Quadratic Quadrilateral
1010  assign_elem_nodes[0] = 0;
1011  assign_elem_nodes[1] = 7;
1012  assign_elem_nodes[2] = 3;
1013  assign_elem_nodes[3] = 6;
1014  assign_elem_nodes[4] = 2;
1015  assign_elem_nodes[5] = 5;
1016  assign_elem_nodes[6] = 1;
1017  assign_elem_nodes[7] = 4;
1018  break;
1019  }
1020 
1021  case QUAD9:
1022  {
1023  fe_descriptor_id = 300; // Plane Stress Quadratic Quadrilateral
1024  assign_elem_nodes[0] = 0;
1025  assign_elem_nodes[1] = 7;
1026  assign_elem_nodes[2] = 3;
1027  assign_elem_nodes[3] = 6;
1028  assign_elem_nodes[4] = 2;
1029  assign_elem_nodes[5] = 5;
1030  assign_elem_nodes[6] = 1;
1031  assign_elem_nodes[7] = 4;
1032  assign_elem_nodes[8] = 8;
1033  break;
1034  }
1035 
1036  case TET4:
1037  {
1038  fe_descriptor_id = 111; // Solid Linear Tetrahedron
1039  assign_elem_nodes[0] = 0;
1040  assign_elem_nodes[1] = 1;
1041  assign_elem_nodes[2] = 2;
1042  assign_elem_nodes[3] = 3;
1043  break;
1044  }
1045 
1046  case PRISM6:
1047  {
1048  fe_descriptor_id = 112; // Solid Linear Prism
1049  assign_elem_nodes[0] = 0;
1050  assign_elem_nodes[1] = 1;
1051  assign_elem_nodes[2] = 2;
1052  assign_elem_nodes[3] = 3;
1053  assign_elem_nodes[4] = 4;
1054  assign_elem_nodes[5] = 5;
1055  break;
1056  }
1057 
1058  case HEX8:
1059  {
1060  fe_descriptor_id = 115; // Solid Linear Brick
1061  assign_elem_nodes[0] = 0;
1062  assign_elem_nodes[1] = 4;
1063  assign_elem_nodes[2] = 5;
1064  assign_elem_nodes[3] = 1;
1065  assign_elem_nodes[4] = 3;
1066  assign_elem_nodes[5] = 7;
1067  assign_elem_nodes[6] = 6;
1068  assign_elem_nodes[7] = 2;
1069  break;
1070  }
1071 
1072  case HEX20:
1073  {
1074  fe_descriptor_id = 116; // Solid Quadratic Brick
1075  assign_elem_nodes[ 0] = 0;
1076  assign_elem_nodes[ 1] = 12;
1077  assign_elem_nodes[ 2] = 4;
1078  assign_elem_nodes[ 3] = 16;
1079  assign_elem_nodes[ 4] = 5;
1080  assign_elem_nodes[ 5] = 13;
1081  assign_elem_nodes[ 6] = 1;
1082  assign_elem_nodes[ 7] = 8;
1083 
1084  assign_elem_nodes[ 8] = 11;
1085  assign_elem_nodes[ 9] = 19;
1086  assign_elem_nodes[10] = 17;
1087  assign_elem_nodes[11] = 9;
1088 
1089  assign_elem_nodes[12] = 3;
1090  assign_elem_nodes[13] = 15;
1091  assign_elem_nodes[14] = 7;
1092  assign_elem_nodes[15] = 18;
1093  assign_elem_nodes[16] = 6;
1094  assign_elem_nodes[17] = 14;
1095  assign_elem_nodes[18] = 2;
1096  assign_elem_nodes[19] = 10;
1097 
1098 
1099  break;
1100  }
1101 
1102  case TET10:
1103  {
1104  fe_descriptor_id = 118; // Solid Quadratic Tetrahedron
1105  assign_elem_nodes[0] = 0;
1106  assign_elem_nodes[1] = 4;
1107  assign_elem_nodes[2] = 1;
1108  assign_elem_nodes[3] = 5;
1109  assign_elem_nodes[4] = 2;
1110  assign_elem_nodes[5] = 6;
1111  assign_elem_nodes[6] = 7;
1112  assign_elem_nodes[7] = 8;
1113  assign_elem_nodes[8] = 9;
1114  assign_elem_nodes[9] = 3;
1115  break;
1116  }
1117 
1118  default:
1119  libmesh_error_msg("ERROR: Element type = " << Utility::enum_to_string(elem->type()) << " not supported in " << "UNVIO!");
1120  }
1121 
1122  dof_id_type elem_id = elem->id();
1123 
1124  out_file << std::setw(10) << elem_id // element ID
1125  << std::setw(10) << fe_descriptor_id // type of element
1126  << std::setw(10) << phys_prop_tab_dummy // not supported
1127  << std::setw(10) << mat_prop_tab_dummy // not supported
1128  << std::setw(10) << color_dummy // not supported
1129  << std::setw(10) << elem->n_nodes() // No. of nodes per element
1130  << '\n';
1131 
1132  for (auto j : elem->node_index_range())
1133  {
1134  // assign_elem_nodes[j]-th node: i.e., j loops over the
1135  // libMesh numbering, and assign_elem_nodes[j] over the
1136  // UNV numbering.
1137  const Node * node_in_unv_order = elem->node_ptr(assign_elem_nodes[j]);
1138 
1139  // new record after 8 id entries
1140  if (j==8 || j==16)
1141  out_file << '\n';
1142 
1143  // Write foreign label for this node
1144  dof_id_type node_id = node_in_unv_order->id();
1145 
1146  out_file << std::setw(10) << node_id;
1147  }
1148 
1149  out_file << '\n';
1150 
1151  n_elem_written++;
1152  }
1153 
1154  if (this->verbose())
1155  libMesh::out << " Finished writing " << n_elem_written << " elements" << std::endl;
1156 
1157  // Write end of dataset
1158  out_file << " -1\n";
1159 }
const MT & mesh() const
Definition: mesh_output.h:259
bool & verbose()
Set the flag indicating if we should be verbose.
Definition: unv_io.C:91
static const std::string _elements_dataset_label
label for the element dataset
Definition: unv_io.h:198
std::string enum_to_string(const T e)
OStreamProxy out
uint8_t dof_id_type
Definition: id_types.h:67

◆ get_add_sides()

virtual bool libMesh::MeshOutput< MeshBase >::get_add_sides ( )
inlineprotectedvirtualinherited
Returns
Whether or not added sides are expected to be output, to plot SIDE_DISCONTINUOUS data. Subclasses should override this if they are capable of plotting such data.

Reimplemented in libMesh::ExodusII_IO.

Definition at line 176 of file mesh_output.h.

176 { return false; }

◆ get_data()

const std::vector< Number > * libMesh::UNVIO::get_data ( Node node) const
Returns
A pointer the values associated with the node node, as read in by the read_dataset() method.

If no values exist for the node in question, a nullptr is returned instead. It is up to the user to check the return value before using it.

Definition at line 1319 of file unv_io.C.

References _node_data.

1320 {
1321  auto it = _node_data.find(node);
1322 
1323  if (it == _node_data.end())
1324  return nullptr;
1325  else
1326  return &(it->second);
1327 }
std::map< Node *, std::vector< Number > > _node_data
Map from libMesh Node* to data at that node, as read in by the read_dataset() function.
Definition: unv_io.h:214

◆ groups_in()

void libMesh::UNVIO::groups_in ( std::istream &  in_file)
private

Reads the "groups" section of the file.

The format of the groups section is described here: http://www.sdrl.uc.edu/universal-file-formats-for-modal-analysis-testing-1/file-format-storehouse/unv_2467.htm

Definition at line 419 of file unv_io.C.

References _unv_elem_id_to_libmesh_elem_id, libMesh::BoundaryInfo::add_side(), libMesh::as_range(), libMesh::Elem::dim(), libMesh::MeshBase::elem_ptr(), libMesh::err, libMesh::MeshBase::get_boundary_info(), libMesh::Elem::key(), max_elem_dimension_seen(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::BoundaryInfo::sideset_name(), libMesh::Elem::subdomain_id(), and libMesh::MeshBase::subdomain_name().

Referenced by read_implementation().

420 {
421  // Grab reference to the Mesh, so we can add boundary info data to it
422  MeshBase & mesh = MeshInput<MeshBase>::mesh();
423 
424  // Record the max and min element dimension seen while reading the file.
425  unsigned char max_dim = this->max_elem_dimension_seen();
426 
427  // Container which stores lower-dimensional elements (based on
428  // Elem::key()) for later assignment of boundary conditions. We
429  // could use e.g. an unordered_set with Elems as keys for this, but
430  // this turns out to be much slower on the search side, since we
431  // have to build an entire side in order to search, rather than just
432  // calling elem->key(side) to compute a key.
433  typedef std::unordered_multimap<dof_id_type, Elem *> map_type;
434  map_type provide_bcs;
435 
436  // Read groups until there aren't any more to read...
437  while (true)
438  {
439  // If we read a -1, it means there is nothing else to read in this section.
440  int group_number;
441  in_file >> group_number;
442 
443  if (group_number == -1)
444  break;
445 
446  // The first record consists of 8 entries:
447  // Field 1 -- group number (that we just read)
448  // Field 2 -- active constraint set no. for group
449  // Field 3 -- active restraint set no. for group
450  // Field 4 -- active load set no. for group
451  // Field 5 -- active dof set no. for group
452  // Field 6 -- active temperature set no. for group
453  // Field 7 -- active contact set no. for group
454  // Field 8 -- number of entities in group
455  // Only the first and last of these are relevant to us...
456  unsigned num_entities;
457  std::string group_name;
458  {
459  unsigned dummy;
460  in_file >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy
461  >> num_entities;
462 
463  // The second record has 1 field, the group name
464  in_file >> group_name;
465  }
466 
467  // The dimension of the elements in the group will determine
468  // whether this is a sideset group or a subdomain group.
469  bool
470  is_subdomain_group = false,
471  is_sideset_group = false;
472 
473  // Each subsequent line has 8 entries, there are two entity type
474  // codes and two tags per line that we need to read. In all my
475  // examples, the entity type code was always "8", which stands for
476  // "finite elements" but it's possible that we could eventually
477  // support other entity type codes...
478  // Field 1 -- entity type code
479  // Field 2 -- entity tag
480  // Field 3 -- entity node leaf id.
481  // Field 4 -- entity component/ ham id.
482  // Field 5 -- entity type code
483  // Field 6 -- entity tag
484  // Field 7 -- entity node leaf id.
485  // Field 8 -- entity component/ ham id.
486  {
487  unsigned entity_type_code, entity_tag, dummy;
488  for (unsigned entity=0; entity<num_entities; ++entity)
489  {
490  in_file >> entity_type_code >> entity_tag >> dummy >> dummy;
491 
492  if (entity_type_code != 8)
493  libMesh::err << "Warning, unrecognized entity type code = "
494  << entity_type_code
495  << " in group "
496  << group_name
497  << std::endl;
498 
499  // Try to find this ID in the map from UNV element ids to libmesh ids.
500  auto it = _unv_elem_id_to_libmesh_elem_id.find(entity_tag);
501  if (it != _unv_elem_id_to_libmesh_elem_id.end())
502  {
503  unsigned libmesh_elem_id = it->second;
504 
505  // Attempt to get a pointer to the elem listed in the group
506  Elem * group_elem = mesh.elem_ptr(libmesh_elem_id);
507 
508  // dim < max_dim means the Elem defines a boundary condition
509  if (group_elem->dim() < max_dim)
510  {
511  is_sideset_group = true;
512 
513  // We can only handle elements that are *exactly*
514  // one dimension lower than the max element
515  // dimension. Not sure if "edge" BCs in 3D
516  // actually make sense/are required...
517  libmesh_error_msg_if(group_elem->dim()+1 != max_dim,
518  "ERROR: Expected boundary element of dimension "
519  << max_dim-1 << " but got " << group_elem->dim());
520 
521  // Set the current group number as the lower-dimensional element's subdomain ID.
522  // We will use this later to set a boundary ID.
523  group_elem->subdomain_id() =
524  cast_int<subdomain_id_type>(group_number);
525 
526  // Store the lower-dimensional element in the provide_bcs container.
527  provide_bcs.emplace(group_elem->key(), group_elem);
528  }
529 
530  // dim == max_dim means this group defines a subdomain ID
531  else if (group_elem->dim() == max_dim)
532  {
533  is_subdomain_group = true;
534  group_elem->subdomain_id() =
535  cast_int<subdomain_id_type>(group_number);
536  }
537 
538  else
539  libmesh_error_msg("ERROR: Found an elem with dim=" \
540  << group_elem->dim() << " > " << "max_dim=" << +max_dim);
541  }
542  else
543  libMesh::err << "WARNING: UNV Element " << entity_tag << " not found while parsing groups." << std::endl;
544  } // end for (entity)
545  } // end scope
546 
547  // Associate this group_number with the group_name in the BoundaryInfo object.
548  if (is_sideset_group)
550  (cast_int<boundary_id_type>(group_number)) = group_name;
551 
552  if (is_subdomain_group)
554  (cast_int<subdomain_id_type>(group_number)) = group_name;
555 
556  } // end while (true)
557 
558  // Loop over elements and try to assign boundary information
559  for (auto & elem : mesh.active_element_ptr_range())
560  if (elem->dim() == max_dim)
561  for (auto sn : elem->side_index_range())
562  for (const auto & pr : as_range(provide_bcs.equal_range (elem->key(sn))))
563  {
564  // This is a max-dimension element that may require BCs.
565  // For each of its sides, including internal sides, we'll
566  // see if a lower-dimensional element provides boundary
567  // information for it. Note that we have not yet called
568  // find_neighbors(), so we can't use elem->neighbor(sn) in
569  // this algorithm...
570 
571  // Build a side to confirm the hash mapped to the correct side.
572  std::unique_ptr<Elem> side (elem->build_side_ptr(sn));
573 
574  // Get a pointer to the lower-dimensional element
575  Elem * lower_dim_elem = pr.second;
576 
577  // This was a hash, so it might not be perfect. Let's verify...
578  if (*lower_dim_elem == *side)
579  mesh.get_boundary_info().add_side(elem, sn, lower_dim_elem->subdomain_id());
580  }
581 }
OStreamProxy err
unsigned char max_elem_dimension_seen()
Definition: unv_io.C:386
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
Definition: simple_range.h:57
std::string & subdomain_name(subdomain_id_type id)
Definition: mesh_base.C:1619
std::map< unsigned, unsigned > _unv_elem_id_to_libmesh_elem_id
Map UNV element IDs to libmesh element IDs.
Definition: unv_io.h:208
std::string & sideset_name(boundary_id_type id)
virtual const Elem * elem_ptr(const dof_id_type i) const =0
subdomain_id_type subdomain_id() const
Definition: elem.h:2391
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure...

◆ is_parallel_format()

bool libMesh::MeshInput< MeshBase >::is_parallel_format ( ) const
inlineinherited

Returns true iff this mesh file format and input class are parallelized, so that all processors can read their share of the data at once.

Definition at line 87 of file mesh_input.h.

References libMesh::MeshInput< MT >::_is_parallel_format.

87 { return this->_is_parallel_format; }
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
Definition: mesh_input.h:130

◆ max_elem_dimension_seen()

unsigned char libMesh::UNVIO::max_elem_dimension_seen ( )
private
Returns
The maximum geometric element dimension encountered while reading the Mesh. Only valid after the elements have been read in and the elems_of_dimension array has been populated.

Definition at line 386 of file unv_io.C.

References libMesh::MeshInput< MeshBase >::elems_of_dimension.

Referenced by groups_in(), and read_implementation().

387 {
388  unsigned char max_dim = 0;
389 
390  unsigned char elem_dimensions_size = cast_int<unsigned char>
391  (elems_of_dimension.size());
392  // The elems_of_dimension array is 1-based in the UNV reader
393  for (unsigned char i=1; i<elem_dimensions_size; ++i)
394  if (elems_of_dimension[i])
395  max_dim = i;
396 
397  return max_dim;
398 }
std::vector< bool > elems_of_dimension
A vector of bools describing what dimension elements have been encountered when reading a mesh...
Definition: mesh_input.h:107

◆ mesh() [1/2]

MeshBase & libMesh::MeshInput< MeshBase >::mesh ( )
inlineprotectedinherited
Returns
The object as a writable reference.

Definition at line 178 of file mesh_input.h.

Referenced by libMesh::GMVIO::_read_one_cell(), libMesh::VTKIO::cells_to_vtk(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::TetGenIO::element_in(), elements_in(), elements_out(), libMesh::VTKIO::get_local_node_values(), libMesh::ExodusII_IO::get_sideset_data_indices(), groups_in(), libMesh::TetGenIO::node_in(), nodes_in(), nodes_out(), libMesh::VTKIO::nodes_to_vtk(), libMesh::Nemesis_IO::prepare_to_write_nodal_data(), libMesh::GMVIO::read(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::VTKIO::read(), libMesh::CheckpointIO::read_bcs(), libMesh::CheckpointIO::read_connectivity(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::UCDIO::read_implementation(), read_implementation(), libMesh::GmshIO::read_mesh(), libMesh::DynaIO::read_mesh(), libMesh::CheckpointIO::read_nodes(), libMesh::CheckpointIO::read_nodesets(), libMesh::CheckpointIO::read_remote_elem(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::ExodusII_IO::read_sideset_data(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), libMesh::CheckpointIO::read_subdomain_names(), libMesh::TetGenIO::write(), libMesh::Nemesis_IO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::ExodusII_IO::write(), libMesh::GMVIO::write_ascii_new_impl(), libMesh::GMVIO::write_ascii_old_impl(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::Nemesis_IO::write_element_data(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO::write_elemsets(), libMesh::UCDIO::write_header(), libMesh::UCDIO::write_implementation(), libMesh::UCDIO::write_interior_elems(), libMesh::GmshIO::write_mesh(), libMesh::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::UCDIO::write_nodes(), libMesh::CheckpointIO::write_nodesets(), libMesh::XdrIO::write_parallel(), libMesh::GmshIO::write_post(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::ExodusII_IO::write_sideset_data(), libMesh::UCDIO::write_soln(), and libMesh::CheckpointIO::write_subdomain_names().

179 {
180  libmesh_error_msg_if(_obj == nullptr, "ERROR: _obj should not be nullptr!");
181  return *_obj;
182 }
MeshBase * _obj
A pointer to a non-const object object.
Definition: mesh_input.h:123

◆ mesh() [2/2]

const MeshBase & libMesh::MeshOutput< MeshBase >::mesh ( ) const
inlineprotectedinherited

◆ need_D_to_e()

bool libMesh::UNVIO::need_D_to_e ( std::string &  number)
private

Replaces "1.1111D+00" with "1.1111e+00" if necessary.

This function only needs to be called once per stream, one can assume that if one number needs rewriting, they all do.

Returns
true if the replacement occurs, false otherwise.

Definition at line 402 of file unv_io.C.

Referenced by read_dataset().

403 {
404  // find "D" in string, start looking at 6th element since dont expect a "D" earlier.
405  std::string::size_type position = number.find("D", 6);
406 
407  if (position != std::string::npos)
408  {
409  // replace "D" in string
410  number.replace(position, 1, "e");
411  return true;
412  }
413  else
414  return false;
415 }

◆ nodes_in()

void libMesh::UNVIO::nodes_in ( std::istream &  in_file)
private

Read nodes from file.

Definition at line 300 of file unv_io.C.

References _unv_node_id_to_libmesh_node_ptr, libMesh::MeshBase::add_point(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::out, and verbose().

Referenced by read_implementation().

301 {
302  LOG_SCOPE("nodes_in()","UNVIO");
303 
304  if (this->verbose())
305  libMesh::out << " Reading nodes" << std::endl;
306 
307  MeshBase & mesh = MeshInput<MeshBase>::mesh();
308 
309  // node label, we use an int here so we can read in a -1
310  int node_label;
311 
312  // We'll just read the floating point values as strings even when
313  // there are no "D" characters in the file. This will make parsing
314  // the file a bit slower but the logic to do so will all be
315  // simplified and in one place...
316  std::string line;
317  std::istringstream coords_stream;
318 
319  // Continue reading nodes until there are none left
320  unsigned ctr = 0;
321  while (true)
322  {
323  // Read the node label
324  in_file >> node_label;
325 
326  // Break out of the while loop when we hit -1
327  if (node_label == -1)
328  break;
329 
330  // Read and discard the the rest of the node data on this line
331  // which we do not currently use:
332  // .) exp_coord_sys_num
333  // .) disp_coord_sys_num
334  // .) color
335  std::getline(in_file, line);
336 
337  // read the floating-point data
338  std::getline(in_file, line);
339 
340  // Replace any "D" characters used for exponents with "E"
341  size_t last_pos = 0;
342  while (true)
343  {
344  last_pos = line.find("D", last_pos);
345 
346  if (last_pos != std::string::npos)
347  line.replace(last_pos, 1, "E");
348  else
349  break;
350  }
351 
352  // Construct a stream object from the current line and then
353  // stream in the xyz values.
354  coords_stream.str(line);
355  coords_stream.clear(); // clear iostate bits! Important!
356 
357  // always 3 coordinates in the UNV file, no matter
358  // what LIBMESH_DIM is.
359  std::array<Real, 3> xyz;
360 
361  coords_stream >> xyz[0] >> xyz[1] >> xyz[2];
362 
363  Point p(xyz[0]);
364 #if LIBMESH_DIM > 1
365  p(1) = xyz[1];
366 #else
367  libmesh_assert_equal_to(xyz[1], 0);
368 #endif
369 #if LIBMESH_DIM > 2
370  p(2) = xyz[2];
371 #else
372  libmesh_assert_equal_to(xyz[2], 0);
373 #endif
374 
375  // Add node to the Mesh, bump the counter.
376  Node * added_node = mesh.add_point(p, ctr++);
377 
378  // Maintain the mapping between UNV node ids and libmesh Node
379  // pointers.
380  _unv_node_id_to_libmesh_node_ptr[node_label] = added_node;
381  }
382 }
bool & verbose()
Set the flag indicating if we should be verbose.
Definition: unv_io.C:91
std::map< dof_id_type, Node * > _unv_node_id_to_libmesh_node_ptr
Maps UNV node IDs to libMesh Node*s.
Definition: unv_io.h:188
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
OStreamProxy out

◆ nodes_out()

void libMesh::UNVIO::nodes_out ( std::ostream &  out_file)
private

Outputs nodes to the file out_file.

Do not use this directly, but through the proper write method.

Definition at line 872 of file unv_io.C.

References _nodes_dataset_label, libMesh::MeshOutput< MeshBase >::ascii_precision(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::out, libMesh::Real, and verbose().

Referenced by write_implementation().

873 {
874  if (this->verbose())
875  libMesh::out << " Writing " << MeshOutput<MeshBase>::mesh().n_nodes() << " nodes" << std::endl;
876 
877  // Write beginning of dataset
878  out_file << " -1\n"
879  << " "
881  << '\n';
882 
883  unsigned int
884  exp_coord_sys_dummy = 0, // export coordinate sys. (not supported yet)
885  disp_coord_sys_dummy = 0, // displacement coordinate sys. (not supp. yet)
886  color_dummy = 0; // color(not supported yet)
887 
888  // A reference to the parent class's mesh
889  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
890 
891  // Use scientific notation with capital E and default 17 digits for printing out the coordinates
892  out_file << std::scientific << std::setprecision(this->ascii_precision()) << std::uppercase;
893 
894  for (const auto & current_node : mesh.node_ptr_range())
895  {
896  dof_id_type node_id = current_node->id();
897 
898  out_file << std::setw(10) << node_id
899  << std::setw(10) << exp_coord_sys_dummy
900  << std::setw(10) << disp_coord_sys_dummy
901  << std::setw(10) << color_dummy
902  << '\n';
903 
904  // The coordinates - always write out three coords regardless of LIBMESH_DIM
905  Real x = (*current_node)(0);
906 
907 #if LIBMESH_DIM > 1
908  Real y = (*current_node)(1);
909 #else
910  Real y = 0.;
911 #endif
912 
913 #if LIBMESH_DIM > 2
914  Real z = (*current_node)(2);
915 #else
916  Real z = 0.;
917 #endif
918 
919  out_file << std::setw(25) << x
920  << std::setw(25) << y
921  << std::setw(25) << z
922  << '\n';
923  }
924 
925  // Write end of dataset
926  out_file << " -1\n";
927 }
const MT & mesh() const
Definition: mesh_output.h:259
bool & verbose()
Set the flag indicating if we should be verbose.
Definition: unv_io.C:91
unsigned int & ascii_precision()
Return/set the precision to use when writing ASCII files.
Definition: mesh_output.h:269
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
OStreamProxy out
static const std::string _nodes_dataset_label
label for the node dataset
Definition: unv_io.h:193
uint8_t dof_id_type
Definition: id_types.h:67

◆ read()

void libMesh::UNVIO::read ( const std::string &  file_name)
overridevirtual

This method implements reading a mesh from a specified file.

Implements libMesh::MeshInput< MeshBase >.

Definition at line 98 of file unv_io.C.

References read_implementation().

Referenced by libMesh::NameBasedIO::read().

99 {
100  if (file_name.rfind(".gz") < file_name.size())
101  {
102 #ifdef LIBMESH_HAVE_GZSTREAM
103 
104  igzstream in_stream (file_name.c_str());
105  this->read_implementation (in_stream);
106 
107 #else
108 
109  libmesh_error_msg("ERROR: You must have the zlib.h header files and libraries to read and write compressed streams.");
110 
111 #endif
112  return;
113  }
114 
115  else
116  {
117  std::ifstream in_stream (file_name.c_str());
118  this->read_implementation (in_stream);
119  return;
120  }
121 }
void read_implementation(std::istream &in_stream)
The actual implementation of the read function.
Definition: unv_io.C:124

◆ read_dataset()

void libMesh::UNVIO::read_dataset ( std::string  file_name)

Read a UNV data file containing a dataset of type "2414".

For more info, see http://tinyurl.com/htcf6zm

Definition at line 1163 of file unv_io.C.

References _node_data, _unv_node_id_to_libmesh_node_ptr, need_D_to_e(), and libMesh::Real.

1164 {
1165  std::ifstream in_stream(file_name.c_str());
1166 
1167  libmesh_error_msg_if(!in_stream.good(), "Error opening UNV data file.");
1168 
1169  std::string olds, news, dummy;
1170 
1171  while (true)
1172  {
1173  in_stream >> olds >> news;
1174 
1175  // A "-1" followed by a number means the beginning of a dataset.
1176  while (((olds != "-1") || (news == "-1")) && !in_stream.eof())
1177  {
1178  olds = news;
1179  in_stream >> news;
1180  }
1181 
1182  if (in_stream.eof())
1183  break;
1184 
1185  // We only support reading datasets in the "2414" format.
1186  if (news == "2414")
1187  {
1188  // Ignore the rest of the current line and the next two
1189  // lines that contain analysis dataset label and name.
1190  for (unsigned int i=0; i<3; i++)
1191  std::getline(in_stream, dummy);
1192 
1193  // Read the dataset location, where
1194  // 1: Data at nodes
1195  // 2: Data on elements
1196  // Currently only data on nodes is supported.
1197  unsigned int dataset_location;
1198  in_stream >> dataset_location;
1199 
1200  // Currently only nodal datasets are supported.
1201  libmesh_error_msg_if(dataset_location != 1, "ERROR: Currently only Data at nodes is supported.");
1202 
1203  // Ignore the rest of this line and the next five records.
1204  for (unsigned int i=0; i<6; i++)
1205  std::getline(in_stream, dummy);
1206 
1207  // These data are all of no interest to us...
1208  unsigned int
1209  model_type,
1210  analysis_type,
1211  data_characteristic,
1212  result_type;
1213 
1214  // The type of data (complex, real, float, double etc, see
1215  // below).
1216  unsigned int data_type;
1217 
1218  // The number of floating-point values per entity.
1219  unsigned int num_vals_per_node;
1220 
1221  in_stream >> model_type // not used here
1222  >> analysis_type // not used here
1223  >> data_characteristic // not used here
1224  >> result_type // not used here
1225  >> data_type
1226  >> num_vals_per_node;
1227 
1228  // Ignore the rest of record 9, and records 10-13.
1229  for (unsigned int i=0; i<5; i++)
1230  std::getline(in_stream, dummy);
1231 
1232  // Now get the foreign (aka UNV node) node number and
1233  // the respective nodal data.
1234  int f_n_id;
1235  std::vector<Number> values;
1236 
1237  while (true)
1238  {
1239  in_stream >> f_n_id;
1240 
1241  // If -1 then we have reached the end of the dataset.
1242  if (f_n_id == -1)
1243  break;
1244 
1245  // Resize the values vector (usually data in three
1246  // principle directions, i.e. num_vals_per_node = 3).
1247  values.resize(num_vals_per_node);
1248 
1249  // Read the values for the respective node.
1250  for (unsigned int data_cnt=0; data_cnt<num_vals_per_node; data_cnt++)
1251  {
1252  // Check what data type we are reading.
1253  // 2,4: Real
1254  // 5,6: Complex
1255  // other data types are not supported yet.
1256  // As again, these floats may also be written
1257  // using a 'D' instead of an 'e'.
1258  if (data_type == 2 || data_type == 4)
1259  {
1260  std::string buf;
1261  in_stream >> buf;
1262  this->need_D_to_e(buf);
1263 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
1264  values[data_cnt] = Complex(std::atof(buf.c_str()), 0.);
1265 #else
1266  values[data_cnt] = std::atof(buf.c_str());
1267 #endif
1268  }
1269 
1270  else if (data_type == 5 || data_type == 6)
1271  {
1272 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
1273  Real re_val, im_val;
1274 
1275  std::string buf;
1276  in_stream >> buf;
1277 
1278  if (this->need_D_to_e(buf))
1279  {
1280  re_val = std::atof(buf.c_str());
1281  in_stream >> buf;
1282  this->need_D_to_e(buf);
1283  im_val = std::atof(buf.c_str());
1284  }
1285  else
1286  {
1287  re_val = std::atof(buf.c_str());
1288  in_stream >> im_val;
1289  }
1290 
1291  values[data_cnt] = Complex(re_val,im_val);
1292 #else
1293 
1294  libmesh_error_msg("ERROR: Complex data only supported when libMesh is configured with --enable-complex!");
1295 #endif
1296  }
1297 
1298  else
1299  libmesh_error_msg("ERROR: Data type not supported.");
1300 
1301  } // end loop data_cnt
1302 
1303  // Get a pointer to the Node associated with the UNV node id.
1304  auto & node_ptr = libmesh_map_find(_unv_node_id_to_libmesh_node_ptr, f_n_id);
1305 
1306  // Store the nodal values in our map which uses the
1307  // libMesh Node* as the key. We use operator[] here
1308  // because we want to create an empty vector if the
1309  // entry does not already exist.
1310  _node_data[node_ptr] = values;
1311  } // end while (true)
1312  } // end if (news == "2414")
1313  } // end while (true)
1314 }
MPI_Datatype data_type
std::map< dof_id_type, Node * > _unv_node_id_to_libmesh_node_ptr
Maps UNV node IDs to libMesh Node*s.
Definition: unv_io.h:188
std::map< Node *, std::vector< Number > > _node_data
Map from libMesh Node* to data at that node, as read in by the read_dataset() function.
Definition: unv_io.h:214
std::complex< Real > Complex
bool need_D_to_e(std::string &number)
Replaces "1.1111D+00" with "1.1111e+00" if necessary.
Definition: unv_io.C:402
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ read_implementation()

void libMesh::UNVIO::read_implementation ( std::istream &  in_stream)
private

The actual implementation of the read function.

The public read interface simply decides which type of stream to pass the implementation.

Definition at line 124 of file unv_io.C.

References _elements_dataset_label, _groups_dataset_label, _nodes_dataset_label, libMesh::MeshBase::delete_elem(), elements_in(), libMesh::MeshInput< MeshBase >::elems_of_dimension, groups_in(), max_elem_dimension_seen(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), nodes_in(), libMesh::out, and verbose().

Referenced by read().

125 {
126  // Keep track of what kinds of elements this file contains
127  elems_of_dimension.clear();
128  elems_of_dimension.resize(4, false);
129 
130  {
131  libmesh_error_msg_if(!in_stream.good(), "ERROR: Input file not good.");
132 
133  // Flags to be set when certain sections are encountered
134  bool
135  found_node = false,
136  found_elem = false,
137  found_group = false;
138 
139  // strings for reading the file line by line
140  std::string
141  old_line,
142  current_line;
143 
144  while (true)
145  {
146  // Save off the old_line. This will provide extra reliability
147  // for detecting the beginnings of the different sections.
148  old_line = current_line;
149 
150  // Try to read something. This may set EOF!
151  std::getline(in_stream, current_line);
152 
153  // If the stream is still "valid", parse the line
154  if (in_stream)
155  {
156  // UNV files always have some amount of leading
157  // whitespace, let's not rely on exactly how much... This
158  // command deletes it.
159  current_line.erase(std::remove_if(current_line.begin(), current_line.end(),
160  [](unsigned char const c){return std::isspace(c);}),
161  current_line.end());
162 
163  // Parse the nodes section
164  if (current_line == _nodes_dataset_label &&
165  old_line == "-1")
166  {
167  found_node = true;
168  this->nodes_in(in_stream);
169  }
170 
171  // Parse the elements section
172  else if (current_line == _elements_dataset_label &&
173  old_line == "-1")
174  {
175  // The current implementation requires the nodes to
176  // have been read before reaching the elements
177  // section.
178  libmesh_error_msg_if(!found_node,
179  "ERROR: The Nodes section must come before the Elements section of the UNV file!");
180 
181  found_elem = true;
182  this->elements_in(in_stream);
183  }
184 
185  // Parse the groups section
186  else if (current_line == _groups_dataset_label &&
187  old_line == "-1")
188  {
189  // The current implementation requires the nodes and
190  // elements to have already been read before reaching
191  // the groups section.
192  libmesh_error_msg_if(!found_node || !found_elem,
193  "ERROR: The Nodes and Elements sections must come before the Groups section of the UNV file!");
194 
195  found_group = true;
196  this->groups_in(in_stream);
197  }
198 
199  // We can stop reading once we've found the nodes, elements,
200  // and group sections.
201  if (found_node && found_elem && found_group)
202  break;
203 
204  // If we made it here, we're not done yet, so keep reading
205  continue;
206  }
207 
208  // if (!in_stream) check to see if EOF was set. If so, break out of while loop.
209  if (in_stream.eof())
210  break;
211 
212  // If !in_stream and !in_stream.eof(), stream is in a bad state!
213  libmesh_error_msg("Stream is bad! Perhaps the file does not exist?");
214  } // end while (true)
215 
216  // By now we better have found the datasets for nodes and elements,
217  // otherwise the unv file is bad!
218  libmesh_error_msg_if(!found_node, "ERROR: Could not find nodes!");
219  libmesh_error_msg_if(!found_elem, "ERROR: Could not find elements!");
220  }
221 
222 
223 
224  {
225  // Set the mesh dimension to the largest element dimension encountered
226  MeshInput<MeshBase>::mesh().set_mesh_dimension(max_elem_dimension_seen());
227 
228 #if LIBMESH_DIM < 3
229  libmesh_error_msg_if(MeshInput<MeshBase>::mesh().mesh_dimension() > LIBMESH_DIM,
230  "Cannot open dimension "
231  << MeshInput<MeshBase>::mesh().mesh_dimension()
232  << " mesh file when configured without "
233  << MeshInput<MeshBase>::mesh().mesh_dimension()
234  << "D support." );
235 #endif
236 
237  // Delete any lower-dimensional elements that might have been
238  // added to the mesh strictly for setting BCs.
239  {
240  // Grab reference to the Mesh
241  MeshBase & mesh = MeshInput<MeshBase>::mesh();
242 
243  unsigned char max_dim = this->max_elem_dimension_seen();
244 
245  for (const auto & elem : mesh.element_ptr_range())
246  if (elem->dim() < max_dim)
247  mesh.delete_elem(elem);
248  }
249 
250  if (this->verbose())
251  libMesh::out << " Finished." << std::endl << std::endl;
252  }
253 }
bool & verbose()
Set the flag indicating if we should be verbose.
Definition: unv_io.C:91
static const std::string _elements_dataset_label
label for the element dataset
Definition: unv_io.h:198
std::vector< bool > elems_of_dimension
A vector of bools describing what dimension elements have been encountered when reading a mesh...
Definition: mesh_input.h:107
void nodes_in(std::istream &in_file)
Read nodes from file.
Definition: unv_io.C:300
unsigned char max_elem_dimension_seen()
Definition: unv_io.C:386
static const std::string _groups_dataset_label
label for the groups dataset
Definition: unv_io.h:203
virtual void delete_elem(Elem *e)=0
Removes element e from the mesh.
OStreamProxy out
static const std::string _nodes_dataset_label
label for the node dataset
Definition: unv_io.h:193
void elements_in(std::istream &in_file)
Method reads elements and stores them in std::vector<Elem *> _elements in the same order as they come...
Definition: unv_io.C:585
void groups_in(std::istream &in_file)
Reads the "groups" section of the file.
Definition: unv_io.C:419

◆ set_n_partitions()

void libMesh::MeshInput< MeshBase >::set_n_partitions ( unsigned int  n_parts)
inlineprotectedinherited

Sets the number of partitions in the mesh.

Typically this gets done by the partitioner, but some parallel file formats begin "pre-partitioned".

Definition at line 101 of file mesh_input.h.

References libMesh::MeshInput< MT >::mesh().

Referenced by libMesh::Nemesis_IO::read(), and libMesh::XdrIO::read_header().

101 { this->mesh().set_n_partitions() = n_parts; }
unsigned int & set_n_partitions()
Definition: mesh_base.h:1789

◆ skip_comment_lines()

void libMesh::MeshInput< MeshBase >::skip_comment_lines ( std::istream &  in,
const char  comment_start 
)
protectedinherited

Reads input from in, skipping all the lines that start with the character comment_start.

Definition at line 187 of file mesh_input.h.

Referenced by libMesh::TetGenIO::read(), and libMesh::UCDIO::read_implementation().

189 {
190  char c, line[256];
191 
192  while (in.get(c), c==comment_start)
193  in.getline (line, 255);
194 
195  // put back first character of
196  // first non-comment line
197  in.putback (c);
198 }

◆ verbose()

bool & libMesh::UNVIO::verbose ( )

Set the flag indicating if we should be verbose.

Definition at line 91 of file unv_io.C.

References _verbose.

Referenced by elements_in(), elements_out(), nodes_in(), nodes_out(), and read_implementation().

92 {
93  return _verbose;
94 }
bool _verbose
should be be verbose?
Definition: unv_io.h:182

◆ write()

void libMesh::UNVIO::write ( const std::string &  file_name)
overridevirtual

This method implements writing a mesh to a specified file.

Implements libMesh::MeshOutput< MeshBase >.

Definition at line 259 of file unv_io.C.

References write_implementation().

Referenced by libMesh::NameBasedIO::write().

260 {
261  if (file_name.rfind(".gz") < file_name.size())
262  {
263 #ifdef LIBMESH_HAVE_GZSTREAM
264 
265  ogzstream out_stream(file_name.c_str());
266  this->write_implementation (out_stream);
267 
268 #else
269 
270  libmesh_error_msg("ERROR: You must have the zlib.h header files and libraries to read and write compressed streams.");
271 
272 #endif
273 
274  return;
275  }
276 
277  else
278  {
279  std::ofstream out_stream (file_name.c_str());
280  this->write_implementation (out_stream);
281  return;
282  }
283 }
void write_implementation(std::ostream &out_stream)
The actual implementation of the write function.
Definition: unv_io.C:288

◆ write_discontinuous_equation_systems()

void libMesh::MeshOutput< MeshBase >::write_discontinuous_equation_systems ( const std::string &  fname,
const EquationSystems es,
const std::set< std::string > *  system_names = nullptr 
)
virtualinherited

This method implements writing a mesh with discontinuous data to a specified file where the data is taken from the EquationSystems object.

Definition at line 89 of file mesh_output.C.

References libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_variable_names(), libMesh::EquationSystems::get_mesh(), libMesh::libmesh_assert(), and libMesh::out.

Referenced by libMesh::ExodusII_IO::write_timestep_discontinuous().

92 {
93  LOG_SCOPE("write_discontinuous_equation_systems()", "MeshOutput");
94 
95  // We may need to gather and/or renumber a DistributedMesh to output
96  // it, making that const qualifier in our constructor a dirty lie
97  MT & my_mesh = const_cast<MT &>(*_obj);
98 
99  // If we're asked to write data that's associated with a different
100  // mesh, output files full of garbage are the result.
101  libmesh_assert_equal_to(&es.get_mesh(), _obj);
102 
103  // A non-renumbered mesh may not have a contiguous numbering, and
104  // that needs to be fixed before we can build a solution vector.
105  if (my_mesh.max_elem_id() != my_mesh.n_elem() ||
106  my_mesh.max_node_id() != my_mesh.n_nodes())
107  {
108  // If we were allowed to renumber then we should have already
109  // been properly renumbered...
110  libmesh_assert(!my_mesh.allow_renumbering());
111 
112  libmesh_do_once(libMesh::out <<
113  "Warning: This MeshOutput subclass only supports meshes which are contiguously renumbered!"
114  << std::endl;);
115 
116  my_mesh.allow_renumbering(true);
117 
118  my_mesh.renumber_nodes_and_elements();
119 
120  // Not sure what good going back to false will do here, the
121  // renumbering horses have already left the barn...
122  my_mesh.allow_renumbering(false);
123  }
124 
125  MeshSerializer serialize(const_cast<MT &>(*_obj), !_is_parallel_format, _serial_only_needed_on_proc_0);
126 
127  // Build the list of variable names that will be written.
128  std::vector<std::string> names;
129  es.build_variable_names (names, nullptr, system_names);
130 
131  if (!_is_parallel_format)
132  {
133  // Build the nodal solution values & get the variable
134  // names from the EquationSystems object
135  std::vector<Number> soln;
136  es.build_discontinuous_solution_vector (soln, system_names,
137  nullptr, false, /* defaults */
138  this->get_add_sides());
139 
140  this->write_nodal_data_discontinuous (fname, soln, names);
141  }
142  else // _is_parallel_format
143  {
144  libmesh_not_implemented();
145  }
146 }
virtual void write_nodal_data_discontinuous(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
This method implements writing a mesh with discontinuous data to a specified file where the nodal dat...
Definition: mesh_output.h:118
const MeshBase *const _obj
A pointer to a constant object.
Definition: mesh_output.h:202
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
Definition: mesh_output.h:184
libmesh_assert(ctx)
OStreamProxy out
const bool _serial_only_needed_on_proc_0
Flag specifying whether this format can be written by only serializing the mesh to processor zero...
Definition: mesh_output.h:193

◆ write_equation_systems()

void libMesh::MeshOutput< MeshBase >::write_equation_systems ( const std::string &  fname,
const EquationSystems es,
const std::set< std::string > *  system_names = nullptr 
)
virtualinherited

This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems object.

Reimplemented in libMesh::NameBasedIO.

Definition at line 31 of file mesh_output.C.

References libMesh::EquationSystems::build_solution_vector(), libMesh::EquationSystems::build_variable_names(), libMesh::EquationSystems::get_mesh(), libMesh::libmesh_assert(), and libMesh::out.

Referenced by libMesh::Nemesis_IO::write_timestep(), and libMesh::ExodusII_IO::write_timestep().

34 {
35  LOG_SCOPE("write_equation_systems()", "MeshOutput");
36 
37  // We may need to gather and/or renumber a DistributedMesh to output
38  // it, making that const qualifier in our constructor a dirty lie
39  MT & my_mesh = const_cast<MT &>(*_obj);
40 
41  // If we're asked to write data that's associated with a different
42  // mesh, output files full of garbage are the result.
43  libmesh_assert_equal_to(&es.get_mesh(), _obj);
44 
45  // A non-parallel format, non-renumbered mesh may not have a contiguous
46  // numbering, and that needs to be fixed before we can build a solution vector.
47  if (!_is_parallel_format &&
48  (my_mesh.max_elem_id() != my_mesh.n_elem() ||
49  my_mesh.max_node_id() != my_mesh.n_nodes()))
50  {
51  // If we were allowed to renumber then we should have already
52  // been properly renumbered...
53  libmesh_assert(!my_mesh.allow_renumbering());
54 
55  libmesh_do_once(libMesh::out <<
56  "Warning: This MeshOutput subclass only supports meshes which are contiguously renumbered!"
57  << std::endl;);
58 
59  my_mesh.allow_renumbering(true);
60 
61  my_mesh.renumber_nodes_and_elements();
62 
63  // Not sure what good going back to false will do here, the
64  // renumbering horses have already left the barn...
65  my_mesh.allow_renumbering(false);
66  }
67 
69  {
70  MeshSerializer serialize(const_cast<MT &>(*_obj), !_is_parallel_format, _serial_only_needed_on_proc_0);
71 
72  // Build the list of variable names that will be written.
73  std::vector<std::string> names;
74  es.build_variable_names (names, nullptr, system_names);
75 
76  // Build the nodal solution values & get the variable
77  // names from the EquationSystems object
78  std::vector<Number> soln;
79  es.build_solution_vector (soln, system_names,
80  this->get_add_sides());
81 
82  this->write_nodal_data (fname, soln, names);
83  }
84  else // _is_parallel_format
85  this->write_nodal_data (fname, es, system_names);
86 }
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
This method implements writing a mesh with nodal data to a specified file where the nodal data and va...
Definition: mesh_output.h:109
const MeshBase *const _obj
A pointer to a constant object.
Definition: mesh_output.h:202
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
Definition: mesh_output.h:184
libmesh_assert(ctx)
OStreamProxy out
const bool _serial_only_needed_on_proc_0
Flag specifying whether this format can be written by only serializing the mesh to processor zero...
Definition: mesh_output.h:193

◆ write_implementation()

void libMesh::UNVIO::write_implementation ( std::ostream &  out_stream)
private

The actual implementation of the write function.

The public write interface simply decides which type of stream to pass the implementation.

Definition at line 288 of file unv_io.C.

References elements_out(), and nodes_out().

Referenced by write().

289 {
290  libmesh_error_msg_if(!out_file.good(), "ERROR: Output file not good.");
291 
292  // write the nodes, then the elements
293  this->nodes_out (out_file);
294  this->elements_out (out_file);
295 }
void nodes_out(std::ostream &out_file)
Outputs nodes to the file out_file.
Definition: unv_io.C:872
void elements_out(std::ostream &out_file)
Outputs the element data to the file out_file.
Definition: unv_io.C:934

◆ write_nodal_data() [1/3]

virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  ,
const std::vector< Number > &  ,
const std::vector< std::string > &   
)
inlinevirtualinherited

This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are provided.

Reimplemented in libMesh::ExodusII_IO, libMesh::Nemesis_IO, libMesh::GmshIO, libMesh::NameBasedIO, libMesh::VTKIO, libMesh::UCDIO, libMesh::GMVIO, libMesh::MEDITIO, libMesh::GnuPlotIO, and libMesh::TecplotIO.

Definition at line 109 of file mesh_output.h.

112  { libmesh_not_implemented(); }

◆ write_nodal_data() [2/3]

void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  fname,
const NumericVector< Number > &  parallel_soln,
const std::vector< std::string > &  names 
)
virtualinherited

This method may be overridden by "parallel" output formats for writing nodal data.

Instead of getting a localized copy of the nodal solution vector, it is passed a NumericVector of type=PARALLEL which is in node-major order i.e. (u0,v0,w0, u1,v1,w1, u2,v2,w2, u3,v3,w3, ...) and contains n_nodes*n_vars total entries. Then, it is up to the individual I/O class to extract the required solution values from this vector and write them in parallel.

If not implemented, localizes the parallel vector into a std::vector and calls the other version of this function.

Reimplemented in libMesh::Nemesis_IO.

Definition at line 149 of file mesh_output.C.

References libMesh::NumericVector< T >::localize().

152 {
153  // This is the fallback implementation for parallel I/O formats that
154  // do not yet implement proper writing in parallel, and instead rely
155  // on the full solution vector being available on all processors.
156  std::vector<Number> soln;
157  parallel_soln.localize(soln);
158  this->write_nodal_data(fname, soln, names);
159 }
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
This method implements writing a mesh with nodal data to a specified file where the nodal data and va...
Definition: mesh_output.h:109
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.

◆ write_nodal_data() [3/3]

void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  fname,
const EquationSystems es,
const std::set< std::string > *  system_names 
)
virtualinherited

This method should be overridden by "parallel" output formats for writing nodal data.

Instead of getting a localized copy of the nodal solution vector, it directly uses EquationSystems current_local_solution vectors to look up nodal values.

If not implemented, reorders the solutions into a nodal-only NumericVector and calls the above version of this function.

Reimplemented in libMesh::Nemesis_IO.

Definition at line 162 of file mesh_output.C.

References libMesh::EquationSystems::build_parallel_solution_vector(), and libMesh::EquationSystems::build_variable_names().

165 {
166  std::vector<std::string> names;
167  es.build_variable_names (names, nullptr, system_names);
168 
169  std::unique_ptr<NumericVector<Number>> parallel_soln =
170  es.build_parallel_solution_vector(system_names);
171 
172  this->write_nodal_data (fname, *parallel_soln, names);
173 }
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
This method implements writing a mesh with nodal data to a specified file where the nodal data and va...
Definition: mesh_output.h:109

◆ write_nodal_data_discontinuous()

virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data_discontinuous ( const std::string &  ,
const std::vector< Number > &  ,
const std::vector< std::string > &   
)
inlinevirtualinherited

This method implements writing a mesh with discontinuous data to a specified file where the nodal data and variables names are provided.

Reimplemented in libMesh::ExodusII_IO.

Definition at line 118 of file mesh_output.h.

121  { libmesh_not_implemented(); }

Member Data Documentation

◆ _elements_dataset_label

const std::string libMesh::UNVIO::_elements_dataset_label = "2412"
staticprivate

label for the element dataset

Definition at line 198 of file unv_io.h.

Referenced by elements_out(), and read_implementation().

◆ _groups_dataset_label

const std::string libMesh::UNVIO::_groups_dataset_label = "2467"
staticprivate

label for the groups dataset

Definition at line 203 of file unv_io.h.

Referenced by read_implementation().

◆ _is_parallel_format

const bool libMesh::MeshOutput< MeshBase >::_is_parallel_format
protectedinherited

Flag specifying whether this format is parallel-capable.

If this is false (default) I/O is only permitted when the mesh has been serialized.

Definition at line 184 of file mesh_output.h.

Referenced by libMesh::FroIO::write(), libMesh::PostscriptIO::write(), and libMesh::EnsightIO::write().

◆ _node_data

std::map<Node *, std::vector<Number> > libMesh::UNVIO::_node_data
private

Map from libMesh Node* to data at that node, as read in by the read_dataset() function.

Definition at line 214 of file unv_io.h.

Referenced by get_data(), and read_dataset().

◆ _nodes_dataset_label

const std::string libMesh::UNVIO::_nodes_dataset_label = "2411"
staticprivate

label for the node dataset

Definition at line 193 of file unv_io.h.

Referenced by nodes_out(), and read_implementation().

◆ _serial_only_needed_on_proc_0

const bool libMesh::MeshOutput< MeshBase >::_serial_only_needed_on_proc_0
protectedinherited

Flag specifying whether this format can be written by only serializing the mesh to processor zero.

If this is false (default) the mesh will be serialized to all processors

Definition at line 193 of file mesh_output.h.

◆ _unv_elem_id_to_libmesh_elem_id

std::map<unsigned, unsigned> libMesh::UNVIO::_unv_elem_id_to_libmesh_elem_id
private

Map UNV element IDs to libmesh element IDs.

Definition at line 208 of file unv_io.h.

Referenced by elements_in(), and groups_in().

◆ _unv_node_id_to_libmesh_node_ptr

std::map<dof_id_type, Node *> libMesh::UNVIO::_unv_node_id_to_libmesh_node_ptr
private

Maps UNV node IDs to libMesh Node*s.

Used when reading. Even if the libMesh Mesh is renumbered, this map should continue to be valid.

Definition at line 188 of file unv_io.h.

Referenced by elements_in(), nodes_in(), and read_dataset().

◆ _verbose

bool libMesh::UNVIO::_verbose
private

should be be verbose?

Definition at line 182 of file unv_io.h.

Referenced by verbose().

◆ elems_of_dimension

std::vector<bool> libMesh::MeshInput< MeshBase >::elems_of_dimension
protectedinherited

The documentation for this class was generated from the following files: