| 1 | /*
 | 
|---|
| 2 |  * LinkedCell_Model.hpp
 | 
|---|
| 3 |  *
 | 
|---|
| 4 |  *  Created on: Nov 15, 2011
 | 
|---|
| 5 |  *      Author: heber
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | #ifndef LINKEDCELL_MODEL_HPP_
 | 
|---|
| 9 | #define LINKEDCELL_MODEL_HPP_
 | 
|---|
| 10 | 
 | 
|---|
| 11 | // include config.h
 | 
|---|
| 12 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 13 | #include <config.h>
 | 
|---|
| 14 | #endif
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #include <boost/multi_array.hpp>
 | 
|---|
| 17 | #include <map>
 | 
|---|
| 18 | 
 | 
|---|
| 19 | #include "LinearAlgebra/defs.hpp"
 | 
|---|
| 20 | #include "LinearAlgebra/RealSpaceMatrix.hpp"
 | 
|---|
| 21 | #include "LinkedCell/types.hpp"
 | 
|---|
| 22 | 
 | 
|---|
| 23 | class Box;
 | 
|---|
| 24 | class IPointCloud;
 | 
|---|
| 25 | class LinkedCell_ModelTest;
 | 
|---|
| 26 | class TesselPoint;
 | 
|---|
| 27 | class Vector;
 | 
|---|
| 28 | 
 | 
|---|
| 29 | namespace LinkedCell {
 | 
|---|
| 30 | 
 | 
|---|
| 31 |   /** This is the model in the MVC ansatz for the LinkedCell structure.
 | 
|---|
| 32 |    *
 | 
|---|
| 33 |    * \sa linkedcell
 | 
|---|
| 34 |    *
 | 
|---|
| 35 |    * The model represents a certain linked cell structure with a specific mesh
 | 
|---|
| 36 |    * size (i.e. edge length). Note that all coordinates are internally always
 | 
|---|
| 37 |    * transformed to [0,1]^3, hence we require the domain (\ref Box) for the
 | 
|---|
| 38 |    * transformation matrices.
 | 
|---|
| 39 |    *
 | 
|---|
| 40 |    * This class stores internally list of particles in three-dimensional arrays.
 | 
|---|
| 41 |    *
 | 
|---|
| 42 |    */
 | 
|---|
| 43 |   class LinkedCell_Model
 | 
|---|
| 44 |   {
 | 
|---|
| 45 |     //!> grant unit test access to internal structure
 | 
|---|
| 46 |     friend class ::LinkedCell_ModelTest;
 | 
|---|
| 47 |   public:
 | 
|---|
| 48 |     LinkedCell_Model(const double radius, const Box &_domain);
 | 
|---|
| 49 |     LinkedCell_Model(IPointCloud &set, const double radius, const Box &_domain);
 | 
|---|
| 50 |     ~LinkedCell_Model();
 | 
|---|
| 51 | 
 | 
|---|
| 52 |     typedef std::pair<tripleIndex,tripleIndex> LinkedCellNeighborhoodBounds;
 | 
|---|
| 53 | 
 | 
|---|
| 54 |     const tripleIndex getIndexToVector(const Vector &position) const;
 | 
|---|
| 55 |     const LinkedCellNeighborhoodBounds getNeighborhoodBounds(const tripleIndex &index, const tripleIndex &step = NearestNeighbors) const;
 | 
|---|
| 56 |     const tripleIndex getStep(const double distance) const;
 | 
|---|
| 57 |     const LinkedCell& getCell(const tripleIndex &index) const;
 | 
|---|
| 58 |     bool checkArrayBounds(const tripleIndex &index) const;
 | 
|---|
| 59 |     void applyBoundaryConditions(tripleIndex &index) const;
 | 
|---|
| 60 | 
 | 
|---|
| 61 |     void addNode(TesselPoint *&Walker);
 | 
|---|
| 62 |     void deleteNode(const TesselPoint *Walker);
 | 
|---|
| 63 |     void moveNode(const TesselPoint *Walker);
 | 
|---|
| 64 | 
 | 
|---|
| 65 |     void setPartition(double distance);
 | 
|---|
| 66 | 
 | 
|---|
| 67 |     //!> static indices to get nearest neighbors as default argument
 | 
|---|
| 68 |     static tripleIndex NearestNeighbors;
 | 
|---|
| 69 | 
 | 
|---|
| 70 |   private:
 | 
|---|
| 71 |     void AllocateCells();
 | 
|---|
| 72 |     void Reset();
 | 
|---|
| 73 |     void insertPointCloud(IPointCloud &set);
 | 
|---|
| 74 | 
 | 
|---|
| 75 |     LinkedCellArray::index getSize(const size_t dim) const;
 | 
|---|
| 76 | 
 | 
|---|
| 77 |     typedef LinkedCellArray::size_type size_type;
 | 
|---|
| 78 |     typedef LinkedCellArray::iterator iterator3;
 | 
|---|
| 79 |     typedef boost::subarray_gen<LinkedCellArray, NDIM-1>::type::iterator iterator2;
 | 
|---|
| 80 |     typedef boost::subarray_gen<LinkedCellArray, NDIM-2>::type::iterator iterator1;
 | 
|---|
| 81 | 
 | 
|---|
| 82 |     typedef std::map<TesselPoint *, LinkedCell *> MapPointToCell;
 | 
|---|
| 83 | 
 | 
|---|
| 84 |     //!> internal shape of multi_array
 | 
|---|
| 85 |     size_type *internal_Sizes;
 | 
|---|
| 86 | 
 | 
|---|
| 87 |     //!> internal index of current cell, this makes going through linked cell faster
 | 
|---|
| 88 |     tripleIndex internal_index;
 | 
|---|
| 89 | 
 | 
|---|
| 90 |     //!> Lookup map to get the cell for a given TesselPoint
 | 
|---|
| 91 |     MapPointToCell CellLookup;
 | 
|---|
| 92 | 
 | 
|---|
| 93 |     //!> edge length per axis
 | 
|---|
| 94 |     boost::array<double, 3> EdgeLength;
 | 
|---|
| 95 | 
 | 
|---|
| 96 |     //!> Linked cell array
 | 
|---|
| 97 |     LinkedCellArray N;
 | 
|---|
| 98 | 
 | 
|---|
| 99 |     //!> matrix to divide Box with
 | 
|---|
| 100 |     RealSpaceMatrix Dimensions;
 | 
|---|
| 101 | 
 | 
|---|
| 102 |     //!> matrix to transform normal position to obtain partitioned position
 | 
|---|
| 103 |     RealSpaceMatrix Partition;
 | 
|---|
| 104 | 
 | 
|---|
| 105 |     //!> Box with matrix transformations and boundary conditions
 | 
|---|
| 106 |     const Box &domain;
 | 
|---|
| 107 |   };
 | 
|---|
| 108 | 
 | 
|---|
| 109 | }
 | 
|---|
| 110 | 
 | 
|---|
| 111 | // inlined functions
 | 
|---|
| 112 | #include "LinkedCell_Model_inline.hpp"
 | 
|---|
| 113 | 
 | 
|---|
| 114 | #endif /* LINKEDCELL_MODEL_HPP_ */
 | 
|---|