Changeset b453f9
- Timestamp:
- Oct 27, 2009, 8:54:44 AM (15 years ago)
- Branches:
- 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
- Children:
- 70ff32
- Parents:
- 831a14
- Location:
- src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
src/atom.cpp
r831a14 rb453f9 43 43 sort = &nr; 44 44 node = &x; 45 } 45 }; 46 46 47 47 … … 83 83 * \param **res return value (only set if atom::father is equal to \a *ptr) 84 84 */ 85 void atom::EqualsFather ( atom *ptr, atom **res )85 void atom::EqualsFather ( const atom *ptr, const atom **res ) const 86 86 { 87 87 if ( ptr == father ) … … 94 94 * \return true - is inside, false - is not 95 95 */ 96 bool atom::IsInParallelepiped( Vector offset, double *parallelepiped)96 bool atom::IsInParallelepiped(const Vector offset, const double *parallelepiped) const 97 97 { 98 98 return (node->IsInParallelepiped(offset, parallelepiped)); … … 110 110 }; 111 111 112 /** Output of a single atom .112 /** Output of a single atom with given numbering. 113 113 * \param ElementNo cardinal number of the element 114 114 * \param AtomNo cardinal number among these atoms of the same element … … 117 117 * \return true - \a *out present, false - \a *out is NULL 118 118 */ 119 bool atom::Output (ofstream *out, int ElementNo,int AtomNo, const char *comment) const119 bool atom::OutputIndexed(ofstream *out, const int ElementNo, const int AtomNo, const char *comment) const 120 120 { 121 121 if (out != NULL) { … … 133 133 return false; 134 134 }; 135 bool atom::Output(ofstream *out, int *ElementNo, int *AtomNo, const char *comment) 135 136 /** Output of a single atom with numbering from array according to atom::type. 137 * \param *ElementNo cardinal number of the element 138 * \param *AtomNo cardinal number among these atoms of the same element 139 * \param *out stream to output to 140 * \param *comment commentary after '#' sign 141 * \return true - \a *out present, false - \a *out is NULL 142 */ 143 bool atom::OutputArrayIndexed(ofstream *out, const int *ElementNo, int *AtomNo, const char *comment) const 136 144 { 137 145 AtomNo[type->Z]++; // increment number … … 171 179 * \return true - \a *out present, false - \a *out is NULL 172 180 */ 173 bool atom::OutputTrajectory(ofstream *out, int *ElementNo, int *AtomNo,int step) const181 bool atom::OutputTrajectory(ofstream *out, const int *ElementNo, int *AtomNo, const int step) const 174 182 { 175 183 AtomNo[type->Z]++; … … 193 201 * \return true - \a *out present, false - \a *out is NULL 194 202 */ 195 bool atom::OutputTrajectoryXYZ(ofstream *out, int step) const203 bool atom::OutputTrajectoryXYZ(ofstream *out, const int step) const 196 204 { 197 205 if (out != NULL) { … … 210 218 * \param *AtomNo pointer to atom counter that is increased by one 211 219 */ 212 void atom::OutputMPQCLine(ofstream *out, Vector *center, int *AtomNo = NULL) const220 void atom::OutputMPQCLine(ofstream *out, const Vector *center, int *AtomNo = NULL) const 213 221 { 214 222 *out << "\t\t" << type->symbol << " [ " << x.x[0]-center->x[0] << "\t" << x.x[1]-center->x[1] << "\t" << x.x[2]-center->x[2] << " ]" << endl; … … 217 225 }; 218 226 219 ostream & operator << (ostream &ost, const ParticleInfo &a)220 {221 ost << "[" << a.Name << "|" << &a << "]";222 return ost;223 };224 225 ostream & ParticleInfo::operator << (ostream &ost)226 {227 ost << "[" << Name << "|" << this << "]";228 return ost;229 };230 231 227 /** Compares the indices of \a this atom with a given \a ptr. 232 228 * \param ptr atom to compare index against 233 229 * \return true - this one's is smaller, false - not 234 230 */ 235 bool atom::Compare(const atom &ptr) 231 bool atom::Compare(const atom &ptr) const 236 232 { 237 233 if (nr < ptr.nr) … … 245 241 * \return distance squared 246 242 */ 247 double atom::DistanceSquaredToVector( Vector &origin)243 double atom::DistanceSquaredToVector(const Vector &origin) const 248 244 { 249 245 return origin.DistanceSquared(&x); … … 254 250 * \return distance 255 251 */ 256 double atom::DistanceToVector( Vector &origin)252 double atom::DistanceToVector(const Vector &origin) const 257 253 { 258 254 return origin.Distance(&x); -
src/atom.hpp
r831a14 rb453f9 49 49 virtual ~atom(); 50 50 51 bool Output (ofstream *out, int ElementNo,int AtomNo, const char *comment = NULL) const;52 bool Output (ofstream *out, int *ElementNo, int *AtomNo, const char *comment = NULL);51 bool OutputIndexed(ofstream *out, const int ElementNo, const int AtomNo, const char *comment = NULL) const; 52 bool OutputArrayIndexed(ofstream *out, const int *ElementNo, int *AtomNo, const char *comment = NULL) const; 53 53 bool OutputXYZLine(ofstream *out) const; 54 bool OutputTrajectory(ofstream *out, int *ElementNo, int *AtomNo,int step) const;55 bool OutputTrajectoryXYZ(ofstream *out, int step) const;56 void OutputMPQCLine(ofstream *out, Vector *center, int *AtomNo) const;54 bool OutputTrajectory(ofstream *out, const int *ElementNo, int *AtomNo, const int step) const; 55 bool OutputTrajectoryXYZ(ofstream *out, const int step) const; 56 void OutputMPQCLine(ofstream *out, const Vector *center, int *AtomNo) const; 57 57 58 58 void InitComponentNr(); 59 59 60 void EqualsFather ( atom *ptr, atom **res );60 void EqualsFather ( const atom *ptr, const atom **res ) const; 61 61 void CorrectFather(); 62 62 atom *GetTrueFather(); 63 bool Compare(const atom &ptr) ;63 bool Compare(const atom &ptr) const; 64 64 65 double DistanceToVector( Vector &origin);66 double DistanceSquaredToVector( Vector &origin);67 bool IsInParallelepiped( Vector offset, double *parallelepiped);65 double DistanceToVector(const Vector &origin) const; 66 double DistanceSquaredToVector(const Vector &origin) const; 67 bool IsInParallelepiped(const Vector offset, const double *parallelepiped) const; 68 68 69 69 private: -
src/atom_bondedparticle.cpp
r831a14 rb453f9 31 31 * \param *file output stream 32 32 */ 33 void BondedParticle::OutputOrder(ofstream *file) 33 void BondedParticle::OutputOrder(ofstream *file) const 34 34 { 35 35 *file << nr << "\t" << (int)AdaptiveOrder << "\t" << (int)MaxOrder << endl; -
src/atom_bondedparticle.hpp
r831a14 rb453f9 44 44 bool OutputBondOfAtom(ofstream *out) const; 45 45 void OutputAdjacency(ofstream *AdjacencyFile) const; 46 void OutputOrder(ofstream *file) ;46 void OutputOrder(ofstream *file) const; 47 47 48 48 private: -
src/atom_particleinfo.cpp
r831a14 rb453f9 20 20 }; 21 21 22 ostream & operator << (ostream &ost, const ParticleInfo &a) 23 { 24 ost << "[" << a.Name << "|" << &a << "]"; 25 return ost; 26 }; 27 28 ostream & ParticleInfo::operator << (ostream &ost) const 29 { 30 ost << "[" << Name << "|" << this << "]"; 31 return ost; 32 }; 33 -
src/atom_particleinfo.hpp
r831a14 rb453f9 33 33 ~ParticleInfo(); 34 34 35 ostream & operator << (ostream &ost) ;35 ostream & operator << (ostream &ost) const; 36 36 37 37 private: -
src/atom_trajectoryparticle.cpp
r831a14 rb453f9 42 42 * \param *Force Force matrix to store result in 43 43 */ 44 void TrajectoryParticle::EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force) 44 void TrajectoryParticle::EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force) const 45 45 { 46 46 double constant = 10.; … … 129 129 * \param *TotalVelocity pointer to tota velocity sum 130 130 */ 131 void TrajectoryParticle::SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) 131 void TrajectoryParticle::SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) const 132 132 { 133 133 *TotalMass += type->mass; // sum up total mass -
src/atom_trajectoryparticle.hpp
r831a14 rb453f9 44 44 // constraint potential and dynamics stuff 45 45 void AddKineticToTemperature(double *temperature, int step) const; 46 void EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force) ;46 void EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force) const; 47 47 void CorrectVelocity(double *ActualTemp, int Step, Vector *CoGVelocity); 48 48 … … 51 51 void CopyStepOnStep(int dest, int src); 52 52 void VelocityVerletUpdate(int MDSteps, config *configuration, ForceMatrix *Force); 53 void SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) ;53 void SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) const; 54 54 55 55 // thermostats -
src/config.cpp
r831a14 rb453f9 1474 1474 // output of atoms 1475 1475 AtomNo = 0; 1476 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, center, &AtomNo );1476 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo ); 1477 1477 delete(center); 1478 1478 *output << "\t}" << endl; … … 1509 1509 // output of atoms 1510 1510 AtomNo = 0; 1511 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, center, &AtomNo );1511 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo ); 1512 1512 delete(center); 1513 1513 *output << "\t}" << endl; -
src/molecule.cpp
r831a14 rb453f9 497 497 498 498 // get the pendant atoms of current bond in the copy molecule 499 copy->ActOnAllAtoms( &atom::EqualsFather, Binder->leftatom,&LeftAtom );500 copy->ActOnAllAtoms( &atom::EqualsFather, Binder->rightatom,&RightAtom );499 copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->leftatom, (const atom **)&LeftAtom ); 500 copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->rightatom, (const atom **)&RightAtom ); 501 501 502 502 NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree); … … 526 526 * @param three vectors forming the matrix that defines the shape of the parallelpiped 527 527 */ 528 molecule* molecule::CopyMoleculeFromSubRegion( Vector offset, double *parallelepiped){528 molecule* molecule::CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const { 529 529 molecule *copy = new molecule(elemente); 530 530 … … 733 733 ElementNo[i] = current++; 734 734 } 735 ActOnAllAtoms( &atom::Output , out, ElementNo, AtomNo, (const char *) NULL ); // (bool (atom::*)(int *, int *, ofstream *, const char *))735 ActOnAllAtoms( &atom::OutputArrayIndexed, (ofstream *)out, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL ); 736 736 return true; 737 737 } … … 765 765 ElementNo[i] = current++; 766 766 } 767 ActOnAllAtoms( &atom::OutputTrajectory, out, ElementNo, AtomNo,step );767 ActOnAllAtoms( &atom::OutputTrajectory, out, (const int *)ElementNo, AtomNo, (const int)step ); 768 768 } 769 769 return true; … … 971 971 Distances = Malloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances"); 972 972 OtherDistances = Malloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances"); 973 SetIndexedArrayForEachAtomTo ( Distances, &atom::nr, &atom::DistanceSquaredToVector, CenterOfGravity);974 SetIndexedArrayForEachAtomTo ( OtherDistances, &atom::nr, &atom::DistanceSquaredToVector, CenterOfGravity);973 SetIndexedArrayForEachAtomTo ( Distances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity); 974 SetIndexedArrayForEachAtomTo ( OtherDistances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity); 975 975 976 976 /// ... sort each list (using heapsort (o(N log N)) from GSL) … … 1084 1084 }; 1085 1085 1086 void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) 1086 void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) const 1087 1087 { 1088 1088 atom *Walker = start; -
src/molecule.hpp
r831a14 rb453f9 116 116 117 117 // templates for allowing global manipulation of all vectors 118 template <typename res> void ActOnAllVectors( res (Vector::*f)() );119 template <typename res> void ActOnAllVectors( res (Vector::*f)() const);120 118 template <typename res> void ActOnAllVectors( res (Vector::*f)() ) const; 121 119 template <typename res> void ActOnAllVectors( res (Vector::*f)() const) const; 122 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T), T t );123 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T) const, T t );124 120 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T), T t ) const; 125 121 template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T) const, T t ) const; 126 template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U), T t, U u );127 template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u );128 122 template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const; 129 123 template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const; 130 template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v);131 template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v);132 124 template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const; 133 125 template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const; 134 126 135 127 // templates for allowing global manipulation of molecule with each atom as single argument 136 template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) );137 template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) const);138 128 template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) ) const; 139 129 template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) const) const; 140 130 141 131 // templates for allowing global copying of molecule with each atom as single argument 142 template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy);143 template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const , molecule *copy);144 132 template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const; 145 133 template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const; 146 134 147 135 // templates for allowing global manipulation of all atoms 148 template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() );149 template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() const );150 136 template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() ) const; 151 137 template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() const) const; 152 template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T), T t );153 template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T) const, T t );154 138 template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T), T t ) const; 155 139 template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T) const, T t ) const; 156 template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U), T t, U u );157 template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u );158 140 template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const; 159 141 template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const; 160 template <typename res, typename typ, typename T, typename U, typename V> void ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v);161 template <typename res, typename typ, typename T, typename U, typename V> void ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v);162 142 template <typename res, typename typ, typename T, typename U, typename V> void ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const; 163 143 template <typename res, typename typ, typename T, typename U, typename V> void ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const; 164 template <typename res, typename typ, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w);165 template <typename res, typename typ, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w);166 144 template <typename res, typename typ, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const; 167 145 template <typename res, typename typ, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const; 168 146 169 147 // templates for allowing conditional global copying of molecule with each atom as single argument 170 template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ); 171 template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ); 172 template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ); 173 template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ); 148 template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const; 149 template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const; 150 template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const; 151 template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () const ) const; 152 template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const; 153 template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const; 154 template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T), T t ) const; 155 template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T) const, T t ) const; 156 template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const; 157 template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const; 158 template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const; 159 template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const; 160 template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const; 161 template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const; 162 template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const; 163 template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const; 174 164 175 165 // templates for allowing global manipulation of an array with one entry per atom 176 void SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::* index); 177 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *)); 178 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *), T t); 179 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *), T *t); 180 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *)); 181 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *), T t); 182 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *), T *t); 183 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(Vector &), Vector atom::*value); 184 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(Vector &), Vector &vect ); 166 void SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::* index) const; 167 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *)) const; 168 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *), T t) const; 169 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *), T *t) const; 170 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *)) const; 171 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *), T t) const; 172 template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *), T *t) const; 173 template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value) const; 174 template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value) const; 175 template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const; 176 template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const; 185 177 186 178 // templates for allowing global manipulation of each atom by entries in an array 187 template <typename T, typename typ, typename typ2> void SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ); 188 template <typename T, typename typ> void SetAtomValueToValue ( T value, T typ::*ptr ); 189 190 template <typename res, typename typ> res SumPerAtom(res (typ::*f)() ); 191 template <typename res, typename typ> res SumPerAtom(res (typ::*f)() const ); 179 template <typename T, typename typ, typename typ2> void SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const; 180 template <typename T, typename typ> void SetAtomValueToValue ( T value, T typ::*ptr ) const; 181 192 182 template <typename res, typename typ> res SumPerAtom(res (typ::*f)() ) const; 193 183 template <typename res, typename typ> res SumPerAtom(res (typ::*f)() const ) const; 194 template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) , T t );195 template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) const, T t );196 184 template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) , T t ) const; 197 185 template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) const, T t ) const; … … 276 264 277 265 molecule *CopyMolecule(); 278 molecule* CopyMoleculeFromSubRegion( Vector offset, double *parallelepiped);266 molecule* CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const; 279 267 280 268 /// Fragment molecule by two different approaches: -
src/molecule_template.hpp
r831a14 rb453f9 21 21 22 22 // zero arguments 23 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() )24 {25 atom *Walker = start;26 while (Walker->next != end) {27 Walker = Walker->next;28 ((Walker->node)->*f)();29 }30 };31 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const )32 {33 atom *Walker = start;34 while (Walker->next != end) {35 Walker = Walker->next;36 ((Walker->node)->*f)();37 }38 };39 23 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const 40 24 { … … 54 38 }; 55 39 // one argument 56 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) 40 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const 57 41 { 58 42 atom *Walker = start; … … 62 46 } 63 47 }; 64 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) 48 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const 65 49 { 66 50 atom *Walker = start; … … 70 54 } 71 55 }; 72 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const73 {74 atom *Walker = start;75 while (Walker->next != end) {76 Walker = Walker->next;77 ((Walker->node)->*f)(t);78 }79 };80 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const81 {82 atom *Walker = start;83 while (Walker->next != end) {84 Walker = Walker->next;85 ((Walker->node)->*f)(t);86 }87 };88 56 // two arguments 89 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) 57 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const 90 58 { 91 59 atom *Walker = start; … … 95 63 } 96 64 }; 97 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) 65 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const 98 66 { 99 67 atom *Walker = start; … … 103 71 } 104 72 }; 105 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const106 {107 atom *Walker = start;108 while (Walker->next != end) {109 Walker = Walker->next;110 ((Walker->node)->*f)(t, u);111 }112 };113 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const114 {115 atom *Walker = start;116 while (Walker->next != end) {117 Walker = Walker->next;118 ((Walker->node)->*f)(t, u);119 }120 };121 73 // three arguments 122 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) 74 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const 123 75 { 124 76 atom *Walker = start; … … 128 80 } 129 81 }; 130 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) 82 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const 131 83 { 132 84 atom *Walker = start; … … 136 88 } 137 89 }; 138 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const139 {140 atom *Walker = start;141 while (Walker->next != end) {142 Walker = Walker->next;143 ((Walker->node)->*f)(t, u, v);144 }145 };146 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const147 {148 atom *Walker = start;149 while (Walker->next != end) {150 Walker = Walker->next;151 ((Walker->node)->*f)(t, u, v);152 }153 };154 90 155 91 // ========================= Summing over each Atoms =================================== // 156 92 157 93 // zero arguments 158 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) 94 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) const 159 95 { 160 96 res result = 0; … … 166 102 return result; 167 103 }; 168 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) 104 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) const 169 105 { 170 106 res result = 0; … … 176 112 return result; 177 113 }; 178 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) const 114 // one argument 115 template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) const 179 116 { 180 117 res result = 0; … … 182 119 while (Walker->next != end) { 183 120 Walker = Walker->next; 184 result += (Walker->*f)( );121 result += (Walker->*f)(t); 185 122 } 186 123 return result; 187 124 }; 188 template <typename res, typename typ > res molecule::SumPerAtom(res (typ::*f)() const ) const125 template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) const 189 126 { 190 127 res result = 0; … … 192 129 while (Walker->next != end) { 193 130 Walker = Walker->next; 194 result += (Walker->*f)( );131 result += (Walker->*f)(t); 195 132 } 196 133 return result; 197 134 }; 135 136 137 // ================== Acting with each Atoms on same molecule ========================== // 138 139 // zero arguments 140 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const 141 { 142 atom *Walker = start; 143 while (Walker->next != end) { 144 Walker = Walker->next; 145 (*f)(Walker); 146 } 147 }; 148 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const 149 { 150 atom *Walker = start; 151 while (Walker->next != end) { 152 Walker = Walker->next; 153 (*f)(Walker); 154 } 155 }; 156 157 // ================== Acting with each Atoms on copy molecule ========================== // 158 159 // zero arguments 160 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const 161 { 162 atom *Walker = start; 163 while (Walker->next != end) { 164 Walker = Walker->next; 165 (copy->*f)(Walker); 166 } 167 }; 168 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const 169 { 170 atom *Walker = start; 171 while (Walker->next != end) { 172 Walker = Walker->next; 173 (copy->*f)(Walker); 174 } 175 }; 176 177 // ================== Acting with each Atoms on copy molecule if true ========================== // 178 179 // zero arguments 180 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const 181 { 182 atom *Walker = start; 183 while (Walker->next != end) { 184 Walker = Walker->next; 185 if ((Walker->*condition)()) 186 (copy->*f)(Walker); 187 } 188 }; 189 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const 190 { 191 atom *Walker = start; 192 while (Walker->next != end) { 193 Walker = Walker->next; 194 if ((Walker->*condition)()) 195 (copy->*f)(Walker); 196 } 197 }; 198 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const 199 { 200 atom *Walker = start; 201 while (Walker->next != end) { 202 Walker = Walker->next; 203 if ((Walker->*condition)()) 204 (copy->*f)(Walker); 205 } 206 }; 207 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const 208 { 209 atom *Walker = start; 210 while (Walker->next != end) { 211 Walker = Walker->next; 212 if ((Walker->*condition)()) 213 (copy->*f)(Walker); 214 } 215 }; 198 216 // one argument 199 template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) 200 { 201 res result = 0; 202 atom *Walker = start; 203 while (Walker->next != end) { 204 Walker = Walker->next; 205 result += (Walker->*f)(t); 206 } 207 return result; 208 }; 209 template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) 210 { 211 res result = 0; 212 atom *Walker = start; 213 while (Walker->next != end) { 214 Walker = Walker->next; 215 result += (Walker->*f)(t); 216 } 217 return result; 218 }; 219 template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) const 220 { 221 res result = 0; 222 atom *Walker = start; 223 while (Walker->next != end) { 224 Walker = Walker->next; 225 result += (Walker->*f)(t); 226 } 227 return result; 228 }; 229 template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) const 230 { 231 res result = 0; 232 atom *Walker = start; 233 while (Walker->next != end) { 234 Walker = Walker->next; 235 result += (Walker->*f)(t); 236 } 237 return result; 238 }; 239 240 241 // ================== Acting with each Atoms on same molecule ========================== // 217 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const 218 { 219 atom *Walker = start; 220 while (Walker->next != end) { 221 Walker = Walker->next; 222 if ((Walker->*condition)(t)) 223 (copy->*f)(Walker); 224 } 225 }; 226 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const 227 { 228 atom *Walker = start; 229 while (Walker->next != end) { 230 Walker = Walker->next; 231 if ((Walker->*condition)(t)) 232 (copy->*f)(Walker); 233 } 234 }; 235 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const 236 { 237 atom *Walker = start; 238 while (Walker->next != end) { 239 Walker = Walker->next; 240 if ((Walker->*condition)(t)) 241 (copy->*f)(Walker); 242 } 243 }; 244 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const 245 { 246 atom *Walker = start; 247 while (Walker->next != end) { 248 Walker = Walker->next; 249 if ((Walker->*condition)(t)) 250 (copy->*f)(Walker); 251 } 252 }; 253 // two arguments 254 template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const 255 { 256 atom *Walker = start; 257 while (Walker->next != end) { 258 Walker = Walker->next; 259 if ((Walker->*condition)(t,u)) 260 (copy->*f)(Walker); 261 } 262 }; 263 template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const 264 { 265 atom *Walker = start; 266 while (Walker->next != end) { 267 Walker = Walker->next; 268 if ((Walker->*condition)(t,u)) 269 (copy->*f)(Walker); 270 } 271 }; 272 template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const 273 { 274 atom *Walker = start; 275 while (Walker->next != end) { 276 Walker = Walker->next; 277 if ((Walker->*condition)(t,u)) 278 (copy->*f)(Walker); 279 } 280 }; 281 template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const 282 { 283 atom *Walker = start; 284 while (Walker->next != end) { 285 Walker = Walker->next; 286 if ((Walker->*condition)(t,u)) 287 (copy->*f)(Walker); 288 } 289 }; 290 // three arguments 291 template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const 292 { 293 atom *Walker = start; 294 while (Walker->next != end) { 295 Walker = Walker->next; 296 if ((Walker->*condition)(t,u,v)) 297 (copy->*f)(Walker); 298 } 299 }; 300 template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const 301 { 302 atom *Walker = start; 303 while (Walker->next != end) { 304 Walker = Walker->next; 305 if ((Walker->*condition)(t,u,v)) 306 (copy->*f)(Walker); 307 } 308 }; 309 template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const 310 { 311 atom *Walker = start; 312 while (Walker->next != end) { 313 Walker = Walker->next; 314 if ((Walker->*condition)(t,u,v)) 315 (copy->*f)(Walker); 316 } 317 }; 318 template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const 319 { 320 atom *Walker = start; 321 while (Walker->next != end) { 322 Walker = Walker->next; 323 if ((Walker->*condition)(t,u,v)) 324 (copy->*f)(Walker); 325 } 326 }; 327 328 // ================== Acting on all Atoms ========================== // 242 329 243 330 // zero arguments 244 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) 245 { 246 atom *Walker = start; 247 while (Walker->next != end) { 248 Walker = Walker->next; 249 (*f)(Walker); 250 } 251 }; 252 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) 253 { 254 atom *Walker = start; 255 while (Walker->next != end) { 256 Walker = Walker->next; 257 (*f)(Walker); 258 } 259 }; 260 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const 261 { 262 atom *Walker = start; 263 while (Walker->next != end) { 264 Walker = Walker->next; 265 (*f)(Walker); 266 } 267 }; 268 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const 269 { 270 atom *Walker = start; 271 while (Walker->next != end) { 272 Walker = Walker->next; 273 (*f)(Walker); 274 } 275 }; 276 277 // ================== Acting with each Atoms on copy molecule ========================== // 278 279 // zero arguments 280 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) 281 { 282 atom *Walker = start; 283 while (Walker->next != end) { 284 Walker = Walker->next; 285 (copy->*f)(Walker); 286 } 287 }; 288 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const , molecule *copy) 289 { 290 atom *Walker = start; 291 while (Walker->next != end) { 292 Walker = Walker->next; 293 (copy->*f)(Walker); 294 } 295 }; 296 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const 297 { 298 atom *Walker = start; 299 while (Walker->next != end) { 300 Walker = Walker->next; 301 (copy->*f)(Walker); 302 } 303 }; 304 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const 305 { 306 atom *Walker = start; 307 while (Walker->next != end) { 308 Walker = Walker->next; 309 (copy->*f)(Walker); 310 } 311 }; 312 313 // ================== Acting with each Atoms on copy molecule if true ========================== // 314 315 // zero arguments 316 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) 317 { 318 atom *Walker = start; 319 while (Walker->next != end) { 320 Walker = Walker->next; 321 if ((Walker->*condition)()) 322 (copy->*f)(Walker); 331 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const 332 { 333 atom *Walker = start; 334 while (Walker->next != end) { 335 Walker = Walker->next; 336 (Walker->*f)(); 337 } 338 }; 339 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const 340 { 341 atom *Walker = start; 342 while (Walker->next != end) { 343 Walker = Walker->next; 344 (Walker->*f)(); 323 345 } 324 346 }; 325 347 // one argument 326 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) 327 { 328 atom *Walker = start; 329 while (Walker->next != end) { 330 Walker = Walker->next; 331 if ((Walker->*condition)(t)) 332 (copy->*f)(Walker); 333 } 334 }; 335 // two arguments 336 template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) 337 { 338 atom *Walker = start; 339 while (Walker->next != end) { 340 Walker = Walker->next; 341 if ((Walker->*condition)(t,u)) 342 (copy->*f)(Walker); 343 } 344 }; 345 // three arguments 346 template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) 347 { 348 atom *Walker = start; 349 while (Walker->next != end) { 350 Walker = Walker->next; 351 if ((Walker->*condition)(t,u,v)) 352 (copy->*f)(Walker); 353 } 354 }; 355 356 // ================== Acting on all Atoms ========================== // 357 358 // zero arguments 359 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) 360 { 361 atom *Walker = start; 362 while (Walker->next != end) { 363 Walker = Walker->next; 364 (Walker->*f)(); 365 } 366 }; 367 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) 368 { 369 atom *Walker = start; 370 while (Walker->next != end) { 371 Walker = Walker->next; 372 (Walker->*f)(); 373 } 374 }; 375 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const 376 { 377 atom *Walker = start; 378 while (Walker->next != end) { 379 Walker = Walker->next; 380 (Walker->*f)(); 381 } 382 }; 383 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const 384 { 385 atom *Walker = start; 386 while (Walker->next != end) { 387 Walker = Walker->next; 388 (Walker->*f)(); 389 } 390 }; 391 // one argument 392 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) 348 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const 393 349 { 394 350 atom *Walker = start; … … 398 354 } 399 355 }; 400 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) 356 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const 401 357 { 402 358 atom *Walker = start; … … 406 362 } 407 363 }; 408 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const409 {410 atom *Walker = start;411 while (Walker->next != end) {412 Walker = Walker->next;413 (Walker->*f)(t);414 }415 };416 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const417 {418 atom *Walker = start;419 while (Walker->next != end) {420 Walker = Walker->next;421 (Walker->*f)(t);422 }423 };424 364 // two argument 425 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) 365 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const 426 366 { 427 367 atom *Walker = start; … … 431 371 } 432 372 }; 433 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) 373 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const 434 374 { 435 375 atom *Walker = start; … … 439 379 } 440 380 }; 441 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const442 {443 atom *Walker = start;444 while (Walker->next != end) {445 Walker = Walker->next;446 (Walker->*f)(t, u);447 }448 };449 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const450 {451 atom *Walker = start;452 while (Walker->next != end) {453 Walker = Walker->next;454 (Walker->*f)(t, u);455 }456 };457 381 // three argument 458 template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) 382 template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const 459 383 { 460 384 atom *Walker = start; … … 464 388 } 465 389 }; 466 template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) 390 template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const 467 391 { 468 392 atom *Walker = start; … … 472 396 } 473 397 }; 474 template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const475 {476 atom *Walker = start;477 while (Walker->next != end) {478 Walker = Walker->next;479 (Walker->*f)(t, u, v);480 }481 };482 template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const483 {484 atom *Walker = start;485 while (Walker->next != end) {486 Walker = Walker->next;487 (Walker->*f)(t, u, v);488 }489 };490 398 // four arguments 491 template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) 399 template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const 492 400 { 493 401 atom *Walker = start; … … 497 405 } 498 406 }; 499 template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) 407 template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const 500 408 { 501 409 atom *Walker = start; … … 505 413 } 506 414 }; 507 template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const508 {509 atom *Walker = start;510 while (Walker->next != end) {511 Walker = Walker->next;512 (Walker->*f)(t, u, v, w);513 }514 };515 template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const516 {517 atom *Walker = start;518 while (Walker->next != end) {519 Walker = Walker->next;520 (Walker->*f)(t, u, v, w);521 }522 };523 415 524 416 // ===================== Accessing arrays indexed by some integer for each atom ====================== 525 417 526 418 // for atom ints 527 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) 419 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const 528 420 { 529 421 atom *Walker = start; … … 534 426 } 535 427 }; 536 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) 428 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const 537 429 { 538 430 atom *Walker = start; … … 542 434 } 543 435 }; 544 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) 436 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const 545 437 { 546 438 atom *Walker = start; … … 551 443 }; 552 444 // for element ints 553 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) 445 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const 554 446 { 555 447 atom *Walker = start; … … 560 452 } 561 453 }; 562 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) 454 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const 563 455 { 564 456 atom *Walker = start; … … 568 460 } 569 461 }; 570 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) 462 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const 571 463 { 572 464 atom *Walker = start; … … 577 469 }; 578 470 579 template <typename T > void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(Vector &), Vector atom::*value )471 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const 580 472 { 581 473 atom *Walker = start; … … 585 477 } 586 478 }; 587 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(Vector &), Vector &vect ) 479 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value ) const 480 { 481 atom *Walker = start; 482 while (Walker->next != end) { 483 Walker = Walker->next; 484 array[(Walker->*index)] = (Walker->*Setor) (Walker->*value); 485 } 486 }; 487 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const 588 488 { 589 489 atom *Walker = start; … … 593 493 } 594 494 }; 595 596 template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) 495 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const 496 { 497 atom *Walker = start; 498 while (Walker->next != end) { 499 Walker = Walker->next; 500 array[(Walker->*index)] = (Walker->*Setor) (vect); 501 } 502 }; 503 template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const 597 504 { 598 505 atom *Walker = start; … … 604 511 }; 605 512 606 template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) 513 template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const 607 514 { 608 515 atom *Walker = start; -
src/vector.cpp
r831a14 rb453f9 1276 1276 * @param three vectors forming the matrix that defines the shape of the parallelpiped 1277 1277 */ 1278 bool Vector::IsInParallelepiped( Vector offset, double *parallelepiped)1278 bool Vector::IsInParallelepiped(const Vector offset, const double *parallelepiped) const 1279 1279 { 1280 1280 Vector a; -
src/vector.hpp
r831a14 rb453f9 77 77 void AskPosition(double *cell_size, bool check); 78 78 bool Output(ofstream *out) const; 79 bool IsInParallelepiped( Vector offset, double *parallelepiped);79 bool IsInParallelepiped(const Vector offset, const double *parallelepiped) const; 80 80 void WrapPeriodically(const double *M, const double *Minv); 81 81 };
Note:
See TracChangeset
for help on using the changeset viewer.