FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

sampledSurfaces.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) 1991-2010 OpenCFD Ltd.
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::sampledSurfaces
00026 
00027 Description
00028     Set of surfaces to sample.
00029 
00030     The write() method is used to sample and write files.
00031 
00032 SourceFiles
00033     sampledSurfaces.C
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef sampledSurfaces_H
00038 #define sampledSurfaces_H
00039 
00040 #include <sampling/sampledSurface.H>
00041 #include <sampling/surfaceWriter.H>
00042 #include <finiteVolume/volFieldsFwd.H>
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 class fvMesh;
00050 class dictionary;
00051 
00052 /*---------------------------------------------------------------------------*\
00053                       Class sampledSurfaces Declaration
00054 \*---------------------------------------------------------------------------*/
00055 
00056 class sampledSurfaces
00057 :
00058     public PtrList<sampledSurface>
00059 {
00060     // Private classes
00061 
00062         //- Class used for grouping field types
00063         template<class Type>
00064         class fieldGroup
00065         :
00066             public DynamicList<word>
00067         {
00068         public:
00069 
00070             //- Surface formatter
00071             autoPtr< surfaceWriter<Type> > formatter;
00072 
00073             //- Construct null
00074             fieldGroup()
00075             :
00076                 DynamicList<word>(0),
00077                 formatter(NULL)
00078             {}
00079 
00080             //- Construct for a particular surface format
00081             fieldGroup(const word& writeFormat)
00082             :
00083                 DynamicList<word>(0),
00084                 formatter(surfaceWriter<Type>::New(writeFormat))
00085             {}
00086 
00087             //- Construct for a particular surface format and a list of field
00088             //  names
00089             fieldGroup
00090             (
00091                 const word& writeFormat,
00092                 const wordList& fieldNames
00093             )
00094             :
00095                 DynamicList<word>(fieldNames),
00096                 formatter(surfaceWriter<Type>::New(writeFormat))
00097             {}
00098 
00099             void reset(const label nElem)
00100             {
00101                 formatter.clear();
00102                 DynamicList<word>::setCapacity(nElem);
00103                 DynamicList<word>::clear(); 
00104             }
00105 
00106             void operator=(const word& writeFormat)
00107             {
00108                 formatter = surfaceWriter<Type>::New(writeFormat);
00109             }
00110 
00111             void operator=(const wordList& fieldNames)
00112             {
00113                 DynamicList<word>::operator=(fieldNames);
00114             }
00115         };
00116 
00117 
00118         //- Class used for surface merging information
00119         class mergeInfo
00120         {
00121         public:
00122             pointField points;
00123             faceList   faces;
00124             labelList  pointsMap;
00125 
00126             //- Clear all storage
00127             void clear()
00128             {
00129                 points.clear();
00130                 faces.clear();
00131                 pointsMap.clear();
00132             }
00133         };
00134 
00135 
00136     // Static data members
00137 
00138         //- output verbosity
00139         static bool verbose_;
00140 
00141         //- Tolerance for merging points (fraction of mesh bounding box)
00142         static scalar mergeTol_;
00143 
00144     // Private data
00145 
00146         //- Name of this set of surfaces,
00147         //  Also used as the name of the sampledSurfaces directory.
00148         const word name_;
00149 
00150         //- Const reference to fvMesh
00151         const fvMesh& mesh_;
00152 
00153         //- Load fields from files (not from objectRegistry)
00154         const bool loadFromFiles_;
00155 
00156         //- output path
00157         fileName outputPath_;
00158 
00159 
00160         // Read from dictonary
00161 
00162             //- Names of fields to sample
00163             wordList fieldNames_;
00164 
00165             //- Interpolation scheme to use
00166             word interpolationScheme_;
00167 
00168             //- Output format to use
00169             word writeFormat_;
00170 
00171 
00172         // surfaces
00173 
00174             //- Information for merging surfaces
00175             List<mergeInfo> mergeList_;
00176 
00177 
00178         // Calculated
00179 
00180             //- Generic surface formatter
00181             autoPtr< surfaceWriter<bool> > genericFormatter_;
00182 
00183             //- Categorized scalar/vector/tensor fields
00184             fieldGroup<scalar> scalarFields_;
00185             fieldGroup<vector> vectorFields_;
00186             fieldGroup<sphericalTensor> sphericalTensorFields_;
00187             fieldGroup<symmTensor> symmTensorFields_;
00188             fieldGroup<tensor> tensorFields_;
00189 
00190 
00191     // Private Member Functions
00192 
00193         //- Classify field types, returns the number of fields
00194         label classifyFieldTypes();
00195 
00196         //- Write geometry only
00197         void writeGeometry() const;
00198 
00199         //- Sample and write a particular volume field
00200         template<class Type>
00201         void sampleAndWrite
00202         (
00203             const GeometricField<Type, fvPatchField, volMesh>&,
00204             const surfaceWriter<Type>& formatter
00205         );
00206 
00207         //- Sample and write all the fields of the given type
00208         template <class Type>
00209         void sampleAndWrite(fieldGroup<Type>&);
00210 
00211         //- Disallow default bitwise copy construct and assignment
00212         sampledSurfaces(const sampledSurfaces&);
00213         void operator=(const sampledSurfaces&);
00214 
00215 
00216 public:
00217 
00218     //- Runtime type information
00219     TypeName("surfaces");
00220 
00221 
00222     // Constructors
00223 
00224         //- Construct for given objectRegistry and dictionary
00225         //  allow the possibility to load fields from files
00226         sampledSurfaces
00227         (
00228             const word& name,
00229             const objectRegistry&,
00230             const dictionary&,
00231             const bool loadFromFiles = false
00232         );
00233 
00234 
00235     // Destructor
00236 
00237         virtual ~sampledSurfaces();
00238 
00239 
00240     // Member Functions
00241 
00242         //- Does any of the surfaces need an update?
00243         virtual bool needsUpdate() const;
00244 
00245         //- Mark the surfaces as needing an update.
00246         //  May also free up unneeded data.
00247         //  Return false if all surfaces were already marked as expired.
00248         virtual bool expire();
00249 
00250         //- Update the surfaces as required and merge surface points (parallel).
00251         //  Return false if no surfaces required an update.
00252         virtual bool update();
00253 
00254 
00255         //- Return name of the set of surfaces
00256         virtual const word& name() const
00257         {
00258             return name_;
00259         }
00260 
00261         //- set verbosity level
00262         void verbose(const bool verbosity = true);
00263 
00264         //- Execute, currently does nothing
00265         virtual void execute();
00266 
00267         //- Execute at the final time-loop, currently does nothing
00268         virtual void end();
00269 
00270         //- Sample and write
00271         virtual void write();
00272 
00273         //- Read the sampledSurfaces dictionary
00274         virtual void read(const dictionary&);
00275 
00276         //- Update for changes of mesh - expires the surfaces
00277         virtual void updateMesh(const mapPolyMesh&);
00278 
00279         //- Update for mesh point-motion - expires the surfaces
00280         virtual void movePoints(const pointField&);
00281 
00282         //- Update for changes of mesh due to readUpdate - expires the surfaces
00283         virtual void readUpdate(const polyMesh::readUpdateState state);
00284 
00285 };
00286 
00287 
00288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00289 
00290 } // End namespace Foam
00291 
00292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00293 
00294 #ifdef NoRepository
00295 #   include "sampledSurfacesTemplates.C"
00296 #endif
00297 
00298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00299 
00300 #endif
00301 
00302 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines