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 #include "ignitionSite.H"
00027 #include <OpenFOAM/Time.H>
00028 #include <finiteVolume/volFields.H>
00029
00030
00031
00032 namespace Foam
00033 {
00034
00035
00036
00037 void ignitionSite::findIgnitionCells(const fvMesh& mesh)
00038 {
00039
00040
00041 const volVectorField& centres = mesh.C();
00042 const scalarField& vols = mesh.V();
00043
00044 label ignCell = mesh.findCell(location_);
00045 if (ignCell == -1)
00046 {
00047 return;
00048 }
00049
00050 scalar radius = diameter_/2.0;
00051
00052 cells_.setSize(1);
00053 cellVolumes_.setSize(1);
00054
00055 cells_[0] = ignCell;
00056 cellVolumes_[0] = vols[ignCell];
00057
00058 scalar minDist = GREAT;
00059 label nearestCell = 0;
00060 label nIgnCells = 1;
00061
00062 forAll(centres, celli)
00063 {
00064 scalar dist = mag(centres[celli] - location_);
00065
00066 if (dist < minDist)
00067 {
00068 nearestCell = celli;
00069 minDist = dist;
00070 }
00071
00072 if (dist < radius && celli != ignCell)
00073 {
00074 cells_.setSize(nIgnCells+1);
00075 cellVolumes_.setSize(nIgnCells+1);
00076
00077 cells_[nIgnCells] = celli;
00078 cellVolumes_[nIgnCells] = vols[celli];
00079
00080 nIgnCells++;
00081 }
00082 }
00083
00084 if (cells_.size())
00085 {
00086 Pout<< "Found ignition cells:" << endl << cells_ << endl;
00087 }
00088 }
00089
00090
00091
00092
00093 const labelList& ignitionSite::cells() const
00094 {
00095 if (mesh_.changing() && timeIndex_ != db_.timeIndex())
00096 {
00097 const_cast<ignitionSite&>(*this).findIgnitionCells(mesh_);
00098 }
00099 timeIndex_ = db_.timeIndex();
00100
00101 return cells_;
00102 }
00103
00104
00105 bool ignitionSite::igniting() const
00106 {
00107 scalar curTime = db_.value();
00108 scalar deltaT = db_.deltaT().value();
00109
00110 return
00111 (
00112 (curTime - deltaT >= time_)
00113 &&
00114 (curTime - deltaT < time_ + max(duration_, deltaT) + SMALL)
00115 );
00116 }
00117
00118
00119 bool ignitionSite::ignited() const
00120 {
00121 scalar curTime = db_.value();
00122 scalar deltaT = db_.deltaT().value();
00123
00124 return(curTime - deltaT >= time_);
00125 }
00126
00127
00128
00129
00130 void ignitionSite::operator=(const ignitionSite& is)
00131 {
00132 location_ = is.location_;
00133 diameter_ = is.diameter_;
00134 time_ = is.time_;
00135 duration_ = is.duration_;
00136 strength_ = is.strength_;
00137 cells_ = is.cells_;
00138 cellVolumes_ = is.cellVolumes_;
00139 }
00140
00141
00142
00143
00144 }
00145
00146