$extrastylesheet
#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 |
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 683 of file mesh_data.h.
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.
: 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); }
| bool libMesh::MeshDataUnvHeader::need_D_to_e | ( | std::string & | number | ) | [static, private] |
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().
{
// find "D" in string, start looking at 6th element, to improve speed.
// We dont expect a "D" earlier
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 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.
{
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
libMesh::err << "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
libMesh::err << "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 libMesh::MeshDataUnvHeader::operator== | ( | const MeshDataUnvHeader & | omduh | ) | const |
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.
{
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 libMesh::MeshDataUnvHeader::read | ( | std::istream & | in_file | ) | [protected] |
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().
{
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,'\n');
std::getline(in_file, dataset_name, '\n');
in_file >> this->dataset_location;
in_file.ignore(256,'\n');
for (unsigned int n=0; n<5; n++)
std::getline(in_file, this->id_lines_1_to_5[n], '\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 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.
{
this->_desired_dataset_label = ds_label;
}
| 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().
{
char buf[82];
std::sprintf(buf, "%6i\n",this->dataset_label);
out_file << buf;
out_file << this->dataset_name << "\n";
std::sprintf(buf, "%6i\n",this->dataset_location);
out_file << buf;
for (unsigned int n=0; n<5; n++)
out_file << this->id_lines_1_to_5[n] << "\n";
std::sprintf(buf, "%10i%10i%10i%10i%10i%10i\n",
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\n",
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\n", record_11[0], record_11[1]);
out_file << buf;
std::sprintf(buf, "%13.5E%13.5E%13.5E%13.5E%13.5E%13.5E\n",
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\n",
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;
}
friend class MeshData [friend] |
Make the MeshData class a friend.
Definition at line 826 of file mesh_data.h.
unsigned int libMesh::MeshDataUnvHeader::_desired_dataset_label [private] |
the desired dataset label. defaults to -1 if not given
Definition at line 813 of file mesh_data.h.
Referenced by operator=(), operator==(), read(), and which_dataset().
| unsigned int libMesh::MeshDataUnvHeader::analysis_type |
Definition at line 756 of file mesh_data.h.
Referenced by operator=(), operator==(), read(), and write().
| unsigned int libMesh::MeshDataUnvHeader::data_characteristic |
Definition at line 756 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 766 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 729 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 740 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 734 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 745 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 756 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 772 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 778 of file mesh_data.h.
Referenced by MeshDataUnvHeader(), operator=(), operator==(), read(), and write().
| std::vector<int> libMesh::MeshDataUnvHeader::record_11 |
Definition at line 778 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 785 of file mesh_data.h.
Referenced by MeshDataUnvHeader(), operator=(), operator==(), read(), and write().
| std::vector<Real> libMesh::MeshDataUnvHeader::record_13 |
Definition at line 785 of file mesh_data.h.
Referenced by MeshDataUnvHeader(), operator=(), operator==(), read(), and write().
| unsigned int libMesh::MeshDataUnvHeader::result_type |
Definition at line 756 of file mesh_data.h.
Referenced by operator=(), operator==(), read(), and write().