source: src/Atom/atom.hpp@ 910a5d

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

atom::father is now accessible through getter and setter only.

  • this allows to manage signing on and off to and from father to be notified when it's destroyed.
  • Property mode set to 100644
File size: 7.7 KB
Line 
1/*
2 * atom.hpp
3 *
4 * Created on: Aug 3, 2009
5 * Author: heber
6 */
7
8#ifndef ATOM_HPP_
9#define ATOM_HPP_
10
11using namespace std;
12
13/*********************************************** includes ***********************************/
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include <iosfwd>
21#include <list>
22#include <vector>
23
24#include "atom_atominfo.hpp"
25#include "atom_bondedparticle.hpp"
26#include "atom_graphnode.hpp"
27#include "atom_particleinfo.hpp"
28#include "Atom/TesselPoint.hpp"
29#include "types.hpp"
30
31#include "CodePatterns/enumeration.hpp"
32
33/****************************************** forward declarations *****************************/
34
35class AtomicInfo;
36class Vector;
37class World;
38class molecule;
39class Shape;
40
41/********************************************** declarations *******************************/
42
43/** Single atom.
44 * Class incorporates position, type
45 */
46class atom : public GraphNode, public BondedParticle, public TesselPoint {
47 friend atom* NewAtom(atomId_t);
48 friend void DeleteAtom(atom*);
49
50 atom *father; //!< In many-body bond order fragmentations points to originating atom
51 int *sort; //!< sort criteria
52
53public:
54
55 /** Clones this atom.
56 *
57 * Does not clone the bonds!
58 *
59 * @return reference to atom
60 */
61 virtual atom *clone();
62
63 /** Pushes back another step in all trajectory vectors.
64 *
65 * This allows to extend all trajectories contained in different classes
66 * consistently. This is implemented by the topmost class which calls the
67 * real functions, \sa AppendTrajectoryStep(), by all necessary subclasses.
68 */
69 virtual void UpdateStep(const unsigned int _step);
70
71 /** Pops the last step in all trajectory vectors.
72 *
73 * This allows to decrease all trajectories contained in different classes
74 * by one consistently. This is implemented by the topmost class which calls
75 * the real functions, \sa removeTrajectoryStep(), by all necessary subclasses.
76 */
77 virtual void removeStep(const unsigned int _step);
78
79 /** Output of a single atom with given numbering.
80 * \param ElementNo cardinal number of the element
81 * \param AtomNo cardinal number among these atoms of the same element
82 * \param *out stream to output to
83 * \param *comment commentary after '#' sign
84 * \return true - \a *out present, false - \a *out is NULL
85 */
86 bool OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const;
87
88 /** Output of a single atom with numbering from array according to atom::type.
89 * \param *ElementNo cardinal number of the element
90 * \param *AtomNo cardinal number among these atoms of the same element
91 * \param *out stream to output to
92 * \param *comment commentary after '#' sign
93 * \return true - \a *out present, false - \a *out is NULL
94 */
95 bool OutputArrayIndexed(ostream * const out,const enumeration<const element*>&, int *AtomNo, const char *comment = NULL) const;
96
97 /** Initialises the component number array.
98 * Size is set to atom::ListOfBonds.size()+1 (last is th encode end by -1)
99 */
100 void InitComponentNr();
101
102 /** Resets GraphNr to -1.
103 *
104 */
105 void resetGraphNr();
106
107 /** Check whether father is equal to given atom.
108 * \param *ptr atom to compare father to
109 * \param **res return value (only set if atom::father is equal to \a *ptr)
110 */
111 void EqualsFather ( const atom *ptr, const atom **res ) const;
112
113 /** States whether the given \a *ptr is our father.
114 *
115 * @param ptr atom to compare atom::Father with
116 * @return true - \a *ptr is father, false - not
117 */
118 bool isFather(const atom *ptr);
119
120 /** If we are copy of copy, we are linked to be just a copy.
121 *
122 */
123 void CorrectFather();
124
125 /** Climbs up the father list until NULL, last is returned.
126 * \return true father, i.e. whose father points to itself, NULL if it could not be found or has none (added hydrogen)
127 */
128 atom *GetTrueFather();
129
130 /** Const version of \sa GetTrueFather().
131 * \return true father, i.e. whose father points to itself, NULL if it could not be found or has none (added hydrogen)
132 */
133 const atom *GetTrueFather() const;
134
135 /** Const getter for the atoms father.
136 *
137 * \return father of this atom
138 */
139 atom * const getFather() const
140 { return father; }
141
142 /** Sets the father for this atom.
143 *
144 * \param _father ptr to father atom
145 */
146 void setFather(atom * const _father);
147
148 /** Compares the indices of \a this atom with a given \a ptr.
149 * \param ptr atom to compare index against
150 * \return true - this one's is smaller, false - not
151 */
152 bool Compare(const atom &ptr) const;
153
154 /** Returns distance to a given vector.
155 * \param origin vector to calculate distance to
156 * \return distance
157 */
158 double DistanceToVector(const Vector &origin) const;
159
160 /** Returns squared distance to a given vector.
161 * \param origin vector to calculate distance to
162 * \return distance squared
163 */
164 double DistanceSquaredToVector(const Vector &origin) const;
165
166 // getter and setter
167
168 /**
169 * returns the World that contains this atom.
170 * Use this if you need to get the world without locking
171 * the singleton for example.
172 *
173 */
174 World *getWorld();
175 void setWorld(World*);
176
177 virtual atomId_t getId() const;
178 virtual bool changeId(atomId_t newId);
179
180 /**
181 * this function sets the Id without notifying the world. Only use it, if the world has already
182 * gotten an ID for this Atom.
183 */
184 virtual void setId(atomId_t);
185
186 /** Returns pointer to the molecule which atom belongs to.
187 * \return containing molecule
188 */
189 molecule* getMolecule() const;
190
191 /** Erases the atom in atom::mol's list of atoms and sets it to zero.
192 */
193 void removeFromMolecule();
194
195 /** Changes the molecule internal ParticleInfo::Nr of this atom.
196 *
197 * @param newNr new ParticleInfo::Nr to set
198 * @return true - change successful, false - changed not successful, id remains the old one
199 */
200 bool changeNr(int newNr);
201
202 /** Getter for ParticleInfo::Nr of the atom.
203 *
204 * @return index
205 */
206 int getNr() const;
207
208 // Output operator
209 std::ostream & operator << (std::ostream &ost) const;
210
211 protected:
212
213 /**
214 * Protected constructor to ensure construction of atoms through the world.
215 * see World::createAtom()
216 */
217 atom();
218
219 /**
220 * Protected copy-constructor to ensure construction of atoms by cloning.
221 * see atom::clone()
222 */
223 atom(class atom *pointer);
224
225 /**
226 * Protected destructor to ensure destruction of atoms through the world.
227 * see World::destroyAtom()
228 */
229 virtual ~atom();
230 private:
231 friend class molecule;
232 friend class AtomicInfo;
233 /** Makes the atom be contained in the new molecule \a *_mol.
234 * Uses atom::removeFromMolecule() to delist from old molecule.
235 * \param *_mol pointer to new molecule
236 */
237 void setMolecule(molecule*);
238
239 /** Makes the atom be contained in the no molecule.
240 * Use atom::removeFromMolecule() to delist from old molecule,
241 * this assume that the molecule already knows about it.
242 */
243 void unsetMolecule();
244
245
246 private:
247 molecule *mol; // !< the molecule this atom belongs to
248 World* world;
249 atomId_t id;
250};
251
252/**
253 * Global output operator for class atom.
254 */
255std::ostream & operator << (std::ostream &ost, const atom &_atom);
256
257/**
258 * internal method used by the world. Do not use if you don't know what you are doing.
259 * You might get burned...
260 * Use World::createAtom() instead.
261 */
262atom* NewAtom(atomId_t _id);
263
264/**
265* internal method used by the world. Do not use if you don't know what you are doing.
266 * You might get burned...
267 * Use World::destroyAtom() instead.
268 */
269void DeleteAtom(atom*);
270
271/**
272 * Simple function to compare atoms by their elements to allow sorting of atoms by this criteria
273 */
274bool compareAtomElements(atom* atom1,atom* atom2);
275
276
277#endif /* ATOM_HPP_ */
Note: See TracBrowser for help on using the repository browser.