nastranSurfaceWriter.H
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::nastranSurfaceWriter 00026 00027 Description 00028 A surface writer for the Nastran file format - both surface mesh and fields 00029 00030 SourceFiles 00031 nastranSurfaceWriter.C 00032 nastranSurfaceWriterTemplates.C 00033 00034 \*---------------------------------------------------------------------------*/ 00035 00036 #ifndef nastranSurfaceWriter_H 00037 #define nastranSurfaceWriter_H 00038 00039 #include "surfaceWriter.H" 00040 #include "NamedEnum.H" 00041 #include "OFstream.H" 00042 00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00044 00045 namespace Foam 00046 { 00047 00048 /*---------------------------------------------------------------------------*\ 00049 Class nastranSurfaceWriter Declaration 00050 \*---------------------------------------------------------------------------*/ 00051 00052 class nastranSurfaceWriter 00053 : 00054 public surfaceWriter 00055 { 00056 public: 00057 00058 enum writeFormat 00059 { 00060 wfShort, 00061 wfLong, 00062 wfFree 00063 }; 00064 00065 static const NamedEnum<writeFormat, 3> writeFormatNames_; 00066 00067 00068 private: 00069 00070 // Private data 00071 00072 //- Write option 00073 writeFormat writeFormat_; 00074 00075 //- Map of OpenFOAM field name vs nastran field name 00076 HashTable<word> fieldMap_; 00077 00078 00079 // Private Member Functions 00080 00081 //- Initialise the output stream format params 00082 void formatOS(OFstream& os) const; 00083 00084 //- Write a co-ordinate 00085 void writeCoord 00086 ( 00087 const point& p, 00088 const label pointI, 00089 OFstream& os 00090 ) const; 00091 00092 //- Write a face element (CTRIA3 or CQUAD4) 00093 void writeFace 00094 ( 00095 const word& faceType, 00096 const labelList& facePts, 00097 label& nFace, 00098 OFstream& os 00099 ) const; 00100 00101 //- Main driver to write the surface mesh geometry 00102 void writeGeometry 00103 ( 00104 const pointField& points, 00105 const faceList& faces, 00106 List<DynamicList<face> >& decomposedFaces, 00107 OFstream& os 00108 ) const; 00109 00110 //- Write a face-based value 00111 template<class Type> 00112 void writeFaceValue 00113 ( 00114 const word& nasFieldName, 00115 const Type& value, 00116 const label EID, 00117 OFstream& os 00118 ) const; 00119 00120 //- Templated write operation 00121 template<class Type> 00122 void writeTemplate 00123 ( 00124 const fileName& outputDir, 00125 const fileName& surfaceName, 00126 const pointField& points, 00127 const faceList& faces, 00128 const word& fieldName, 00129 const Field<Type>& values, 00130 const bool isNodeValues, 00131 const bool verbose 00132 ) const; 00133 00134 00135 public: 00136 00137 //- Runtime type information 00138 TypeName("nastran"); 00139 00140 00141 // Constructors 00142 00143 //- Construct null 00144 nastranSurfaceWriter(); 00145 00146 //- Construct with some output options 00147 nastranSurfaceWriter(const dictionary& options); 00148 00149 00150 //- Destructor 00151 virtual ~nastranSurfaceWriter(); 00152 00153 00154 // Member Functions 00155 00156 //- True if the surface format supports geometry in a separate file. 00157 // False if geometry and field must be in a single file 00158 virtual bool separateGeometry() 00159 { 00160 return false; 00161 } 00162 00163 //- Write single surface geometry to file. 00164 virtual void write 00165 ( 00166 const fileName& outputDir, 00167 const fileName& surfaceName, 00168 const pointField& points, 00169 const faceList& faces, 00170 const bool verbose = false 00171 ) const; 00172 00173 //- Write scalarField for a single surface to file. 00174 // One value per face or vertex (isNodeValues = true) 00175 virtual void write 00176 ( 00177 const fileName& outputDir, 00178 const fileName& surfaceName, 00179 const pointField& points, 00180 const faceList& faces, 00181 const word& fieldName, 00182 const Field<scalar>& values, 00183 const bool isNodeValues, 00184 const bool verbose = false 00185 ) const; 00186 00187 //- Write vectorField for a single surface to file. 00188 // One value per face or vertex (isNodeValues = true) 00189 virtual void write 00190 ( 00191 const fileName& outputDir, 00192 const fileName& surfaceName, 00193 const pointField& points, 00194 const faceList& faces, 00195 const word& fieldName, 00196 const Field<vector>& values, 00197 const bool isNodeValues, 00198 const bool verbose = false 00199 ) const; 00200 00201 //- Write sphericalTensorField for a single surface to file. 00202 // One value per face or vertex (isNodeValues = true) 00203 virtual void write 00204 ( 00205 const fileName& outputDir, 00206 const fileName& surfaceName, 00207 const pointField& points, 00208 const faceList& faces, 00209 const word& fieldName, 00210 const Field<sphericalTensor>& values, 00211 const bool isNodeValues, 00212 const bool verbose = false 00213 ) const; 00214 00215 //- Write symmTensorField for a single surface to file. 00216 // One value per face or vertex (isNodeValues = true) 00217 virtual void write 00218 ( 00219 const fileName& outputDir, 00220 const fileName& surfaceName, 00221 const pointField& points, 00222 const faceList& faces, 00223 const word& fieldName, 00224 const Field<symmTensor>& values, 00225 const bool isNodeValues, 00226 const bool verbose = false 00227 ) const; 00228 00229 //- Write tensorField for a single surface to file. 00230 // One value per face or vertex (isNodeValues = true) 00231 virtual void write 00232 ( 00233 const fileName& outputDir, 00234 const fileName& surfaceName, 00235 const pointField& points, 00236 const faceList& faces, 00237 const word& fieldName, 00238 const Field<tensor>& values, 00239 const bool isNodeValues, 00240 const bool verbose = false 00241 ) const; 00242 }; 00243 00244 00245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00246 00247 } // End namespace Foam 00248 00249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00250 00251 #ifdef NoRepository 00252 #include "nastranSurfaceWriterTemplates.C" 00253 #endif 00254 00255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00256 00257 #endif 00258 00259 // ************************************************************************* //
