source: src/Jobs/Grid/SamplingGrid.hpp@ cb3363

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

Added SamplingGrid::integral().

  • this is also used for output streamer.
  • Property mode set to 100644
File size: 3.8 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 */
30class SamplingGrid : public SamplingGridProperties
31{
32 //!> grant unit test access to private parts
33 friend class SamplingGridTest;
34 //!> grant output operator access
35 friend std::ostream & operator<<(std::ostream &ost, const SamplingGrid& other);
36public:
37 //!> typedef for sampled values
38 typedef std::vector< double > sampledvalues_t;
39
40 /** Constructor for class SamplingGrid.
41 *
42 * \param _begin offset for grid
43 * \param _size edge length of grid
44 * \param _level number of grid points in \f$2^{\text{level}}\f$
45 * \param _sampled_grid sample points
46 */
47 SamplingGrid(const double _begin[3],
48 const double _size,
49 const int _level,
50 const sampledvalues_t &_sampled_grid);
51
52 /** Copy constructor for class SamplingGrid.
53 *
54 * \param _grid grid to copy
55 */
56 SamplingGrid(const SamplingGrid &_grid);
57
58 /** Copy constructor for class SamplingGrid from SamplingGridProperties.
59 *
60 * \param _props properties to copy
61 */
62 SamplingGrid(const SamplingGridProperties &_props);
63
64 /** Copy constructor for class SamplingGrid from SamplingGridProperties.
65 *
66 * \param _props properties to copy
67 * \param _sampled_grid sample points
68 */
69 SamplingGrid(
70 const SamplingGridProperties &_props,
71 const sampledvalues_t &_sampled_grid);
72
73 /** default cstor.
74 */
75 SamplingGrid()
76 {}
77
78 virtual ~SamplingGrid();
79
80 /** Assignment operator.
81 *
82 * \param other other instance to assign ourselves to
83 */
84 SamplingGrid& operator=(const SamplingGrid& other);
85
86 /** Addition operator with another SamplingGrid instance \a other.
87 *
88 * \param other other instance to sum onto this one.
89 * \return ref to this instance
90 */
91 SamplingGrid& operator+=(const SamplingGrid& other)
92 {
93 superposeOtherGrids(other, +1.);
94 return *this;
95 }
96
97 /** Subtraction operator with another SamplingGrid instance \a other.
98 *
99 * \param other other instance to subtract from this one.
100 * \return ref to this instance
101 */
102 SamplingGrid& operator-=(const SamplingGrid& other)
103 {
104 superposeOtherGrids(other, -1.);
105 return *this;
106 }
107
108 /** Returns the numeric integral over the grid.
109 *
110 * @return sum of grid values times volume element
111 */
112 double integral() const;
113
114private:
115 /** Helper function that contains all the logic of how to superpose two
116 * grids.
117 *
118 * Is called by SamplingGrid::operator+=() and SamplingGrid::operator-=()
119 *
120 * @param other other histogram
121 * @param prefactor +1. is then addition, -1. is subtraction.
122 */
123 void superposeOtherGrids(const SamplingGrid &other, const double prefactor);
124
125public:
126 //!> sample points
127 sampledvalues_t sampled_grid;
128
129private:
130 friend class MPQCData;
131
132 friend class boost::serialization::access;
133 // serialization
134 template <typename Archive>
135 void serialize(Archive& ar, const unsigned int version)
136 {
137 ar & boost::serialization::base_object<SamplingGridProperties>(*this);
138 ar & const_cast< sampledvalues_t &>(sampled_grid);
139 }
140};
141
142/** Output operator for class SamplingGrid.
143 *
144 * \param ost output stream to print to
145 * \param other instance to print
146 * \return ref to stream for concatenation
147 */
148std::ostream & operator<<(std::ostream &ost, const SamplingGrid& other);
149
150// we need to give this class a unique key for serialization
151// its is only serialized through its base class FragmentJob
152BOOST_CLASS_EXPORT_KEY(SamplingGrid)
153
154#endif /* SAMPLINGGRID_HPP_ */
Note: See TracBrowser for help on using the repository browser.