Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
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 
00067 
00068 
00069 class explicitSource
00070 :
00071     public basicSource
00072 {
00073     
00074 
00075         template<class Type>
00076         class fieldList
00077         :
00078             public HashTable<Type>
00079         {
00080 
00081             explicitSource& OwnerPtr_;
00082 
00083         public:
00084 
00085             
00086             fieldList()
00087             :
00088                 HashTable<Type>(0),
00089                 OwnerPtr_(*this)
00090             {}
00091 
00092 
00093             
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     
00123 
00124         
00125         fieldList<scalar> scalarFields_;
00126         fieldList<vector> vectorFields_;
00127 
00128         
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         
00140         template<class Type>
00141         void addSources
00142         (
00143             Field<Type>& fieldSource,
00144             Type& data
00145         ) const;
00146 
00147 
00148 public:
00149 
00150 
00151     
00152 
00153         
00154         enum volumeModeType
00155         {
00156             vmAbsolute,
00157             vmSpecific
00158         };
00159 
00160         
00161         static const wordList volumeModeTypeNames_;
00162 
00163 
00164 protected:
00165 
00166     
00167 
00168          
00169         const dictionary& dict_;
00170 
00171         
00172         volumeModeType volumeMode_;
00173 
00174         
00175         List<point> points_;
00176 
00177         
00178         scalarList volSource_;
00179 
00180 
00181     
00182 
00183         
00184         volumeModeType wordToVolumeModeType(const word& vtName) const;
00185 
00186         
00187         word volumeModeTypeToWord(const volumeModeType& vtType) const;
00188 
00189         
00190         void setFieldData(const dictionary& dict);
00191 
00192         
00193         void setSelectedCellsFromPoints();
00194 
00195 
00196 public:
00197 
00198     
00199     TypeName("explicitSource");
00200 
00201 
00202     
00203 
00204         
00205         explicitSource
00206         (
00207             const word& name,
00208             const dictionary& dict,
00209             const fvMesh& mesh
00210         );
00211 
00212         
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     
00225 
00226         
00227 
00228             
00229             inline const volumeModeType& volumeMode() const;
00230 
00231 
00232         
00233 
00234             
00235             inline volumeModeType& volumeMode();
00236 
00237             
00238             inline  const List<point>& points() const;
00239 
00240 
00241         
00242 
00243             
00244             virtual void addSu(fvMatrix<vector>& UEqn);
00245 
00246             
00247             virtual void addSu(fvMatrix<scalar>& UEqn);
00248 
00249             
00250             virtual void addExplicitSources();
00251 
00252             
00253             virtual void addSu(DimensionedField<vector, volMesh>& field);
00254 
00255             
00256             virtual void addSu(DimensionedField<scalar, volMesh>& field);
00257 
00258 
00259         
00260 
00261             
00262             virtual void writeData(Ostream&) const;
00263 
00264             
00265             virtual bool read(const dictionary& dict);
00266 
00267             
00268             friend Ostream& operator<<
00269             (
00270                 Ostream& os,
00271                 const explicitSource& source
00272             );
00273 };
00274 
00275 
00276 
00277 
00278 } 
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