[d82961] | 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 |
|
---|
[e776dc] | 19 | #include "CodePatterns/Observer/Observable.hpp"
|
---|
[2614e2a] | 20 | #include "CodePatterns/Observer/Observer.hpp"
|
---|
[d82961] | 21 | #include "LinearAlgebra/defs.hpp"
|
---|
| 22 | #include "LinearAlgebra/RealSpaceMatrix.hpp"
|
---|
[4459fc] | 23 | #include "LinkedCell/tripleIndex.hpp"
|
---|
[d82961] | 24 | #include "LinkedCell/types.hpp"
|
---|
| 25 |
|
---|
| 26 | class Box;
|
---|
| 27 | class IPointCloud;
|
---|
| 28 | class LinkedCell_ModelTest;
|
---|
[c29915] | 29 | class LinkedCell_ViewTest;
|
---|
[d82961] | 30 | class TesselPoint;
|
---|
| 31 | class Vector;
|
---|
| 32 |
|
---|
| 33 | namespace LinkedCell {
|
---|
| 34 |
|
---|
[c29915] | 35 | class LinkedCell_Controller;
|
---|
| 36 |
|
---|
[d82961] | 37 | /** This is the model in the MVC ansatz for the LinkedCell structure.
|
---|
| 38 | *
|
---|
| 39 | * \sa linkedcell
|
---|
| 40 | *
|
---|
| 41 | * The model represents a certain linked cell structure with a specific mesh
|
---|
| 42 | * size (i.e. edge length). Note that all coordinates are internally always
|
---|
| 43 | * transformed to [0,1]^3, hence we require the domain (\ref Box) for the
|
---|
| 44 | * transformation matrices.
|
---|
| 45 | *
|
---|
| 46 | * This class stores internally list of particles in three-dimensional arrays.
|
---|
| 47 | *
|
---|
| 48 | */
|
---|
[2614e2a] | 49 | class LinkedCell_Model : public Observer
|
---|
[d82961] | 50 | {
|
---|
[c29915] | 51 | //!> grant our own unit test access to internal structure
|
---|
[d82961] | 52 | friend class ::LinkedCell_ModelTest;
|
---|
[c29915] | 53 | //!> grant view's unit test access to internal structure (used as stub there)
|
---|
| 54 | friend class ::LinkedCell_ViewTest;
|
---|
[d82961] | 55 | public:
|
---|
| 56 | ~LinkedCell_Model();
|
---|
| 57 |
|
---|
| 58 | typedef std::pair<tripleIndex,tripleIndex> LinkedCellNeighborhoodBounds;
|
---|
| 59 |
|
---|
| 60 | const tripleIndex getIndexToVector(const Vector &position) const;
|
---|
| 61 | const LinkedCellNeighborhoodBounds getNeighborhoodBounds(const tripleIndex &index, const tripleIndex &step = NearestNeighbors) const;
|
---|
| 62 | const tripleIndex getStep(const double distance) const;
|
---|
| 63 | const LinkedCell& getCell(const tripleIndex &index) const;
|
---|
| 64 | bool checkArrayBounds(const tripleIndex &index) const;
|
---|
| 65 | void applyBoundaryConditions(tripleIndex &index) const;
|
---|
[53d894] | 66 | bool empty() const { return CellLookup.size() == 0; }
|
---|
[d82961] | 67 |
|
---|
[029870] | 68 | void addNode(const TesselPoint *Walker);
|
---|
[d82961] | 69 | void deleteNode(const TesselPoint *Walker);
|
---|
| 70 | void moveNode(const TesselPoint *Walker);
|
---|
| 71 |
|
---|
| 72 | void setPartition(double distance);
|
---|
| 73 |
|
---|
[c80643] | 74 | void insertPointCloud(IPointCloud &set);
|
---|
| 75 |
|
---|
[d82961] | 76 | //!> static indices to get nearest neighbors as default argument
|
---|
| 77 | static tripleIndex NearestNeighbors;
|
---|
| 78 |
|
---|
[2614e2a] | 79 | protected:
|
---|
| 80 | void update(Observable *publisher);
|
---|
| 81 | void recieveNotification(Observable *publisher, Notification_ptr notification);
|
---|
| 82 | void subjectKilled(Observable *publisher);
|
---|
| 83 |
|
---|
[c29915] | 84 | private:
|
---|
| 85 | friend class LinkedCell_Controller;
|
---|
| 86 | // don't allow any one else beside controller to create new models
|
---|
| 87 | LinkedCell_Model(const double radius, const Box &_domain);
|
---|
| 88 | LinkedCell_Model(IPointCloud &set, const double radius, const Box &_domain);
|
---|
| 89 | LinkedCell_Model(const LinkedCell_Model&);
|
---|
| 90 | LinkedCell_Model& operator=(const LinkedCell_Model&);
|
---|
| 91 |
|
---|
[d82961] | 92 | private:
|
---|
| 93 | void AllocateCells();
|
---|
| 94 | void Reset();
|
---|
| 95 |
|
---|
[402f2c] | 96 | void startListening();
|
---|
| 97 | void stopListening();
|
---|
| 98 |
|
---|
[e776dc] | 99 | // forward declaration for external Update class, containing update ops.
|
---|
| 100 | class Update;
|
---|
| 101 | // forward declaration for external changeModel class, containing change queue.
|
---|
| 102 | class changeModel;
|
---|
| 103 | //!> changeModel instance that contains a queue(map) with all changes to do.
|
---|
| 104 | changeModel *Changes;
|
---|
| 105 |
|
---|
[db8960] | 106 | void addNode_internal(const TesselPoint *Walker);
|
---|
| 107 | void deleteNode_internal(const TesselPoint *Walker);
|
---|
| 108 | void moveNode_internal(const TesselPoint *Walker);
|
---|
| 109 |
|
---|
[d82961] | 110 | LinkedCellArray::index getSize(const size_t dim) const;
|
---|
| 111 |
|
---|
| 112 | typedef LinkedCellArray::size_type size_type;
|
---|
| 113 | typedef LinkedCellArray::iterator iterator3;
|
---|
| 114 | typedef boost::subarray_gen<LinkedCellArray, NDIM-1>::type::iterator iterator2;
|
---|
| 115 | typedef boost::subarray_gen<LinkedCellArray, NDIM-2>::type::iterator iterator1;
|
---|
| 116 |
|
---|
[029870] | 117 | typedef std::map<const TesselPoint *, LinkedCell *> MapPointToCell;
|
---|
[d82961] | 118 |
|
---|
| 119 | //!> internal shape of multi_array
|
---|
| 120 | size_type *internal_Sizes;
|
---|
| 121 |
|
---|
| 122 | //!> internal index of current cell, this makes going through linked cell faster
|
---|
| 123 | tripleIndex internal_index;
|
---|
| 124 |
|
---|
| 125 | //!> Lookup map to get the cell for a given TesselPoint
|
---|
| 126 | MapPointToCell CellLookup;
|
---|
| 127 |
|
---|
| 128 | //!> edge length per axis
|
---|
| 129 | boost::array<double, 3> EdgeLength;
|
---|
| 130 |
|
---|
[8c31865] | 131 | // forward declaration for LinkedCellArrayContainer, containing cached LinkedCellArray
|
---|
| 132 | class LinkedCellArrayCache;
|
---|
| 133 | //!> Linked cell array cache
|
---|
| 134 | LinkedCellArrayCache *N;
|
---|
[d82961] | 135 |
|
---|
| 136 | //!> matrix to divide Box with
|
---|
| 137 | RealSpaceMatrix Dimensions;
|
---|
| 138 |
|
---|
| 139 | //!> matrix to transform normal position to obtain partitioned position
|
---|
| 140 | RealSpaceMatrix Partition;
|
---|
| 141 |
|
---|
| 142 | //!> Box with matrix transformations and boundary conditions
|
---|
| 143 | const Box &domain;
|
---|
| 144 | };
|
---|
| 145 |
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | #endif /* LINKEDCELL_MODEL_HPP_ */
|
---|