ESyS-Particle  4.0.1
GougeBlock3D.h
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 #ifndef ESYS_LSMGOUGEBLOCK3D_H
00015 #define ESYS_LSMGOUGEBLOCK3D_H
00016 
00017 #include "Foundation/BoundingBox.h"
00018 #include "Geometry/CircularNeighbourTable.h"
00019 #include "Geometry/BlockGenerator.h"
00020 #include "Geometry/Plane.h"
00021 #include "Geometry/BasicInteraction.h"
00022 
00023 #include <boost/shared_ptr.hpp>
00024 
00025 #include <vector>
00026 #include <float.h>
00027 
00028 namespace esys
00029 {
00030   namespace lsm
00031   {
00032     typedef std::vector<Plane> PlaneVector;
00033     enum Orientation
00034     {
00035       XY,
00036       XZ,
00037       YZ
00038     };
00039 
00040     class ParticleBlockPrms
00041     {
00042     public:
00043       ParticleBlockPrms();
00044 
00045       ParticleBlockPrms(double size, double minRadius, double maxRadius);
00046 
00047       ~ParticleBlockPrms();
00048 
00049       double m_size;
00050       double m_minRadius;
00051       double m_maxRadius;
00052     };
00053 
00054     typedef std::vector<bool> BoolVector;
00055     typedef std::vector<BoundingBox> BoundingBoxVector;
00056     
00057     class PackingInfo
00058     {
00059     public:
00060       PackingInfo(
00061         const BoundingBox &bBox,
00062         const BoolVector  &periodicDimensions,
00063         Orientation       orientation,
00064         double            minRadius,
00065         double            maxRadius
00066       );
00067       
00068       bool is3d() const;
00069       
00070       void initialiseFitPlaneVector();
00071       
00072       const BoundingBox &getBBox() const;
00073       
00074       const PlaneVector &getFitPlaneVector() const;
00075       
00076       double getMinRadius() const;
00077       
00078       double getMaxRadius() const;
00079       
00080       const BoolVector &getPeriodicDimensions() const;
00081     private:
00082       BoundingBox m_bBox;
00083       BoolVector  m_periodicDimensions;
00084       Orientation m_orientation;
00085       double      m_minRadius;
00086       double      m_maxRadius;
00087       PlaneVector m_fitPlaneVector;
00088     };
00089 
00090     typedef std::vector<PackingInfo> PackingInfoVector;
00091     class GougeBlockPrms
00092     {
00093     public:
00094       GougeBlockPrms();
00098       GougeBlockPrms(
00099         const BoundingBox       &bBox,
00100         double                  padRadius,
00101         Orientation             orientation,
00102         const ParticleBlockPrms &faultRegionPrms,
00103         const ParticleBlockPrms &gougeRegionPrms,
00104         const BoolVector        &peridicDimensions=BoolVector(3, false),
00105         int                     maxInsertionFailures=100,
00106         double                  tolerance = DBL_EPSILON*128,
00107         double                  connectionTolerance = DBL_EPSILON*128*10
00108       );
00109 
00110       ~GougeBlockPrms();
00111 
00112       double getTolerance() const;
00113 
00114       double getConnectionTolerance() const;
00115 
00116       const BoundingBox &getBBox() const;
00117 
00118       int getMaxInsertionFailures() const;
00119 
00120       double getRegularBlockRadius() const;
00121 
00122       double getFaultMinRadius() const;
00123 
00124       double getFaultMaxRadius() const;
00125 
00126       double getGougeMinRadius() const;
00127 
00128       double getGougeMaxRadius() const;
00129 
00130       const BoolVector &getPeriodicDimensions() const;
00131 
00132       BoundingBoxVector getRegularBBoxVector() const;
00133 
00134       PackingInfoVector getGougePackingInfoVector() const;
00135 
00136       PackingInfoVector getFaultPackingInfoVector() const;
00137 
00138       BoundingBox cutFromCentre(double d1, double d2) const;
00139 
00140       Orientation getOrientation() const;
00141 
00142       int getOrientationIndex() const;
00143 
00144       double getOrientationSize() const;
00145 
00146       double getMaxRadius() const;
00147       
00148       double getMinRadius() const;
00149       
00150       bool is2d() const;
00151 
00152     private:
00153       BoundingBox       m_bBox;
00154       double            m_padRadius;
00155       Orientation       m_orientation;
00156       ParticleBlockPrms m_faultPrms;
00157       ParticleBlockPrms m_gougePrms;
00158       BoolVector        m_periodicDimensions;
00159       int               m_maxInsertionFailures;
00160       double            m_tolerance;
00161       double            m_connectionTolerance;
00162     };
00163 
00168     class GougeBlock3D
00169     {
00170     public:
00171       typedef SimpleParticle Particle;
00172       GougeBlock3D(const GougeBlockPrms &prms);
00173 
00174       virtual ~GougeBlock3D();
00175 
00176       virtual void generate();
00177 
00178       int getNumParticles() const;
00179 
00180       typedef CircularNeighbourTable<SimpleParticle> NTable;
00181       typedef boost::shared_ptr<NTable>              NTablePtr;
00182       typedef boost::shared_ptr<BlockGenerator>      GeneratorPtr;
00183       typedef std::vector<GeneratorPtr>              GeneratorPtrVector;
00184       typedef NTable::ParticlePool                   ParticlePool;
00185       typedef NTable::ParticlePoolPtr                ParticlePoolPtr;
00186 
00187       const GeneratorPtrVector &getGougeGeneratorVector() const;
00188 
00189       const GeneratorPtrVector &getFaultGeneratorVector() const;
00190 
00191       bool isGougeParticle(const SimpleParticle &particle) const;
00192 
00193       bool areInDifferentFaultBlocks(
00194         const SimpleParticle &p1,
00195         const SimpleParticle &p2
00196       ) const;
00197 
00198       virtual void write(std::ostream &oStream) const;
00199 
00200       void writeToFile(const std::string &fileName) const;
00201 
00202       void tagGougeParticles(int tag);
00203 
00204       void tagFaultParticles(int tag);
00205       
00206       void tagDrivingPlateParticles(
00207         int minDrivingTag,
00208         int maxDrivingTag,
00209         double distanceFromBBoxEdge
00210       );
00211 
00212       typedef std::set<BasicInteraction,BILess> InteractionSet;
00213       
00214       virtual void createInteractionSet();
00215 
00216       const InteractionSet &getInteractionSet() const;
00217 
00218       template <typename TmplVisitor>
00219       void visitParticles(TmplVisitor &visitor)
00220       {
00221         for (
00222           GeneratorPtrVector::iterator it = m_genPtrVector.begin();
00223           it != m_genPtrVector.end();
00224           it++
00225         )
00226         {
00227           BlockGenerator::ParticleIterator particleIt = (*it)->getParticleIterator();
00228           while (particleIt.hasNext()) {
00229             particleIt.next()->visit(visitor);
00230           }
00231         }
00232       }
00233 
00234       template <typename TmplVisitor>
00235       void visitParticles(const TmplVisitor &visitor) const
00236       {
00237         for (
00238           GeneratorPtrVector::const_iterator it = m_genPtrVector.begin();
00239           it != m_genPtrVector.end();
00240           it++
00241         )
00242         {
00243           BlockGenerator::ParticleIterator particleIt = (*it)->getParticleIterator();
00244           while (particleIt.hasNext()) {
00245             particleIt.next()->visit(visitor);
00246           }
00247         }
00248       }
00249 
00250       template <typename TmplVisitor>
00251       void visitInteractions(TmplVisitor &visitor) const
00252       {
00253         const InteractionSet &interactionSet = getInteractionSet();
00254         for (
00255           InteractionSet::const_iterator it = interactionSet.begin();
00256           it != interactionSet.end();
00257           it++
00258         )
00259         {
00260           it->visit(visitor);
00261         }
00262       }
00263       
00264       const GougeBlockPrms &getPrms() const
00265       {
00266         return m_prms;
00267       }
00268 
00269     protected:
00270       NTablePtr          m_nTablePtr;
00271       GougeBlockPrms     m_prms;
00272       InteractionSet     m_interactionSet;
00273       GeneratorPtrVector m_gougeGenPtrVector;
00274       GeneratorPtrVector m_genPtrVector;
00275       ParticlePoolPtr    m_particlePoolPtr;
00276 
00277       void createRegularBlockGenerators();
00278       void createFaultBlockGenerators();
00279       virtual void createGougeBlockGenerators();
00280 
00281     private:
00282       GeneratorPtrVector m_regularGenPtrVector;
00283       GeneratorPtrVector m_faultGenPtrVector;
00284     };
00285   };
00286 };
00287 
00288 #endif