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

basicSourceList.C

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 \*---------------------------------------------------------------------------*/
00025 
00026 #include "basicSourceList.H"
00027 
00028 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00029 
00030 Foam::basicSourceList::basicSourceList
00031 (
00032     const fvMesh& mesh,
00033     const dictionary& dict
00034 )
00035 :
00036     PtrList<basicSource>(),
00037     mesh_(mesh)
00038 {
00039     label count = 0;
00040     forAllConstIter(dictionary, dict, iter)
00041     {
00042         // safety:
00043         if (iter().isDict())
00044         {
00045             count ++;
00046         }
00047     }
00048 
00049     this->setSize(count);
00050     label i = 0;
00051     forAllConstIter(dictionary, dict, iter)
00052     {
00053         const word& name = iter().keyword();
00054         const dictionary& dict = iter().dict();
00055 
00056         this->set
00057         (
00058             i++,
00059             basicSource::New(name, dict, mesh)
00060         );
00061     }
00062 }
00063 
00064 
00065 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00066 
00067 
00068 void Foam::basicSourceList::addSu(fvMatrix<scalar>& Eqn)
00069 {
00070     forAll(*this, i)
00071     {
00072         if (this->operator[](i).isActive())
00073         {
00074             this->operator[](i).addSu(Eqn);
00075         }
00076     }
00077 }
00078 
00079 
00080 void Foam::basicSourceList::addSu(fvMatrix<vector>& Eqn)
00081 {
00082 
00083     forAll(*this, i)
00084     {
00085         if (this->operator[](i).isActive())
00086         {
00087             this->operator[](i).addSu(Eqn);
00088         }
00089     }
00090 }
00091 
00092 
00093 void Foam::basicSourceList::addExplicitSources()
00094 {
00095 
00096     forAll(*this, i)
00097     {
00098         if (this->operator[](i).isActive())
00099         {
00100             this->operator[](i).addExplicitSources();
00101         }
00102     }
00103 }
00104 
00105 
00106 void Foam::basicSourceList::addSu
00107 (
00108     DimensionedField<scalar, volMesh>& field
00109 )
00110 {
00111     forAll(*this, i)
00112     {
00113         if (this->operator[](i).isActive())
00114         {
00115             this->operator[](i).addSu(field);
00116         }
00117     }
00118 }
00119 
00120 
00121 void Foam::basicSourceList::addSu
00122 (
00123     DimensionedField<vector, volMesh>& field
00124 )
00125 {
00126     forAll(*this, i)
00127     {
00128         if (this->operator[](i).isActive())
00129         {
00130             this->operator[](i).addSu(field);
00131         }
00132     }
00133 }
00134 
00135 
00136 bool Foam::basicSourceList::read(const dictionary& dict)
00137 {
00138     forAll(*this, i)
00139     {
00140         this->operator[](i).read(dict);
00141     }
00142     return true;
00143 }
00144 
00145 
00146 bool Foam::basicSourceList::writeData(Ostream& os) const
00147 {
00148     // Write size of list
00149     os << nl << this->size();
00150 
00151     // Write beginning of contents
00152     os << nl << token::BEGIN_LIST;
00153 
00154     // Write list contents
00155     forAll(*this, i)
00156     {
00157         os << nl;
00158         this->operator[](i).writeData(os);
00159     }
00160 
00161     // Write end of contents
00162     os << token::END_LIST << token::END_STATEMENT << nl;
00163 
00164     // Check state of IOstream
00165      return os.good();
00166 }
00167 
00168 
00169 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
00170 
00171 Foam::Ostream& Foam::operator<<
00172 (
00173     Ostream& os,
00174     const basicSourceList& sources
00175 )
00176 {
00177     sources.writeData(os);
00178     return os;
00179 }
00180 
00181 
00182 // ************************************************************************* //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines