Back to index

salome-smesh  6.5.0
UNV2412_Structure.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  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   label(-1),
00187   fe_descriptor_id(-1),
00188   phys_prop_tab_num(2),
00189   mat_prop_tab_num(1),
00190   color(7),
00191   beam_orientation(0),
00192   beam_fore_end(1), // default values
00193   beam_aft_end(1) // default values
00194 {}
00195 
00196 void UNV2412::Read(std::ifstream& in_stream, TDataSet& theDataSet)
00197 {
00198   if(!in_stream.good())
00199     EXCEPTION(runtime_error,"ERROR: Input file not good.");
00200 
00201   /*
00202    * adjust the \p istream to our
00203    * position
00204    */
00205   if(!beginning_of_dataset(in_stream,_label_dataset))
00206     EXCEPTION(runtime_error,"ERROR: Could not find "<<_label_dataset<<" dataset!");
00207 
00208   TRecord aRec;
00209   while( !in_stream.eof())
00210   {
00211     in_stream >> aRec.label ;
00212     if (aRec.label == -1)
00213       // end of dataset is reached
00214       break;
00215     
00216     int n_nodes;
00217     in_stream>>aRec.fe_descriptor_id;
00218     in_stream>>aRec.phys_prop_tab_num;
00219     in_stream>>aRec.mat_prop_tab_num;
00220     in_stream>>aRec.color;
00221     in_stream>>n_nodes;
00222 
00223     if(IsBeam(aRec.fe_descriptor_id)){
00224       in_stream>>aRec.beam_orientation;
00225       in_stream>>aRec.beam_fore_end;
00226       in_stream>>aRec.beam_aft_end;
00227     }
00228 
00229     aRec.node_labels.resize(n_nodes);
00230     for(int j=0; j < n_nodes; j++)
00231       // read node labels
00232       in_stream>>aRec.node_labels[j];             
00233 
00234     theDataSet.push_back(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   {
00254     const TRecord& aRec = *anIter;
00255     out_stream<<std::setw(10)<<aRec.label;  /* 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     {
00264       out_stream<<std::setw(10)<<aRec.beam_orientation;
00265       out_stream<<std::setw(10)<<aRec.beam_fore_end;
00266       out_stream<<std::setw(10)<<aRec.beam_aft_end<<std::endl;
00267     }
00268 
00269     int n_nodes = aRec.node_labels.size();
00270     int iEnd = (n_nodes-1)/8 + 1;
00271     for(int i = 0, k = 0; i < iEnd; i++){
00272       int jEnd = n_nodes - 8*(i+1);
00273       if(jEnd < 0) 
00274         jEnd = 8 + jEnd;
00275       else
00276         jEnd = 8;
00277       for(int j = 0; j < jEnd ; k++, j++){
00278         out_stream<<std::setw(10)<<aRec.node_labels[k];
00279       }
00280       out_stream<<std::endl;
00281     }
00282   }
00283 
00284   /*
00285    * Write end of dataset
00286    */
00287   out_stream<<"    -1\n";
00288 }
00289 
00290 
00291 bool UNV2412::IsBeam(int theFeDescriptorId){
00292   switch (theFeDescriptorId){
00293   case 11: // edge with 2 nodes
00294   case 21: 
00295   case 22: // edge with 3 nodes
00296   case 23: // curved beam
00297   case 24:
00298   case 25:
00299     return true;
00300   }
00301   return false;
00302 }
00303 
00304 
00305 bool UNV2412::IsFace(int theFeDescriptorId){
00306   return ( 41 <= theFeDescriptorId && theFeDescriptorId <= 96 );
00307 //   switch (theFeDescriptorId){
00308     
00309 //   case 71: // TRI3
00310 //   case 72:
00311 //   case 74:
00312 
00313 //   case 41: // Plane Stress Linear Triangle - TRI3
00314 //   case 51: // Plane Strain Linear Triangle
00315 //   case 91: // Thin Shell Linear Triangle - TRI3
00316 
00317 //   case 42: // Plane Stress Quadratic Triangle - TRI6
00318 //   case 52: // Plane Strain Parabolic Triangle
00319 //   case 92: // Thin Shell Quadratic Triangle - TRI6
00320 
00321 //   case 43: // Plane Stress Cubic Triangle
00322 
00323 //   case 44: // Plane Stress Linear Quadrilateral - QUAD4
00324 //   case 94: // Thin Shell   Linear Quadrilateral -  QUAD4
00325 
00326 //   case 45: // Plane Stress Quadratic Quadrilateral - QUAD8
00327 //   case 95: // Thin Shell   Quadratic Quadrilateral - QUAD8
00328 
00329 //   case 46: // Plane Stress Cubic Quadrilateral
00330 
00331 //     return true;
00332 //   }
00333 //  return false;
00334 }
00335 
00336 
00337 bool UNV2412::IsVolume(int theFeDescriptorId){
00338   //if(!IsBeam(theFeDescriptorId) && !IsFace(theFeDescriptorId))
00339   //  return true;
00340   switch (theFeDescriptorId){
00341 
00342   case 111: // Solid Linear Tetrahedron - TET4
00343   case 118: // Solid Quadratic Tetrahedron - TET10
00344 
00345   case 112: // Solid Linear Prism - PRISM6
00346   case 113: // Solid Quadratic Prism - PRISM15
00347 
00348   case 115: // Solid Linear Brick - HEX8
00349   case 116: // Solid Quadratic Brick - HEX20
00350 
00351   case 117: // Solid Cubic Brick
00352 
00353   case 114: // pyramid of 13 nodes (quadratic)
00354     return true;
00355   }
00356   return false;
00357 }