libMesh::MeshDataUnvHeader Class Reference

#include <mesh_data.h>

Public Member Functions

 MeshDataUnvHeader ()
 
 ~MeshDataUnvHeader ()
 
void which_dataset (const unsigned int ds_label)
 
void operator= (const MeshDataUnvHeader &omduh)
 
bool operator== (const MeshDataUnvHeader &omduh) const
 

Public Attributes

unsigned int dataset_label
 
std::string dataset_name
 
unsigned int dataset_location
 
std::vector< std::string > id_lines_1_to_5
 
unsigned int model_type
 
unsigned int analysis_type
 
unsigned int data_characteristic
 
unsigned int result_type
 
unsigned int data_type
 
unsigned int nvaldc
 
std::vector< int > record_10
 
std::vector< int > record_11
 
std::vector< Realrecord_12
 
std::vector< Realrecord_13
 

Protected Member Functions

bool read (std::istream &in_file)
 
void write (std::ostream &out_file)
 

Static Private Member Functions

static bool need_D_to_e (std::string &number)
 

Private Attributes

unsigned int _desired_dataset_label
 

Friends

class MeshData
 

Detailed Description

Class MeshDataUnvHeader handles the data specified at the beginning of a dataset 2414 in a universal file. This header is structured in records 1 to 13. A typical header is described here. The text after the # are comments and are not part of such a dataset. The text in brackets after the # are the corresponding class members names.

*
* -1                                                                           # beginning of dataset
* 2414                                                                         # type of dataset: data at mesh entities
* 1                                                                            # R.  1: unique number of dataset (dataset_label)
* STRUCTURAL MODE     1                                                        # R.  2: text describing content (dataset_name)
* 1                                                                            # R.  3: data belongs to: nodes, elements,...
* #        (dataset_location)
* Default Model                                                                # R.  4: user-specified text (id_lines_1_to_5[0])
* I-DEAS Master Series                                                         # R.  5: user-specified text (id_lines_1_to_5[1])
* 18-AUG-2003 20:00:12    HPUX11_64     MAR2003                                # R.  6: user-specified text (id_lines_1_to_5[2])
* MODE   1 FREQUENCY       501.25 Hz                                           # R.  7: user-specified text (id_lines_1_to_5[3])
* STRUCTURAL MODE     1                                                        # R.  8: user-specified text (id_lines_1_to_5[4])
* 0         2         3         8         2         6                          # R.  9: (model_type) (analysis_type)
* #        (data_characteristic) (result_type)
* #        (data_type) (nvaldc)
* 0         0         0         0         0         1         0         0      # R. 10: analysis-specific data (record_10)
* 0         0                                                                  # R. 11: analysis-specific data (record_11)
* 0.00000E+00  0.50125E+03  0.99192E+07  0.10000E+01  0.00000E+00  0.00000E+00 # R. 12: analysis-specific data (record_12)
* 0.00000E+00  0.00000E+00  0.00000E+00  0.00000E+00  0.00000E+00  0.00000E+00 # R. 13: analysis-specific data (record_13)
* 

For more details we refer to the general description of the I-DEAS universal file format.

An instance of this class may be attached to the MeshData of some mesh. Then the read() and write() methods of MeshData use this MeshDataUnvHeader instead of some empty default. Also files that contain multiple datasets of type 2414 may be handled through the which_dataset() method. Note that an instance of this class has to be attached to the MeshData prior to using the read() or write() methods of the MeshData.

Definition at line 673 of file mesh_data.h.

Constructor & Destructor Documentation

libMesh::MeshDataUnvHeader::MeshDataUnvHeader ( )

Default Constructor. Initializes the respective data.

Definition at line 591 of file mesh_data_unv_support.C.

References id_lines_1_to_5, record_10, record_11, record_12, and record_13.

591  :
592  dataset_label (0),
593  dataset_name ("libMesh mesh data"),
594  dataset_location (1), // default to nodal data
595  model_type (0),
596  analysis_type (0),
598  result_type (0),
599 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
600  data_type (5), // default to single precision complex
601 #else
602  data_type (2), // default to single precision real
603 #endif
604  nvaldc (3), // default to 3 (principle directions)
606 {
607  id_lines_1_to_5.resize(5);
608  std::fill (id_lines_1_to_5.begin(), id_lines_1_to_5.end(), std::string("libMesh default"));
609  /*
610  * resize analysis specific data.
611  */
612  record_10.resize(8);
613  record_11.resize(2);
614  record_12.resize(6);
615  record_13.resize(6);
616 }
unsigned int _desired_dataset_label
Definition: mesh_data.h:803
unsigned int data_characteristic
Definition: mesh_data.h:746
const unsigned int invalid_uint
Definition: libmesh.h:185
std::vector< Real > record_13
Definition: mesh_data.h:775
std::vector< int > record_10
Definition: mesh_data.h:768
unsigned int result_type
Definition: mesh_data.h:746
std::vector< Real > record_12
Definition: mesh_data.h:775
std::vector< std::string > id_lines_1_to_5
Definition: mesh_data.h:735
unsigned int analysis_type
Definition: mesh_data.h:746
unsigned int dataset_label
Definition: mesh_data.h:719
std::vector< int > record_11
Definition: mesh_data.h:768
unsigned int dataset_location
Definition: mesh_data.h:730
libMesh::MeshDataUnvHeader::~MeshDataUnvHeader ( )

Destructor.

Definition at line 622 of file mesh_data_unv_support.C.

623 {
624  // empty
625 }

Member Function Documentation

bool libMesh::MeshDataUnvHeader::need_D_to_e ( std::string &  number)
staticprivate
Returns
true when the string number has a 'D' that needs to be replaced by 'e', false otherwise. Also actually replaces the 'D' by an 'e'.

Definition at line 788 of file mesh_data_unv_support.C.

Referenced by read(), and libMesh::MeshData::read_unv_implementation().

789 {
790  // find "D" in string, start looking at 6th element, to improve speed.
791  // We dont expect a "D" earlier
792  std::string::size_type position = number.find("D",6);
793 
794  if(position!=std::string::npos) // npos means no position
795  {
796  // replace "D" in string
797  number.replace(position,1,"e");
798  return true;
799  }
800  else
801  // we assume that if this one number is written correctly, all numbers are
802  return false;
803 }
void libMesh::MeshDataUnvHeader::operator= ( const MeshDataUnvHeader omduh)

Assignment operator. Simply assigns all values from omduh to this.

Definition at line 814 of file mesh_data_unv_support.C.

References _desired_dataset_label, analysis_type, data_characteristic, data_type, dataset_label, dataset_location, dataset_name, libMesh::err, id_lines_1_to_5, model_type, nvaldc, record_10, record_11, record_12, record_13, and result_type.

815 {
816  this->dataset_label = omduh.dataset_label;
817  this->dataset_name = omduh.dataset_name;
818  this->dataset_location = omduh.dataset_location;
819  this->id_lines_1_to_5 = omduh.id_lines_1_to_5;
820 
821  this->model_type = omduh.model_type;
822  this->analysis_type = omduh.analysis_type;
823  this->data_characteristic = omduh.data_characteristic;
824  this->result_type = omduh.result_type;
825 
826 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
827  /*
828  * in complex mode allow only
829  * values 5 or 6 (complex) for data_type
830  */
831  if ((omduh.data_type == 5) ||
832  (omduh.data_type == 6))
833  this->data_type = omduh.data_type;
834  else
835  {
836 # ifdef DEBUG
837  libMesh::err << "WARNING: MeshDataUnvHeader::operator=(): Other object has data_type for" << std::endl
838  << " real values. Will use default data_type=5 during assignment." << std::endl
839  << std::endl;
840 # endif
841  this->data_type = 5;
842  }
843 
844 #else
845 
846  /*
847  * in real mode allow only
848  * values 2 or 4 (real) for data_type
849  */
850  if ((omduh.data_type == 2) ||
851  (omduh.data_type == 4))
852  this->data_type = omduh.data_type;
853  else
854  {
855 # ifdef DEBUG
856  libMesh::err << "WARNING: Other MeshDataUnvHeader has data_type for complex values." << std::endl
857  << " Data import will likely _not_ work and result in infinite loop," << std::endl
858  << " provided the user forgot to re-size nvaldc to 2*nvaldc_old!" << std::endl
859  << std::endl;
860 # endif
861  this->data_type = 2;
862  }
863 
864 #endif
865 
866  this->nvaldc = omduh.nvaldc;
867 
868  this->record_10 = omduh.record_10;
869  this->record_11 = omduh.record_11;
870  this->record_12 = omduh.record_12;
871  this->record_13 = omduh.record_13;
872 
873  this->_desired_dataset_label = omduh._desired_dataset_label;
874 }
unsigned int _desired_dataset_label
Definition: mesh_data.h:803
unsigned int data_characteristic
Definition: mesh_data.h:746
std::vector< Real > record_13
Definition: mesh_data.h:775
std::vector< int > record_10
Definition: mesh_data.h:768
unsigned int result_type
Definition: mesh_data.h:746
std::vector< Real > record_12
Definition: mesh_data.h:775
std::vector< std::string > id_lines_1_to_5
Definition: mesh_data.h:735
unsigned int analysis_type
Definition: mesh_data.h:746
unsigned int dataset_label
Definition: mesh_data.h:719
OStreamProxy err(std::cerr)
std::vector< int > record_11
Definition: mesh_data.h:768
unsigned int dataset_location
Definition: mesh_data.h:730
bool libMesh::MeshDataUnvHeader::operator== ( const MeshDataUnvHeader omduh) const
Returns
true when this and omduh are equal, false otherwise.

Definition at line 879 of file mesh_data_unv_support.C.

References _desired_dataset_label, analysis_type, data_characteristic, data_type, dataset_label, dataset_location, dataset_name, id_lines_1_to_5, model_type, nvaldc, record_10, record_11, record_12, record_13, and result_type.

880 {
881  return (this->dataset_label == omduh.dataset_label &&
882  this->dataset_name == omduh.dataset_name &&
883  this->dataset_location == omduh.dataset_location &&
884  this->id_lines_1_to_5 == omduh.id_lines_1_to_5 &&
885 
886  this->model_type == omduh.model_type &&
887  this->analysis_type == omduh.analysis_type &&
888  this->data_characteristic == omduh.data_characteristic &&
889  this->result_type == omduh.result_type &&
890 
891  this->data_type == omduh.data_type &&
892  this->nvaldc == omduh.nvaldc &&
893 
894  this->record_10 == omduh.record_10 &&
895  this->record_11 == omduh.record_11 &&
896  this->record_12 == omduh.record_12 &&
897  this->record_13 == omduh.record_13 &&
898 
899  this->_desired_dataset_label == omduh._desired_dataset_label);
900 }
unsigned int dataset_label
Definition: mesh_data.h:719
bool libMesh::MeshDataUnvHeader::read ( std::istream &  in_file)
protected
Returns
true when this dataset is the one that the user wants, false otherwise. When no desired dataset is given, always returns true. Aside from this return value, this method also reads the header information from the stream in_file.

Definition at line 630 of file mesh_data_unv_support.C.

References _desired_dataset_label, analysis_type, data_characteristic, data_type, dataset_label, dataset_location, dataset_name, id_lines_1_to_5, libMesh::invalid_uint, model_type, need_D_to_e(), nvaldc, record_10, record_11, record_12, record_13, and result_type.

Referenced by libMesh::MeshData::read_unv_implementation().

631 {
632  in_file >> this->dataset_label;
633 
634  /*
635  * currently, we compare only the
636  * dataset_label with the _desired_dataset_label,
637  * but it may be easy to also compare the
638  * dataset_name.
639  *
640  * When the user provided a dataset label, and
641  * the current label does _not_ match, then just
642  * return false.
643  *
644  * Otherwise: when the current label matches,
645  * or when there is no desired dataset label,
646  * simply proceed.
647  */
649  (this->dataset_label != this->_desired_dataset_label))
650  return false;
651 
652 
653  in_file.ignore(256,'\n');
654  std::getline(in_file, dataset_name, '\n');
655 
656  in_file >> this->dataset_location;
657  in_file.ignore(256,'\n');
658 
659 
660  for (unsigned int n=0; n<5; n++)
661  std::getline(in_file, this->id_lines_1_to_5[n], '\n');
662 
663 
664  in_file >> this->model_type
665  >> this->analysis_type
666  >> this->data_characteristic
667  >> this->result_type
668  >> this->data_type
669  >> this->nvaldc;
670 
671  for (unsigned int i=0; i<8; i++)
672  in_file >> this->record_10[i];
673 
674  for (unsigned int i=0; i<2; i++)
675  in_file >> this->record_11[i];
676 
677 
678  /*
679  * There are UNV-files where floats are
680  * written with 'D' as the 10th-power
681  * character. Replace this 'D' by 'e',
682  * so that std::atof() can work fine.
683  */
684  std::string buf;
685  in_file >> buf;
686 
687  if (need_D_to_e(buf))
688  {
689  // have to convert _all_ 'D' to 'e'
690  this->record_12[0] = std::atof(buf.c_str());
691 
692  for (unsigned int i=1; i<6; i++)
693  {
694  in_file >> buf;
695  need_D_to_e(buf);
696  this->record_12[i] = std::atof(buf.c_str());
697  }
698 
699  for (unsigned int i=0; i<6; i++)
700  {
701  in_file >> buf;
702  need_D_to_e(buf);
703  this->record_13[i] = std::atof(buf.c_str());
704  }
705  }
706  else
707  {
708  // no 'D', the stream will recognize the floats
709  this->record_12[0] = std::atof(buf.c_str());
710 
711  for (unsigned int i=1; i<6; i++)
712  in_file >> this->record_12[i];
713 
714  for (unsigned int i=0; i<6; i++)
715  in_file >> this->record_13[i];
716  }
717 
718  /*
719  * no matter whether the user provided a desired
720  * dataset label or not: return true, b/c the
721  * non-match was already caught before.
722  */
723  return true;
724 }
unsigned int _desired_dataset_label
Definition: mesh_data.h:803
unsigned int data_characteristic
Definition: mesh_data.h:746
const unsigned int invalid_uint
Definition: libmesh.h:185
std::vector< Real > record_13
Definition: mesh_data.h:775
std::vector< int > record_10
Definition: mesh_data.h:768
unsigned int result_type
Definition: mesh_data.h:746
std::vector< Real > record_12
Definition: mesh_data.h:775
static bool need_D_to_e(std::string &number)
std::vector< std::string > id_lines_1_to_5
Definition: mesh_data.h:735
unsigned int analysis_type
Definition: mesh_data.h:746
unsigned int dataset_label
Definition: mesh_data.h:719
std::vector< int > record_11
Definition: mesh_data.h:768
unsigned int dataset_location
Definition: mesh_data.h:730
void libMesh::MeshDataUnvHeader::which_dataset ( const unsigned int  ds_label)

Universal files may contain multiple data sets of type 2414. These sets are identified through their labels (not to be confused with the dataset label 2414!). The user may provide a label of the dataset that she wants. Then the file is scanned for this dataset, and datasets with a different label are skipped.

When this method is not called, then simply the first dataset in the file is used. Note that for this method to have any effect, this method has to be called prior to using the MeshData::read() or MeshData::write() methods.

Definition at line 807 of file mesh_data_unv_support.C.

References _desired_dataset_label.

808 {
809  this->_desired_dataset_label = ds_label;
810 }
unsigned int _desired_dataset_label
Definition: mesh_data.h:803
void libMesh::MeshDataUnvHeader::write ( std::ostream &  out_file)
protected

Write the header information to the stream out_file.

Definition at line 729 of file mesh_data_unv_support.C.

References analysis_type, data_characteristic, data_type, dataset_label, dataset_location, dataset_name, id_lines_1_to_5, model_type, nvaldc, record_10, record_11, record_12, record_13, and result_type.

Referenced by libMesh::MeshData::write_unv_implementation().

730 {
731 
732 
733  char buf[82];
734 
735  std::sprintf(buf, "%6i\n",this->dataset_label);
736 
737  out_file << buf;
738 
739  out_file << this->dataset_name << "\n";
740 
741  std::sprintf(buf, "%6i\n",this->dataset_location);
742 
743  out_file << buf;
744 
745  for (unsigned int n=0; n<5; n++)
746  out_file << this->id_lines_1_to_5[n] << "\n";
747 
748  std::sprintf(buf, "%10i%10i%10i%10i%10i%10i\n",
751 
752  out_file << buf;
753 
754  std::sprintf(buf, "%10i%10i%10i%10i%10i%10i%10i%10i\n",
755  record_10[0], record_10[1], record_10[2], record_10[3],
756  record_10[4], record_10[5], record_10[6], record_10[7]);
757 
758  out_file << buf;
759 
760  std::sprintf(buf, "%10i%10i\n", record_11[0], record_11[1]);
761  out_file << buf;
762 
763  std::sprintf(buf, "%13.5E%13.5E%13.5E%13.5E%13.5E%13.5E\n",
764  static_cast<double>(record_12[0]),
765  static_cast<double>(record_12[1]),
766  static_cast<double>(record_12[2]),
767  static_cast<double>(record_12[3]),
768  static_cast<double>(record_12[4]),
769  static_cast<double>(record_12[5]));
770 
771  out_file << buf;
772 
773  std::sprintf(buf, "%13.5E%13.5E%13.5E%13.5E%13.5E%13.5E\n",
774  static_cast<double>(record_13[0]),
775  static_cast<double>(record_13[1]),
776  static_cast<double>(record_13[2]),
777  static_cast<double>(record_13[3]),
778  static_cast<double>(record_13[4]),
779  static_cast<double>(record_13[5]));
780 
781  out_file << buf;
782 }
unsigned int data_characteristic
Definition: mesh_data.h:746
std::vector< Real > record_13
Definition: mesh_data.h:775
std::vector< int > record_10
Definition: mesh_data.h:768
unsigned int result_type
Definition: mesh_data.h:746
std::vector< Real > record_12
Definition: mesh_data.h:775
std::vector< std::string > id_lines_1_to_5
Definition: mesh_data.h:735
unsigned int analysis_type
Definition: mesh_data.h:746
unsigned int dataset_label
Definition: mesh_data.h:719
std::vector< int > record_11
Definition: mesh_data.h:768
unsigned int dataset_location
Definition: mesh_data.h:730

Friends And Related Function Documentation

friend class MeshData
friend

Make the MeshData class a friend.

Definition at line 816 of file mesh_data.h.

Member Data Documentation

unsigned int libMesh::MeshDataUnvHeader::_desired_dataset_label
private

the desired dataset label. defaults to -1 if not given

Definition at line 803 of file mesh_data.h.

Referenced by operator=(), operator==(), read(), and which_dataset().

unsigned int libMesh::MeshDataUnvHeader::analysis_type

Definition at line 746 of file mesh_data.h.

Referenced by operator=(), operator==(), read(), and write().

unsigned int libMesh::MeshDataUnvHeader::data_characteristic

Definition at line 746 of file mesh_data.h.

Referenced by operator=(), operator==(), read(), and write().

unsigned int libMesh::MeshDataUnvHeader::data_type

Record 9, second part. See first part, then we have: the data type (currently supported: 2,4 for Real, and 5,6 for Complex. other possibilities: e.g. integer),

Definition at line 756 of file mesh_data.h.

Referenced by operator=(), operator==(), read(), libMesh::MeshData::read_unv_implementation(), write(), and libMesh::MeshData::write_unv_implementation().

unsigned int libMesh::MeshDataUnvHeader::dataset_label

Record 1. User specified analysis dataset label.

Definition at line 719 of file mesh_data.h.

Referenced by operator=(), operator==(), read(), and write().

unsigned int libMesh::MeshDataUnvHeader::dataset_location

Record 3. The dataset location (e.g. data at nodes, data on elements, etc.).

Definition at line 730 of file mesh_data.h.

Referenced by operator=(), operator==(), read(), libMesh::MeshData::read_unv_implementation(), and write().

std::string libMesh::MeshDataUnvHeader::dataset_name

Record 2. User specified analysis dataset name.

Definition at line 724 of file mesh_data.h.

Referenced by operator=(), operator==(), read(), and write().

std::vector<std::string> libMesh::MeshDataUnvHeader::id_lines_1_to_5

Record 4 trough 8 are ID lines.

Definition at line 735 of file mesh_data.h.

Referenced by MeshDataUnvHeader(), operator=(), operator==(), read(), and write().

unsigned int libMesh::MeshDataUnvHeader::model_type

Record 9, first part. This record contains data specifying the model type (e.g. unknown, structural, etc.), the analysis type (e.g. unknown, static, transient, normal mode, etc.), the data characteristics (such as scalar, 3 dof global translation vector, etc.), the result type (e.g. stress, strain, velocity, etc.).

Definition at line 746 of file mesh_data.h.

Referenced by operator=(), operator==(), read(), and write().

unsigned int libMesh::MeshDataUnvHeader::nvaldc

Record 9, third and last part. See first and second part, then we have: the number of data values for the mesh data.

Definition at line 762 of file mesh_data.h.

Referenced by operator=(), operator==(), read(), libMesh::MeshData::read_unv_implementation(), write(), and libMesh::MeshData::write_unv_implementation().

std::vector<int> libMesh::MeshDataUnvHeader::record_10

Record 10 and 11 are analysis specific data of type integer.

Definition at line 768 of file mesh_data.h.

Referenced by MeshDataUnvHeader(), operator=(), operator==(), read(), and write().

std::vector<int> libMesh::MeshDataUnvHeader::record_11

Definition at line 768 of file mesh_data.h.

Referenced by MeshDataUnvHeader(), operator=(), operator==(), read(), and write().

std::vector<Real> libMesh::MeshDataUnvHeader::record_12

Record 12 and 13 are analysis specific data of type Real.

Definition at line 775 of file mesh_data.h.

Referenced by MeshDataUnvHeader(), operator=(), operator==(), read(), and write().

std::vector<Real> libMesh::MeshDataUnvHeader::record_13

Definition at line 775 of file mesh_data.h.

Referenced by MeshDataUnvHeader(), operator=(), operator==(), read(), and write().

unsigned int libMesh::MeshDataUnvHeader::result_type

Definition at line 746 of file mesh_data.h.

Referenced by operator=(), operator==(), read(), and write().


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