| 1 | /*
|
|---|
| 2 | * LinkedCell_Controller.hpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Nov 15, 2011
|
|---|
| 5 | * Author: heber
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #ifndef LINKEDCELL_CONTROLLER_HPP_
|
|---|
| 9 | #define LINKEDCELL_CONTROLLER_HPP_
|
|---|
| 10 |
|
|---|
| 11 | // include config.h
|
|---|
| 12 | #ifdef HAVE_CONFIG_H
|
|---|
| 13 | #include <config.h>
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 | #include <map>
|
|---|
| 17 |
|
|---|
| 18 | #include "CodePatterns/Range.hpp"
|
|---|
| 19 | #include "LinkedCell/LinkedCell_View.hpp"
|
|---|
| 20 |
|
|---|
| 21 | class LinkedCell_ControllerTest;
|
|---|
| 22 |
|
|---|
| 23 | namespace LinkedCell {
|
|---|
| 24 |
|
|---|
| 25 | class LinkedCell_Model;
|
|---|
| 26 |
|
|---|
| 27 | /** This is the controller in the MVC ansatz for the LinkedCell structure.
|
|---|
| 28 | *
|
|---|
| 29 | * \sa linkedcell
|
|---|
| 30 | *
|
|---|
| 31 | * The Controller contains multiple models (i.e. LinkedCell instances) and he
|
|---|
| 32 | * takes care that the view (the interface) can give its functionality with
|
|---|
| 33 | * low computational complexity.
|
|---|
| 34 | *
|
|---|
| 35 | * Here, it contains multiple LinkedCell models, each with different edge
|
|---|
| 36 | * lengths of the inherent mesh. You request a LinkedCell instance from the
|
|---|
| 37 | * controller, but you basically just receive a const interface reference
|
|---|
| 38 | * to a present LinkedCell instance.
|
|---|
| 39 | *
|
|---|
| 40 | */
|
|---|
| 41 | class LinkedCell_Controller
|
|---|
| 42 | {
|
|---|
| 43 | //!> grant unit tests access to internal parts
|
|---|
| 44 | friend class ::LinkedCell_ControllerTest;
|
|---|
| 45 | public:
|
|---|
| 46 | LinkedCell_Controller(const Box &_domain);
|
|---|
| 47 | ~LinkedCell_Controller();
|
|---|
| 48 |
|
|---|
| 49 | LinkedCell_View getView(const double distance);
|
|---|
| 50 |
|
|---|
| 51 | private:
|
|---|
| 52 | const LinkedCell_Model * getBestModel(const double distance) const;
|
|---|
| 53 | const range<double> getHeuristicRange(const double distance) const;
|
|---|
| 54 | void insertNewModel(const double edgelength, LinkedCell_Model*& instance);
|
|---|
| 55 |
|
|---|
| 56 | private:
|
|---|
| 57 | //!> typedef for the (edge length, model) map
|
|---|
| 58 | typedef std::map<double, LinkedCell_Model* > MapEdgelengthModel;
|
|---|
| 59 |
|
|---|
| 60 | //!> internal map of present LinkedCell_Model instances by their egde length
|
|---|
| 61 | MapEdgelengthModel ModelsMap;
|
|---|
| 62 |
|
|---|
| 63 | //!> lower threshold below which no new instances are generated.
|
|---|
| 64 | static double lower_threshold;
|
|---|
| 65 |
|
|---|
| 66 | //!> upper threshold above which no new instances are generated.
|
|---|
| 67 | static double upper_threshold;
|
|---|
| 68 |
|
|---|
| 69 | //!> internal reference to domain required for constructing LinkedCell_Model instances.
|
|---|
| 70 | const Box &domain;
|
|---|
| 71 | };
|
|---|
| 72 |
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | #endif /* LINKEDCELL_CONTROLLER_HPP_ */
|
|---|