OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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