timeActivatedExplicitCellSource.C
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 #include "timeActivatedExplicitCellSource.H"
00028 #include "volFields.H"
00029
00030
00031
00032 void Foam::timeActivatedExplicitCellSource::updateCellSet()
00033 {
00034 cellSelector_->applyToSet(topoSetSource::NEW, selectedCellSet_);
00035
00036 Info<< " " << name_ << ": selected "
00037 << returnReduce(selectedCellSet_.size(), sumOp<label>())
00038 << " cells" << nl << endl;
00039
00040 V_ = scalarField(selectedCellSet_.size(), 1.0);
00041 if (volumeType_ == vtAbsolute)
00042 {
00043 label i = 0;
00044 forAllConstIter(cellSet, selectedCellSet_, iter)
00045 {
00046 V_[i++] = mesh_.V()[iter.key()];
00047 }
00048 }
00049 }
00050
00051
00052
00053
00054 Foam::timeActivatedExplicitCellSource::timeActivatedExplicitCellSource
00055 (
00056 const word& name,
00057 const fvMesh& mesh,
00058 const dimensionSet& dims
00059 )
00060 :
00061 timeActivatedExplicitSource(name, mesh, dims),
00062 onValue_(readScalar(lookup("onValue"))),
00063 offValue_(readScalar(lookup("offValue"))),
00064 V_(0),
00065 cellSource_(lookup("cellSource")),
00066 cellSelector_
00067 (
00068 topoSetSource::New
00069 (
00070 cellSource_,
00071 mesh,
00072 subDict(cellSource_ + "Coeffs")
00073 )
00074 ),
00075 selectedCellSet_
00076 (
00077 mesh,
00078 name + "SourceCellSet",
00079 mesh.nCells()/10 + 1
00080 )
00081 {
00082
00083 updateCellSet();
00084 }
00085
00086
00087
00088
00089 Foam::scalar Foam::timeActivatedExplicitCellSource::onValue() const
00090 {
00091 return onValue_;
00092 }
00093
00094
00095 Foam::scalar Foam::timeActivatedExplicitCellSource::offValue() const
00096 {
00097 return offValue_;
00098 }
00099
00100
00101 Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >
00102 Foam::timeActivatedExplicitCellSource::Su()
00103 {
00104 tmp<DimensionedField<scalar, volMesh> > tSource
00105 (
00106 new DimensionedField<scalar, volMesh>
00107 (
00108 IOobject
00109 (
00110 name_ + "Su",
00111 runTime_.timeName(),
00112 mesh_,
00113 IOobject::NO_READ,
00114 IOobject::NO_WRITE
00115 ),
00116 mesh_,
00117 dimensionedScalar("zero", dimensions_, 0.0)
00118 )
00119 );
00120
00121 scalar value = offValue_;
00122 if
00123 (
00124 active_
00125 && (runTime_.time().value() >= timeStart_)
00126 && (runTime_.time().value() <= timeStart_ + duration_)
00127 )
00128 {
00129
00130 if (mesh_.changing())
00131 {
00132 updateCellSet();
00133 }
00134
00135 value = onValue_;
00136 }
00137
00138 DimensionedField<scalar, volMesh>& sourceField = tSource();
00139
00140 label i = 0;
00141 forAllConstIter(cellSet, selectedCellSet_, iter)
00142 {
00143 sourceField[iter.key()] = value/V_[i++];
00144 }
00145
00146 return tSource;
00147 }
00148
00149
00150 bool Foam::timeActivatedExplicitCellSource::read()
00151 {
00152 if (timeActivatedExplicitSource::read())
00153 {
00154 lookup("onValue") >> onValue_;
00155 lookup("offValue") >> offValue_;
00156 lookup("cellSource") >> cellSource_;
00157 cellSelector_ =
00158 topoSetSource::New
00159 (
00160 cellSource_,
00161 mesh_,
00162 subDict(cellSource_ + "Coeffs")
00163 );
00164 updateCellSet();
00165
00166 return true;
00167 }
00168 else
00169 {
00170 return false;
00171 }
00172 }
00173
00174
00175
Copyright © 2000-2009 OpenCFD Ltd