1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "ignitionSite.H"
28 #include "volFields.H"
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 void Foam::ignitionSite::findIgnitionCells(const fvMesh& mesh)
34 // Bit tricky: generate C and V before shortcutting if cannot find
35 // cell locally. mesh.C generation uses parallel communication.
36 const volVectorField& centres = mesh.C();
37 const scalarField& vols = mesh.V();
39 label ignCell = mesh.findCell(location_);
45 scalar radius = diameter_/2.0;
48 cellVolumes_.setSize(1);
51 cellVolumes_[0] = vols[ignCell];
53 scalar minDist = GREAT;
56 forAll(centres, celli)
58 scalar dist = mag(centres[celli] - location_);
65 if (dist < radius && celli != ignCell)
67 cells_.setSize(nIgnCells+1);
68 cellVolumes_.setSize(nIgnCells+1);
70 cells_[nIgnCells] = celli;
71 cellVolumes_[nIgnCells] = vols[celli];
79 Pout<< "Found ignition cells:" << endl << cells_ << endl;
84 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
86 const Foam::labelList& Foam::ignitionSite::cells() const
88 if (mesh_.changing() && timeIndex_ != db_.timeIndex())
90 const_cast<ignitionSite&>(*this).findIgnitionCells(mesh_);
92 timeIndex_ = db_.timeIndex();
98 bool Foam::ignitionSite::igniting() const
100 scalar curTime = db_.value();
101 scalar deltaT = db_.deltaTValue();
105 (curTime - deltaT >= time_)
107 (curTime - deltaT < time_ + max(duration_, deltaT) + SMALL)
112 bool Foam::ignitionSite::ignited() const
114 scalar curTime = db_.value();
115 scalar deltaT = db_.deltaTValue();
117 return(curTime - deltaT >= time_);
121 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
123 void Foam::ignitionSite::operator=(const ignitionSite& is)
125 location_ = is.location_;
126 diameter_ = is.diameter_;
128 duration_ = is.duration_;
129 strength_ = is.strength_;
131 cellVolumes_ = is.cellVolumes_;
135 // ************************************************************************* //