source: src/Jobs/Grid/SamplingGrid.hpp@ 3d9a8d

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 3d9a8d was 3d9a8d, checked in by Frederik Heber <heber@…>, 12 years ago

SamplingGrid has no more size parameter but an end array.

  • this rather fits into scheme with the later to come window.
  • also several changes in interface due to SamplingGrid::size -> ::end[3] replacement.
  • Property mode set to 100644
File size: 4.7 KB
Line 
1/*
2 * SamplingGrid.hpp
3 *
4 * Created on: 25.07.2012
5 * Author: heber
6 */
7
8#ifndef SAMPLINGGRID_HPP_
9#define SAMPLINGGRID_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <iosfwd>
17#include <vector>
18
19#include "boost/serialization/export.hpp"
20#include "boost/serialization/vector.hpp"
21
22#include "Jobs/Grid/SamplingGridProperties.hpp"
23
24class MPQCData;
25class SamplingGridTest;
26
27/** This class stores a sample function on a three-dimensional grid.
28 *
29 * \note We do not use boost::multi_array because it is not trivial to serialize.
30 *
31 */
32class SamplingGrid : public SamplingGridProperties
33{
34 //!> grant unit test access to private parts
35 friend class SamplingGridTest;
36 //!> grant output operator access
37 friend std::ostream & operator<<(std::ostream &ost, const SamplingGrid& other);
38public:
39 //!> typedef for sampled values
40 typedef std::vector< double > sampledvalues_t;
41
42 /** Constructor for class SamplingGrid.
43 *
44 * \param _begin offset for grid per axis
45 * \param _end edge length of grid per axis
46 * \param _level number of grid points in \f$2^{\mathrm{level}}\f$
47 * \param _sampled_grid sample points
48 */
49 SamplingGrid(const double _begin[3],
50 const double _end[3],
51 const int _level,
52 const sampledvalues_t &_sampled_grid);
53
54 /** Copy constructor for class SamplingGrid.
55 *
56 * \param _grid grid to copy
57 */
58 SamplingGrid(const SamplingGrid &_grid);
59
60 /** Copy constructor for class SamplingGrid from SamplingGridProperties.
61 *
62 * \param _props properties to copy
63 */
64 SamplingGrid(const SamplingGridProperties &_props);
65
66 /** Copy constructor for class SamplingGrid from SamplingGridProperties.
67 *
68 * \param _props properties to copy
69 * \param _sampled_grid sample points
70 */
71 SamplingGrid(
72 const SamplingGridProperties &_props,
73 const sampledvalues_t &_sampled_grid);
74
75 /** default cstor.
76 */
77 SamplingGrid()
78 {}
79
80 virtual ~SamplingGrid();
81
82 /** Assignment operator.
83 *
84 * \param other other instance to assign ourselves to
85 */
86 SamplingGrid& operator=(const SamplingGrid& other);
87
88 /** Addition operator with another SamplingGrid instance \a other.
89 *
90 * \param other other instance to sum onto this one.
91 * \return ref to this instance
92 */
93 SamplingGrid& operator+=(const SamplingGrid& other)
94 {
95 superposeOtherGrids(other, +1.);
96 return *this;
97 }
98
99 /** Element-wise multiplication operator with another SamplingGrid instance \a other.
100 *
101 * \param other other instance to sum onto this one.
102 * \return ref to this instance
103 */
104 SamplingGrid& operator*=(const SamplingGrid& other);
105
106 /** Subtraction operator with another SamplingGrid instance \a other.
107 *
108 * \param other other instance to subtract from this one.
109 * \return ref to this instance
110 */
111 SamplingGrid& operator-=(const SamplingGrid& other)
112 {
113 superposeOtherGrids(other, -1.);
114 return *this;
115 }
116
117 /** Returns the numeric integral over the grid.
118 *
119 * @return sum of grid values times volume element
120 */
121 double integral() const;
122
123 /** Returns the numeric integral over the grid where the grid is element-wise multiplied with \a weight.
124 *
125 * @param weight grid of weights
126 * @return sum of grid values weighted by respective element in weight times volume element
127 */
128 double integral(const SamplingGrid &weight) const;
129
130private:
131 /** Returns the volume of the domain for this sampled function.
132 *
133 * @return volume
134 */
135 double getVolume() const;
136
137 /** Helper function that contains all the logic of how to superpose two
138 * grids.
139 *
140 * Is called by SamplingGrid::operator+=() and SamplingGrid::operator-=()
141 *
142 * @param other other histogram
143 * @param prefactor +1. is then addition, -1. is subtraction.
144 */
145 void superposeOtherGrids(const SamplingGrid &other, const double prefactor);
146
147public:
148 //!> sample points
149 sampledvalues_t sampled_grid;
150
151private:
152 friend class MPQCData;
153
154 friend class boost::serialization::access;
155 // serialization
156 template <typename Archive>
157 void serialize(Archive& ar, const unsigned int version)
158 {
159 ar & boost::serialization::base_object<SamplingGridProperties>(*this);
160 ar & const_cast< sampledvalues_t &>(sampled_grid);
161 }
162};
163
164/** Output operator for class SamplingGrid.
165 *
166 * \param ost output stream to print to
167 * \param other instance to print
168 * \return ref to stream for concatenation
169 */
170std::ostream & operator<<(std::ostream &ost, const SamplingGrid& other);
171
172template<typename T> T ZeroInstance();
173template<> SamplingGrid ZeroInstance<SamplingGrid>();
174
175// we need to give this class a unique key for serialization
176// its is only serialized through its base class FragmentJob
177BOOST_CLASS_EXPORT_KEY(SamplingGrid)
178
179#endif /* SAMPLINGGRID_HPP_ */
Note: See TracBrowser for help on using the repository browser.