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