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 "Geometry/SimpleBlock.h" 00015 #include <stdexcept> 00016 #include <fstream> 00017 #include <sstream> 00018 #include <iomanip> 00019 00020 #include <boost/limits.hpp> 00021 00022 namespace esys 00023 { 00024 namespace lsm 00025 { 00026 template <typename TmplParticle> 00027 SimpleBlockGenerator<TmplParticle>::SimpleBlockGenerator( 00028 unsigned int numX, 00029 unsigned int numY, 00030 unsigned int numZ, 00031 double radius 00032 ) 00033 : m_radius(radius), 00034 m_dimCounts(numX, numY, numZ) 00035 { 00036 } 00037 00038 template <typename TmplParticle> 00039 Vec3 SimpleBlockGenerator<TmplParticle>::getPos(const Vec3L &idx) 00040 { 00041 return 00042 Vec3( 00043 idx[0]*2.0*getRadius() + getRadius(), 00044 idx[1]*2.0*getRadius() + getRadius(), 00045 idx[2]*2.0*getRadius() + ((m_dimCounts[2] > 1) ? getRadius() : 0.0) 00046 ); 00047 } 00048 00049 template <typename TmplParticle> 00050 int SimpleBlockGenerator<TmplParticle>::getId(const Vec3L &idx) 00051 { 00052 return 00053 idx[0] 00054 + 00055 idx[1]*m_dimCounts[0] 00056 + 00057 idx[2]*m_dimCounts[0]*m_dimCounts[1]; 00058 } 00059 00060 template <typename TmplParticle> 00061 template <typename TmplParticleCollection> 00062 void 00063 SimpleBlockGenerator<TmplParticle>::createParticles( 00064 TmplParticleCollection &particleCollection 00065 ) 00066 { 00067 Vec3L idx(0, 0, 0); 00068 for (idx[2]=0; idx[2] < m_dimCounts[2]; (idx[2])++) 00069 { 00070 for (idx[1]=0; idx[1] < m_dimCounts[1]; (idx[1])++) 00071 { 00072 for (idx[0]=0; idx[0] < m_dimCounts[0]; (idx[0])++) 00073 { 00074 particleCollection.createParticle( 00075 TmplParticle( 00076 getPos(idx), 00077 getRadius(), 00078 getId(idx), 00079 0 00080 ) 00081 ); 00082 } 00083 } 00084 } 00085 } 00086 00087 template <typename TmplParticle> 00088 SimpleBlockGenerator<TmplParticle>::~SimpleBlockGenerator() 00089 { 00090 } 00091 00092 template <typename TmplParticle> 00093 double SimpleBlockGenerator<TmplParticle>::getRadius() const 00094 { 00095 return m_radius; 00096 } 00097 00098 00099 00100 00101 00102 00103 00104 template <typename TmplParticle> 00105 SimpleBlock<TmplParticle>::SimpleBlock( 00106 unsigned int numX, 00107 unsigned int numY, 00108 unsigned int numZ, 00109 double radius 00110 ) 00111 : ParticleCollection<TmplParticle>(), 00112 m_generator(numX, numY, numZ, radius) 00113 { 00114 createParticles(); 00115 } 00116 00117 template <typename TmplParticle> 00118 SimpleBlock<TmplParticle>::~SimpleBlock() 00119 { 00120 } 00121 00122 template <typename TmplParticle> 00123 void SimpleBlock<TmplParticle>::createParticles() 00124 { 00125 m_generator.createParticles(*this); 00126 } 00127 00128 template <typename TmplParticle> 00129 double SimpleBlock<TmplParticle>::getRadius() const 00130 { 00131 return m_generator.getRadius(); 00132 } 00133 } 00134 }