1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "ignitionSite.H"
27 #include "objectRegistry.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;
62 forAll(centres, celli)
64 scalar dist = mag(centres[celli] - location_);
71 if (dist < radius && celli != ignCell)
73 cells_.setSize(nIgnCells+1);
74 cellVolumes_.setSize(nIgnCells+1);
76 cells_[nIgnCells] = celli;
77 cellVolumes_[nIgnCells] = vols[celli];
85 Pout<< "Found ignition cells:" << endl << cells_ << endl;
90 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92 const labelList& ignitionSite::cells() const
94 if (mesh_.changing() && timeIndex_ != db_.timeIndex())
96 const_cast<ignitionSite&>(*this).findIgnitionCells(mesh_);
98 timeIndex_ = db_.timeIndex();
104 bool ignitionSite::igniting() const
106 scalar curTime = db_.value();
107 scalar deltaT = db_.deltaT().value();
111 (curTime - deltaT >= time_)
113 (curTime - deltaT < time_ + max(duration_, deltaT) + SMALL)
118 bool ignitionSite::ignited() const
120 scalar curTime = db_.value();
121 scalar deltaT = db_.deltaT().value();
123 return(curTime - deltaT >= time_);
127 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
129 void ignitionSite::operator=(const ignitionSite& is)
131 location_ = is.location_;
132 diameter_ = is.diameter_;
134 duration_ = is.duration_;
135 strength_ = is.strength_;
137 cellVolumes_ = is.cellVolumes_;
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 } // End namespace Foam
145 // ************************************************************************* //