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

sampledSets.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::sampledSets
00026 
00027 Description
00028     Set of sets to sample.
00029     Call sampledSets.write() to sample&write files.
00030 
00031 SourceFiles
00032     sampledSets.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef sampledSets_H
00037 #define sampledSets_H
00038 
00039 #include <sampling/sampledSet.H>
00040 #include <finiteVolume/volFieldsFwd.H>
00041 #include <meshTools/meshSearch.H>
00042 #include <finiteVolume/interpolation.H>
00043 #include <sampling/coordSet.H>
00044 #include <sampling/writer.H>
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 class objectRegistry;
00052 class dictionary;
00053 class fvMesh;
00054 
00055 /*---------------------------------------------------------------------------*\
00056                       Class sampledSets Declaration
00057 \*---------------------------------------------------------------------------*/
00058 
00059 class sampledSets
00060 :
00061     public PtrList<sampledSet>
00062 {
00063     // Private classes
00064 
00065         //- Class used for grouping field types
00066         template<class Type>
00067         class fieldGroup
00068         :
00069             public wordList
00070         {
00071         public:
00072 
00073             //- Set formatter
00074             autoPtr<writer<Type> > formatter;
00075 
00076             //- Construct null
00077             fieldGroup()
00078             :
00079                 wordList(0),
00080                 formatter(NULL)
00081             {}
00082 
00083             void clear()
00084             {
00085                 wordList::clear();
00086                 formatter.clear();
00087             }
00088         };
00089 
00090 
00091         //- Class used for sampling volFields
00092         template <class Type>
00093         class volFieldSampler
00094         :
00095             public List<Field<Type> >
00096         {
00097             //- Name of this collection of values
00098             const word name_;
00099 
00100         public:
00101 
00102             //- Construct interpolating field to the sampleSets
00103             volFieldSampler
00104             (
00105                 const word& interpolationScheme,
00106                 const GeometricField<Type, fvPatchField, volMesh>& field,
00107                 const PtrList<sampledSet>&
00108             );
00109 
00110             //- Construct mapping field to the sampleSets
00111             volFieldSampler
00112             (
00113                 const GeometricField<Type, fvPatchField, volMesh>& field,
00114                 const PtrList<sampledSet>&
00115             );
00116 
00117             //- Construct from components
00118             volFieldSampler
00119             (
00120                 const List<Field<Type> >& values,
00121                 const word& name
00122             );
00123 
00124             //- Return the field name
00125             const word& name() const
00126             {
00127                 return name_;
00128             }
00129         };
00130 
00131 
00132     // Static data members
00133 
00134         //- output verbosity
00135         static bool verbose_;
00136 
00137 
00138     // Private data
00139 
00140         //- Name of this set of sets,
00141         //  Also used as the name of the sampledSets directory.
00142         word name_;
00143 
00144         //- Const reference to fvMesh
00145         const fvMesh& mesh_;
00146 
00147         //- Keep the dictionary to recreate sets for moving mesh cases
00148         dictionary dict_;
00149 
00150         //- Load fields from files (not from objectRegistry)
00151         bool loadFromFiles_;
00152 
00153         //- Output path
00154         fileName outputPath_;
00155 
00156         //- Mesh search engine
00157         meshSearch searchEngine_;
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         // Categorized scalar/vector/tensor fields
00173 
00174             fieldGroup<scalar> scalarFields_;
00175             fieldGroup<vector> vectorFields_;
00176             fieldGroup<sphericalTensor> sphericalTensorFields_;
00177             fieldGroup<symmTensor> symmTensorFields_;
00178             fieldGroup<tensor> tensorFields_;
00179 
00180 
00181         // Merging structures
00182 
00183             PtrList<coordSet> masterSampledSets_;
00184             labelListList indexSets_;
00185 
00186 
00187     // Private Member Functions
00188 
00189         //- Classify field types, return true if nFields > 0
00190         bool checkFieldTypes();
00191 
00192         //- Find the fields in the list of the given type, return count
00193         template<class Type>
00194         label grep
00195         (
00196             fieldGroup<Type>& fieldList,
00197             const wordList& fieldTypes
00198         ) const;
00199 
00200         //- Combine points from all processors. Sort by curveDist and produce
00201         //  index list. Valid result only on master processor.
00202         void combineSampledSets
00203         (
00204             PtrList<coordSet>& masterSampledSets,
00205             labelListList& indexSets
00206         );
00207 
00208         //- Combine values from all processors.
00209         //  Valid result only on master processor.
00210         template<class T>
00211         void combineSampledValues
00212         (
00213             const PtrList<volFieldSampler<T> >& sampledFields,
00214             const labelListList& indexSets,
00215             PtrList<volFieldSampler<T> >& masterFields
00216         );
00217 
00218         template<class Type>
00219         void writeSampleFile
00220         (
00221             const coordSet& masterSampleSet,
00222             const PtrList<volFieldSampler<Type> >& masterFields,
00223             const label setI,
00224             const fileName& timeDir,
00225             const writer<Type>& formatter
00226         );
00227 
00228         template<class Type>
00229         void sampleAndWrite(fieldGroup<Type>& fields);
00230 
00231 
00232         //- Disallow default bitwise copy construct and assignment
00233         sampledSets(const sampledSets&);
00234         void operator=(const sampledSets&);
00235 
00236 
00237 public:
00238 
00239     //- Runtime type information
00240     TypeName("sets");
00241 
00242 
00243     // Constructors
00244 
00245         //- Construct for given objectRegistry and dictionary
00246         //  allow the possibility to load fields from files
00247         sampledSets
00248         (
00249             const word& name,
00250             const objectRegistry&,
00251             const dictionary&,
00252             const bool loadFromFiles = false
00253         );
00254 
00255 
00256     // Destructor
00257 
00258         virtual ~sampledSets();
00259 
00260 
00261     // Member Functions
00262 
00263         //- Return name of the set of probes
00264         virtual const word& name() const
00265         {
00266             return name_;
00267         }
00268 
00269         //- set verbosity level
00270         void verbose(const bool verbosity = true);
00271 
00272         //- Execute, currently does nothing
00273         virtual void execute();
00274 
00275         //- Execute at the final time-loop, currently does nothing
00276         virtual void end();
00277 
00278         //- Sample and write
00279         virtual void write();
00280 
00281         //- Read the sampledSets
00282         virtual void read(const dictionary&);
00283 
00284         //- Correct for mesh changes
00285         void correct();
00286 
00287         //- Update for changes of mesh
00288         virtual void updateMesh(const mapPolyMesh&);
00289 
00290         //- Update for mesh point-motion
00291         virtual void movePoints(const pointField&);
00292 
00293         //- Update for changes of mesh due to readUpdate
00294         virtual void readUpdate(const polyMesh::readUpdateState state);
00295 };
00296 
00297 
00298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00299 
00300 } // End namespace Foam
00301 
00302 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00303 
00304 #ifdef NoRepository
00305 #   include <sampling/sampledSetsTemplates.C>
00306 #endif
00307 
00308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00309 
00310 #endif
00311 
00312 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines