ESyS-Particle
4.0.1
|
00001 00002 // // 00003 // Copyright (c) 2003-2011 by The University of Queensland // 00004 // Earth Systems Science Computational Centre (ESSCC) // 00005 // http://www.uq.edu.au/esscc // 00006 // // 00007 // Primary Business: Brisbane, Queensland, Australia // 00008 // Licensed under the Open Software License version 3.0 // 00009 // http://www.opensource.org/licenses/osl-3.0.php // 00010 // // 00012 00013 00014 #include "Foundation/Rng.h" 00015 00016 namespace esys 00017 { 00018 namespace lsm 00019 { 00020 template <typename TmplParticle> 00021 ConstRadiusGen<TmplParticle>::ConstRadiusGen(double radius) 00022 : m_radius(radius) 00023 { 00024 } 00025 00026 template <typename TmplParticle> 00027 const double &ConstRadiusGen<TmplParticle>::getParticleRadius() const 00028 { 00029 return m_radius; 00030 } 00031 00032 template <typename TmplParticle> 00033 const double &ConstRadiusGen<TmplParticle>::getMinFitRadius() const 00034 { 00035 return this->getParticleRadius(); 00036 } 00037 00038 template <typename TmplParticle> 00039 const double &ConstRadiusGen<TmplParticle>::getMaxFitRadius() const 00040 { 00041 return this->getParticleRadius(); 00042 } 00043 00044 template <typename TmplParticle> 00045 typename ConstRadiusGen<TmplParticle>::Particle 00046 ConstRadiusGen<TmplParticle>::getParticle(const Vec3 &posn) const 00047 { 00048 return Particle(posn, getParticleRadius()); 00049 } 00050 00051 template <typename TmplParticle> 00052 typename ConstRadiusGen<TmplParticle>::Particle 00053 ConstRadiusGen<TmplParticle>::getParticle( 00054 const Vec3 &posn, 00055 const double &maxRadius 00056 ) const 00057 { 00058 return getParticle(posn); 00059 } 00060 00061 template <typename TmplParticle> 00062 bool ConstRadiusGen<TmplParticle>::isValidFitRadius( 00063 const double &fitRadius 00064 ) const 00065 { 00066 return (fitRadius == getParticleRadius()); 00067 } 00068 //======================================================================== 00069 //======================================================================== 00070 //======================================================================== 00071 template <typename TmplParticle> 00072 RangeRadiusGen<TmplParticle>::RangeRadiusGen( 00073 double minFitRadius, 00074 double maxFitRadius 00075 ) 00076 : m_minFitRadius(minFitRadius), 00077 m_maxFitRadius(maxFitRadius) 00078 { 00079 } 00080 00081 template <typename TmplParticle> 00082 RangeRadiusGen<TmplParticle>::~RangeRadiusGen() 00083 { 00084 } 00085 00086 template <typename TmplParticle> 00087 const double &RangeRadiusGen<TmplParticle>::getMinFitRadius() const 00088 { 00089 return m_minFitRadius; 00090 } 00091 00092 template <typename TmplParticle> 00093 const double &RangeRadiusGen<TmplParticle>::getMaxFitRadius() const 00094 { 00095 return m_maxFitRadius; 00096 } 00097 00098 template <typename TmplParticle> 00099 bool RangeRadiusGen<TmplParticle>::isValidFitRadius( 00100 const double &fitRadius 00101 ) const 00102 { 00103 return 00104 ( 00105 (fitRadius >= this->getMinFitRadius()) 00106 && 00107 (fitRadius <= this->getMaxFitRadius()) 00108 ); 00109 } 00110 //======================================================================== 00111 //======================================================================== 00112 //======================================================================== 00113 template <typename TmplParticle> 00114 RndRadiusGen<TmplParticle>::RndRadiusGen( 00115 double minFitRadius, 00116 double maxFitRadius 00117 ) : Inherited(minFitRadius, maxFitRadius) 00118 { 00119 } 00120 00121 template <typename TmplParticle> 00122 double RndRadiusGen<TmplParticle>::getRandomRadius() const 00123 { 00124 return 00125 this->getMinFitRadius() 00126 + 00127 (this->getMaxFitRadius()-this->getMinFitRadius()) 00128 * 00129 rng::s_zeroOneUniform(); 00130 } 00131 00132 template <typename TmplParticle> 00133 typename RndRadiusGen<TmplParticle>::Particle 00134 RndRadiusGen<TmplParticle>::getParticle(const Vec3 &posn) const 00135 { 00136 return Particle(posn, getRandomRadius()); 00137 } 00138 00139 template <typename TmplParticle> 00140 typename RndRadiusGen<TmplParticle>::Particle 00141 RndRadiusGen<TmplParticle>::getParticle( 00142 const Vec3 &posn, 00143 double suggestedRadius 00144 ) const 00145 { 00146 return getParticle(posn); 00147 } 00148 //======================================================================== 00149 //======================================================================== 00150 //======================================================================== 00151 template <typename TmplGrain> 00152 GrainRndRadiusGen<TmplGrain>::GrainRndRadiusGen( 00153 double minGrainRadius, 00154 double maxGrainRadius 00155 ) : Inherited(minGrainRadius, maxGrainRadius) 00156 { 00157 } 00158 00159 template <typename TmplGrain> 00160 GrainRndRadiusGen<TmplGrain>::~GrainRndRadiusGen() 00161 { 00162 } 00163 00164 template <typename TmplGrain> 00165 const double &GrainRndRadiusGen<TmplGrain>::getMinGrainRadius() const 00166 { 00167 return this->getMinFitRadius(); 00168 } 00169 00170 template <typename TmplGrain> 00171 const double &GrainRndRadiusGen<TmplGrain>::getMaxGrainRadius() const 00172 { 00173 return this->getMaxFitRadius(); 00174 } 00175 00176 //======================================================================== 00177 //======================================================================== 00178 //======================================================================== 00179 00180 template <typename TmplGrain> 00181 SingleParticleGrainGen<TmplGrain>::SingleParticleGrainGen( 00182 double minGrainRadius, 00183 double maxGrainRadius 00184 ) : Inherited(minGrainRadius, maxGrainRadius) 00185 { 00186 } 00187 00188 template <typename TmplGrain> 00189 const double &SingleParticleGrainGen<TmplGrain>::getMinParticleRadius() const 00190 { 00191 return this->getMinGrainRadius(); 00192 } 00193 00194 template <typename TmplGrain> 00195 const double &SingleParticleGrainGen<TmplGrain>::getMaxParticleRadius() const 00196 { 00197 return this->getMaxGrainRadius(); 00198 } 00199 00200 template <typename TmplGrain> 00201 typename SingleParticleGrainGen<TmplGrain>::Grain 00202 SingleParticleGrainGen<TmplGrain>::getGrain(const Particle &p) 00203 { 00204 Grain g; 00205 g.createParticle(p); 00206 return g; 00207 } 00208 } 00209 }