ignitionSite.C
Go to the documentation of this file.
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.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "ignitionSite.H"
27 #include "Time.H"
28 #include "volFields.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
33 {
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();
38 
39  label ignCell = mesh.findCell(location_);
40  if (ignCell == -1)
41  {
42  return;
43  }
44 
45  scalar radius = diameter_/2.0;
46 
47  cells_.setSize(1);
49 
50  cells_[0] = ignCell;
51  cellVolumes_[0] = vols[ignCell];
52 
53  scalar minDist = GREAT;
54  label nIgnCells = 1;
55 
56  forAll(centres, celli)
57  {
58  scalar dist = mag(centres[celli] - location_);
59 
60  if (dist < minDist)
61  {
62  minDist = dist;
63  }
64 
65  if (dist < radius && celli != ignCell)
66  {
67  cells_.setSize(nIgnCells+1);
68  cellVolumes_.setSize(nIgnCells+1);
69 
70  cells_[nIgnCells] = celli;
71  cellVolumes_[nIgnCells] = vols[celli];
72 
73  nIgnCells++;
74  }
75  }
76 
77  if (cells_.size())
78  {
79  Pout<< "Found ignition cells:" << endl << cells_ << endl;
80  }
81 }
82 
83 
84 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
85 
87 {
88  if (mesh_.changing() && timeIndex_ != db_.timeIndex())
89  {
90  const_cast<ignitionSite&>(*this).findIgnitionCells(mesh_);
91  }
92  timeIndex_ = db_.timeIndex();
93 
94  return cells_;
95 }
96 
97 
99 {
100  scalar curTime = db_.value();
101  scalar deltaT = db_.deltaTValue();
102 
103  return
104  (
105  (curTime - deltaT >= time_)
106  &&
107  (curTime - deltaT < time_ + max(duration_, deltaT) + SMALL)
108  );
109 }
110 
111 
113 {
114  scalar curTime = db_.value();
115  scalar deltaT = db_.deltaTValue();
116 
117  return(curTime - deltaT >= time_);
118 }
119 
120 
121 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
122 
124 {
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_;
132 }
133 
134 
135 // ************************************************************************* //
volFields.H
Foam::ignitionSite::cells
const labelList & cells() const
Return the ignition cells updated if the mesh moved.
Definition: ignitionSite.C:86
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
ignitionSite.H
Foam::ignitionSite::strength_
scalar strength_
Definition: ignitionSite.H:71
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::ignitionSite::cellVolumes_
scalarList cellVolumes_
Definition: ignitionSite.H:74
Foam::ignitionSite
Foam::ignitionSite.
Definition: ignitionSite.H:58
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::ignitionSite::ignited
bool ignited() const
Definition: ignitionSite.C:112
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam::ignitionSite::findIgnitionCells
void findIgnitionCells(const fvMesh &)
Definition: ignitionSite.C:32
Foam::ignitionSite::location_
vector location_
Definition: ignitionSite.H:67
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::Pout
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::ignitionSite::operator=
void operator=(const ignitionSite &)
Definition: ignitionSite.C:123
Foam::ignitionSite::igniting
bool igniting() const
Definition: ignitionSite.C:98
Foam::ignitionSite::time_
scalar time_
Definition: ignitionSite.H:69
Foam::ignitionSite::cells_
labelList cells_
Definition: ignitionSite.H:73
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::ignitionSite::duration_
scalar duration_
Definition: ignitionSite.H:70
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::ignitionSite::diameter_
scalar diameter_
Definition: ignitionSite.H:68