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