00001
00011 #ifndef _NASTRAN_INPUT_BASSO_H_
00012 #define _NASTRAN_INPUT_BASSO_H_
00013
00014
00015 #include <iostream>
00016 #include <iomanip>
00017 #include <fstream>
00018
00019
00020 #include <vector>
00021 #include <list>
00022 #include <set>
00023 #include <map>
00024
00025
00026 #include "basso.h"
00027 #include "FEInput.h"
00028
00029 namespace basso {
00030
00031
00032 class NastranCard
00033 {
00034
00035 public:
00036 NastranCard() : mFields(25) { mNumFelds=0; }
00037
00038 bool ReadNextGrid( ifstream &inFile ) { }
00039 bool ReadNextElement( ifstream &inFile ) { }
00040
00041 int NumFields() const { return mNumFields; }
00042
00043 const int &operator ( int f ) const { }
00044 const Numeric &operator ( int f ) const { }
00045 const String &operator ( int f ) const { }
00046
00047 private:
00048
00049 int mNumFields;
00050 Array<String> mFields;
00051
00052 };
00053
00059 class NastranInput : public FEInput {
00060
00061 public:
00062
00064
00067 NastranInput( ) : Input( ) { fProcessed=false; }
00068 NastranInput( const String &file ) : Input(file) { fProcessed=false; }
00071 virtual ~NastranInput() {}
00072
00073
00074
00078 virtual void ReadNodes( Array<Node> &nodes );
00079
00087 virtual void AddElements( list<Element> &elem, int pid=-999 ) const;
00088
00095 virtual void AddNodeSet( set<int> &nid, int pid ) const;
00096
00097 protected:
00098
00104 int ReadNextCard( list<String> &fields, ifstream &inFile ) const;
00105
00111 int ConvertField( int fid, const list<String> &fields ) const;
00112
00118 Numeric ConvertField( int fid, const list<String> &fields ) const;
00119
00124 BasisType GetBasisType( const String &etype, int nn ) const;
00125
00127 int NumNodes() const;
00128
00129 protected:
00130
00131
00132
00133 };
00134
00135 int NastranInput::NumNodes() const
00136 {
00137
00138 std::ifstream inFile;
00139 if ( OpenFile(inFile) )
00140 WarningMessage("NastranInput::NumNodes","could not open file");
00141
00142 int nn=0;
00143
00144 while ( !GotoNextSection("GRID") )
00145 ++nn;
00146
00147 CloseFile(inFile);
00148
00149 return nn;
00150 }
00151
00152 void NastranInput::ReadNodes( Array<Node> &node )
00153 {
00154
00155
00156 std::ifstream inFile;
00157 if ( OpenFile(inFile) )
00158 WarningMessage("NastranInput::ReadNodes","could not open file");
00159
00160
00161 int nn=NumNodes();
00162 if ( node.size()!=nn )
00163 resize( node, nn );
00164
00165
00166 int i=0;
00167 while ( !GotoNextSection("GRID") )
00168 {
00169 int id, cid;
00170 char card(16);
00171 Numeric x, y, z;
00172 inFile >> card >> id >> cid >> x >> y >> z;
00173 node[i]=Node(i,x,y,z);
00174 mNodeMap[id]=i++;
00175 }
00176
00177 CloseFile(inFile);
00178
00179 }
00180
00181 void NastranInput::AddElements( list<Element> &elem, int pid ) const
00182 {
00183
00184 std::ifstream inFile;
00185 if ( OpenFile(inFile) )
00186 WarningMessage("NastranInput::ReadElements","could not open file");
00187
00188 WarningMessage("NastranInput::AddElements","not yet implemented");
00189
00190 while ( GotoNextSection("C") )
00191 {
00192 if ( fields)
00193 }
00194
00195 CloseFile(inFile);
00196
00197 }
00198
00199 void NastranInput::AddNodeSet( set<int> &nset, int pid ) const
00200 {
00201
00202 std::ifstream inFile;
00203 if ( OpenFile(inFile) )
00204 WarningMessage("NastranInput::ReadNodeSet","could not open file");
00205
00206 WarningMessage("NastranInput::AddNodeSet","not yet implemented");
00207
00208 CloseFile(inFile);
00209 }
00210
00211
00212
00213 BasisType NastranInput::GetBasisType( const String &etype, int nn ) const
00214 {
00215 switch (etype) {
00216
00217 case "CBAR":
00218 return kLINE2;
00219
00220 case "CTRIA3":
00221 return kTRIA3;
00222
00223 case "CQUAD4":
00224 return kQUAD4;
00225
00226 case "CTETRA":
00227 return kTETRA4;
00228
00229 case "CHEXA ":
00230 return kHEXA8;
00231
00232 case "CPENTA":
00233 return kPRISM6;
00234
00235 case "CTRIA6":
00236 return kTRIA6;
00237
00238 case "CQUAD8":
00239 return kQUAD8;
00240
00241 case "CTETRA":
00242 return kTETRA10;
00243
00244 case "CHEXA ":
00245 return kHEXA20;
00246
00247 case "CPENTA":
00248 return kPRISM18;
00249
00250 case "CMASS1":
00251 return kPOINT1;
00252
00253 case "CPENTA":
00254 return kPRISM15;
00255
00256 default:
00257 WarningMessage("BasisType NastranInput::GetBasisType( int etype )","Unknown etype");
00258 return kNONE;
00259 }
00260 }
00261
00262
00263
00264
00265
00266 }
00267 #endif