Changeset b453f9 for src


Ignore:
Timestamp:
Oct 27, 2009, 8:54:44 AM (15 years ago)
Author:
Frederik Heber <heber@…>
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
Message:

Begun with ticket #38 (make const what is const).

  • basically all changes to member function that now state that they do not change member attributes.
  • in molecule_template.hpp all member functions are declared const, as we only need start and end from molecule and these are never changed (lots of overloaded templates removed thereby).
  • Vector::Distance...() and ...DistanceSquared() are const now too
Location:
src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • src/atom.cpp

    r831a14 rb453f9  
    4343  sort = &nr;
    4444  node = &x;
    45 }
     45};
    4646
    4747
     
    8383 * \param **res return value (only set if atom::father is equal to \a *ptr)
    8484 */
    85 void atom::EqualsFather ( atom *ptr, atom **res )
     85void atom::EqualsFather ( const atom *ptr, const atom **res ) const
    8686{
    8787  if ( ptr == father )
     
    9494 * \return true - is inside, false - is not
    9595 */
    96 bool atom::IsInParallelepiped(Vector offset, double *parallelepiped)
     96bool atom::IsInParallelepiped(const Vector offset, const double *parallelepiped) const
    9797{
    9898  return (node->IsInParallelepiped(offset, parallelepiped));
     
    110110};
    111111
    112 /** Output of a single atom.
     112/** Output of a single atom with given numbering.
    113113 * \param ElementNo cardinal number of the element
    114114 * \param AtomNo cardinal number among these atoms of the same element
     
    117117  * \return true - \a *out present, false - \a *out is NULL
    118118 */
    119 bool atom::Output(ofstream *out, int ElementNo, int AtomNo, const char *comment) const
     119bool atom::OutputIndexed(ofstream *out, const int ElementNo, const int AtomNo, const char *comment) const
    120120{
    121121  if (out != NULL) {
     
    133133    return false;
    134134};
    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 */
     143bool atom::OutputArrayIndexed(ofstream *out, const int *ElementNo, int *AtomNo, const char *comment) const
    136144{
    137145  AtomNo[type->Z]++;  // increment number
     
    171179  * \return true - \a *out present, false - \a *out is NULL
    172180 */
    173 bool atom::OutputTrajectory(ofstream *out, int *ElementNo, int *AtomNo, int step) const
     181bool atom::OutputTrajectory(ofstream *out, const int *ElementNo, int *AtomNo, const int step) const
    174182{
    175183  AtomNo[type->Z]++;
     
    193201 * \return true - \a *out present, false - \a *out is NULL
    194202 */
    195 bool atom::OutputTrajectoryXYZ(ofstream *out, int step) const
     203bool atom::OutputTrajectoryXYZ(ofstream *out, const int step) const
    196204{
    197205  if (out != NULL) {
     
    210218 * \param *AtomNo pointer to atom counter that is increased by one
    211219 */
    212 void atom::OutputMPQCLine(ofstream *out, Vector *center, int *AtomNo = NULL) const
     220void atom::OutputMPQCLine(ofstream *out, const Vector *center, int *AtomNo = NULL) const
    213221{
    214222  *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;
     
    217225};
    218226
    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 
    231227/** Compares the indices of \a this atom with a given \a ptr.
    232228 * \param ptr atom to compare index against
    233229 * \return true - this one's is smaller, false - not
    234230 */
    235 bool atom::Compare(const atom &ptr)
     231bool atom::Compare(const atom &ptr) const
    236232{
    237233  if (nr < ptr.nr)
     
    245241 * \return distance squared
    246242 */
    247 double atom::DistanceSquaredToVector(Vector &origin)
     243double atom::DistanceSquaredToVector(const Vector &origin) const
    248244{
    249245  return origin.DistanceSquared(&x);
     
    254250 * \return distance
    255251 */
    256 double atom::DistanceToVector(Vector &origin)
     252double atom::DistanceToVector(const Vector &origin) const
    257253{
    258254  return origin.Distance(&x);
  • src/atom.hpp

    r831a14 rb453f9  
    4949  virtual ~atom();
    5050
    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;
    5353  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;
    5757
    5858  void InitComponentNr();
    5959
    60   void EqualsFather ( atom *ptr, atom **res );
     60  void EqualsFather ( const atom *ptr, const atom **res ) const;
    6161  void CorrectFather();
    6262  atom *GetTrueFather();
    63   bool Compare(const atom &ptr);
     63  bool Compare(const atom &ptr) const;
    6464
    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;
    6868
    6969  private:
  • src/atom_bondedparticle.cpp

    r831a14 rb453f9  
    3131 * \param *file output stream
    3232 */
    33 void BondedParticle::OutputOrder(ofstream *file)
     33void BondedParticle::OutputOrder(ofstream *file) const
    3434{
    3535  *file << nr << "\t" << (int)AdaptiveOrder << "\t" << (int)MaxOrder << endl;
  • src/atom_bondedparticle.hpp

    r831a14 rb453f9  
    4444  bool OutputBondOfAtom(ofstream *out) const;
    4545  void OutputAdjacency(ofstream *AdjacencyFile) const;
    46   void OutputOrder(ofstream *file);
     46  void OutputOrder(ofstream *file) const;
    4747
    4848private:
  • src/atom_particleinfo.cpp

    r831a14 rb453f9  
    2020};
    2121
     22ostream & operator << (ostream &ost, const ParticleInfo &a)
     23{
     24  ost << "[" << a.Name << "|" << &a << "]";
     25  return ost;
     26};
     27
     28ostream & ParticleInfo::operator << (ostream &ost) const
     29{
     30  ost << "[" << Name << "|" << this << "]";
     31  return ost;
     32};
     33
  • src/atom_particleinfo.hpp

    r831a14 rb453f9  
    3333  ~ParticleInfo();
    3434
    35   ostream & operator << (ostream &ost);
     35  ostream & operator << (ostream &ost) const;
    3636
    3737private:
  • src/atom_trajectoryparticle.cpp

    r831a14 rb453f9  
    4242 * \param *Force Force matrix to store result in
    4343 */
    44 void TrajectoryParticle::EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force)
     44void TrajectoryParticle::EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force) const
    4545{
    4646  double constant = 10.;
     
    129129 * \param *TotalVelocity pointer to tota velocity sum
    130130 */
    131 void TrajectoryParticle::SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity )
     131void TrajectoryParticle::SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) const
    132132{
    133133  *TotalMass += type->mass;  // sum up total mass
  • src/atom_trajectoryparticle.hpp

    r831a14 rb453f9  
    4444  // constraint potential and dynamics stuff
    4545  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;
    4747  void CorrectVelocity(double *ActualTemp, int Step, Vector *CoGVelocity);
    4848
     
    5151  void CopyStepOnStep(int dest, int src);
    5252  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;
    5454
    5555  // thermostats
  • src/config.cpp

    r831a14 rb453f9  
    14741474  // output of atoms
    14751475  AtomNo = 0;
    1476   mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, center, &AtomNo );
     1476  mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
    14771477  delete(center);
    14781478  *output << "\t}" << endl;
     
    15091509  // output of atoms
    15101510  AtomNo = 0;
    1511   mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, center, &AtomNo );
     1511  mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
    15121512  delete(center);
    15131513  *output << "\t}" << endl;
  • src/molecule.cpp

    r831a14 rb453f9  
    497497
    498498    // 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 );
    501501
    502502    NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree);
     
    526526 * @param three vectors forming the matrix that defines the shape of the parallelpiped
    527527 */
    528 molecule* molecule::CopyMoleculeFromSubRegion(Vector offset, double *parallelepiped) {
     528molecule* molecule::CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const {
    529529  molecule *copy = new molecule(elemente);
    530530
     
    733733        ElementNo[i] = current++;
    734734    }
    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 );
    736736    return true;
    737737  }
     
    765765          ElementNo[i] = current++;
    766766      }
    767       ActOnAllAtoms( &atom::OutputTrajectory, out, ElementNo, AtomNo, step );
     767      ActOnAllAtoms( &atom::OutputTrajectory, out, (const int *)ElementNo, AtomNo, (const int)step );
    768768    }
    769769    return true;
     
    971971    Distances = Malloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances");
    972972    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);
    975975
    976976    /// ... sort each list (using heapsort (o(N log N)) from GSL)
     
    10841084};
    10851085
    1086 void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index)
     1086void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) const
    10871087{
    10881088  atom *Walker = start;
  • src/molecule.hpp

    r831a14 rb453f9  
    116116
    117117  // 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);
    120118  template <typename res> void ActOnAllVectors( res (Vector::*f)() ) const;
    121119  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 );
    124120  template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T), T t ) const;
    125121  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 );
    128122  template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const;
    129123  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);
    132124  template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const;
    133125  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;
    134126
    135127  // 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);
    138128  template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) ) const;
    139129  template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) const) const;
    140130
    141131  // 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);
    144132  template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const;
    145133  template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const;
    146134
    147135  // 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 );
    150136  template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() ) const;
    151137  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 );
    154138  template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T), T t ) const;
    155139  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 );
    158140  template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const;
    159141  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);
    162142  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;
    163143  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);
    166144  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;
    167145  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;
    168146
    169147  // 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;
    174164
    175165  // 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;
    185177
    186178  // 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
    192182  template <typename res, typename typ> res SumPerAtom(res (typ::*f)() ) const;
    193183  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 );
    196184  template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) , T t ) const;
    197185  template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) const, T t ) const;
     
    276264
    277265  molecule *CopyMolecule();
    278   molecule* CopyMoleculeFromSubRegion(Vector offset, double *parallelepiped);
     266  molecule* CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const;
    279267
    280268  /// Fragment molecule by two different approaches:
  • src/molecule_template.hpp

    r831a14 rb453f9  
    2121
    2222// 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 };
    3923template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const
    4024    {
     
    5438};
    5539// one argument
    56 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t )
     40template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const
    5741{
    5842  atom *Walker = start;
     
    6246  }
    6347};
    64 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t )
     48template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const
    6549{
    6650  atom *Walker = start;
     
    7054  }
    7155};
    72 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const
    73 {
    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 ) const
    81 {
    82   atom *Walker = start;
    83   while (Walker->next != end) {
    84     Walker = Walker->next;
    85     ((Walker->node)->*f)(t);
    86   }
    87 };
    8856// two arguments
    89 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u )
     57template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
    9058{
    9159  atom *Walker = start;
     
    9563  }
    9664};
    97 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u )
     65template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const
    9866{
    9967  atom *Walker = start;
     
    10371  }
    10472};
    105 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
    106 {
    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 ) const
    114 {
    115   atom *Walker = start;
    116   while (Walker->next != end) {
    117     Walker = Walker->next;
    118     ((Walker->node)->*f)(t, u);
    119   }
    120 };
    12173// 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)
     74template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const
    12375{
    12476  atom *Walker = start;
     
    12880  }
    12981};
    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)
     82template <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
    13183{
    13284  atom *Walker = start;
     
    13688  }
    13789};
    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) const
    139 {
    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) const
    147 {
    148   atom *Walker = start;
    149   while (Walker->next != end) {
    150     Walker = Walker->next;
    151     ((Walker->node)->*f)(t, u, v);
    152   }
    153 };
    15490
    15591// ========================= Summing over each Atoms =================================== //
    15692
    15793// zero arguments
    158 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() )
     94template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) const
    15995{
    16096  res result = 0;
     
    166102  return result;
    167103};
    168 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const )
     104template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) const
    169105{
    170106  res result = 0;
     
    176112  return result;
    177113};
    178 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) const
     114// one argument
     115template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) const
    179116{
    180117  res result = 0;
     
    182119  while (Walker->next != end) {
    183120    Walker = Walker->next;
    184     result += (Walker->*f)();
     121    result += (Walker->*f)(t);
    185122  }
    186123  return result;
    187124};
    188 template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) const
     125template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) const
    189126{
    190127  res result = 0;
     
    192129  while (Walker->next != end) {
    193130    Walker = Walker->next;
    194     result += (Walker->*f)();
     131    result += (Walker->*f)(t);
    195132  }
    196133  return result;
    197134};
     135
     136
     137// ================== Acting with each Atoms on same molecule ========================== //
     138
     139// zero arguments
     140template <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};
     148template <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
     160template <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};
     168template <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
     180template <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};
     189template <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};
     198template <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};
     207template <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};
    198216// 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 ========================== //
     217template <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};
     226template <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};
     235template <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};
     244template <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
     254template <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};
     263template <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};
     272template <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};
     281template <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
     291template <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};
     300template <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};
     309template <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};
     318template <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 ========================== //
    242329
    243330// 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);
     331template <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};
     339template <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)();
    323345  }
    324346};
    325347// 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 )
     348template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
    393349{
    394350  atom *Walker = start;
     
    398354  }
    399355};
    400 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t )
     356template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const
    401357{
    402358  atom *Walker = start;
     
    406362  }
    407363};
    408 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
    409 {
    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 ) const
    417 {
    418   atom *Walker = start;
    419   while (Walker->next != end) {
    420     Walker = Walker->next;
    421     (Walker->*f)(t);
    422   }
    423 };
    424364// two argument
    425 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u )
     365template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const
    426366{
    427367  atom *Walker = start;
     
    431371  }
    432372};
    433 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u )
     373template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const
    434374{
    435375  atom *Walker = start;
     
    439379  }
    440380};
    441 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const
    442 {
    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 ) const
    450 {
    451   atom *Walker = start;
    452   while (Walker->next != end) {
    453     Walker = Walker->next;
    454     (Walker->*f)(t, u);
    455   }
    456 };
    457381// 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)
     382template <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
    459383{
    460384  atom *Walker = start;
     
    464388  }
    465389};
    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)
     390template <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
    467391{
    468392  atom *Walker = start;
     
    472396  }
    473397};
    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) const
    475 {
    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) const
    483 {
    484   atom *Walker = start;
    485   while (Walker->next != end) {
    486     Walker = Walker->next;
    487     (Walker->*f)(t, u, v);
    488   }
    489 };
    490398// 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)
     399template <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
    492400{
    493401  atom *Walker = start;
     
    497405  }
    498406};
    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)
     407template <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
    500408{
    501409  atom *Walker = start;
     
    505413  }
    506414};
    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) const
    508 {
    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) const
    516 {
    517   atom *Walker = start;
    518   while (Walker->next != end) {
    519     Walker = Walker->next;
    520     (Walker->*f)(t, u, v, w);
    521   }
    522 };
    523415
    524416// ===================== Accessing arrays indexed by some integer for each atom ======================
    525417
    526418// for atom ints
    527 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) )
     419template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const
    528420{
    529421  atom *Walker = start;
     
    534426  }
    535427};
    536 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value )
     428template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const
    537429{
    538430  atom *Walker = start;
     
    542434  }
    543435};
    544 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value )
     436template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const
    545437{
    546438  atom *Walker = start;
     
    551443};
    552444// for element ints
    553 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) )
     445template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const
    554446{
    555447  atom *Walker = start;
     
    560452  }
    561453};
    562 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value )
     454template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const
    563455{
    564456  atom *Walker = start;
     
    568460  }
    569461};
    570 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value )
     462template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const
    571463{
    572464  atom *Walker = start;
     
    577469};
    578470
    579 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(Vector &), Vector atom::*value )
     471template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const
    580472{
    581473  atom *Walker = start;
     
    585477  }
    586478};
    587 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(Vector &), Vector &vect )
     479template <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};
     487template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const
    588488{
    589489  atom *Walker = start;
     
    593493  }
    594494};
    595 
    596 template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value )
     495template <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};
     503template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const
    597504{
    598505  atom *Walker = start;
     
    604511};
    605512
    606 template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr )
     513template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const
    607514{
    608515  atom *Walker = start;
  • src/vector.cpp

    r831a14 rb453f9  
    12761276 * @param three vectors forming the matrix that defines the shape of the parallelpiped
    12771277 */
    1278 bool Vector::IsInParallelepiped(Vector offset, double *parallelepiped)
     1278bool Vector::IsInParallelepiped(const Vector offset, const double *parallelepiped) const
    12791279{
    12801280  Vector a;
  • src/vector.hpp

    r831a14 rb453f9  
    7777  void AskPosition(double *cell_size, bool check);
    7878  bool Output(ofstream *out) const;
    79   bool IsInParallelepiped(Vector offset, double *parallelepiped);
     79  bool IsInParallelepiped(const Vector offset, const double *parallelepiped) const;
    8080  void WrapPeriodically(const double *M, const double *Minv);
    8181};
Note: See TracChangeset for help on using the changeset viewer.