1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "ignitionSite.H"
29 #include "volFields.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
38 void ignitionSite::findIgnitionCells(const fvMesh& mesh)
40 // Bit tricky: generate C and V before shortcutting if cannot find
41 // cell locally. mesh.C generation uses parallel communication.
42 const volVectorField& centres = mesh.C();
43 const scalarField& vols = mesh.V();
45 label ignCell = mesh.findCell(location_);
51 scalar radius = diameter_/2.0;
54 cellVolumes_.setSize(1);
57 cellVolumes_[0] = vols[ignCell];
59 scalar minDist = GREAT;
60 label nearestCell = 0;
63 forAll(centres, celli)
65 scalar dist = mag(centres[celli] - location_);
73 if (dist < radius && celli != ignCell)
75 cells_.setSize(nIgnCells+1);
76 cellVolumes_.setSize(nIgnCells+1);
78 cells_[nIgnCells] = celli;
79 cellVolumes_[nIgnCells] = vols[celli];
87 Pout<< "Found ignition cells:" << endl << cells_ << endl;
92 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 const labelList& ignitionSite::cells() const
96 if (mesh_.changing() && timeIndex_ != db_.timeIndex())
98 const_cast<ignitionSite&>(*this).findIgnitionCells(mesh_);
100 timeIndex_ = db_.timeIndex();
106 bool ignitionSite::igniting() const
108 scalar curTime = db_.value();
109 scalar deltaT = db_.deltaT().value();
113 (curTime - deltaT >= time_)
115 (curTime - deltaT < time_ + max(duration_, deltaT) + SMALL)
120 bool ignitionSite::ignited() const
122 scalar curTime = db_.value();
123 scalar deltaT = db_.deltaT().value();
125 return(curTime - deltaT >= time_);
129 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
131 void ignitionSite::operator=(const ignitionSite& is)
133 location_ = is.location_;
134 diameter_ = is.diameter_;
136 duration_ = is.duration_;
137 strength_ = is.strength_;
139 cellVolumes_ = is.cellVolumes_;
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 } // End namespace Foam
147 // ************************************************************************* //