SpherePackingScenarioGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
FractureNetworkGenerator.h
Go to the documentation of this file.
00001 /*
00002  * FractureNetworkGenerator.h
00003  *
00004  *  Created on: Mar 3, 2012
00005  *      Author: michael
00006  */
00007 
00008 #ifndef FRACTURENETWORKGENERATOR_H_
00009 #define FRACTURENETWORKGENERATOR_H_
00010 
00011 #include <cmath>
00012 #include <cstdlib>
00013 #include <vector>
00014 #include "algorithms/geometries/Channel.h"
00015 #include "tarch/logging/Log.h"
00016 #include "algorithms/CalculationBasics.h"
00017 
00018 namespace algorithms {
00019   namespace channels {
00020     class FractureNetworkGenerator;
00021   } /* namespace channels */
00022 } /* namespace algorithms */
00023 
00024 class algorithms::channels::FractureNetworkGenerator {
00025 public:
00026   FractureNetworkGenerator(
00027       const double& lengthMin,
00028       const double& lengthMax,
00029       const double& widthMin,
00030       const double& widthMax,
00031       const double& orientationMin,
00032       const double& orientationMax,
00033       const double& domainSizePerDirection,
00034       const int&    numObjects);
00035 
00036   virtual
00037   ~FractureNetworkGenerator();
00038 
00044   algorithms::geometries::Channel generateRandomChannel() {
00045 #ifdef Debug
00046     std::stringstream ss;
00047     ss <<"generateRandomChannel()"
00048         << "min orientation: " <<CalculationBasics::toDegree(_orientationMin) <<", "
00049         << "max orientation: " <<CalculationBasics::toDegree(_orientationMax) <<std::endl
00050         ;
00051     _log.debug("generateRandomChannel", ss.str());
00052 #endif
00053     return algorithms::geometries::Channel(
00054         getRandomDoubleInRange(_lengthMin, _lengthMax),
00055         getRandomDoubleInRange(_widthMin,  _widthMax),
00056         getRandomDoubleInRange(_domainMin, _domainMax),
00057         getRandomDoubleInRange(_domainMin, _domainMax),
00058         getRandomDoubleInRange(_orientationMin, _orientationMax)
00059     );
00060   }
00061 
00066   std::vector< algorithms::geometries::Channel >& generateFractureNetwork() {
00067     _channels.clear();
00068     _channels.reserve(_numObjects);
00069     for(unsigned int i=0;i<_numObjects;i++){
00070       _channels.push_back(generateRandomChannel());
00071     }
00072     std::stringstream ss;
00073     ss << "generated " << _numObjects <<" channels";
00074     _log.info("generateFractureNetwork",ss.str());
00075     return _channels;
00076   }
00077 
00078   std::vector<algorithms::geometries::Channel>& getChannels();
00079 private:
00083   double getRandomDoubleInRange(const double& min, const double& max) {
00084     return static_cast<double>(rand())/static_cast<double>((RAND_MAX)) * (max-min) + min;
00085   }
00086 
00087   static tarch::logging::Log _log;
00088   const double&       _lengthMin;
00089   const double&       _lengthMax;
00090   const double&       _widthMin;
00091   const double&       _widthMax;
00092   const double&       _orientationMin;
00093   const double&       _orientationMax;
00094   const double        _domainMin;
00095   const double        _domainMax;
00096   const unsigned int  _numObjects;
00097   std::vector< algorithms::geometries::Channel > _channels;
00098 };
00099 
00100 
00101 #endif /* FRACTURENETWORKGENERATOR_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines