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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.hh (Version 11.3.0) and /examples/advanced/fastAerosol/include/FastAerosol.hh (Version 8.2)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26                                                   
 27 // -------------------------------------------    
 28 // GEANT 4 class header file                      
 29 //                                                
 30 //                                                
 31 // FastAerosol                                    
 32 //                                                
 33 // Class description:                             
 34 //                                                
 35 //   A FastAerosol is a collection of points i    
 36 //   arbitrarily-shaped volume with methods im    
 37 //   grids/voxels and for efficiently finding     
 38 //                                                
 39 // Author: A.Knaian (ara@nklabs.com), N.MacFad    
 40 // -------------------------------------------    
 41                                                   
 42 #ifndef FastAerosol_h                             
 43 #define FastAerosol_h                             
 44                                                   
 45 #include "globals.hh"                             
 46 #include "Randomize.hh"                           
 47 #include "G4ThreeVector.hh"                       
 48 #include "G4VSolid.hh"                            
 49                                                   
 50 // rotations and number density distribution      
 51 #include <functional>                             
 52 #include "G4RotationMatrix.hh"                    
 53 #include <atomic>                                 
 54                                                   
 55 //using namespace std;                            
 56                                                   
 57 class FastAerosol                                 
 58 {                                                 
 59 public:                                           
 60  // Constructor; creates a random cloud of dro    
 61  FastAerosol(const G4String& pName, G4VSolid*     
 62        G4double pR, G4double pMinD,               
 63        G4double pAvgNumDens, G4double pdR,        
 64        std::function<G4double (G4ThreeVector)>    
 65                                                   
 66 FastAerosol(const G4String& pName, G4VSolid* p    
 67       G4double pR, G4double pMinD,                
 68       G4double pNumDens, G4double pdR);           
 69                                                   
 70 FastAerosol(const G4String& pName, G4VSolid* p    
 71       G4double pR, G4double pMinD, G4double pN    
 72                                                   
 73 ~FastAerosol()=default;                           
 74                                                   
 75 // Populate all grids. Otherwise, they are pop    
 76 void PopulateAllGrids();                          
 77                                                   
 78 // Save locations of droplets to a file for vi    
 79 void SaveToFile(const char *filename);            
 80                                                   
 81 // Get absolutely nearest droplet - must be pu    
 82 bool GetNearestDroplet(const G4ThreeVector &p,    
 83                                                   
 84 // Get nearest droplet along a vector - must b    
 85 bool GetNearestDroplet(const G4ThreeVector &p,    
 86                                                   
 87 // ======                                         
 88 // Inline                                         
 89 // ======                                         
 90 // Input quantities                               
 91 inline G4String GetName() const; //fasterosol     
 92 inline G4VSolid* GetBulk() const; // bulk shap    
 93 inline G4double GetRadius() const; // droplet     
 94 inline G4double GetAvgNumDens() const;  // dro    
 95 //inline G4double GetPitch() const;   // grid     
 96                                                   
 97 inline G4int GetNumDroplets() const;              
 98 // in case the absolute number is more relevan    
 99                                                   
100 // Bulk quantities                                
101 inline G4double GetXHalfLength() const;           
102 inline G4double GetYHalfLength() const;           
103 inline G4double GetZHalfLength() const;           
104 inline void GetBoundingLimits(G4ThreeVector &p    
105 inline G4double GetCubicVolume() const;           
106                                                   
107 inline G4double DistanceToCloud(const G4ThreeV    
108 inline G4double DistanceToCloud(const G4ThreeV    
109                                                   
110 // Misc getters and setters                       
111 inline long GetSeed();                            
112 inline void SetSeed(long seed);                   
113                                                   
114 inline G4int GetNumPlacementTries();              
115 inline void SetNumPlacementTries(G4int numTrie    
116                                                   
117 inline G4int GetPreSphereR();                     
118 inline void SetPreSphereR(G4int fPreSphereRIn)    
119                                                   
120 inline std::function<G4double (G4ThreeVector)>    
121                                                   
122 inline G4double GetDropletsPerVoxel();            
123 inline void SetDropletsPerVoxel(G4double newDr    
124                                                   
125 // Printing diagnostic tool                       
126 inline void PrintPopulationReport();              
127                                                   
128 private:                                          
129  G4double kCarTolerance;                          
130                                                   
131 // Parameters, set in constructor                 
132  G4String fName;                                  
133  G4VSolid* fCloud; // Solid volume of the clou    
134  G4double fDx, fDy, fDz; // Half widths           
135  G4double fR; // Bounding radius of each dropl    
136  G4double fR2;  // Bounding radius squared of     
137  G4double fdR;  // Uncertainty in DistanceToIn    
138                                                   
139 G4double fMinD; // Minimum distance allowed be    
140                                                   
141 std::function<G4double (G4ThreeVector)> fDistr    
142 G4double fAvgNumDens; // Average droplet numbe    
143                                                   
144 long int fNumDroplets = 0;                        
145 // Number of droplets that have been created      
146                                                   
147 G4double fGridPitch;                              
148 // Pitch of collision detection grid.  Must be    
149                                                   
150 // Ramdom engine                                  
151 CLHEP::HepJamesRandom fCloudEngine;               
152 long fSeed = 0; // Global random seed             
153                                                   
154 G4double fDropletsPerVoxel = 4.0;                 
155 // Expected number of droplets per voxel          
156                                                   
157 // How far the voxel center must be inside the    
158 //order for there to be no risk of placing a d    
159 G4double fEdgeDistance;                           
160                                                   
161 // Grid variables                                 
162 std::vector<std::vector<G4ThreeVector>> fGrid;    
163 // Grid of lists of inidices to grid points,      
164 //used for fast collsion checking                 
165                                                   
166 std::vector<G4double> fGridMean;                  
167 // Array listing mean count for each voxel        
168                                                   
169 std::atomic<bool> *fGridValid;                    
170 // Array listing validity of each grid. uses a    
171                                                   
172 G4int fNx, fNy, fNz; // Number of x, y, and z     
173                                                   
174 G4int fNxy; // Cached fNx*fNy                     
175 long int fNumGridCells; // Cached fNx*fNy*fNz     
176                                                   
177 G4double fCollisionLimit2;                        
178 // Threshold distance squared when checking fo    
179                                                   
180 G4int fNumNewPointTries = 100;                    
181 // How many times we try to place droplets        
182                                                   
183 G4double fMaxDropPercent = 1.0;                   
184 // The maximal percentage of skipped droplets     
185                                                   
186 G4int fMaxDropCount;                              
187 // The maximal number of skipped droplets befo    
188                                                   
189 G4int fNumDropped = 0;                            
190 // Number of skipped droplets due to collision    
191                                                   
192 G4int fNumCollisions = 0;                         
193 // How many collisions occured when attempting    
194                                                   
195 // Droplet search variables                       
196 G4int fVectorSearchRadius;                        
197 // maximum vector search radius                   
198                                                   
199 // Droplet placement functions                    
200 // ===========================                    
201 void InitializeGrid();                            
202                                                   
203 G4bool FindNewPoint(G4bool edgeVoxel, G4double    
204                                                   
205 G4double VoxelOverlap(G4ThreeVector voxelCente    
206                                                   
207 bool CheckCollision(G4double x, G4double y, G4    
208 bool CheckCollisionInsideGrid(G4double x, G4do    
209 bool CheckCollisionWithDroplet(G4double x, G4d    
210                                                   
211 // Droplet distance functions                     
212 // ==========================                     
213 void SearchSphere(G4int searchRad, G4double &m    
214                                                   
215 void GetNearestDropletInsideRegion(G4double &m    
216                                                   
217 void GetNearestDropletInsideGrid(G4double &min    
218                                                   
219 void GetNearestDropletInsideGrid(G4double &min    
220                                                   
221 // Voxelized sphere methods                       
222 // ========================                       
223 // a collection of points as in {{x1,y1},{x2,y    
224 typedef std::vector<std::vector<int>> fCircleT    
225                                                   
226 // a collection of points describing a spheric    
227 // with points (x,y,z)=(i-R,j-R,sphere[i][j][k    
228 // that is, first index gives x-position, seco    
229 // gives y-position, and the value gives z-pos    
230 //                                                
231 // this is done so that searching may be optim    
232 // if searching some x=i-R that is outside the    
233 // aerosol's bounding box, immediately increme    
234 // (similar for y).                               
235 typedef std::vector<std::vector<std::vector<in    
236                                                   
237 G4int fMaxCircleR;                                
238 G4int fMaxSphereR;                                
239 G4int fPreSphereR = 20;                           
240 std::vector<fCircleType> fCircleCollection;       
241 std::vector<fSphereType> fSphereCollection;       
242 fSphereType MakeSphere(G4int R);                  
243 fCircleType MakeCircle(G4int R);                  
244 fCircleType MakeHalfCircle(G4int R);              
245                                                   
246 void PopulateGrid(unsigned int xi, unsigned in    
247                                                   
248 // ======                                         
249 // Inline                                         
250 // ======                                         
251 inline bool GetGrid(const G4ThreeVector &p, G4    
252                                                   
253 inline bool AnyIndexOutOfBounds(G4int xGrid, G    
254                                                   
255 inline unsigned int GetGridIndex(unsigned int     
256                                                   
257 inline G4ThreeVector GetIndexCoord(G4int index    
258                                                   
259 inline std::pair<G4int, G4int> GetMinMaxSide(G    
260 };                                                
261                                                   
262 #include "FastAerosol.icc"                        
263                                                   
264 #endif                                            
265