source: src/Fragmentation/Summation/SetValues/Fragment.hpp@ 8eafd6

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests 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_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 FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix 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 8eafd6 was fbf143, checked in by Frederik Heber <heber@…>, 12 years ago

Placed Containers, Converter, and SetValues as subfolders into Summation.

  • also libMolecuilderFragmentationSummation is now a shared library, easing linkage to libMolecuilderJobs, and contains all of the three convenience libraries.
  • libMolecuilderFragmentationSetValues is now again convenience, as contained in ..Summation which in turn is shared.
  • KeySetsContainer right now is the link between lib..Summation and lib.. Fragmentation. Hence, we had to extract the module and change it into a shared library, as it is required by libMolecuilderJobs through ..Summation but also by ..Fragmentation that heavily relies on this container.
  • moved parseKeySetFile down into Fragmentation folder to KeySetsContainer, it is also contained in new shared library libMolecuilderFragmentation_ KeySetsContainer.
  • Property mode set to 100644
File size: 4.1 KB
Line 
1/*
2 * Fragment.hpp
3 *
4 * Created on: Aug 8, 2012
5 * Author: heber
6 */
7
8#ifndef FRAGMENT_HPP_
9#define FRAGMENT_HPP_
10
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
17#include <boost/serialization/export.hpp>
18#include <boost/serialization/vector.hpp>
19#include <boost/serialization/utility.hpp>
20
21#include <iosfwd>
22#include <vector>
23
24class FragmentTest;
25
26class Fragment {
27 //!> grant ostream operator access
28 friend std::ostream & operator<<(std::ostream &ost, const Fragment &f);
29 //!> grant unit test access
30 friend class FragmentTest;
31public:
32 typedef std::vector<double> position_t;
33 typedef std::vector< position_t > positions_t;
34 typedef double charge_t;
35 typedef std::vector< charge_t > charges_t;
36 typedef std::pair< position_t, charge_t> nucleus_t;
37 typedef std::vector< nucleus_t > nuclei_t;
38
39 /** Default constructor of class Fragment.
40 *
41 */
42 Fragment();
43
44 /** Default constructor of class Fragment.
45 *
46 */
47 Fragment(const nuclei_t &_nuclei) :
48 nuclei(_nuclei)
49 {}
50
51 /** Constructor of class Fragment.
52 *
53 * @param _positions given positions
54 * @param _charges given charges
55 */
56 Fragment(const positions_t &_positions, const charges_t &_charges);
57
58 /** Adding another fragment onto this one.
59 *
60 * \note The operation is area-conserving, i.e. the new area is the sum of
61 * both areas.
62 *
63 * @param other other fragment
64 * @return ref to this instance
65 */
66 Fragment& operator+=(const Fragment &other);
67
68 /** Assignment operator.
69 *
70 * @param other other fragment to make ourselves equal to
71 * @return ref to this instance
72 */
73 Fragment& operator=(const Fragment &other);
74
75 /** Subtracting another fragment from this one.
76 *
77 * @param other other fragment
78 * @return ref to this instance
79 */
80 Fragment& operator-=(const Fragment &other);
81
82 /** Getter for all stored positions.
83 *
84 * @return vector of positions
85 */
86 positions_t getPositions() const;
87
88 /** Getter for all stored charges.
89 *
90 * @return vector of charges
91 */
92 charges_t getCharges() const;
93
94 /** Equality operator.
95 *
96 * @param other other instance to check against
97 * @return true - both are equal, false - some nucleus_t differ
98 */
99 bool operator==(const Fragment& other) const;
100
101 bool operator!=(const Fragment& other) const
102 {
103 return (!(*this == other));
104 }
105
106 /** Creates type nucleus_t from given \a position and \a charge.
107 *
108 * @param position position of nucleus to create
109 * @param charge charge of nucleus to create
110 * @return nucleus with given \a position and \a charge
111 */
112 static nucleus_t createNucleus(const position_t &position, const double charge);
113
114 /** Helper function to check whether two positions are equal.
115 *
116 * @param a first position
117 * @param b second position
118 * @return a equals b within numerical precision
119 */
120 static bool isPositionEqual(const position_t &a, const position_t &b);
121
122private:
123 /** Helper function that checks whether this nuclei \b position is present.
124 *
125 * This operation is \f${\cal O}(n)\f$
126 *
127 * @param n nuclei to check
128 * @return true - is contained, false - is not contained
129 */
130 bool containsNuclei(const nucleus_t &n) const;
131
132 /** Seeks through all nuclei and removes one with matching \b position if found.
133 *
134 * @param n nuclei to remove
135 */
136 void removeNuclei(const nucleus_t &n);
137
138private:
139 nuclei_t nuclei;
140
141private:
142 friend class boost::serialization::access;
143 // serialization
144 template <typename Archive>
145 void serialize(Archive& ar, const unsigned int version)
146 {
147 ar & nuclei;
148 }
149};
150
151// we need to give this class a unique key for serialization
152BOOST_CLASS_EXPORT_KEY(Fragment)
153
154/** Equality operator for two nuclei.
155 *
156 * @param a first nuclei
157 * @param b second nuclei
158 * @return true - both have same position and charge, false - either charge or position is different
159 */
160bool operator==(const Fragment::nucleus_t &a, const Fragment::nucleus_t &b);
161
162std::ostream & operator<<(std::ostream &ost, const Fragment::nucleus_t &n);
163
164std::ostream & operator<<(std::ostream &ost, const Fragment &f);
165
166template<typename T> T ZeroInstance();
167template<> Fragment ZeroInstance<Fragment>();
168
169#endif /* FRAGMENT_HPP_ */
Note: See TracBrowser for help on using the repository browser.