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.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 
 26 // --------------------------------------------------------------------
 27 // GEANT 4 inline definitions file
 28 //
 29 // FastAerosol.icc
 30 //
 31 // Implementation of inline methods of FastAerosol
 32 //
 33 // Author: A.Knaian (ara@nklabs.com), N.MacFadden (natemacfadden@gmail.com)
 34 // --------------------------------------------------------------------
 35 
 36 inline
 37 G4String FastAerosol::GetName() const
 38 {
 39   return(fName);
 40 }
 41 
 42 inline
 43 G4VSolid* FastAerosol::GetBulk() const
 44 {
 45   return(fCloud);
 46 }
 47 
 48 inline
 49 G4double FastAerosol::GetRadius() const
 50 {
 51   return(fR);
 52 }
 53 
 54 inline
 55 G4double FastAerosol::GetAvgNumDens() const
 56 {
 57   return(fAvgNumDens);
 58 }
 59 
 60 inline
 61 G4int FastAerosol::GetNumDroplets() const
 62 {
 63   return((int)(fAvgNumDens*GetCubicVolume()));
 64 }
 65 
 66 
 67 
 68 inline
 69 G4double FastAerosol::GetXHalfLength() const
 70 {
 71   return(fDx);
 72 }
 73 
 74 inline    
 75 G4double FastAerosol::GetYHalfLength() const
 76 {
 77   return(fDy);
 78 }
 79 
 80 inline
 81 G4double FastAerosol::GetZHalfLength() const
 82 {
 83   return(fDz);
 84 }
 85 
 86 inline
 87 void FastAerosol::GetBoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
 88 {
 89   pMin.setX(-fDx); pMax.setX(fDx);
 90   pMin.setY(-fDy); pMax.setY(fDy);
 91   pMin.setZ(-fDz); pMax.setZ(fDz);
 92 }
 93 
 94 inline
 95 G4double FastAerosol::GetCubicVolume() const
 96 {
 97   return(fCloud->GetCubicVolume());
 98 }
 99 
100 
101 // Find the absolute distance to the cloud bulk from p
102 inline
103 G4double FastAerosol::DistanceToCloud(const G4ThreeVector &p) {
104   if (fCloud->Inside(p)==kOutside)
105   {
106     return(fCloud->DistanceToIn(p));
107   }
108   else
109   {
110     return(0);
111   }
112 }
113 
114 // Find the distance to the cloud bulk from p along a vector v
115 inline
116 G4double FastAerosol::DistanceToCloud(const G4ThreeVector &p, const G4ThreeVector &v) {
117   if (fCloud->Inside(p)==kInside)
118   {
119     return(0);
120   }
121   else
122   {
123     return(fCloud->DistanceToIn(p,v));
124   }
125 }
126 
127 
128 // Get and set the base of the random seed used to set droplet positions
129 // For a given seed and a given geometry, the droplet positions are the same
130 inline
131 long FastAerosol::GetSeed() {
132   return(fSeed);
133 }
134 
135 inline
136 void FastAerosol::SetSeed(long seedIn) {
137   fSeed = seedIn;
138 }
139 
140 
141 // Get and set the maximum radius of the voxelized spheres to pre-populate
142 inline
143 G4int FastAerosol::GetPreSphereR() {
144   return(fPreSphereR);
145 }
146 
147 inline
148 void FastAerosol::SetPreSphereR(G4int preSphereRIn) {
149   fPreSphereR = preSphereRIn;
150 }
151 
152 
153 // Get the droplet distribution function
154 inline
155 std::function<G4double (G4ThreeVector)> FastAerosol::GetDistribution() {
156   return(fDistribution);
157 }
158 
159 
160 // Get and set the maximum number of droplet placement tries in the solid
161 // Skip placement if attempting to place a single droplet more than this
162 inline
163 G4int FastAerosol::GetNumPlacementTries()
164 {
165   return(fNumNewPointTries);
166 }
167 
168 inline
169 void FastAerosol::SetNumPlacementTries(G4int numTries)
170 {
171   fNumNewPointTries = numTries;
172 }
173 
174 // Get and set the expected number of droplets per voxel (on average)
175 inline
176 G4double FastAerosol::GetDropletsPerVoxel()
177 {
178   return(fDropletsPerVoxel);
179 }
180 
181 inline
182 void FastAerosol::SetDropletsPerVoxel(G4double newDropletsPerVoxel)
183 {
184   if (newDropletsPerVoxel >= std::pow(4.0*std::sqrt(2),-1.0))
185   {
186     fDropletsPerVoxel = newDropletsPerVoxel;
187     InitializeGrid();
188   }
189   else
190   {
191     std::ostringstream message;
192     message << "Invalid droplets/voxel for cloud: " << GetName() << "!" << G4endl
193         << "    For grid pitch to be larger than radius (currently assumed),"
194         << "    droplets/voxel must be greater than or equal to 1/(4*sqrt(2))"
195         << "        newDropletsPerVoxel = " << newDropletsPerVoxel;
196     G4Exception("FastAerosol::SetDropletsPerVoxel()", "GeomSolids0002",
197           FatalErrorInArgument, message);
198   }
199 }
200 
201 
202 inline
203 void FastAerosol::PrintPopulationReport() {
204   G4cout << "Total grids: " << fNumGridCells << G4endl;
205   G4cout << "Droplets created: " << fNumDroplets << G4endl;
206   G4cout << "Average Number density: " << fAvgNumDens << G4endl;
207   G4cout << "Droplets expected: " << GetNumDroplets() << G4endl;
208 }
209 
210 
211 // =======
212 // Private
213 // =======
214 // Find the grid associated with a point.  Return true if that is a valid grid,
215 // false if it is out of bounds.
216 inline
217 bool FastAerosol::GetGrid(const G4ThreeVector &p, int &xGrid, int &yGrid, int &zGrid) {
218   xGrid = (int)floorl((p.x() + fDx) / fGridPitch);
219   yGrid = (int)floorl((p.y() + fDy) / fGridPitch);
220   zGrid = (int)floorl((p.z() + fDz) / fGridPitch);
221   return(!AnyIndexOutOfBounds(xGrid, yGrid, zGrid));
222 }
223 
224 // Return true if any grid index given is out of bounds, false otherwise
225 inline
226 bool FastAerosol::AnyIndexOutOfBounds(G4int xGrid, G4int yGrid, G4int zGrid) {
227   return ((xGrid < 0) || (xGrid >= fNx) ||
228       (yGrid < 0) || (yGrid >= fNy) ||
229       (zGrid < 0) || (zGrid >= fNz));
230 }
231 
232 // Create index for grid 
233 inline
234 unsigned int FastAerosol::GetGridIndex(unsigned int xi, unsigned int yi, unsigned int zi) {
235   return(zi*fNxy + yi*fNx + xi);
236 }
237 
238 // Create get coordinates of index
239 inline
240 G4ThreeVector FastAerosol::GetIndexCoord(G4int index) {
241   G4int x = index % fNx;
242   G4int y = ( (index -x)/fNx ) % fNy;
243   G4int z = (index -x -fNx*y )/(fNx*fNy);
244   return(G4ThreeVector(x,y,z));
245 }
246 
247 // find lower and upper grid boundary
248 inline
249 std::pair<G4int, G4int> FastAerosol::GetMinMaxSide(G4int i, G4int numGrids) {
250   return(std::make_pair((i == 0) ? 0 : (i-1),
251                (i == (numGrids-1)) ? i : (i+1)));
252 }