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

basicSource.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) 2010-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::basicSource
00026 
00027 Description
00028     Basic source abtract class
00029 
00030     Sources described by:
00031 
00032     source1
00033     {
00034         typeModel       actuationDiskSource; // explicitSource
00035         active          on;            // on/off switch
00036         timeStart       0.0;           // start time
00037         duration        1000.0;        // duration
00038         selectionMode   cellSet;       // cellSet // points //cellZone
00039         cellSet         c0;            // cellSet name
00040 
00041         actuationDiskSourceCoeffs
00042         {
00043             diskDir     (-1 0 0); // orientation of the disk
00044             Cp          0.53;     // Cp
00045             Ct          0.58;     // Ct
00046             diskArea    40;       // disk area
00047         }
00048     }
00049 
00050     source2
00051     {
00052         typeModel       explicitSource;
00053         active          on;
00054         timeStart       0.0;
00055         duration        1000.0;
00056         selectionMode   points;
00057         cellSet         c0;
00058 
00059         explicitSourceCoeffs
00060         {
00061             points            // list of points when selectionMode = points
00062             (
00063                 (-0.088 0.007 -0.02)
00064                 (-0.028 0.007 -0.02)
00065             );
00066             volumeMode      specific;  //absolute
00067             fieldData                  //field data
00068             {
00069                 k   30.7;
00070                 epsilon  1.5;
00071             }
00072         }
00073     }
00074 
00075 SourceFiles
00076     basicSource.C
00077     basicSourceIO.C
00078 
00079 \*---------------------------------------------------------------------------*/
00080 
00081 #ifndef basicSource_H
00082 #define basicSource_H
00083 
00084 #include <finiteVolume/fvMatrices.H>
00085 #include <meshTools/cellSet.H>
00086 #include <finiteVolume/volFieldsFwd.H>
00087 #include <OpenFOAM/DimensionedField.H>
00088 #include <OpenFOAM/autoPtr.H>
00089 #include <OpenFOAM/runTimeSelectionTables.H>
00090 
00091 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00092 
00093 namespace Foam
00094 {
00095 
00096 class fvMesh;
00097 
00098 /*---------------------------------------------------------------------------*\
00099                           Class basicSource Declaration
00100 \*---------------------------------------------------------------------------*/
00101 
00102 class basicSource
00103 {
00104 public:
00105 
00106     // Public data
00107 
00108         //- Enumeration for selection mode types
00109         enum selectionModeType
00110         {
00111             smPoints,
00112             smCellSet,
00113             smCellZone,
00114             smAll
00115         };
00116 
00117         //- Word list of selection mode type names
00118         static const wordList selectionModeTypeNames_;
00119 
00120 
00121 protected:
00122 
00123     // Protected data
00124 
00125         //- Source name
00126         word name_;
00127 
00128         //- Reference to the mesh database
00129         const fvMesh& mesh_;
00130 
00131         //- Dictionary containing the data of the source
00132         const dictionary& dict_;
00133 
00134         //- Source active flag
00135         bool active_;
00136 
00137         //- Time start
00138         scalar timeStart_;
00139 
00140         //- Duration
00141         scalar duration_;
00142 
00143         //- Cell selection mode
00144         selectionModeType selectionMode_;
00145 
00146         //- Name of cell set for "cellSet" and "cellZone" selectionMode
00147         word cellSetName_;
00148 
00149         //- Set of cells to apply source to
00150         labelList cells_;
00151 
00152         //- Sum of cell volumes
00153         scalar V_;
00154 
00155 
00156     // Protected functions
00157 
00158         //- Helper function to convert from a word to a selectionModeType
00159         selectionModeType wordToSelectionModeType(const word& smtName) const;
00160 
00161         //- Helper function to convert from a selectionModeType to a word
00162         word selectionModeTypeToWord(const selectionModeType& smtType) const;
00163 
00164         //- Set the cellSet or points selection
00165         void setSelection(const dictionary& dict);
00166 
00167         //- Set the cell set based on the user input selection mode
00168         void setCellSet();
00169 
00170 
00171 public:
00172 
00173     //- Runtime type information
00174     TypeName("basicSource");
00175 
00176 
00177      // Declare run-time constructor selection table
00178 
00179         declareRunTimeSelectionTable
00180         (
00181             autoPtr,
00182             basicSource,
00183             dictionary,
00184             (
00185                 const word& name,
00186                 const dictionary& dict,
00187                 const fvMesh& mesh
00188             ),
00189             (name, dict, mesh)
00190         );
00191 
00192 
00193     // Constructors
00194 
00195         //- Construct from components
00196         basicSource
00197         (
00198             const word& name,
00199             const dictionary& dict,
00200             const fvMesh& mesh
00201         );
00202 
00203         //- Return clone
00204         autoPtr<basicSource> clone() const
00205         {
00206             notImplemented
00207             (
00208                 "autoPtr<basicSource> clone() const"
00209             );
00210             return autoPtr<basicSource>(NULL);
00211         }
00212 
00213         //- Return pointer to new basicSource object created
00214         //  on the freestore from an Istream
00215         class iNew
00216         {
00217             //- Reference to the mesh database
00218             const fvMesh& mesh_;
00219             const word& name_;
00220 
00221         public:
00222 
00223             iNew
00224             (
00225                 const fvMesh& mesh,
00226                 const word& name
00227             )
00228             :
00229                 mesh_(mesh),
00230                 name_(name)
00231             {}
00232 
00233             autoPtr<basicSource> operator()(Istream& is) const
00234             {
00235                 //const word name(is);
00236                 const dictionary dict(is);
00237 
00238                 return autoPtr<basicSource>
00239                 (
00240                     basicSource::New
00241                     (
00242                         name_,
00243                         dict,
00244                         mesh_
00245                     )
00246                 );
00247             }
00248         };
00249 
00250 
00251     // Selectors
00252 
00253         //- Return a reference to the selected basicSource model
00254         static autoPtr<basicSource> New
00255         (
00256             const word& name,
00257             const dictionary& dict,
00258             const fvMesh& mesh
00259         );
00260 
00261 
00262     //- Destructor
00263     virtual ~basicSource()
00264     {}
00265 
00266 
00267     // Member Functions
00268 
00269         // Access
00270 
00271             //- Return const access to the source name
00272             inline const word& name() const;
00273 
00274             //- Return const access to the mesh database
00275             inline const fvMesh& mesh() const;
00276 
00277             //- Return dictionay
00278             inline const dictionary& dictCoeffs() const;
00279 
00280             //- Return const access to the source active flag
00281             inline bool active() const;
00282 
00283             //- Return const access to the time start
00284             inline scalar timeStart() const;
00285 
00286             //- Return const access to the duration
00287             inline scalar duration() const;
00288 
00289             //- Return const access to the time end
00290             inline scalar timeEnd() const;
00291 
00292             //- Return const access to the cell selection mode
00293             inline const selectionModeType& selectionMode() const;
00294 
00295             //- Return const access to the name of cell set for "cellSet"
00296             //  selectionMode
00297             inline const word& cellSetName() const;
00298 
00299             //- Return const access to the total cell volume
00300             inline scalar V() const;
00301 
00302             //- Return const access to the cell set
00303             inline const labelList& cells() const;
00304 
00305 
00306         // Edit
00307 
00308             //- Return access to the source name
00309             inline word& name();
00310 
00311             //- Return access to the source active flag
00312             inline bool& active();
00313 
00314             //- Return access to the time start
00315             inline scalar& timeStart();
00316 
00317             //- Return access to the duration
00318             inline scalar& duration();
00319 
00320             //- Return access to the cell selection mode
00321             inline selectionModeType& selectionMode();
00322 
00323             //- Return access to the list of points for "points" selectionMode
00324             inline List<point>& points();
00325 
00326             //- Return access to the name of cell set for "cellSet"
00327             //  selectionMode
00328             inline word& cellSetName();
00329 
00330             //- Return access to the total cell volume
00331             inline scalar& V();
00332 
00333             //- Return access to the cell set
00334             inline labelList& cells();
00335 
00336 
00337         // Checks
00338 
00339             //- Is the source active?
00340             bool isActive();
00341 
00342 
00343         // Evaluation
00344 
00345             //- Add all explicit sources
00346             virtual void addExplicitSources() = 0;
00347 
00348             //- Add source to scalar field
00349             virtual void addSu(DimensionedField<scalar, volMesh>& field) = 0;
00350 
00351             //- Add source to vector field
00352             virtual void addSu(DimensionedField<vector, volMesh>& field) = 0;
00353 
00354             //- Add source term to vector fvMatrix
00355             virtual void addSu(fvMatrix<vector>& Eqn) = 0;
00356 
00357             //- Add source term to scalar fvMatrix
00358             virtual void addSu(fvMatrix<scalar>& Eqn) = 0;
00359 
00360 
00361         // I-O
00362 
00363             //- Write the source properties
00364             virtual void writeData(Ostream&) const = 0;
00365 
00366             //- Read source dictionary
00367             virtual bool read(const dictionary& dict) = 0;
00368 
00369 };
00370 
00371 
00372 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00373 
00374 } // End namespace Foam
00375 
00376 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00377 
00378 #include "basicSourceI.H"
00379 
00380 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00381 
00382 #endif
00383 
00384 // ************************************************************************* //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines