mesh_data_unv_support.C
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 00019 00020 // C++ includes 00021 #include <cstdio> // for std::sprintf 00022 #include <fstream> 00023 00024 // Local includes 00025 #include "libmesh/libmesh_config.h" 00026 #include "libmesh/mesh_data.h" 00027 #include "libmesh/auto_ptr.h" 00028 00029 #ifdef LIBMESH_HAVE_GZSTREAM 00030 # include "gzstream.h" // For reading/writing compressed streams 00031 #endif 00032 00033 00034 namespace libMesh 00035 { 00036 00037 //------------------------------------------------------ 00038 // MeshData UNV support functions 00039 void MeshData::read_unv (const std::string& file_name) 00040 { 00041 /* 00042 * we should better be active or in compatibility mode 00043 */ 00044 libmesh_assert (this->_active || this->_compatibility_mode); 00045 00046 /* 00047 * When reading data, make sure the id maps are ok 00048 */ 00049 libmesh_assert (this->_node_id_map_closed); 00050 libmesh_assert (this->_elem_id_map_closed); 00051 00052 /* 00053 * clear the data, but keep the id maps 00054 */ 00055 this->clear(); 00056 00057 /* 00058 * We can read either ".unv", or ".unv.gz" 00059 * files, provided zlib.h is there 00060 */ 00061 if (file_name.rfind(".gz") < file_name.size()) 00062 { 00063 #ifdef LIBMESH_HAVE_GZSTREAM 00064 igzstream in_stream(file_name.c_str()); 00065 this->read_unv_implementation (in_stream); 00066 #else 00067 libMesh::err << "ERROR: You must have the zlib.h header " 00068 << "files and libraries to read and write " 00069 << "compressed streams." 00070 << std::endl; 00071 libmesh_error(); 00072 #endif 00073 return; 00074 } 00075 00076 else 00077 { 00078 std::ifstream in_stream(file_name.c_str()); 00079 this->read_unv_implementation (in_stream); 00080 return; 00081 } 00082 } 00083 00084 00085 00086 00087 00088 00089 void MeshData::read_unv_implementation (std::istream& in_file) 00090 { 00091 /* 00092 * This is the actual implementation of 00093 * reading in UNV format. This enables 00094 * to read either through the conventional 00095 * C++ stream, or through a stream that 00096 * allows to read .gz'ed files. 00097 */ 00098 if ( !in_file.good() ) 00099 { 00100 libMesh::err << "ERROR: Input file not good." 00101 << std::endl; 00102 libmesh_error(); 00103 } 00104 00105 const std::string _label_dataset_mesh_data = "2414"; 00106 00107 /* 00108 * locate the beginning of data set 00109 * and read it. 00110 */ 00111 { 00112 std::string olds, news; 00113 00114 while (true) 00115 { 00116 in_file >> olds >> news; 00117 00118 /* 00119 * Yes, really dirty: 00120 * 00121 * When we found a dataset, and the user does 00122 * not want this dataset, we jump back here 00123 */ 00124 go_and_find_the_next_dataset: 00125 00126 /* 00127 * a "-1" followed by a number means the beginning of a dataset 00128 * stop combing at the end of the file 00129 */ 00130 while( ((olds != "-1") || (news == "-1") ) && !in_file.eof() ) 00131 { 00132 olds = news; 00133 in_file >> news; 00134 } 00135 00136 if(in_file.eof()) 00137 break; 00138 00139 /* 00140 * if beginning of dataset 00141 */ 00142 if (news == _label_dataset_mesh_data) 00143 { 00144 00145 /* 00146 * Now read the data of interest. 00147 * Start with the header. For 00148 * explanation of the variable 00149 * dataset_location, see below. 00150 */ 00151 unsigned int dataset_location; 00152 00153 /* 00154 * the type of data (complex, real, 00155 * float, double etc, see below) 00156 */ 00157 unsigned int data_type; 00158 00159 /* 00160 * the number of floating-point values per entity 00161 */ 00162 unsigned int NVALDC; 00163 00164 00165 /* 00166 * If there is no MeshDataUnvHeader object 00167 * attached 00168 */ 00169 if (_unv_header==NULL) 00170 { 00171 /* 00172 * Ignore the first lines that stand for 00173 * analysis dataset label and name. 00174 */ 00175 for(unsigned int i=0; i<3; i++) 00176 in_file.ignore(256,'\n'); 00177 00178 /* 00179 * Read the dataset location, where 00180 * 1: Data at nodes 00181 * 2: Data on elements 00182 * other sets are currently not supported. 00183 */ 00184 in_file >> dataset_location; 00185 00186 /* 00187 * Ignore five ID lines. 00188 */ 00189 for(unsigned int i=0; i<6; i++) 00190 in_file.ignore(256,'\n'); 00191 00192 /* 00193 * These data are all of no interest to us... 00194 */ 00195 unsigned int model_type, 00196 analysis_type, 00197 data_characteristic, 00198 result_type; 00199 00200 /* 00201 * Read record 9. 00202 */ 00203 in_file >> model_type // not used here 00204 >> analysis_type // not used here 00205 >> data_characteristic // not used here 00206 >> result_type // not used here 00207 >> data_type 00208 >> NVALDC; 00209 00210 00211 /* 00212 * Ignore record 10 and 11 00213 * (Integer analysis type specific data). 00214 */ 00215 for (unsigned int i=0; i<3; i++) 00216 in_file.ignore(256,'\n'); 00217 00218 /* 00219 * Ignore record 12 and record 13. Since there 00220 * exist UNV files with 'D' instead of 'e' as 00221 * 10th-power char, it is safer to use a string 00222 * to read the dummy reals. 00223 */ 00224 { 00225 std::string dummy_Real; 00226 for (unsigned int i=0; i<12; i++) 00227 in_file >> dummy_Real; 00228 } 00229 00230 } 00231 else 00232 { 00233 00234 /* 00235 * the read() method returns false when 00236 * the user wanted a special header, and 00237 * when the current header is _not_ the correct 00238 * header 00239 */ 00240 if (_unv_header->read(in_file)) 00241 { 00242 dataset_location = _unv_header->dataset_location; 00243 NVALDC = _unv_header->nvaldc; 00244 data_type = _unv_header->data_type; 00245 } 00246 else 00247 { 00248 /* 00249 * This is not the correct header. Go 00250 * and find the next. For this to 00251 * work correctly, shift to the 00252 * next line, so that the "-1" 00253 * disappears from olds 00254 */ 00255 olds = news; 00256 in_file >> news; 00257 00258 /* 00259 * No good style, i know... 00260 */ 00261 goto go_and_find_the_next_dataset; 00262 } 00263 00264 } 00265 00266 /* 00267 * Check the location of the dataset. 00268 */ 00269 if (dataset_location != 1) 00270 { 00271 libMesh::err << "ERROR: Currently only Data at nodes is supported." 00272 << std::endl; 00273 libmesh_error(); 00274 } 00275 00276 00277 /* 00278 * Now get the foreign node id number and the respective nodal data. 00279 */ 00280 int f_n_id; 00281 std::vector<Number> values; 00282 00283 while(true) 00284 { 00285 in_file >> f_n_id; 00286 00287 /* 00288 * if node_nr = -1 then we have reached the end of the dataset. 00289 */ 00290 if (f_n_id==-1) 00291 break; 00292 00293 /* 00294 * Resize the values vector (usually data in three 00295 * principle directions, i.e. NVALDC = 3). 00296 */ 00297 values.resize(NVALDC); 00298 00299 /* 00300 * Read the meshdata for the respective node. 00301 */ 00302 for (unsigned int data_cnt=0; data_cnt<NVALDC; data_cnt++) 00303 { 00304 /* 00305 * Check what data type we are reading. 00306 * 2,4: Real 00307 * 5,6: Complex 00308 * other data types are not supported yet. 00309 * As again, these floats may also be written 00310 * using a 'D' instead of an 'e'. 00311 */ 00312 if (data_type == 2 || data_type == 4) 00313 { 00314 std::string buf; 00315 in_file >> buf; 00316 MeshDataUnvHeader::need_D_to_e(buf); 00317 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 00318 values[data_cnt] = Complex(std::atof(buf.c_str()), 0.); 00319 #else 00320 values[data_cnt] = std::atof(buf.c_str()); 00321 #endif 00322 } 00323 00324 else if(data_type == 5 || data_type == 6) 00325 00326 { 00327 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 00328 Real re_val, im_val; 00329 00330 std::string buf; 00331 in_file >> buf; 00332 00333 if (MeshDataUnvHeader::need_D_to_e(buf)) 00334 { 00335 re_val = std::atof(buf.c_str()); 00336 in_file >> buf; 00337 MeshDataUnvHeader::need_D_to_e(buf); 00338 im_val = std::atof(buf.c_str()); 00339 } 00340 else 00341 { 00342 re_val = std::atof(buf.c_str()); 00343 in_file >> im_val; 00344 } 00345 00346 values[data_cnt] = Complex(re_val,im_val); 00347 #else 00348 00349 libMesh::err << "ERROR: Complex data only supported" << std::endl 00350 << "when libMesh is configured with --enable-complex!" 00351 << std::endl; 00352 libmesh_error(); 00353 #endif 00354 } 00355 00356 else 00357 { 00358 libMesh::err << "ERROR: Data type not supported." 00359 << std::endl; 00360 libmesh_error(); 00361 } 00362 00363 } // end loop data_cnt 00364 00365 /* 00366 * Add the values vector to the MeshData data structure. 00367 */ 00368 const Node* node = foreign_id_to_node(f_n_id); 00369 _node_data.insert (std::make_pair(node, values)); 00370 00371 } // while(true) 00372 } 00373 00374 00375 else 00376 { 00377 /* 00378 * all other datasets are ignored 00379 */ 00380 } 00381 00382 } 00383 } 00384 00385 00386 /* 00387 * finished reading. Ready for use, provided 00388 * there was any data contained in the file. 00389 */ 00390 libmesh_assert ((this->_node_data.size() != 0) || (this->_elem_data.size() != 0)); 00391 00392 this->_node_data_closed = true; 00393 this->_elem_data_closed = true; 00394 } 00395 00396 00397 00398 00399 00400 00401 void MeshData::write_unv (const std::string& file_name) 00402 { 00403 /* 00404 * we should better be active or in compatibility mode 00405 */ 00406 libmesh_assert (this->_active || this->_compatibility_mode); 00407 00408 /* 00409 * make sure the id maps are ready 00410 * and that we have data to write 00411 */ 00412 libmesh_assert (this->_node_id_map_closed); 00413 libmesh_assert (this->_elem_id_map_closed); 00414 00415 libmesh_assert (this->_node_data_closed); 00416 libmesh_assert (this->_elem_data_closed); 00417 00418 if (file_name.rfind(".gz") < file_name.size()) 00419 { 00420 #ifdef LIBMESH_HAVE_GZSTREAM 00421 ogzstream out_stream(file_name.c_str()); 00422 this->write_unv_implementation (out_stream); 00423 #else 00424 libMesh::err << "ERROR: You must have the zlib.h header " 00425 << "files and libraries to read and write " 00426 << "compressed streams." 00427 << std::endl; 00428 libmesh_error(); 00429 #endif 00430 return; 00431 00432 } 00433 00434 else 00435 { 00436 std::ofstream out_stream(file_name.c_str()); 00437 this->write_unv_implementation (out_stream); 00438 return; 00439 } 00440 } 00441 00442 00443 00444 00445 00446 00447 void MeshData::write_unv_implementation (std::ostream& out_file) 00448 { 00449 /* 00450 * This is the actual implementation of writing 00451 * unv files, either as .unv or as .unv.gz file 00452 */ 00453 if ( !out_file.good() ) 00454 { 00455 libMesh::err << "ERROR: Output file not good." 00456 << std::endl; 00457 libmesh_error(); 00458 } 00459 00460 00461 /* 00462 * the beginning marker of the dataset block for 00463 * nodal/element-associated data (not to be confused 00464 * with _desired_dataset_label!) 00465 */ 00466 const std::string _label_dataset_mesh_data = "2414"; 00467 00468 /* 00469 * Currently this function handles only nodal data. 00470 */ 00471 libmesh_assert (!_node_data.empty()); 00472 00473 if (!_elem_data.empty()) 00474 libMesh::err << "WARNING: MeshData currently only supports nodal data for Universal files." 00475 << std::endl 00476 << " Will proceed writing only nodal data, ignoring element data." 00477 << std::endl; 00478 00479 00480 /* 00481 * Write the beginning of the dataset. 00482 */ 00483 out_file << " -1\n" 00484 << " " 00485 << _label_dataset_mesh_data 00486 << "\n"; 00487 00488 /* 00489 * Write the header 00490 */ 00491 if (_unv_header==NULL) 00492 { 00493 /* 00494 * create a header that holds at 00495 * least sufficient data to specify 00496 * what this data set currently holds. 00497 * 00498 * The empty constructor automatically 00499 * takes care of \p dataset_location 00500 * and \p data_type. 00501 */ 00502 MeshDataUnvHeader my_header; 00503 00504 /* 00505 * It remains to set the correct nvaldc... 00506 */ 00507 my_header.nvaldc = this->n_val_per_node(); 00508 00509 /* 00510 * and the correct data type. By default 00511 * only distinguish complex or real data. 00512 */ 00513 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 00514 my_header.data_type = 5; 00515 #else 00516 my_header.data_type = 2; 00517 #endif 00518 00519 /* 00520 * write this default header, then let 00521 * the AutoPtr go out of scope. This 00522 * will take care of memory management. 00523 */ 00524 my_header.write (out_file); 00525 } 00526 00527 else 00528 { 00529 /* 00530 * make sure our nvaldc coincide. 00531 */ 00532 if (this->n_val_per_node() != _unv_header->nvaldc) 00533 { 00534 libMesh::err << "WARNING: nvaldc=" << _unv_header->nvaldc 00535 << " of attached MeshDataUnvHeader object not valid!" << std::endl 00536 << " re-set nvaldc to " << this->n_val_per_node() << std::endl; 00537 _unv_header->nvaldc = this->n_val_per_node(); 00538 } 00539 00540 00541 /* 00542 * only issue a warning when data_type does 00543 * not coincide. Perhaps user provided some 00544 * other header in order to convert complex 00545 * to real... 00546 */ 00547 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 00548 const unsigned int my_data_type = 5; 00549 #else 00550 const unsigned int my_data_type = 2; 00551 #endif 00552 if (my_data_type != _unv_header->data_type) 00553 { 00554 libMesh::err << "WARNING: data_type=" << _unv_header->data_type 00555 << " of attached MeshDataUnvHeader differs from" << std::endl 00556 << " default value=" << my_data_type 00557 << " Perhaps the user wanted this," << std::endl 00558 << " so I use the value from the MeshDataUnvHeader." 00559 << std::endl; 00560 } 00561 _unv_header->write (out_file); 00562 } 00563 00564 00565 /* 00566 * Write the foreign node number and the respective data. 00567 */ 00568 std::map<const Node*, 00569 std::vector<Number> >::const_iterator nit = _node_data.begin(); 00570 00571 char buf[27]; 00572 for (; nit != _node_data.end(); ++nit) 00573 { 00574 const Node* node = (*nit).first; 00575 00576 unsigned int f_n_id = node_to_foreign_id (node); 00577 std::sprintf(buf, "%10i\n", f_n_id); 00578 out_file << buf; 00579 00580 /* since we are iterating over our own map, this libmesh_assert 00581 * should never break... 00582 */ 00583 libmesh_assert (this->has_data(node)); 00584 00585 // const reference to the nodal values 00586 const std::vector<Number>& values = this->get_data(node); 00587 00588 for (unsigned int v_cnt=0; v_cnt<values.size(); v_cnt++) 00589 { 00590 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 00591 std::sprintf(buf, "%13.5E%13.5E", values[v_cnt].real(), 00592 values[v_cnt].imag()); 00593 out_file << buf; 00594 #else 00595 std::sprintf(buf, "%13.5E", 00596 static_cast<double>(values[v_cnt])); 00597 out_file << buf; 00598 #endif 00599 } 00600 00601 out_file << "\n"; 00602 00603 00604 } 00605 00606 /* 00607 * Write end of the dataset. 00608 */ 00609 out_file << " -1\n"; 00610 } 00611 00612 00613 00614 00615 00616 //------------------------------------------------------ 00617 // MeshDataUnvHeader functions 00618 MeshDataUnvHeader::MeshDataUnvHeader() : 00619 dataset_label (0), 00620 dataset_name ("libMesh mesh data"), 00621 dataset_location (1), // default to nodal data 00622 model_type (0), 00623 analysis_type (0), 00624 data_characteristic (0), 00625 result_type (0), 00626 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 00627 data_type (5), // default to single precision complex 00628 #else 00629 data_type (2), // default to single precision real 00630 #endif 00631 nvaldc (3), // default to 3 (principle directions) 00632 _desired_dataset_label (libMesh::invalid_uint) 00633 { 00634 id_lines_1_to_5.resize(5); 00635 std::fill (id_lines_1_to_5.begin(), id_lines_1_to_5.end(), std::string("libMesh default")); 00636 /* 00637 * resize analysis specific data. 00638 */ 00639 record_10.resize(8); 00640 record_11.resize(2); 00641 record_12.resize(6); 00642 record_13.resize(6); 00643 } 00644 00645 00646 00647 00648 00649 MeshDataUnvHeader::~MeshDataUnvHeader() 00650 { 00651 // empty 00652 } 00653 00654 00655 00656 00657 bool MeshDataUnvHeader::read (std::istream& in_file) 00658 { 00659 in_file >> this->dataset_label; 00660 00661 /* 00662 * currently, we compare only the 00663 * dataset_label with the _desired_dataset_label, 00664 * but it may be easy to also compare the 00665 * dataset_name. 00666 * 00667 * When the user provided a dataset label, and 00668 * the current label does _not_ match, then just 00669 * return false. 00670 * 00671 * Otherwise: when the current label matches, 00672 * or when there is no desired dataset label, 00673 * simply proceed. 00674 */ 00675 if ((this->_desired_dataset_label != libMesh::invalid_uint) && 00676 (this->dataset_label != this->_desired_dataset_label)) 00677 return false; 00678 00679 00680 in_file.ignore(256,'\n'); 00681 std::getline(in_file, dataset_name, '\n'); 00682 00683 in_file >> this->dataset_location; 00684 in_file.ignore(256,'\n'); 00685 00686 00687 for (unsigned int n=0; n<5; n++) 00688 std::getline(in_file, this->id_lines_1_to_5[n], '\n'); 00689 00690 00691 in_file >> this->model_type 00692 >> this->analysis_type 00693 >> this->data_characteristic 00694 >> this->result_type 00695 >> this->data_type 00696 >> this->nvaldc; 00697 00698 for (unsigned int i=0; i<8; i++) 00699 in_file >> this->record_10[i]; 00700 00701 for (unsigned int i=0; i<2; i++) 00702 in_file >> this->record_11[i]; 00703 00704 00705 /* 00706 * There are UNV-files where floats are 00707 * written with 'D' as the 10th-power 00708 * character. Replace this 'D' by 'e', 00709 * so that std::atof() can work fine. 00710 */ 00711 std::string buf; 00712 in_file >> buf; 00713 00714 if (need_D_to_e(buf)) 00715 { 00716 // have to convert _all_ 'D' to 'e' 00717 this->record_12[0] = std::atof(buf.c_str()); 00718 00719 for (unsigned int i=1; i<6; i++) 00720 { 00721 in_file >> buf; 00722 need_D_to_e(buf); 00723 this->record_12[i] = std::atof(buf.c_str()); 00724 } 00725 00726 for (unsigned int i=0; i<6; i++) 00727 { 00728 in_file >> buf; 00729 need_D_to_e(buf); 00730 this->record_13[i] = std::atof(buf.c_str()); 00731 } 00732 } 00733 else 00734 { 00735 // no 'D', the stream will recognize the floats 00736 this->record_12[0] = std::atof(buf.c_str()); 00737 00738 for (unsigned int i=1; i<6; i++) 00739 in_file >> this->record_12[i]; 00740 00741 for (unsigned int i=0; i<6; i++) 00742 in_file >> this->record_13[i]; 00743 } 00744 00745 /* 00746 * no matter whether the user provided a desired 00747 * dataset label or not: return true, b/c the 00748 * non-match was already caught before. 00749 */ 00750 return true; 00751 } 00752 00753 00754 00755 00756 void MeshDataUnvHeader::write (std::ostream& out_file) 00757 { 00758 00759 00760 char buf[82]; 00761 00762 std::sprintf(buf, "%6i\n",this->dataset_label); 00763 00764 out_file << buf; 00765 00766 out_file << this->dataset_name << "\n"; 00767 00768 std::sprintf(buf, "%6i\n",this->dataset_location); 00769 00770 out_file << buf; 00771 00772 for (unsigned int n=0; n<5; n++) 00773 out_file << this->id_lines_1_to_5[n] << "\n"; 00774 00775 std::sprintf(buf, "%10i%10i%10i%10i%10i%10i\n", 00776 model_type, analysis_type, data_characteristic, 00777 result_type, data_type, nvaldc); 00778 00779 out_file << buf; 00780 00781 std::sprintf(buf, "%10i%10i%10i%10i%10i%10i%10i%10i\n", 00782 record_10[0], record_10[1], record_10[2], record_10[3], 00783 record_10[4], record_10[5], record_10[6], record_10[7]); 00784 00785 out_file << buf; 00786 00787 std::sprintf(buf, "%10i%10i\n", record_11[0], record_11[1]); 00788 out_file << buf; 00789 00790 std::sprintf(buf, "%13.5E%13.5E%13.5E%13.5E%13.5E%13.5E\n", 00791 static_cast<double>(record_12[0]), 00792 static_cast<double>(record_12[1]), 00793 static_cast<double>(record_12[2]), 00794 static_cast<double>(record_12[3]), 00795 static_cast<double>(record_12[4]), 00796 static_cast<double>(record_12[5])); 00797 00798 out_file << buf; 00799 00800 std::sprintf(buf, "%13.5E%13.5E%13.5E%13.5E%13.5E%13.5E\n", 00801 static_cast<double>(record_13[0]), 00802 static_cast<double>(record_13[1]), 00803 static_cast<double>(record_13[2]), 00804 static_cast<double>(record_13[3]), 00805 static_cast<double>(record_13[4]), 00806 static_cast<double>(record_13[5])); 00807 00808 out_file << buf; 00809 } 00810 00811 00812 00813 00814 00815 bool MeshDataUnvHeader::need_D_to_e (std::string& number) 00816 { 00817 // find "D" in string, start looking at 6th element, to improve speed. 00818 // We dont expect a "D" earlier 00819 00820 // #ifdef __HP_aCC 00821 // // Use an "int" instead of unsigned int, 00822 // // otherwise HP aCC may crash! 00823 // const int position = number.find("D",6); 00824 // #else 00825 // const unsigned int position = number.find("D",6); 00826 // #endif 00827 std::string::size_type position = number.find("D",6); 00828 00829 if(position!=std::string::npos) // npos means no position 00830 { 00831 // replace "D" in string 00832 number.replace(position,1,"e"); 00833 return true; 00834 } 00835 else 00836 // we assume that if this one number is written correctly, all numbers are 00837 return false; 00838 } 00839 00840 00841 00842 void MeshDataUnvHeader::which_dataset (const unsigned int ds_label) 00843 { 00844 this->_desired_dataset_label = ds_label; 00845 } 00846 00847 00848 00849 void MeshDataUnvHeader::operator = (const MeshDataUnvHeader& omduh) 00850 { 00851 this->dataset_label = omduh.dataset_label; 00852 this->dataset_name = omduh.dataset_name; 00853 this->dataset_location = omduh.dataset_location; 00854 this->id_lines_1_to_5 = omduh.id_lines_1_to_5; 00855 00856 this->model_type = omduh.model_type; 00857 this->analysis_type = omduh.analysis_type; 00858 this->data_characteristic = omduh.data_characteristic; 00859 this->result_type = omduh.result_type; 00860 00861 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 00862 /* 00863 * in complex mode allow only 00864 * values 5 or 6 (complex) for data_type 00865 */ 00866 if ((omduh.data_type == 5) || 00867 (omduh.data_type == 6)) 00868 this->data_type = omduh.data_type; 00869 else 00870 { 00871 # ifdef DEBUG 00872 libMesh::err << "WARNING: MeshDataUnvHeader::operator=(): Other object has data_type for" << std::endl 00873 << " real values. Will use default data_type=5 during assignment." << std::endl 00874 << std::endl; 00875 # endif 00876 this->data_type = 5; 00877 } 00878 00879 #else 00880 00881 /* 00882 * in real mode allow only 00883 * values 2 or 4 (real) for data_type 00884 */ 00885 if ((omduh.data_type == 2) || 00886 (omduh.data_type == 4)) 00887 this->data_type = omduh.data_type; 00888 else 00889 { 00890 # ifdef DEBUG 00891 libMesh::err << "WARNING: Other MeshDataUnvHeader has data_type for complex values." << std::endl 00892 << " Data import will likely _not_ work and result in infinite loop," << std::endl 00893 << " provided the user forgot to re-size nvaldc to 2*nvaldc_old!" << std::endl 00894 << std::endl; 00895 # endif 00896 this->data_type = 2; 00897 } 00898 00899 #endif 00900 00901 this->nvaldc = omduh.nvaldc; 00902 00903 this->record_10 = omduh.record_10; 00904 this->record_11 = omduh.record_11; 00905 this->record_12 = omduh.record_12; 00906 this->record_13 = omduh.record_13; 00907 00908 this->_desired_dataset_label = omduh._desired_dataset_label; 00909 } 00910 00911 00912 00913 00914 bool MeshDataUnvHeader::operator == (const MeshDataUnvHeader& omduh) const 00915 { 00916 return (this->dataset_label == omduh.dataset_label && 00917 this->dataset_name == omduh.dataset_name && 00918 this->dataset_location == omduh.dataset_location && 00919 this->id_lines_1_to_5 == omduh.id_lines_1_to_5 && 00920 00921 this->model_type == omduh.model_type && 00922 this->analysis_type == omduh.analysis_type && 00923 this->data_characteristic == omduh.data_characteristic && 00924 this->result_type == omduh.result_type && 00925 00926 this->data_type == omduh.data_type && 00927 this->nvaldc == omduh.nvaldc && 00928 00929 this->record_10 == omduh.record_10 && 00930 this->record_11 == omduh.record_11 && 00931 this->record_12 == omduh.record_12 && 00932 this->record_13 == omduh.record_13 && 00933 00934 this->_desired_dataset_label == omduh._desired_dataset_label); 00935 } 00936 00937 } // namespace libMesh 00938 00939 00940 00941
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:47 UTC
Hosted By: