BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / engine / ignition / ignitionSite.C
blobdde8bab956fa37b76894175530bd765ae9d117d9
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.findNearestCell(location_);
40     if (ignCell == -1)
41     {
42         Info << "NOT FOUND" << endl;
43         return;
44     }
46     scalar radius = diameter_/2.0;
48     cells_.setSize(1);
49     cellVolumes_.setSize(1);
51     cells_[0] = ignCell;
52     cellVolumes_[0] = vols[ignCell];
54     scalar minDist = GREAT;
55     label nIgnCells = 1;
57     forAll(centres, celli)
58     {
59         scalar dist = mag(centres[celli] - location_);
61         if (dist < minDist)
62         {
63             minDist = dist;
64         }
66         if (dist < radius && celli != ignCell)
67         {
68             cells_.setSize(nIgnCells+1);
69             cellVolumes_.setSize(nIgnCells+1);
71             cells_[nIgnCells] = celli;
72             cellVolumes_[nIgnCells] = vols[celli];
74             nIgnCells++;
75         }
76     }
78     if (cells_.size())
79     {
80         Pout<< "Found ignition cells:" << endl << cells_ << endl;
81     }
85 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
87 const Foam::labelList& Foam::ignitionSite::cells() const
89     if (mesh_.changing() && timeIndex_ != db_.timeIndex())
90     {
91         const_cast<ignitionSite&>(*this).findIgnitionCells(mesh_);
92     }
93     timeIndex_ = db_.timeIndex();
95     return cells_;
99 bool Foam::ignitionSite::igniting() const
101     scalar curTime = db_.value();
102     scalar deltaT = db_.deltaTValue();
104     return
105     (
106         (curTime - deltaT >= time_)
107         &&
108         (curTime - deltaT < time_ + max(duration_, deltaT) + SMALL)
109     );
113 bool Foam::ignitionSite::ignited() const
115     scalar curTime = db_.value();
116     scalar deltaT = db_.deltaTValue();
118     return(curTime - deltaT >= time_);
122 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
124 void Foam::ignitionSite::operator=(const ignitionSite& is)
126     location_ = is.location_;
127     diameter_ = is.diameter_;
128     time_ = is.time_;
129     duration_ = is.duration_;
130     strength_ = is.strength_;
131     cells_ = is.cells_;
132     cellVolumes_ = is.cellVolumes_;
136 // ************************************************************************* //