source: src/LinkedCell/LinkedCell_Model.hpp@ 8c31865

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 8c31865 was 8c31865, checked in by Frederik Heber <heber@…>, 13 years ago

Added new class LinkedCellArrayCache that performs the lazy updates on a LinkedCellArray.

  • basically, we cache all write operations and perform them first when there is a read operation that requires an up-to-date structure.
  • we cannot do this via the Cacheable pattern was there we always have a return value of the update structure. It is currently unknown how to initialize a cached pointer (apart from always checking for this in the update function).
  • Property mode set to 100644
File size: 4.3 KB
Line 
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/Observable.hpp"
20#include "CodePatterns/Observer/Observer.hpp"
21#include "LinearAlgebra/defs.hpp"
22#include "LinearAlgebra/RealSpaceMatrix.hpp"
23#include "LinkedCell/tripleIndex.hpp"
24#include "LinkedCell/types.hpp"
25
26class Box;
27class IPointCloud;
28class LinkedCell_ModelTest;
29class TesselPoint;
30class Vector;
31
32namespace LinkedCell {
33
34 /** This is the model in the MVC ansatz for the LinkedCell structure.
35 *
36 * \sa linkedcell
37 *
38 * The model represents a certain linked cell structure with a specific mesh
39 * size (i.e. edge length). Note that all coordinates are internally always
40 * transformed to [0,1]^3, hence we require the domain (\ref Box) for the
41 * transformation matrices.
42 *
43 * This class stores internally list of particles in three-dimensional arrays.
44 *
45 */
46 class LinkedCell_Model : public Observer
47 {
48 //!> grant unit test access to internal structure
49 friend class ::LinkedCell_ModelTest;
50 public:
51 LinkedCell_Model(const double radius, const Box &_domain);
52 LinkedCell_Model(IPointCloud &set, const double radius, const Box &_domain);
53 ~LinkedCell_Model();
54
55 typedef std::pair<tripleIndex,tripleIndex> LinkedCellNeighborhoodBounds;
56
57 const tripleIndex getIndexToVector(const Vector &position) const;
58 const LinkedCellNeighborhoodBounds getNeighborhoodBounds(const tripleIndex &index, const tripleIndex &step = NearestNeighbors) const;
59 const tripleIndex getStep(const double distance) const;
60 const LinkedCell& getCell(const tripleIndex &index) const;
61 bool checkArrayBounds(const tripleIndex &index) const;
62 void applyBoundaryConditions(tripleIndex &index) const;
63 bool empty() const { return CellLookup.size() == 0; }
64
65 void addNode(const TesselPoint *Walker);
66 void deleteNode(const TesselPoint *Walker);
67 void moveNode(const TesselPoint *Walker);
68
69 void setPartition(double distance);
70
71 void insertPointCloud(IPointCloud &set);
72
73 //!> static indices to get nearest neighbors as default argument
74 static tripleIndex NearestNeighbors;
75
76 protected:
77 void update(Observable *publisher);
78 void recieveNotification(Observable *publisher, Notification_ptr notification);
79 void subjectKilled(Observable *publisher);
80
81 private:
82 void AllocateCells();
83 void Reset();
84
85 void startListening();
86 void stopListening();
87
88 // forward declaration for external Update class, containing update ops.
89 class Update;
90 // forward declaration for external changeModel class, containing change queue.
91 class changeModel;
92 //!> changeModel instance that contains a queue(map) with all changes to do.
93 changeModel *Changes;
94
95 void addNode_internal(const TesselPoint *Walker);
96 void deleteNode_internal(const TesselPoint *Walker);
97 void moveNode_internal(const TesselPoint *Walker);
98
99 LinkedCellArray::index getSize(const size_t dim) const;
100
101 typedef LinkedCellArray::size_type size_type;
102 typedef LinkedCellArray::iterator iterator3;
103 typedef boost::subarray_gen<LinkedCellArray, NDIM-1>::type::iterator iterator2;
104 typedef boost::subarray_gen<LinkedCellArray, NDIM-2>::type::iterator iterator1;
105
106 typedef std::map<const TesselPoint *, LinkedCell *> MapPointToCell;
107
108 //!> internal shape of multi_array
109 size_type *internal_Sizes;
110
111 //!> internal index of current cell, this makes going through linked cell faster
112 tripleIndex internal_index;
113
114 //!> Lookup map to get the cell for a given TesselPoint
115 MapPointToCell CellLookup;
116
117 //!> edge length per axis
118 boost::array<double, 3> EdgeLength;
119
120 // forward declaration for LinkedCellArrayContainer, containing cached LinkedCellArray
121 class LinkedCellArrayCache;
122 //!> Linked cell array cache
123 LinkedCellArrayCache *N;
124
125 //!> matrix to divide Box with
126 RealSpaceMatrix Dimensions;
127
128 //!> matrix to transform normal position to obtain partitioned position
129 RealSpaceMatrix Partition;
130
131 //!> Box with matrix transformations and boundary conditions
132 const Box &domain;
133 };
134
135}
136
137#endif /* LINKEDCELL_MODEL_HPP_ */
Note: See TracBrowser for help on using the repository browser.