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

explicitSource.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::explicitSource
00026 
00027 Description
00028     Explicit source.
00029 
00030     Sources described by:
00031 
00032     explicitSourceCoeffs
00033     {
00034         points            // list of points when selectionMode = points
00035         (
00036             (-0.088 0.007 -0.02)
00037             (-0.028 0.007 -0.02)
00038         );
00039         volumeMode          specific;  //absolute
00040         fieldData            // field data - usage for multiple fields
00041         {
00042             k   30.7;
00043             epsilon  1.5;
00044         }
00045     }
00046 
00047 SourceFiles
00048     explicitSource.C
00049 
00050 \*---------------------------------------------------------------------------*/
00051 
00052 #ifndef explicitSource_H
00053 #define explicitSource_H
00054 
00055 #include <meshTools/cellSet.H>
00056 #include <finiteVolume/volFieldsFwd.H>
00057 #include <OpenFOAM/DimensionedField.H>
00058 #include <finiteVolume/basicSource.H>
00059 
00060 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00061 
00062 namespace Foam
00063 {
00064 
00065 /*---------------------------------------------------------------------------*\
00066                       Class explicitSource Declaration
00067 \*---------------------------------------------------------------------------*/
00068 
00069 class explicitSource
00070 :
00071     public basicSource
00072 {
00073     // Private classes
00074 
00075         template<class Type>
00076         class fieldList
00077         :
00078             public HashTable<Type>
00079         {
00080 
00081             explicitSource& OwnerPtr_;
00082 
00083         public:
00084 
00085             //- null Constructor
00086             fieldList()
00087             :
00088                 HashTable<Type>(0),
00089                 OwnerPtr_(*this)
00090             {}
00091 
00092 
00093             //- Constructor
00094             fieldList(label size, explicitSource& ownerPtr)
00095             :
00096                 HashTable<Type>(size),
00097                 OwnerPtr_(ownerPtr)
00098             {}
00099 
00100 
00101             void applySources()
00102             {
00103                 typedef GeometricField<Type, fvPatchField, volMesh>
00104                     geometricField;
00105 
00106                 forAll(this->toc(), i)
00107                 {
00108                     geometricField& field = const_cast<geometricField&>
00109                     (
00110                         OwnerPtr_.mesh().lookupObject<geometricField>
00111                             (this->toc()[i])
00112                     );
00113 
00114                     Type data = this->operator[](field.name());
00115                     OwnerPtr_.addSources<Type>(field.internalField(), data);
00116                 }
00117             }
00118         };
00119 
00120 private:
00121 
00122     // Private cdata
00123 
00124         //- List of field types
00125         fieldList<scalar> scalarFields_;
00126         fieldList<vector> vectorFields_;
00127 
00128         //- Add field names and values to field table for types.
00129         template<class Type>
00130         void addField
00131         (
00132             HashTable<Type>& fields,
00133             const wordList& fieldTypes,
00134             const wordList& fieldNames,
00135             const dictionary& dict_
00136         );
00137 
00138 
00139         //- Add data to field source
00140         template<class Type>
00141         void addSources
00142         (
00143             Field<Type>& fieldSource,
00144             Type& data
00145         ) const;
00146 
00147 
00148 public:
00149 
00150 
00151     // Public data
00152 
00153         //- Enumeration for volume types
00154         enum volumeModeType
00155         {
00156             vmAbsolute,
00157             vmSpecific
00158         };
00159 
00160         //- Word list of volume mode type names
00161         static const wordList volumeModeTypeNames_;
00162 
00163 
00164 protected:
00165 
00166     // Protected data
00167 
00168          //- Sub dictionary for time activated explicit sources
00169         const dictionary& dict_;
00170 
00171         //- Volume mode
00172         volumeModeType volumeMode_;
00173 
00174         //- List of points for "points" selectionMode
00175         List<point> points_;
00176 
00177         //- Volume of the explicit source
00178         scalarList volSource_;
00179 
00180 
00181     // Protected functions
00182 
00183         //- Helper function to convert from a word to a volumeModeType
00184         volumeModeType wordToVolumeModeType(const word& vtName) const;
00185 
00186         //- Helper function to convert from a volumeModeType to a word
00187         word volumeModeTypeToWord(const volumeModeType& vtType) const;
00188 
00189         //- Set the local field data
00190         void setFieldData(const dictionary& dict);
00191 
00192         //- Set selected cells when smPoint is used
00193         void setSelectedCellsFromPoints();
00194 
00195 
00196 public:
00197 
00198     //- Runtime type information
00199     TypeName("explicitSource");
00200 
00201 
00202     // Constructors
00203 
00204         //- Construct from components
00205         explicitSource
00206         (
00207             const word& name,
00208             const dictionary& dict,
00209             const fvMesh& mesh
00210         );
00211 
00212         //- Return clone
00213         autoPtr<explicitSource> clone() const
00214         {
00215             notImplemented
00216             (
00217                 "autoPtr<explicitSource> clone() const"
00218             );
00219             return autoPtr<explicitSource>(NULL);
00220         }
00221 
00222 
00223 
00224     // Member Functions
00225 
00226         // Access
00227 
00228             //- Return const access to the volume mode
00229             inline const volumeModeType& volumeMode() const;
00230 
00231 
00232         // Edit
00233 
00234             //- Return access to the volume mode
00235             inline volumeModeType& volumeMode();
00236 
00237             //- Return points
00238             inline  const List<point>& points() const;
00239 
00240 
00241         // Evaluation
00242 
00243             //-Source term to fvMatrix<vector>
00244             virtual void addSu(fvMatrix<vector>& UEqn);
00245 
00246             //-Source term to fvMatrix<scalar>
00247             virtual void addSu(fvMatrix<scalar>& UEqn);
00248 
00249             //- Add all explicit source
00250             virtual void addExplicitSources();
00251 
00252             //- Add source to scalar field
00253             virtual void addSu(DimensionedField<vector, volMesh>& field);
00254 
00255             //- Add source to vector field
00256             virtual void addSu(DimensionedField<scalar, volMesh>& field);
00257 
00258 
00259         // I-O
00260 
00261             //- Write the source properties
00262             virtual void writeData(Ostream&) const;
00263 
00264             //- Read fieldData in sub-dictionary
00265             virtual bool read(const dictionary& dict);
00266 
00267             //- Ostream operator
00268             friend Ostream& operator<<
00269             (
00270                 Ostream& os,
00271                 const explicitSource& source
00272             );
00273 };
00274 
00275 
00276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00277 
00278 } // End namespace Foam
00279 
00280 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00281 
00282 #include "explicitSourceIO.C"
00283 #include "explicitSourceI.H"
00284 
00285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00286 
00287 #ifdef NoRepository
00288 #   include "explicitSourceTemplates.C"
00289 #endif
00290 
00291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00292 
00293 #endif
00294 
00295 // ************************************************************************* //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines