BUG: radialActuactionDiskSource: corrected maxR calculation.
[OpenFOAM-2.0.x.git] / src / engine / ignition / ignitionSite.C
blob3ecdd632715253c4ec36539cca93a6174b3af5f2
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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"
27 #include "Time.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_);
40     if (ignCell == -1)
41     {
42         return;
43     }
45     scalar radius = diameter_/2.0;
47     cells_.setSize(1);
48     cellVolumes_.setSize(1);
50     cells_[0] = ignCell;
51     cellVolumes_[0] = vols[ignCell];
53     scalar minDist = GREAT;
54     label nIgnCells = 1;
56     forAll(centres, celli)
57     {
58         scalar dist = mag(centres[celli] - location_);
60         if (dist < minDist)
61         {
62             minDist = dist;
63         }
65         if (dist < radius && celli != ignCell)
66         {
67             cells_.setSize(nIgnCells+1);
68             cellVolumes_.setSize(nIgnCells+1);
70             cells_[nIgnCells] = celli;
71             cellVolumes_[nIgnCells] = vols[celli];
73             nIgnCells++;
74         }
75     }
77     if (cells_.size())
78     {
79         Pout<< "Found ignition cells:" << endl << cells_ << endl;
80     }
84 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
86 const Foam::labelList& Foam::ignitionSite::cells() const
88     if (mesh_.changing() && timeIndex_ != db_.timeIndex())
89     {
90         const_cast<ignitionSite&>(*this).findIgnitionCells(mesh_);
91     }
92     timeIndex_ = db_.timeIndex();
94     return cells_;
98 bool Foam::ignitionSite::igniting() const
100     scalar curTime = db_.value();
101     scalar deltaT = db_.deltaTValue();
103     return
104     (
105         (curTime - deltaT >= time_)
106         &&
107         (curTime - deltaT < time_ + max(duration_, deltaT) + SMALL)
108     );
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_;
127     time_ = is.time_;
128     duration_ = is.duration_;
129     strength_ = is.strength_;
130     cells_ = is.cells_;
131     cellVolumes_ = is.cellVolumes_;
135 // ************************************************************************* //