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

TimeActivatedExplicitSource_.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::TimeActivatedExplicitSource
00026 
00027 Description
00028     Time activated explicit source.
00029 
00030     Sources described by:
00031 
00032     {
00033         active          true;      // on/off switch
00034         timeStart       0.2;       // start time
00035         duration        2.0;       // duration
00036         selectionMode   points;    // cellSet/cellZone/all
00037         volumeMode      absolute;  // specific
00038 
00039         fieldData                  // field data - usage for multiple fields
00040         (
00041             (H2O 0.005)
00042         );
00043 
00044         fieldData       0.005;     // field data - usage for single field
00045 
00046         points                     // list of points when selectionMode = points
00047         (
00048             (2.75 0.5 0)
00049         );
00050 
00051         cellSet         c0;        // cellSet name when selectionMode=cellSet
00052         cellZone        c0;        // cellZone name when selectionMode=cellZone
00053     }
00054 
00055 SourceFiles
00056     TimeActivatedExplicitSource_.C
00057 
00058 \*---------------------------------------------------------------------------*/
00059 
00060 #ifndef TimeActivatedExplicitSource_H
00061 #define TimeActivatedExplicitSource_H
00062 
00063 #include <OpenFOAM/Tuple2.H>
00064 #include <meshTools/cellSet.H>
00065 #include <finiteVolume/volFieldsFwd.H>
00066 #include <OpenFOAM/DimensionedField.H>
00067 
00068 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00069 
00070 namespace Foam
00071 {
00072 
00073 // Forward declaration of classes
00074 
00075 class fvMesh;
00076 
00077 template<class Type>
00078 class TimeActivatedExplicitSource;
00079 
00080 // Forward declaration of friend functions
00081 
00082 template<class Type>
00083 Ostream& operator<<
00084 (
00085     Ostream&,
00086     const TimeActivatedExplicitSource<Type>&
00087 );
00088 
00089 /*---------------------------------------------------------------------------*\
00090                Class TimeActivatedExplicitSource Declaration
00091 \*---------------------------------------------------------------------------*/
00092 
00093 template<class Type>
00094 class TimeActivatedExplicitSource
00095 {
00096 public:
00097 
00098     // Public data
00099 
00100         //- Enumeration for selection mode types
00101         enum selectionModeType
00102         {
00103             smPoints,
00104             smCellSet,
00105             smCellZone,
00106             smAll
00107         };
00108 
00109         //- Word list of selection mode type names
00110         static const wordList selectionModeTypeNames_;
00111 
00112         //- Enumeration for volume types
00113         enum volumeModeType
00114         {
00115             vmAbsolute,
00116             vmSpecific
00117         };
00118 
00119         //- Word list of volume mode type names
00120         static const wordList volumeModeTypeNames_;
00121 
00122 
00123 protected:
00124 
00125     // Protected data
00126 
00127         typedef Tuple2<word, Type> fieldNameValuePair;
00128 
00129         //- Source name
00130         word name_;
00131 
00132         //- Reference to the mesh database
00133         const fvMesh& mesh_;
00134 
00135         //- Source active flag
00136         bool active_;
00137 
00138         //- Time start
00139         scalar timeStart_;
00140 
00141         //- Duration
00142         scalar duration_;
00143 
00144         //- Volume mode
00145         volumeModeType volumeMode_;
00146 
00147         //- Cell selection mode
00148         selectionModeType selectionMode_;
00149 
00150         //- List of points for "points" selectionMode
00151         List<point> points_;
00152 
00153         //- Name of cell set for "cellSet" and "cellZone" selectionMode
00154         word cellSetName_;
00155 
00156         //- Set of cells to apply source to
00157         labelList cells_;
00158 
00159         //- Sum of cell volumes
00160         scalar V_;
00161 
00162         //- List of source field name vs value pairs
00163         List<fieldNameValuePair> fieldData_;
00164 
00165         //- Map of fields ids from supplied fields to local field source ids
00166         labelList fieldIds_;
00167 
00168 
00169     // Protected functions
00170 
00171         //- Helper function to convert from a word to a selectionModeType
00172         selectionModeType wordToSelectionModeType(const word& smtName) const;
00173 
00174         //- Helper function to convert from a word to a volumeModeType
00175         volumeModeType wordToVolumeModeType(const word& vtName) const;
00176 
00177         //- Helper function to convert from a selectionModeType to a word
00178         word selectionModeTypeToWord(const selectionModeType& smtType) const;
00179 
00180         //- Helper function to convert from a volumeModeType to a word
00181         word volumeModeTypeToWord(const volumeModeType& vtType) const;
00182 
00183         //- Set the cellSet or points selection
00184         void setSelection(const dictionary& dict);
00185 
00186         //- Set the local field data
00187         void setFieldData(const dictionary& dict, const wordList& fieldNames);
00188 
00189         //- Set the cell set based on the user input selection mode
00190         void setCellSet();
00191 
00192 
00193 public:
00194 
00195     // Constructors
00196 
00197         //- Construct from components
00198         TimeActivatedExplicitSource
00199         (
00200             const word& name,
00201             const dictionary& dict,
00202             const fvMesh& mesh,
00203             const wordList& fieldNames
00204         );
00205 
00206         //- Return clone
00207         autoPtr<TimeActivatedExplicitSource> clone() const
00208         {
00209             notImplemented
00210             (
00211                 "autoPtr<TimeActivatedExplicitSource> clone() const"
00212             );
00213             return autoPtr<TimeActivatedExplicitSource>(NULL);
00214         }
00215 
00216         //- Return pointer to new TimeActivatedExplicitSource object created
00217         //  on the freestore from an Istream
00218         class iNew
00219         {
00220             //- Reference to the mesh database
00221             const fvMesh& mesh_;
00222 
00223             //- List of field names
00224             const wordList& fieldNames_;
00225 
00226 
00227         public:
00228 
00229             iNew
00230             (
00231                 const fvMesh& mesh,
00232                 const wordList& fieldNames
00233             )
00234             :
00235                 mesh_(mesh),
00236                 fieldNames_(fieldNames)
00237             {}
00238 
00239             autoPtr<TimeActivatedExplicitSource> operator()(Istream& is) const
00240             {
00241                 const word name(is);
00242                 const dictionary dict(is);
00243 
00244                 return autoPtr<TimeActivatedExplicitSource>
00245                 (
00246                     new TimeActivatedExplicitSource
00247                     (
00248                         name,
00249                         dict,
00250                         mesh_,
00251                         fieldNames_
00252                     )
00253                 );
00254             }
00255         };
00256 
00257 
00258     // Member Functions
00259 
00260         // Access
00261 
00262             //- Return const access to the source name
00263             inline const word& name() const;
00264 
00265             //- Return const access to the mesh database
00266             inline const fvMesh& mesh() const;
00267 
00268             //- Return const access to the source active flag
00269             inline bool active() const;
00270 
00271             //- Return const access to the time start
00272             inline scalar timeStart() const;
00273 
00274             //- Return const access to the duration
00275             inline scalar duration() const;
00276 
00277             //- Return const access to the time end
00278             inline scalar timeEnd() const;
00279 
00280             //- Return const access to the volume mode
00281             inline const volumeModeType& volumeMode() const;
00282 
00283             //- Return const access to the cell selection mode
00284             inline const selectionModeType& selectionMode() const;
00285 
00286             //- Return const access to the list of points for "points"
00287             //  selectionMode
00288             inline const List<point>& points() const;
00289 
00290             //- Return const access to the name of cell set for "cellSet"
00291             //  selectionMode
00292             inline const word& cellSetName() const;
00293 
00294             //- Return const access to the total cell volume
00295             inline scalar V() const;
00296 
00297             //- Return const access to the cell set
00298             inline const labelList& cells() const;
00299 
00300             //- Return const access to the source field name vs value pairs
00301             inline const List<fieldNameValuePair>& fieldData() const;
00302 
00303             //- Return const access to the the map of fields ids from supplied
00304             //  fields to local field source ids
00305             inline const labelList& fieldIds() const;
00306 
00307 
00308         // Edit
00309 
00310             //- Return access to the source name
00311             inline word& name();
00312 
00313             //- Return access to the source active flag
00314             inline bool& active();
00315 
00316             //- Return access to the time start
00317             inline scalar& timeStart();
00318 
00319             //- Return access to the duration
00320             inline scalar& duration();
00321 
00322             //- Return access to the volume mode
00323             inline volumeModeType& volumeMode();
00324 
00325             //- Return access to the cell selection mode
00326             inline selectionModeType& selectionMode();
00327 
00328             //- Return access to the list of points for "points" selectionMode
00329             inline List<point>& points();
00330 
00331             //- Return access to the name of cell set for "cellSet"
00332             //  selectionMode
00333             inline word& cellSetName();
00334 
00335             //- Return access to the total cell volume
00336             inline scalar& V();
00337 
00338             //- Return access to the cell set
00339             inline labelList& cells();
00340 
00341             //- Return access to the source field name vs value pairs
00342             inline List<fieldNameValuePair>& fieldData();
00343 
00344             //- Return access to the the map of fields ids from supplied
00345             //  fields to local field source ids
00346             inline labelList& fieldIds();
00347 
00348 
00349         // Evaluation
00350 
00351             //- Add the source contribution to field Su
00352             void addToField
00353             (
00354                 DimensionedField<Type, volMesh>& Su,
00355                 const label fieldI
00356             );
00357 
00358 
00359         // I-O
00360 
00361             //- Write the source properties
00362             void writeData(Ostream&) const;
00363 
00364             //- Ostream operator
00365             friend Ostream& operator<< <Type>
00366             (
00367                 Ostream& os,
00368                 const TimeActivatedExplicitSource& source
00369             );
00370 };
00371 
00372 
00373 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00374 
00375 } // End namespace Foam
00376 
00377 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00378 
00379 #ifdef NoRepository
00380 #   include "TimeActivatedExplicitSource_.C"
00381 #   include "TimeActivatedExplicitSourceIO.C"
00382 #endif
00383 
00384 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00385 
00386 #include "TimeActivatedExplicitSourceI.H"
00387 
00388 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00389 
00390 #endif
00391 
00392 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines