Poster of Linux kernelThe best gift for a Linux geek
MeshDataUnvHeader

MeshDataUnvHeader

Section: C Library Functions (3) Updated: Thu Apr 7 2011
Local index Up
 

NAME

MeshDataUnvHeader -  

SYNOPSIS


#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< Real > record_12

std::vector< Real > record_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)
 .fi


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 681 of file mesh_data.h.
 

Constructor & Destructor Documentation

 

MeshDataUnvHeader::MeshDataUnvHeader ()Default Constructor. Initializes the respective data.

Definition at line 617 of file mesh_data_unv_support.C.

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

                                     :
  dataset_label          (0),
  dataset_name           ('libMesh mesh data'),
  dataset_location       (1),  // default to nodal data
  model_type             (0),          
  analysis_type          (0),
  data_characteristic    (0),
  result_type            (0),
#ifdef LIBMESH_USE_COMPLEX_NUMBERS
  data_type              (5),  // default to single precision complex
#else
  data_type              (2),  // default to single precision real
#endif
  nvaldc                 (3),  // default to 3 (principle directions)
  _desired_dataset_label (libMesh::invalid_uint)
{
  id_lines_1_to_5.resize(5);
  std::fill (id_lines_1_to_5.begin(), id_lines_1_to_5.end(), std::string('libMesh default'));
  /*
   * resize analysis specific data.
   */
  record_10.resize(8);
  record_11.resize(2);
  record_12.resize(6);
  record_13.resize(6);
}
 

MeshDataUnvHeader::~MeshDataUnvHeader ()Destructor.

Definition at line 648 of file mesh_data_unv_support.C.

{
  // empty
}
 

Member Function Documentation

 

bool MeshDataUnvHeader::need_D_to_e (std::string &number) [static, private]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 814 of file mesh_data_unv_support.C.

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

{
  // find 'D' in string, start looking at 6th element, to improve speed.
  // We dont expect a 'D' earlier

// #ifdef __HP_aCC
//   // Use an 'int' instead of unsigned int,
//   // otherwise HP aCC may crash!
//   const int position = number.find('D',6);
// #else
//   const unsigned int position = number.find('D',6);
// #endif
  std::string::size_type position = number.find('D',6);
    
  if(position!=std::string::npos)     // npos means no position
    {
      // replace 'D' in string
      number.replace(position,1,'e'); 
      return true;
    }
  else
      // we assume that if this one number is written correctly, all numbers are
      return false;
}
 

void MeshDataUnvHeader::operator= (const MeshDataUnvHeader &omduh)Assignment operator. Simply assigns all values from omduh to this.

Definition at line 848 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.

{
  this->dataset_label          = omduh.dataset_label;
  this->dataset_name           = omduh.dataset_name;
  this->dataset_location       = omduh.dataset_location;
  this->id_lines_1_to_5        = omduh.id_lines_1_to_5;

  this->model_type             = omduh.model_type;
  this->analysis_type          = omduh.analysis_type;
  this->data_characteristic    = omduh.data_characteristic;
  this->result_type            = omduh.result_type;

#ifdef LIBMESH_USE_COMPLEX_NUMBERS
  /*
   * in complex mode allow only
   * values 5 or 6 (complex) for data_type
   */
  if ((omduh.data_type == 5) ||
      (omduh.data_type == 6))
      this->data_type          = omduh.data_type;
  else
    {
#  ifdef DEBUG
      std::cerr << 'WARNING: MeshDataUnvHeader::operator=(): Other object has data_type for' << std::endl
                << '         real values.  Will use default data_type=5 during assignment.' << std::endl
                << std::endl;
#  endif
      this->data_type          = 5;
    }

#else

  /*
   * in real mode allow only
   * values 2 or 4 (real) for data_type
   */
  if ((omduh.data_type == 2) ||
      (omduh.data_type == 4))
      this->data_type          = omduh.data_type;
  else
    {
#  ifdef DEBUG
      std::cerr << 'WARNING: Other MeshDataUnvHeader has data_type for complex values.' << std::endl
                << '         Data import will likely _not_ work and result in infinite loop,' << std::endl
                << '         provided the user forgot to re-size nvaldc to 2*nvaldc_old!' << std::endl
                << std::endl;
#  endif
      this->data_type          = 2;
    }

#endif

  this->nvaldc                 = omduh.nvaldc;

  this->record_10              = omduh.record_10;
  this->record_11              = omduh.record_11;
  this->record_12              = omduh.record_12;
  this->record_13              = omduh.record_13;

  this->_desired_dataset_label = omduh._desired_dataset_label;
}
 

bool MeshDataUnvHeader::operator== (const MeshDataUnvHeader &omduh) constReturns:

true when this and omduh are equal, false otherwise.

Definition at line 913 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.

{
  return (this->dataset_label          == omduh.dataset_label       &&
          this->dataset_name           == omduh.dataset_name        &&
          this->dataset_location       == omduh.dataset_location    &&
          this->id_lines_1_to_5        == omduh.id_lines_1_to_5     &&

          this->model_type             == omduh.model_type          &&
          this->analysis_type          == omduh.analysis_type       &&
          this->data_characteristic    == omduh.data_characteristic &&
          this->result_type            == omduh.result_type         &&

          this->data_type              == omduh.data_type           &&
          this->nvaldc                 == omduh.nvaldc              &&

          this->record_10              == omduh.record_10           &&
          this->record_11              == omduh.record_11           &&
          this->record_12              == omduh.record_12           &&
          this->record_13              == omduh.record_13           &&

          this->_desired_dataset_label == omduh._desired_dataset_label);
}
 

bool 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 656 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 MeshData::read_unv_implementation().

{
  in_file >> this->dataset_label;

  /*
   * currently, we compare only the 
   * dataset_label with the _desired_dataset_label,
   * but it may be easy to also compare the 
   * dataset_name.
   *
   * When the user provided a dataset label, and
   * the current label does _not_ match, then just
   * return false.
   *
   * Otherwise: when the current label matches,
   * or when there is no desired dataset label,
   * simply proceed.
   */
  if ((this->_desired_dataset_label != libMesh::invalid_uint) &&
      (this->dataset_label != this->_desired_dataset_label))
      return false;


  in_file.ignore(256,');
  std::getline(in_file, dataset_name, ');

  in_file >> this->dataset_location;
  in_file.ignore(256,');


  for (unsigned int n=0; n<5; n++)
      std::getline(in_file, this->id_lines_1_to_5[n], ');


  in_file >> this->model_type     
          >> this->analysis_type
          >> this->data_characteristic
          >> this->result_type
          >> this->data_type
          >> this->nvaldc;
    
  for (unsigned int i=0; i<8; i++)
    in_file >> this->record_10[i];

  for (unsigned int i=0; i<2; i++)
    in_file >> this->record_11[i];


  /*
   * There are UNV-files where floats are 
   * written with 'D' as the 10th-power 
   * character. Replace this 'D' by 'e',
   * so that std::atof() can work fine.
   */
  std::string buf;
  in_file >> buf;

  if (need_D_to_e(buf))
    {
      // have to convert _all_ 'D' to 'e'
      this->record_12[0] = std::atof(buf.c_str());

      for (unsigned int i=1; i<6; i++)
        {
          in_file >> buf;
          need_D_to_e(buf);
          this->record_12[i] = std::atof(buf.c_str());
        }

      for (unsigned int i=0; i<6; i++)
        {
          in_file >> buf;
          need_D_to_e(buf);
          this->record_13[i] = std::atof(buf.c_str());
        }
    }
  else
    {
      // no 'D', the stream will recognize the floats
      this->record_12[0] = std::atof(buf.c_str());

      for (unsigned int i=1; i<6; i++)
          in_file >> this->record_12[i];

      for (unsigned int i=0; i<6; i++)
          in_file >> this->record_13[i];
    }

  /*
   * no matter whether the user provided a desired
   * dataset label or not: return true, b/c the
   * non-match was already caught before.
   */
  return true;
}
 

void MeshDataUnvHeader::which_dataset (const unsigned intds_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 841 of file mesh_data_unv_support.C.

References _desired_dataset_label.

{
  this->_desired_dataset_label = ds_label;
}
 

void MeshDataUnvHeader::write (std::ostream &out_file) [protected]Write the header information to the stream out_file.

Definition at line 755 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 MeshData::write_unv_implementation().

{
  
  
  char buf[82];

  std::sprintf(buf, '%6i,this->dataset_label);
  
  out_file << buf;
 
  out_file << this->dataset_name << ';

  std::sprintf(buf, '%6i,this->dataset_location);
  
  out_file << buf;

  for (unsigned int n=0; n<5; n++)
    out_file << this->id_lines_1_to_5[n] << ';

  std::sprintf(buf, '%10i%10i%10i%10i%10i%10i,
               model_type,  analysis_type, data_characteristic,
               result_type, data_type,     nvaldc);
  
  out_file << buf;

  std::sprintf(buf, '%10i%10i%10i%10i%10i%10i%10i%10i,
               record_10[0], record_10[1], record_10[2], record_10[3],
               record_10[4], record_10[5], record_10[6], record_10[7]);
  
  out_file << buf;

  std::sprintf(buf, '%10i%10i, record_11[0], record_11[1]);
  out_file << buf;

  std::sprintf(buf, '%13.5E%13.5E%13.5E%13.5E%13.5E%13.5E,
               static_cast<double>(record_12[0]),
               static_cast<double>(record_12[1]),
               static_cast<double>(record_12[2]),
               static_cast<double>(record_12[3]),
               static_cast<double>(record_12[4]),
               static_cast<double>(record_12[5]));
  
  out_file << buf;

  std::sprintf(buf, '%13.5E%13.5E%13.5E%13.5E%13.5E%13.5E,
               static_cast<double>(record_13[0]),
               static_cast<double>(record_13[1]),
               static_cast<double>(record_13[2]),
               static_cast<double>(record_13[3]),
               static_cast<double>(record_13[4]),
               static_cast<double>(record_13[5]));
  
  out_file << buf;
}
 

Friends And Related Function Documentation

 

friend class MeshData [friend]Make the MeshData class a friend.

Definition at line 824 of file mesh_data.h.  

Member Data Documentation

 

unsigned int MeshDataUnvHeader::_desired_dataset_label [private]the desired dataset label. defaults to -1 if not given

Definition at line 811 of file mesh_data.h.

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

unsigned int MeshDataUnvHeader::analysis_type

Definition at line 754 of file mesh_data.h.

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

unsigned int MeshDataUnvHeader::data_characteristic

Definition at line 754 of file mesh_data.h.

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

unsigned int MeshDataUnvHeader::data_typeRecord 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 764 of file mesh_data.h.

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

unsigned int MeshDataUnvHeader::dataset_labelRecord 1. User specified analysis dataset label.

Definition at line 727 of file mesh_data.h.

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

unsigned int MeshDataUnvHeader::dataset_locationRecord 3. The dataset location (e.g. data at nodes, data on elements, etc.).

Definition at line 738 of file mesh_data.h.

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

std::string MeshDataUnvHeader::dataset_nameRecord 2. User specified analysis dataset name.

Definition at line 732 of file mesh_data.h.

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

std::vector<std::string> MeshDataUnvHeader::id_lines_1_to_5Record 4 trough 8 are ID lines.

Definition at line 743 of file mesh_data.h.

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

unsigned int MeshDataUnvHeader::model_typeRecord 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 754 of file mesh_data.h.

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

unsigned int MeshDataUnvHeader::nvaldcRecord 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 770 of file mesh_data.h.

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

std::vector<int> MeshDataUnvHeader::record_10Record 10 and 11 are analysis specific data of type integer.

Definition at line 776 of file mesh_data.h.

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

std::vector<int> MeshDataUnvHeader::record_11

Definition at line 776 of file mesh_data.h.

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

std::vector<Real> MeshDataUnvHeader::record_12Record 12 and 13 are analysis specific data of type Real.

Definition at line 783 of file mesh_data.h.

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

std::vector<Real> MeshDataUnvHeader::record_13

Definition at line 783 of file mesh_data.h.

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

unsigned int MeshDataUnvHeader::result_type

Definition at line 754 of file mesh_data.h.

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

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Public Member Functions
Public Attributes
Protected Member Functions
Static Private Member Functions
Private Attributes
Friends
Detailed Description
Constructor & Destructor Documentation
MeshDataUnvHeader::MeshDataUnvHeader ()Default Constructor. Initializes the respective data.
MeshDataUnvHeader::~MeshDataUnvHeader ()Destructor.
Member Function Documentation
bool MeshDataUnvHeader::need_D_to_e (std::string &number) [static, private]Returns:
void MeshDataUnvHeader::operator= (const MeshDataUnvHeader &omduh)Assignment operator. Simply assigns all values from omduh to this.
bool MeshDataUnvHeader::operator== (const MeshDataUnvHeader &omduh) constReturns:
bool MeshDataUnvHeader::read (std::istream &in_file) [protected]Returns:
void MeshDataUnvHeader::which_dataset (const unsigned intds_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.
void MeshDataUnvHeader::write (std::ostream &out_file) [protected]Write the header information to the stream out_file.
Friends And Related Function Documentation
friend class MeshData [friend]Make the MeshData class a friend.
Member Data Documentation
unsigned int MeshDataUnvHeader::_desired_dataset_label [private]the desired dataset label. defaults to -1 if not given
unsigned int MeshDataUnvHeader::analysis_type
unsigned int MeshDataUnvHeader::data_characteristic
unsigned int MeshDataUnvHeader::data_typeRecord 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),
unsigned int MeshDataUnvHeader::dataset_labelRecord 1. User specified analysis dataset label.
unsigned int MeshDataUnvHeader::dataset_locationRecord 3. The dataset location (e.g. data at nodes, data on elements, etc.).
std::string MeshDataUnvHeader::dataset_nameRecord 2. User specified analysis dataset name.
std::vector<std::string> MeshDataUnvHeader::id_lines_1_to_5Record 4 trough 8 are ID lines.
unsigned int MeshDataUnvHeader::model_typeRecord 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.).
unsigned int MeshDataUnvHeader::nvaldcRecord 9, third and last part. See first and second part, then we have: the number of data values for the mesh data.
std::vector<int> MeshDataUnvHeader::record_10Record 10 and 11 are analysis specific data of type integer.
std::vector<int> MeshDataUnvHeader::record_11
std::vector<Real> MeshDataUnvHeader::record_12Record 12 and 13 are analysis specific data of type Real.
std::vector<Real> MeshDataUnvHeader::record_13
unsigned int MeshDataUnvHeader::result_type
Author

This document was created by man2html, using the manual pages.
Time: 21:50:10 GMT, April 16, 2011