00001 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE 00002 // 00003 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, 00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 00005 // 00006 // This library is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU Lesser General Public 00008 // License as published by the Free Software Foundation; either 00009 // version 2.1 of the License. 00010 // 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 // Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public 00017 // License along with this library; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 // 00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com 00021 // 00022 00023 #include <fstream> 00024 #include <iomanip> 00025 00026 #include "UNV2412_Structure.hxx" 00027 #include "UNV_Utilities.hxx" 00028 00029 using namespace std; 00030 using namespace UNV; 00031 using namespace UNV2412; 00032 00033 // Universal Dataset Number 2412 00034 00035 // Name: Elements 00036 // Status: Current 00037 // Owner: Simulation 00038 // Revision Date: 14-AUG-1992 00039 // ----------------------------------------------------------------------- 00040 00041 // Record 1: FORMAT(6I10) 00042 // Field 1 -- element label 00043 // Field 2 -- fe descriptor id 00044 // Field 3 -- physical property table number 00045 // Field 4 -- material property table number 00046 // Field 5 -- color 00047 // Field 6 -- number of nodes on element 00048 00049 // Record 2: *** FOR NON-BEAM ELEMENTS *** 00050 // FORMAT(8I10) 00051 // Fields 1-n -- node labels defining element 00052 00053 // Record 2: *** FOR BEAM ELEMENTS ONLY *** 00054 // FORMAT(3I10) 00055 // Field 1 -- beam orientation node number 00056 // Field 2 -- beam fore-end cross section number 00057 // Field 3 -- beam aft-end cross section number 00058 00059 // Record 3: *** FOR BEAM ELEMENTS ONLY *** 00060 // FORMAT(8I10) 00061 // Fields 1-n -- node labels defining element 00062 00063 // Records 1 and 2 are repeated for each non-beam element in the model. 00064 // Records 1 - 3 are repeated for each beam element in the model. 00065 00066 // Example: 00067 00068 // -1 00069 // 2412 00070 // 1 11 1 5380 7 2 00071 // 0 1 1 00072 // 1 2 00073 // 2 21 2 5380 7 2 00074 // 0 1 1 00075 // 3 4 00076 // 3 22 3 5380 7 2 00077 // 0 1 2 00078 // 5 6 00079 // 6 91 6 5380 7 3 00080 // 11 18 12 00081 // 9 95 6 5380 7 8 00082 // 22 25 29 30 31 26 24 23 00083 // 14 136 8 0 7 2 00084 // 53 54 00085 // 36 116 16 5380 7 20 00086 // 152 159 168 167 166 158 150 151 00087 // 154 170 169 153 157 161 173 172 00088 // 171 160 155 156 00089 // -1 00090 00091 // FE Descriptor Id definitions 00092 // ____________________________ 00093 00094 // 11 Rod 00095 // 21 Linear beam 00096 // 22 Tapered beam 00097 // 23 Curved beam 00098 // 24 Parabolic beam 00099 // 31 Straight pipe 00100 // 32 Curved pipe 00101 // 41 Plane Stress Linear Triangle 00102 // 42 Plane Stress Parabolic Triangle 00103 // 43 Plane Stress Cubic Triangle 00104 // 44 Plane Stress Linear Quadrilateral 00105 // 45 Plane Stress Parabolic Quadrilateral 00106 // 46 Plane Strain Cubic Quadrilateral 00107 // 51 Plane Strain Linear Triangle 00108 // 52 Plane Strain Parabolic Triangle 00109 // 53 Plane Strain Cubic Triangle 00110 // 54 Plane Strain Linear Quadrilateral 00111 // 55 Plane Strain Parabolic Quadrilateral 00112 // 56 Plane Strain Cubic Quadrilateral 00113 // 61 Plate Linear Triangle 00114 // 62 Plate Parabolic Triangle 00115 // 63 Plate Cubic Triangle 00116 // 64 Plate Linear Quadrilateral 00117 // 65 Plate Parabolic Quadrilateral 00118 // 66 Plate Cubic Quadrilateral 00119 // 71 Membrane Linear Quadrilateral 00120 // 72 Membrane Parabolic Triangle 00121 // 73 Membrane Cubic Triangle 00122 // 74 Membrane Linear Triangle 00123 // 75 Membrane Parabolic Quadrilateral 00124 // 76 Membrane Cubic Quadrilateral 00125 // 81 Axisymetric Solid Linear Triangle 00126 // 82 Axisymetric Solid Parabolic Triangle 00127 // 84 Axisymetric Solid Linear Quadrilateral 00128 // 85 Axisymetric Solid Parabolic Quadrilateral 00129 // 91 Thin Shell Linear Triangle 00130 // 92 Thin Shell Parabolic Triangle 00131 // 93 Thin Shell Cubic Triangle 00132 // 94 Thin Shell Linear Quadrilateral 00133 // 95 Thin Shell Parabolic Quadrilateral 00134 // 96 Thin Shell Cubic Quadrilateral 00135 // 101 Thick Shell Linear Wedge 00136 // 102 Thick Shell Parabolic Wedge 00137 // 103 Thick Shell Cubic Wedge 00138 // 104 Thick Shell Linear Brick 00139 // 105 Thick Shell Parabolic Brick 00140 // 106 Thick Shell Cubic Brick 00141 // 111 Solid Linear Tetrahedron 00142 // 112 Solid Linear Wedge 00143 // 113 Solid Parabolic Wedge 00144 // 114 Solid Cubic Wedge 00145 // 115 Solid Linear Brick 00146 // 116 Solid Parabolic Brick 00147 // 117 Solid Cubic Brick 00148 // 118 Solid Parabolic Tetrahedron 00149 // 121 Rigid Bar 00150 // 122 Rigid Element 00151 // 136 Node To Node Translational Spring 00152 // 137 Node To Node Rotational Spring 00153 // 138 Node To Ground Translational Spring 00154 // 139 Node To Ground Rotational Spring 00155 // 141 Node To Node Damper 00156 // 142 Node To Gound Damper 00157 // 151 Node To Node Gap 00158 // 152 Node To Ground Gap 00159 // 161 Lumped Mass 00160 // 171 Axisymetric Linear Shell 00161 // 172 Axisymetric Parabolic Shell 00162 // 181 Constraint 00163 // 191 Plastic Cold Runner 00164 // 192 Plastic Hot Runner 00165 // 193 Plastic Water Line 00166 // 194 Plastic Fountain 00167 // 195 Plastic Baffle 00168 // 196 Plastic Rod Heater 00169 // 201 Linear node-to-node interface 00170 // 202 Linear edge-to-edge interface 00171 // 203 Parabolic edge-to-edge interface 00172 // 204 Linear face-to-face interface 00173 // 208 Parabolic face-to-face interface 00174 // 212 Linear axisymmetric interface 00175 // 213 Parabolic axisymmetric interface 00176 // 221 Linear rigid surface 00177 // 222 Parabolic rigin surface 00178 // 231 Axisymetric linear rigid surface 00179 // 232 Axisymentric parabolic rigid surface 00180 00181 00182 00183 static string _label_dataset = "2412"; 00184 00185 UNV2412::TRecord::TRecord(): 00186 phys_prop_tab_num(2), 00187 mat_prop_tab_num(1), 00188 color(7), 00189 beam_orientation(0), 00190 beam_fore_end(0), 00191 beam_aft_end(0) 00192 {} 00193 00194 void UNV2412::Read(std::ifstream& in_stream, TDataSet& theDataSet) 00195 { 00196 if(!in_stream.good()) 00197 EXCEPTION(runtime_error,"ERROR: Input file not good."); 00198 00199 /* 00200 * adjust the \p istream to our 00201 * position 00202 */ 00203 if(!beginning_of_dataset(in_stream,_label_dataset)) 00204 EXCEPTION(runtime_error,"ERROR: Could not find "<<_label_dataset<<" dataset!"); 00205 00206 TElementLab aLabel; 00207 for(; !in_stream.eof();){ 00208 in_stream >> aLabel ; 00209 if(aLabel == -1){ 00210 // end of dataset is reached 00211 break; 00212 } 00213 00214 int n_nodes; 00215 TRecord aRec; 00216 in_stream>>aRec.fe_descriptor_id; 00217 in_stream>>aRec.phys_prop_tab_num; 00218 in_stream>>aRec.mat_prop_tab_num; 00219 in_stream>>aRec.color; 00220 in_stream>>n_nodes; 00221 00222 if(IsBeam(aRec.fe_descriptor_id)){ 00223 in_stream>>aRec.beam_orientation; 00224 in_stream>>aRec.beam_fore_end; 00225 in_stream>>aRec.beam_aft_end; 00226 } 00227 00228 aRec.node_labels.resize(n_nodes); 00229 for(int j=0; j < n_nodes; j++){ 00230 // read node labels 00231 in_stream>>aRec.node_labels[j]; 00232 } 00233 00234 theDataSet.insert(TDataSet::value_type(aLabel,aRec)); 00235 } 00236 00237 } 00238 00239 00240 void UNV2412::Write(std::ofstream& out_stream, const TDataSet& theDataSet) 00241 { 00242 if(!out_stream.good()) 00243 EXCEPTION(runtime_error,"ERROR: Output file not good."); 00244 00245 /* 00246 * Write beginning of dataset 00247 */ 00248 out_stream<<" -1\n"; 00249 out_stream<<" "<<_label_dataset<<"\n"; 00250 00251 TDataSet::const_iterator anIter = theDataSet.begin(); 00252 for(; anIter != theDataSet.end(); anIter++){ 00253 const TElementLab& aLabel = anIter->first; 00254 const TRecord& aRec = anIter->second; 00255 out_stream<<std::setw(10)<<aLabel; /* element ID */ 00256 out_stream<<std::setw(10)<<aRec.fe_descriptor_id; /* type of element */ 00257 out_stream<<std::setw(10)<<aRec.phys_prop_tab_num; 00258 out_stream<<std::setw(10)<<aRec.mat_prop_tab_num; 00259 out_stream<<std::setw(10)<<aRec.color; 00260 out_stream<<std::setw(10)<<aRec.node_labels.size()<<std::endl; /* No. of nodes per element */ 00261 00262 if(IsBeam(aRec.fe_descriptor_id)){ 00263 out_stream<<std::setw(10)<<aRec.beam_orientation; 00264 out_stream<<std::setw(10)<<aRec.beam_fore_end; 00265 out_stream<<std::setw(10)<<aRec.beam_aft_end<<std::endl; 00266 } 00267 00268 int n_nodes = aRec.node_labels.size(); 00269 int iEnd = (n_nodes-1)/8 + 1; 00270 for(int i = 0, k = 0; i < iEnd; i++){ 00271 int jEnd = n_nodes - 8*(i+1); 00272 if(jEnd < 0) 00273 jEnd = 8 + jEnd; 00274 else 00275 jEnd = 8; 00276 for(int j = 0; j < jEnd ; k++, j++){ 00277 out_stream<<std::setw(10)<<aRec.node_labels[k]; 00278 } 00279 out_stream<<std::endl; 00280 } 00281 } 00282 00283 /* 00284 * Write end of dataset 00285 */ 00286 out_stream<<" -1\n"; 00287 } 00288 00289 00290 bool UNV2412::IsBeam(int theFeDescriptorId){ 00291 switch (theFeDescriptorId){ 00292 case 11: // edge with 2 nodes 00293 case 21: 00294 case 22: // edge with 3 nodes 00295 case 23: // curved beam 00296 case 24: 00297 case 25: 00298 return true; 00299 } 00300 return false; 00301 } 00302 00303 00304 bool UNV2412::IsFace(int theFeDescriptorId){ 00305 return ( 41 <= theFeDescriptorId && theFeDescriptorId <= 96 ); 00306 // switch (theFeDescriptorId){ 00307 00308 // case 71: // TRI3 00309 // case 72: 00310 // case 74: 00311 00312 // case 41: // Plane Stress Linear Triangle - TRI3 00313 // case 51: // Plane Strain Linear Triangle 00314 // case 91: // Thin Shell Linear Triangle - TRI3 00315 00316 // case 42: // Plane Stress Quadratic Triangle - TRI6 00317 // case 52: // Plane Strain Parabolic Triangle 00318 // case 92: // Thin Shell Quadratic Triangle - TRI6 00319 00320 // case 43: // Plane Stress Cubic Triangle 00321 00322 // case 44: // Plane Stress Linear Quadrilateral - QUAD4 00323 // case 94: // Thin Shell Linear Quadrilateral - QUAD4 00324 00325 // case 45: // Plane Stress Quadratic Quadrilateral - QUAD8 00326 // case 95: // Thin Shell Quadratic Quadrilateral - QUAD8 00327 00328 // case 46: // Plane Stress Cubic Quadrilateral 00329 00330 // return true; 00331 // } 00332 // return false; 00333 } 00334 00335 00336 bool UNV2412::IsVolume(int theFeDescriptorId){ 00337 //if(!IsBeam(theFeDescriptorId) && !IsFace(theFeDescriptorId)) 00338 // return true; 00339 switch (theFeDescriptorId){ 00340 00341 case 111: // Solid Linear Tetrahedron - TET4 00342 case 118: // Solid Quadratic Tetrahedron - TET10 00343 00344 case 112: // Solid Linear Prism - PRISM6 00345 case 113: // Solid Quadratic Prism - PRISM15 00346 00347 case 115: // Solid Linear Brick - HEX8 00348 case 116: // Solid Quadratic Brick - HEX20 00349 00350 case 117: // Solid Cubic Brick 00351 00352 case 114: // pyramid of 13 nodes (quadratic) 00353 return true; 00354 } 00355 return false; 00356 }