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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 ]

Diff markup

Differences between /examples/advanced/fastAerosol/include/FastAerosol.icc (Version 11.3.0) and /examples/advanced/fastAerosol/include/FastAerosol.icc (Version 10.7.p1)


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