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 #include "TimeActivatedExplicitSourceList.H"
00027
00028
00029
00030 template<class Type>
00031 Foam::TimeActivatedExplicitSourceList<Type>::TimeActivatedExplicitSourceList
00032 (
00033 const word& name,
00034 const fvMesh& mesh,
00035 const dimensionSet& dimensions,
00036 const wordList& fieldNames
00037 )
00038 :
00039 IOPtrList<TimeActivatedExplicitSource<Type> >
00040 (
00041 IOobject
00042 (
00043 name + "SourceProperties",
00044 mesh.time().constant(),
00045 mesh,
00046 IOobject::MUST_READ,
00047 IOobject::NO_WRITE
00048 ),
00049 typename TimeActivatedExplicitSource<Type>::iNew(mesh, fieldNames)
00050 ),
00051 name_(name),
00052 mesh_(mesh),
00053 dimensions_(dimensions),
00054 fieldNames_(fieldNames)
00055 {}
00056
00057
00058 template<class Type>
00059 Foam::TimeActivatedExplicitSourceList<Type>::TimeActivatedExplicitSourceList
00060 (
00061 const word& name,
00062 const fvMesh& mesh,
00063 const dimensionSet& dimensions,
00064 const word& fieldName
00065 )
00066 :
00067 IOPtrList<TimeActivatedExplicitSource<Type> >
00068 (
00069 IOobject
00070 (
00071 name + "SourceProperties",
00072 mesh.time().constant(),
00073 mesh,
00074 IOobject::MUST_READ,
00075 IOobject::NO_WRITE
00076 ),
00077 typename TimeActivatedExplicitSource<Type>::iNew
00078 (
00079 mesh,
00080 IStringStream('(' + fieldName + ')')()
00081 )
00082 ),
00083 name_(name),
00084 mesh_(mesh),
00085 dimensions_(dimensions),
00086 fieldNames_(1, fieldName)
00087 {}
00088
00089
00090
00091
00092 template<class Type>
00093 Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh> >
00094 Foam::TimeActivatedExplicitSourceList<Type>::Su(const label fieldI)
00095 {
00096 tmp<DimensionedField<Type, volMesh> > tSu
00097 (
00098 new DimensionedField<Type, volMesh>
00099 (
00100 IOobject
00101 (
00102 name_ + "Source_" + fieldNames_[fieldI],
00103 mesh_.time().timeName(),
00104 mesh_,
00105 IOobject::NO_READ,
00106 IOobject::NO_WRITE
00107 ),
00108 mesh_,
00109 dimensioned<Type>("zero", dimensions_, pTraits<Type>::zero)
00110 )
00111 );
00112
00113 DimensionedField<Type, volMesh>& Su = tSu();
00114
00115 forAll(*this, i)
00116 {
00117 this->operator[](i).addToField(Su, fieldI);
00118 }
00119
00120 return tSu;
00121 }
00122
00123
00124 template<class Type>
00125 Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh> >
00126 Foam::TimeActivatedExplicitSourceList<Type>::SuTot()
00127 {
00128 tmp<DimensionedField<Type, volMesh> > tSuTot
00129 (
00130 new DimensionedField<Type, volMesh>
00131 (
00132 IOobject
00133 (
00134 name_ + "TotalSource",
00135 mesh_.time().timeName(),
00136 mesh_,
00137 IOobject::NO_READ,
00138 IOobject::NO_WRITE
00139 ),
00140 mesh_,
00141 dimensioned<Type>("zero", dimensions_, pTraits<Type>::zero)
00142 )
00143 );
00144
00145 DimensionedField<Type, volMesh>& SuTot = tSuTot();
00146
00147 forAll(fieldNames_, fieldI)
00148 {
00149 forAll(*this, sourceI)
00150 {
00151 this->operator[](sourceI).addToField(SuTot, fieldI);
00152 }
00153 }
00154
00155 return tSuTot;
00156 }
00157
00158
00159 template<class Type>
00160 bool Foam::TimeActivatedExplicitSourceList<Type>::readData(Istream& is)
00161 {
00162 this->clear();
00163
00164 IOPtrList<TimeActivatedExplicitSource<Type> > newSources
00165 (
00166 IOobject
00167 (
00168 name_ + "TimeActivatedExplicitSource",
00169 mesh_.time().constant(),
00170 mesh_,
00171 IOobject::MUST_READ,
00172 IOobject::NO_WRITE,
00173 false
00174 ),
00175 typename TimeActivatedExplicitSource<Type>::iNew(mesh_, fieldNames_)
00176 );
00177
00178 this->transfer(newSources);
00179
00180 return is.good();
00181 }
00182
00183
00184 template<class Type>
00185 bool Foam::TimeActivatedExplicitSourceList<Type>::writeData(Ostream& os) const
00186 {
00187
00188 os << nl << this->size();
00189
00190
00191 os << nl << token::BEGIN_LIST;
00192
00193
00194 forAll(*this, i)
00195 {
00196 os << nl;
00197 this->operator[](i).writeData(os);
00198 }
00199
00200
00201 os << token::END_LIST << token::END_STATEMENT << nl;
00202
00203
00204 return os.good();
00205 }
00206
00207
00208
00209
00210 template<class Type>
00211 Foam::Ostream& Foam::operator<<
00212 (
00213 Ostream& os,
00214 const TimeActivatedExplicitSourceList<Type>& sources
00215 )
00216 {
00217 sources.writeData(os);
00218 return os;
00219 }
00220
00221
00222