Changeset 4455f4


Ignore:
Timestamp:
Oct 19, 2009, 1:09:29 PM (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:
c75de1
Parents:
9eefda
Message:

Huge Refactoring: class atom split up into several inherited classes.

Location:
src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/atom.cpp

    r9eefda r4455f4  
    1616/************************************* Functions for class atom *************************************/
    1717
     18/** Constructor of class AtomInfo.
     19 */
     20AtomInfo::AtomInfo() : type(NULL) {};
     21
     22/** Destructor of class AtomInfo.
     23 */
     24AtomInfo::~AtomInfo()
     25{
     26};
     27
     28/** Constructor of class TrajectoryParticleInfo.
     29 */
     30TrajectoryParticleInfo::TrajectoryParticleInfo() : FixedIon(0) {};
     31
     32/** Destructor of class TrajectoryParticleInfo.
     33 */
     34TrajectoryParticleInfo::~TrajectoryParticleInfo()
     35{
     36  Trajectory.R.clear();
     37  Trajectory.U.clear();
     38  Trajectory.F.clear();
     39};
     40
     41/** Constructor of class TrajectoryParticle.
     42 */
     43TrajectoryParticle::TrajectoryParticle()
     44{
     45};
     46
     47/** Destructor of class TrajectoryParticle.
     48 */
     49TrajectoryParticle::~TrajectoryParticle()
     50{
     51};
     52
     53/** Constructor of class GraphNodeInfo.
     54 */
     55GraphNodeInfo::GraphNodeInfo() : GraphNr(-1), ComponentNr(NULL), LowpointNr(-1), SeparationVertex(false), IsCyclic(false), Ancestor(NULL) {};
     56
     57/** Destructor of class GraphNodeInfo.
     58 */
     59GraphNodeInfo::~GraphNodeInfo()
     60{
     61  Free<int>(&ComponentNr, "atom::~atom: *ComponentNr");
     62};
     63
     64/** Constructor of class GraphNode.
     65 */
     66GraphNode::GraphNode()
     67{
     68};
     69
     70/** Destructor of class GraphNode.
     71 */
     72GraphNode::~GraphNode()
     73{
     74};
     75
     76/** Constructor of class BondedParticleInfo.
     77 */
     78BondedParticleInfo::BondedParticleInfo() : AdaptiveOrder(0), MaxOrder(false) {};
     79
     80/** Destructor of class BondedParticleInfo.
     81 */
     82BondedParticleInfo::~BondedParticleInfo()
     83{
     84};
     85
     86/** Constructor of class BondedParticle.
     87 */
     88BondedParticle::BondedParticle(){};
     89
     90/** Destructor of class BondedParticle.
     91 */
     92BondedParticle::~BondedParticle()
     93{
     94  BondList::const_iterator Runner;
     95  while (!ListOfBonds.empty()) {
     96    Runner = ListOfBonds.begin();
     97    removewithoutcheck(*Runner);
     98  }
     99};
     100
    18101/** Constructor of class atom.
    19102 */
     
    23106  previous = NULL;
    24107  next = NULL;
    25   Ancestor = NULL;
    26   type = NULL;
    27   sort = NULL;
    28   FixedIon = 0;
    29   GraphNr = -1;
    30   ComponentNr = NULL;
    31   IsCyclic = false;
    32   SeparationVertex = false;
    33   LowpointNr = -1;
    34   AdaptiveOrder = 0;
    35   MaxOrder = false;
     108  sort = &nr;
     109
    36110  // set LCNode::Vector to our Vector
    37111  node = &x;
     
    42116atom::atom(atom *pointer)
    43117{
    44   Name = NULL;
    45118  previous = NULL;
    46119  next = NULL;
    47120  father = pointer;  // generally, father is itself
    48   Ancestor = NULL;
    49   GraphNr = -1;
    50   ComponentNr = NULL;
    51   IsCyclic = false;
    52   SeparationVertex = false;
    53   LowpointNr = -1;
    54   AdaptiveOrder = 0;
    55   MaxOrder = false;
     121
    56122  type = pointer->type;  // copy element of atom
    57123  x.CopyVector(&pointer->x); // copy coordination
    58124  v.CopyVector(&pointer->v); // copy velocity
    59125  FixedIon = pointer->FixedIon;
    60   nr = -1;
    61126  sort = &nr;
    62127  node = &x;
     
    68133atom::~atom()
    69134{
    70   BondList::const_iterator Runner;
    71   while (!ListOfBonds.empty()) {
    72     Runner = ListOfBonds.begin();
    73     removewithoutcheck(*Runner);
    74   }
    75135  unlink(this);
    76   Free<int>(&ComponentNr, "atom::~atom: *ComponentNr");
    77   Free<char>(&Name, "atom::~atom: *Name");
    78   Trajectory.R.clear();
    79   Trajectory.U.clear();
    80   Trajectory.F.clear();
    81136};
    82137
     
    130185 * \param bonds times bond::BondDegree
    131186 */
    132 int atom::CountBonds() const
     187int BondedParticle::CountBonds() const
    133188{
    134189  int NoBonds = 0;
     
    233288};
    234289
    235 /** Output graph info of this atom.
     290/** Outputs the MPQC configuration line for this atom.
    236291 * \param *out output stream
    237  */
    238 void atom::OutputGraphInfo(ofstream *out) const
    239 {
    240   *out << Verbose(2) << "Atom " << Name << " is " << ((SeparationVertex) ? "a" : "not a") << " separation vertex, components are ";
    241   OutputComponentNumber(out);
    242   *out << " with Lowpoint " << LowpointNr << " and Graph Nr. " << GraphNr << "." << endl;
    243 };
    244 
    245 /** Output a list of flags, stating whether the bond was visited or not.
    246  * Note, we make use of the last entry of the ComponentNr always being -1 if allocated.
    247  * \param *out output stream for debugging
    248  */
    249 void atom::OutputComponentNumber(ofstream *out) const
    250 {
    251   if (ComponentNr != NULL) {
    252     for (int i=0; ComponentNr[i] != -1; i++)
    253       *out << ComponentNr[i] << " ";
    254   }
    255 };
    256 
    257 
    258 /** Prints all bonds of this atom with total degree.
    259  * \param *out stream to output to
    260  * \return true - \a *out present, false - \a *out is NULL
    261  */
    262 bool atom::OutputBondOfAtom(ofstream *out) const
    263 {
    264   if (out != NULL) {
    265 #ifdef ADDHYDROGEN
    266     if (type->Z != 1) {   // regard only non-hydrogen
    267 #endif
    268       *out << Verbose(4) << "Atom " << Name << "/" << nr << " with " << ListOfBonds.size() << " bonds: ";
    269       int TotalDegree = 0;
    270       for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); ++Runner) {
    271         *out << **Runner << "\t";
    272         TotalDegree += (*Runner)->BondDegree;
    273       }
    274       *out << " -- TotalDegree: " << TotalDegree << endl;
    275 #ifdef ADDHYDROGEN
    276     }
    277 #endif
     292 * \param *center center of molecule subtracted from position
     293 * \param *AtomNo pointer to atom counter that is increased by one
     294 */
     295void atom::OutputMPQCLine(ofstream *out, Vector *center, int *AtomNo = NULL) const
     296{
     297  *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;
     298  if (AtomNo != NULL)
     299    *AtomNo++;
     300};
     301
     302ostream & operator << (ostream &ost, const ParticleInfo &a)
     303{
     304  ost << "[" << a.Name << "|" << &a << "]";
     305  return ost;
     306};
     307
     308ostream & ParticleInfo::operator << (ostream &ost)
     309{
     310  ost << "[" << Name << "|" << this << "]";
     311  return ost;
     312};
     313
     314/** Compares the indices of \a this atom with a given \a ptr.
     315 * \param ptr atom to compare index against
     316 * \return true - this one's is smaller, false - not
     317 */
     318bool atom::Compare(const atom &ptr)
     319{
     320  if (nr < ptr.nr)
    278321    return true;
    279   } else
     322  else
    280323    return false;
    281324};
    282325
    283 /** Output of atom::nr along with all bond partners.
    284  * \param *AdjacencyFile output stream
    285  */
    286 void atom::OutputAdjacency(ofstream *AdjacencyFile) const
    287 {
    288   *AdjacencyFile << nr << "\t";
    289   for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner))
    290     *AdjacencyFile << (*Runner)->GetOtherAtom(this)->nr << "\t";
    291   *AdjacencyFile << endl;
    292 };
    293 
    294 /** Outputs the current atom::AdaptiveOrder and atom::MaxOrder to \a *file.
    295  * \param *file output stream
    296  */
    297 void atom::OutputOrder(ofstream *file)
    298 {
    299   *file << nr << "\t" << (int)AdaptiveOrder << "\t" << (int)MaxOrder << endl;
    300   //cout << Verbose(2) << "Storing: " << nr << "\t" << (int)AdaptiveOrder << "\t" << (int)MaxOrder << "." << endl;
     326/** Returns squared distance to a given vector.
     327 * \param origin vector to calculate distance to
     328 * \return distance squared
     329 */
     330double atom::DistanceSquaredToVector(Vector &origin)
     331{
     332  return origin.DistanceSquared(&x);
     333};
     334
     335/** Returns distance to a given vector.
     336 * \param origin vector to calculate distance to
     337 * \return distance
     338 */
     339double atom::DistanceToVector(Vector &origin)
     340{
     341  return origin.Distance(&x);
    301342};
    302343
     
    313354};
    314355
     356
     357bool operator < (atom &a, atom &b)
     358{
     359  return a.Compare(b);
     360};
     361
     362/** Output graph info of this atom.
     363 * \param *out output stream
     364 */
     365void GraphNode::OutputGraphInfo(ofstream *out) const
     366{
     367  *out << Verbose(2) << "Atom " << Name << " is " << ((SeparationVertex) ? "a" : "not a") << " separation vertex, components are ";
     368  OutputComponentNumber(out);
     369  *out << " with Lowpoint " << LowpointNr << " and Graph Nr. " << GraphNr << "." << endl;
     370};
     371
     372/** Output a list of flags, stating whether the bond was visited or not.
     373 * Note, we make use of the last entry of the ComponentNr always being -1 if allocated.
     374 * \param *out output stream for debugging
     375 */
     376void GraphNode::OutputComponentNumber(ofstream *out) const
     377{
     378  if (ComponentNr != NULL) {
     379    for (int i=0; ComponentNr[i] != -1; i++)
     380      *out << ComponentNr[i] << " ";
     381  }
     382};
     383
     384/** Outputs the current atom::AdaptiveOrder and atom::MaxOrder to \a *file.
     385 * \param *file output stream
     386 */
     387void BondedParticle::OutputOrder(ofstream *file)
     388{
     389  *file << nr << "\t" << (int)AdaptiveOrder << "\t" << (int)MaxOrder << endl;
     390  //cout << Verbose(2) << "Storing: " << nr << "\t" << (int)AdaptiveOrder << "\t" << (int)MaxOrder << "." << endl;
     391};
     392
     393/** Prints all bonds of this atom with total degree.
     394 * \param *out stream to output to
     395 * \return true - \a *out present, false - \a *out is NULL
     396 */
     397bool BondedParticle::OutputBondOfAtom(ofstream *out) const
     398{
     399  if (out != NULL) {
     400    *out << Verbose(4) << "Atom " << Name << "/" << nr << " with " << ListOfBonds.size() << " bonds: ";
     401    int TotalDegree = 0;
     402    for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); ++Runner) {
     403      *out << **Runner << "\t";
     404      TotalDegree += (*Runner)->BondDegree;
     405    }
     406    *out << " -- TotalDegree: " << TotalDegree << endl;
     407    return true;
     408  } else
     409    return false;
     410};
     411
     412/** Output of atom::nr along with all bond partners.
     413 * \param *AdjacencyFile output stream
     414 */
     415void BondedParticle::OutputAdjacency(ofstream *AdjacencyFile) const
     416{
     417  *AdjacencyFile << nr << "\t";
     418  for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner))
     419    *AdjacencyFile << (*Runner)->GetOtherAtom(this)->nr << "\t";
     420  *AdjacencyFile << endl;
     421};
     422
    315423/** Puts a given bond into atom::ListOfBonds.
    316424 * \param *Binder bond to insert
    317425 */
    318 bool atom::RegisterBond(bond *Binder)
     426bool BondedParticle::RegisterBond(bond *Binder)
    319427{
    320428  bool status = false;
     
    335443 * \param *Binder bond to remove
    336444 */
    337 bool atom::UnregisterBond(bond *Binder)
     445bool BondedParticle::UnregisterBond(bond *Binder)
    338446{
    339447  bool status = false;
     
    354462 * \note Does not do any memory de-allocation.
    355463 */
    356 void atom::UnregisterAllBond()
     464void BondedParticle::UnregisterAllBond()
    357465{
    358466  ListOfBonds.clear();
     
    362470 * \param *out output stream for debugging
    363471 */
    364 int atom::CorrectBondDegree(ofstream *out)
     472int BondedParticle::CorrectBondDegree(ofstream *out)
    365473{
    366474  int NoBonds = 0;
     
    395503};
    396504
    397 ostream & operator << (ostream &ost, const atom &a)
    398 {
    399   ost << "[" << a.Name << "|" << &a << "]";
    400   return ost;
    401 };
    402 
    403 ostream & atom::operator << (ostream &ost)
    404 {
    405   ost << "[" << Name << "|" << this << "]";
    406   return ost;
    407 };
    408 
    409 /** Compares the indices of \a this atom with a given \a ptr.
    410  * \param ptr atom to compare index against
    411  * \return true - this one's is smaller, false - not
    412  */
    413 bool atom::Compare(const atom &ptr)
    414 {
    415   if (nr < ptr.nr)
    416     return true;
    417   else
    418     return false;
     505/** Adds kinetic energy of this atom to given temperature value.
     506 * \param *temperature add on this value
     507 * \param step given step of trajectory to add
     508 */
     509void TrajectoryParticle::AddKineticToTemperature(double *temperature, int step) const
     510{
     511  for (int i=NDIM;i--;)
     512    *temperature += type->mass * Trajectory.U.at(step).x[i]* Trajectory.U.at(step).x[i];
     513};
     514
     515/** Evaluates some constraint potential if atom moves from \a startstep at once to \endstep in trajectory.
     516 * \param startstep trajectory begins at
     517 * \param endstep trajectory ends at
     518 * \param **PermutationMap if atom switches places with some other atom, there is no translation but a permutaton noted here (not in the trajectories of each).
     519 * \param *Force Force matrix to store result in
     520 */
     521void TrajectoryParticle::EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force)
     522{
     523  double constant = 10.;
     524  TrajectoryParticle *Sprinter = PermutationMap[nr];
     525  // set forces
     526  for (int i=NDIM;i++;)
     527    Force->Matrix[0][nr][5+i] += 2.*constant*sqrt(Trajectory.R.at(startstep).Distance(&Sprinter->Trajectory.R.at(endstep)));
     528};
     529
     530/** Correct velocity against the summed \a CoGVelocity for \a step.
     531 * \param *ActualTemp sum up actual temperature meanwhile
     532 * \param Step MD step in atom::Tracjetory
     533 * \param *CoGVelocity remnant velocity (i.e. vector sum of all atom velocities)
     534 */
     535void TrajectoryParticle::CorrectVelocity(double *ActualTemp, int Step, Vector *CoGVelocity)
     536{
     537  for(int d=0;d<NDIM;d++) {
     538    Trajectory.U.at(Step).x[d] -= CoGVelocity->x[d];
     539    *ActualTemp += 0.5 * type->mass * Trajectory.U.at(Step).x[d] * Trajectory.U.at(Step).x[d];
     540  }
    419541};
    420542
     
    423545 * \param MaxSteps
    424546 */
    425 void atom::ResizeTrajectory(int MaxSteps)
     547void TrajectoryParticle::ResizeTrajectory(int MaxSteps)
    426548{
    427549  if (Trajectory.R.size() <= (unsigned int)(MaxSteps)) {
     
    437559 * \param src index of source step
    438560 */
    439 void atom::CopyStepOnStep(int dest, int src)
     561void TrajectoryParticle::CopyStepOnStep(int dest, int src)
    440562{
    441563  if (dest == src)  // self assignment check
     
    455577 * \param *Force matrix with forces
    456578 */
    457 void atom::VelocityVerletUpdate(int NextStep, config *configuration, ForceMatrix *Force)
     579void TrajectoryParticle::VelocityVerletUpdate(int NextStep, config *configuration, ForceMatrix *Force)
    458580{
    459581  //a = configuration.Deltat*0.5/walker->type->mass;        // (F+F_old)/2m = a and thus: v = (F+F_old)/2m * t = (F + F_old) * a
     
    484606 * \param *TotalVelocity pointer to tota velocity sum
    485607 */
    486 void atom::SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity )
     608void TrajectoryParticle::SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity )
    487609{
    488610  *TotalMass += type->mass;  // sum up total mass
    489611  for(int d=0;d<NDIM;d++) {
    490612    TotalVelocity->x[d] += Trajectory.U.at(Step).x[d]*type->mass;
    491   }
    492 };
    493 
    494 /** Returns squared distance to a given vector.
    495  * \param origin vector to calculate distance to
    496  * \return distance squared
    497  */
    498 double atom::DistanceSquaredToVector(Vector &origin)
    499 {
    500   return origin.DistanceSquared(&x);
    501 };
    502 
    503 /** Adds kinetic energy of this atom to given temperature value.
    504  * \param *temperature add on this value
    505  * \param step given step of trajectory to add
    506  */
    507 void atom::AddKineticToTemperature(double *temperature, int step) const
    508 {
    509   for (int i=NDIM;i--;)
    510     *temperature += type->mass * Trajectory.U.at(step).x[i]* Trajectory.U.at(step).x[i];
    511 };
    512 
    513 /** Returns distance to a given vector.
    514  * \param origin vector to calculate distance to
    515  * \return distance
    516  */
    517 double atom::DistanceToVector(Vector &origin)
    518 {
    519   return origin.Distance(&x);
    520 };
    521 
    522 bool operator < (atom &a, atom &b)
    523 {
    524   return a.Compare(b);
    525 };
    526 
    527 /** Evaluates some constraint potential if atom moves from \a startstep at once to \endstep in trajectory.
    528  * \param startstep trajectory begins at
    529  * \param endstep trajectory ends at
    530  * \param **PermutationMap if atom switches places with some other atom, there is no translation but a permutaton noted here (not in the trajectories of each).
    531  * \param *Force Force matrix to store result in
    532  */
    533 void atom::EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force)
    534 {
    535   double constant = 10.;
    536   atom *Sprinter = PermutationMap[nr];
    537   // set forces
    538   for (int i=NDIM;i++;)
    539     Force->Matrix[0][nr][5+i] += 2.*constant*sqrt(Trajectory.R.at(startstep).Distance(&Sprinter->Trajectory.R.at(endstep)));
    540 };
    541 
    542 /** Correct velocity against the summed \a CoGVelocity for \a step.
    543  * \param *ActualTemp sum up actual temperature meanwhile
    544  * \param Step MD step in atom::Tracjetory
    545  * \param *CoGVelocity remnant velocity (i.e. vector sum of all atom velocities)
    546  */
    547 void atom::CorrectVelocity(double *ActualTemp, int Step, Vector *CoGVelocity)
    548 {
    549   for(int d=0;d<NDIM;d++) {
    550     Trajectory.U.at(Step).x[d] -= CoGVelocity->x[d];
    551     *ActualTemp += 0.5 * type->mass * Trajectory.U.at(Step).x[d] * Trajectory.U.at(Step).x[d];
    552613  }
    553614};
     
    558619 * \param *ekin sum of kinetic energy
    559620 */
    560 void atom::Thermostat_Woodcock(double ScaleTempFactor, int Step, double *ekin)
     621void TrajectoryParticle::Thermostat_Woodcock(double ScaleTempFactor, int Step, double *ekin)
    561622{
    562623  double *U = Trajectory.U.at(Step).x;
     
    573634 * \param *E
    574635 */
    575 void atom::Thermostat_Gaussian_init(int Step, double *G, double *E)
     636void TrajectoryParticle::Thermostat_Gaussian_init(int Step, double *G, double *E)
    576637{
    577638  double *U = Trajectory.U.at(Step).x;
     
    590651 * \param *configuration configuration class with TempFrequency and TargetTemp
    591652 */
    592 void atom::Thermostat_Gaussian_least_constraint(int Step, double G_over_E, double *ekin, config *configuration)
     653void TrajectoryParticle::Thermostat_Gaussian_least_constraint(int Step, double G_over_E, double *ekin, config *configuration)
    593654{
    594655  double *U = Trajectory.U.at(Step).x;
     
    606667 * \param *configuration configuration class with TempFrequency and TargetTemp
    607668 */
    608 void atom::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration)
     669void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration)
    609670{
    610671  double sigma  = sqrt(configuration->TargetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)
     
    631692 * \param *configuration configuration class with TempFrequency and Deltat
    632693 */
    633 void atom::Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration)
     694void TrajectoryParticle::Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration)
    634695{
    635696  double *U = Trajectory.U.at(Step).x;
     
    646707 * \param *delta_alpha additional sum of kinetic energy on return
    647708 */
    648 void atom::Thermostat_NoseHoover_init(int Step, double *delta_alpha)
     709void TrajectoryParticle::Thermostat_NoseHoover_init(int Step, double *delta_alpha)
    649710{
    650711  double *U = Trajectory.U.at(Step).x;
     
    661722 * \param *configuration configuration class with TempFrequency and Deltat
    662723 */
    663 void atom::Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration)
     724void TrajectoryParticle::Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration)
    664725{
    665726  double *U = Trajectory.U.at(Step).x;
  • src/atom.hpp

    r9eefda r4455f4  
    2828/****************************************** forward declarations *****************************/
    2929
     30class atom;
    3031class bond;
    3132class config;
     
    3839/********************************************** declarations *******************************/
    3940
     41class AtomInfo {
     42public:
     43  Vector x;       //!< coordinate vector of atom, giving last position within cell
     44  Vector v;       //!< velocity vector of atom, giving last velocity within cell
     45  Vector F;       //!< Force vector of atom, giving last force within cell
     46  element *type;  //!< pointing to element
     47
     48  AtomInfo();
     49  ~AtomInfo();
     50
     51private:
     52};
     53
     54class TrajectoryParticleInfo {
     55public:
     56  struct
     57  {
     58    vector<Vector> R;  //!< position vector
     59    vector<Vector> U;  //!< velocity vector
     60    vector<Vector> F;  //!< last force vector
     61  } Trajectory;
     62  int FixedIon;   //!< config variable that states whether forces act on the ion or not
     63
     64  TrajectoryParticleInfo();
     65  ~TrajectoryParticleInfo();
     66
     67private:
     68};
     69
     70class TrajectoryParticle :  public TrajectoryParticleInfo, public virtual AtomInfo, public virtual ParticleInfo {
     71public:
     72
     73  TrajectoryParticle();
     74  virtual ~TrajectoryParticle();
     75
     76  // constraint potential and dynamics stuff
     77  void AddKineticToTemperature(double *temperature, int step) const;
     78  void EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force);
     79  void CorrectVelocity(double *ActualTemp, int Step, Vector *CoGVelocity);
     80
     81  // trajectory stuff
     82  void ResizeTrajectory(int MaxSteps);
     83  void CopyStepOnStep(int dest, int src);
     84  void VelocityVerletUpdate(int MDSteps, config *configuration, ForceMatrix *Force);
     85  void SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity );
     86
     87  // thermostats
     88  void Thermostat_Woodcock(double ScaleTempFactor, int Step, double *ekin);
     89  void Thermostat_Gaussian_init(int Step, double *G, double *E);
     90  void Thermostat_Gaussian_least_constraint(int Step, double G_over_E, double *ekin, config *configuration);
     91  void Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration);
     92  void Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration);
     93  void Thermostat_NoseHoover_init(int Step, double *delta_alpha);
     94  void Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration);
     95
     96private:
     97
     98};
     99
     100class GraphNode;
     101
     102class GraphNodeInfo {
     103public:
     104
     105  int GraphNr;      //!< unique number, given in DepthFirstSearchAnalysis()
     106  int *ComponentNr;//!< belongs to this non-separable components, given in DepthFirstSearchAnalysis() (if more than one, then is SeparationVertex)
     107  int LowpointNr; //!< needed in DepthFirstSearchAnalysis() to detect non-separable components, is the lowest possible number of an atom to reach via tree edges only followed by at most one back edge.
     108  bool SeparationVertex; //!< whether this atom separates off subsets of atoms or not, determined in DepthFirstSearchAnalysis()
     109  bool IsCyclic;        //!< whether atom belong to as cycle or not, determined in DepthFirstSearchAnalysis()
     110  atom *Ancestor; //!< "Father" in Depth-First-Search
     111
     112  GraphNodeInfo();
     113  ~GraphNodeInfo();
     114private:
     115
     116};
     117
     118
     119class GraphNode : public GraphNodeInfo, public virtual ParticleInfo {
     120public:
     121
     122  GraphNode();
     123  virtual ~GraphNode();
     124
     125  void OutputGraphInfo(ofstream *out) const;
     126  void OutputComponentNumber(ofstream *out) const;
     127
     128private:
     129
     130};
     131
     132class BondedParticleInfo {
     133public:
     134  unsigned char AdaptiveOrder;  //!< current present bond order at site (0 means "not set")
     135  bool MaxOrder;  //!< whether this atom as a root in fragmentation still creates more fragments on higher orders or not
     136  BondList ListOfBonds; //!< list of all bonds
     137
     138  BondedParticleInfo();
     139  ~BondedParticleInfo();
     140
     141private:
     142
     143};
     144
     145class BondedParticle : public BondedParticleInfo, public virtual ParticleInfo, public virtual AtomInfo {
     146public:
     147  BondedParticle();
     148  virtual ~BondedParticle();
     149
     150  bool RegisterBond(bond *Binder);
     151  bool UnregisterBond(bond *Binder);
     152  void UnregisterAllBond();
     153  int CountBonds() const;
     154  int CorrectBondDegree(ofstream *out);
     155  bool OutputBondOfAtom(ofstream *out) const;
     156  void OutputAdjacency(ofstream *AdjacencyFile) const;
     157  void OutputOrder(ofstream *file);
     158
     159private:
     160
     161};
     162
    40163/** Single atom.
    41164 * Class incorporates position, type
    42165 */
    43 class atom : public TesselPoint {
     166class atom : public TesselPoint, public TrajectoryParticle, public GraphNode, public BondedParticle, public virtual ParticleInfo, public virtual AtomInfo {
    44167  public:
    45     struct
    46     {
    47       vector<Vector> R;  //!< position vector
    48       vector<Vector> U;  //!< velocity vector
    49       vector<Vector> F;  //!< last force vector
    50     } Trajectory;
    51 
    52     Vector x;       //!< coordinate vector of atom, giving last position within cell
    53     Vector v;       //!< velocity vector of atom, giving last velocity within cell
    54     Vector F;       //!< Force vector of atom, giving last force within cell
    55     BondList ListOfBonds; //!< list of all bonds
    56     element *type;  //!< pointing to element
    57168    atom *previous; //!< previous atom in molecule list
    58169    atom *next;     //!< next atom in molecule list
    59170    atom *father;   //!< In many-body bond order fragmentations points to originating atom
    60     atom *Ancestor; //!< "Father" in Depth-First-Search
    61     //char *Name;      //!< unique name used during many-body bond-order fragmentation, comes from TesselPoint
    62     int FixedIon;   //!< config variable that states whether forces act on the ion or not
    63171    int *sort;      //!< sort criteria
    64     //int nr;         //!< continuous, unique number, comes from TesselPoint
    65     int GraphNr;      //!< unique number, given in DepthFirstSearchAnalysis()
    66     int *ComponentNr;//!< belongs to this nonseparable components, given in DepthFirstSearchAnalysis() (if more than one, then is SeparationVertex)
    67     int LowpointNr; //!< needed in DepthFirstSearchAnalysis() to detect nonseparable components, is the lowest possible number of an atom to reach via tree edges only followed by at most one back edge.
    68     bool SeparationVertex; //!< whether this atom separates off subsets of atoms or not, determined in DepthFirstSearchAnalysis()
    69     bool IsCyclic;        //!< whether atom belong to as cycle or not, determined in DepthFirstSearchAnalysis()
    70     unsigned char AdaptiveOrder;  //!< current present bond order at site (0 means "not set")
    71     bool MaxOrder;  //!< whether this atom as a root in fragmentation still creates more fragments on higher orders or not
    72172
    73173  atom();
     
    80180  bool OutputTrajectory(ofstream *out, int *ElementNo, int *AtomNo, int step) const;
    81181  bool OutputTrajectoryXYZ(ofstream *out, int step) const;
    82   bool OutputBondOfAtom(ofstream *out) const;
    83   void OutputAdjacency(ofstream *AdjacencyFile) const;
     182  void OutputMPQCLine(ofstream *out, Vector *center, int *AtomNo) const;
    84183
     184  void InitComponentNr();
    85185
    86186  void EqualsFather ( atom *ptr, atom **res );
     
    89189  bool Compare(const atom &ptr);
    90190
    91   // trajectory stuff
    92   void ResizeTrajectory(int MaxSteps);
    93   void CopyStepOnStep(int dest, int src);
    94   void VelocityVerletUpdate(int MDSteps, config *configuration, ForceMatrix *Force);
    95   void SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity );
    96 
    97191  double DistanceToVector(Vector &origin);
    98192  double DistanceSquaredToVector(Vector &origin);
    99 
    100193  bool IsInParallelepiped(Vector offset, double *parallelepiped);
    101 
    102   // bond order stuff
    103   void OutputOrder(ofstream *file);
    104   void OutputGraphInfo(ofstream *out) const;
    105   void OutputComponentNumber(ofstream *out) const;
    106   void InitComponentNr();
    107   int CountBonds() const;
    108   int CorrectBondDegree(ofstream *out);
    109 
    110   bool RegisterBond(bond *Binder);
    111   bool UnregisterBond(bond *Binder);
    112   void UnregisterAllBond();
    113 
    114   // constraint potential and dynamics stuff
    115   void AddKineticToTemperature(double *temperature, int step) const;
    116   void EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force);
    117   void CorrectVelocity(double *ActualTemp, int Step, Vector *CoGVelocity);
    118 
    119   // thermostats
    120   void Thermostat_Woodcock(double ScaleTempFactor, int Step, double *ekin);
    121   void Thermostat_Gaussian_init(int Step, double *G, double *E);
    122   void Thermostat_Gaussian_least_constraint(int Step, double G_over_E, double *ekin, config *configuration);
    123   void Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration);
    124   void Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration);
    125   void Thermostat_NoseHoover_init(int Step, double *delta_alpha);
    126   void Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration);
    127 
    128 
    129   ostream & operator << (ostream &ost);
    130194
    131195  private:
    132196};
    133197
    134 ostream & operator << (ostream &ost, const atom &a);
    135 
    136198#endif /* ATOM_HPP_ */
  • src/bond.cpp

    r9eefda r4455f4  
    9595 * \return pointer to the other atom in the bond, NULL if no match (indicates something's wrong with the bond)
    9696 */
    97 atom * bond::GetOtherAtom(const atom *Atom) const
     97atom * bond::GetOtherAtom(const ParticleInfo *Atom) const
    9898{
    9999  if(leftatom == Atom)
     
    118118 * \return true if it is either bond::leftatom or bond::rightatom, false otherwise
    119119 */
    120 bool bond::Contains(const atom *ptr)
     120bool bond::Contains(const ParticleInfo *ptr)
    121121{
    122122  return ((leftatom == ptr) || (rightatom == ptr));
  • src/bond.hpp

    r9eefda r4455f4  
    2121
    2222class atom;
     23class ParticleInfo;
    2324
    2425/********************************************** declarations *******************************/
     
    4344    enum EdgeType Type;//!< whether this is a tree or back edge
    4445
    45   atom * GetOtherAtom(const atom *Atom) const;
     46  atom * GetOtherAtom(const ParticleInfo *Atom) const;
    4647
    4748  bool MarkUsed(enum Shading color);
    4849  enum Shading IsUsed();
    4950  void ResetUsed();
    50   bool Contains(const atom *ptr);
     51  bool Contains(const ParticleInfo *ptr);
    5152  bool Contains(const int nr);
    5253
  • src/config.cpp

    r9eefda r4455f4  
    99#include "element.hpp"
    1010#include "helpers.hpp"
     11#include "molecule.hpp"
    1112#include "memoryallocator.hpp"
    1213#include "molecule.hpp"
     
    14441445bool config::SaveMPQC(const char *filename, molecule *mol) const
    14451446{
    1446   int ElementNo = 0;
    14471447  int AtomNo;
    1448   atom *Walker = NULL;
    1449   element *runner = NULL;
    14501448  Vector *center = NULL;
    14511449  ofstream *output = NULL;
     
    14751473  center = mol->DetermineCenterOfAll(output);
    14761474  // output of atoms
    1477   runner = mol->elemente->start;
    1478   while (runner->next != mol->elemente->end) { // go through every element
    1479     runner = runner->next;
    1480     if (mol->ElementsInMolecule[runner->Z]) { // if this element got atoms
    1481       ElementNo++;
    1482       AtomNo = 0;
    1483       Walker = mol->start;
    1484       while (Walker->next != mol->end) { // go through every atom of this element
    1485         Walker = Walker->next;
    1486         if (Walker->type == runner) { // if this atom fits to element
    1487           AtomNo++;
    1488           *output << "\t\t" << Walker->type->symbol << " [ " << Walker->x.x[0]-center->x[0] << "\t" << Walker->x.x[1]-center->x[1] << "\t" << Walker->x.x[2]-center->x[2] << " ]" << endl;
    1489         }
    1490       }
    1491     }
    1492   }
     1475  AtomNo = 0;
     1476  mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, center, &AtomNo );
    14931477  delete(center);
    14941478  *output << "\t}" << endl;
     
    15241508  center = mol->DetermineCenterOfAll(output);
    15251509  // output of atoms
    1526   runner = mol->elemente->start;
    1527   while (runner->next != mol->elemente->end) { // go through every element
    1528     runner = runner->next;
    1529     if (mol->ElementsInMolecule[runner->Z]) { // if this element got atoms
    1530       ElementNo++;
    1531       AtomNo = 0;
    1532       Walker = mol->start;
    1533       while (Walker->next != mol->end) { // go through every atom of this element
    1534         Walker = Walker->next;
    1535         if (Walker->type == runner) { // if this atom fits to element
    1536           AtomNo++;
    1537           *output << "\t\t" << Walker->type->symbol << " [ " << Walker->x.x[0]-center->x[0] << "\t" << Walker->x.x[1]-center->x[1] << "\t" << Walker->x.x[2]-center->x[2] << " ]" << endl;
    1538         }
    1539       }
    1540     }
    1541   }
     1510  AtomNo = 0;
     1511  mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, center, &AtomNo );
    15421512  delete(center);
    15431513  *output << "\t}" << endl;
  • src/molecule.cpp

    r9eefda r4455f4  
    10781078  for (int step=startstep;step < endstep; step++) { // loop over all time steps
    10791079    temperature = 0.;
    1080     ActOnAllAtoms( &atom::AddKineticToTemperature, &temperature, step);
     1080    ActOnAllAtoms( &TrajectoryParticle::AddKineticToTemperature, &temperature, step);
    10811081    *output << step << "\t" << temperature*AtomicEnergyToKelvin << "\t" << temperature << endl;
    10821082  }
     
    10841084};
    10851085
    1086 void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int TesselPoint::*index)
     1086void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index)
    10871087{
    10881088  atom *Walker = start;
  • src/molecule.hpp

    r9eefda r4455f4  
    146146
    147147  // templates for allowing global manipulation of all atoms
    148   template <typename res> void ActOnAllAtoms( res (atom::*f)() );
    149   template <typename res> void ActOnAllAtoms( res (atom::*f)() const );
    150   template <typename res> void ActOnAllAtoms( res (atom::*f)() ) const;
    151   template <typename res> void ActOnAllAtoms( res (atom::*f)() const) const;
    152   template <typename res, typename T> void ActOnAllAtoms( res (atom::*f)(T), T t );
    153   template <typename res, typename T> void ActOnAllAtoms( res (atom::*f)(T) const, T t );
    154   template <typename res, typename T> void ActOnAllAtoms( res (atom::*f)(T), T t ) const;
    155   template <typename res, typename T> void ActOnAllAtoms( res (atom::*f)(T) const, T t ) const;
    156   template <typename res, typename T, typename U> void ActOnAllAtoms( res (atom::*f)(T, U), T t, U u );
    157   template <typename res, typename T, typename U> void ActOnAllAtoms( res (atom::*f)(T, U) const, T t, U u );
    158   template <typename res, typename T, typename U> void ActOnAllAtoms( res (atom::*f)(T, U), T t, U u ) const;
    159   template <typename res, typename T, typename U> void ActOnAllAtoms( res (atom::*f)(T, U) const, T t, U u ) const;
    160   template <typename res, typename T, typename U, typename V> void ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v);
    161   template <typename res, typename T, typename U, typename V> void ActOnAllAtoms( res (atom::*f)(T, U, V) const, T t, U u, V v);
    162   template <typename res, typename T, typename U, typename V> void ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v) const;
    163   template <typename res, typename T, typename U, typename V> void ActOnAllAtoms( res (atom::*f)(T, U, V) const, T t, U u, V v) const;
    164   template <typename res, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (atom::*f)(T, U, V, W), T t, U u, V v, W w);
    165   template <typename res, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (atom::*f)(T, U, V, W) const, T t, U u, V v, W w);
    166   template <typename res, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (atom::*f)(T, U, V, W), T t, U u, V v, W w) const;
    167   template <typename res, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (atom::*f)(T, U, V, W) const, T t, U u, V v, W w) const;
     148  template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() );
     149  template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() const );
     150  template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() ) const;
     151  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  template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T), T t ) const;
     155  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  template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const;
     159  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  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  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  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  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;
    168168
    169169  // templates for allowing conditional global copying of molecule with each atom as single argument
     
    174174
    175175  // templates for allowing global manipulation of an array with one entry per atom
    176   void SetIndexedArrayForEachAtomTo ( atom **array, int TesselPoint::* index);
    177   template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::* index, void (*Setor)(T *, T *));
    178   template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::* index, void (*Setor)(T *, T *), T t);
    179   template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::* 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 TesselPoint::* index, T (atom::*Setor)(Vector &), Vector atom::*value);
    184   template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, T (atom::*Setor)(Vector &), Vector &vect );
     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 );
    185185
    186186  // templates for allowing global manipulation of each atom by entries in an array
    187   template <typename T> void SetAtomValueToIndexedArray ( T *array, int TesselPoint::*index, T atom::*value );
    188   template <typename T> void SetAtomValueToIndexedArray ( T *array, int element::*index, T atom::*value );
    189   template <typename T> void SetAtomValueToValue ( T value, T atom::*ptr );
    190 
    191   template <typename res> res SumPerAtom(res (atom::*f)() );
    192   template <typename res> res SumPerAtom(res (atom::*f)() const );
    193   template <typename res> res SumPerAtom(res (atom::*f)() ) const;
    194   template <typename res> res SumPerAtom(res (atom::*f)() const ) const;
    195   template <typename T, typename res> res SumPerAtom(res (atom::*f)(T) , T t );
    196   template <typename T, typename res> res SumPerAtom(res (atom::*f)(T) const, T t );
    197   template <typename T, typename res> res SumPerAtom(res (atom::*f)(T) , T t ) const;
    198   template <typename T, typename res> res SumPerAtom(res (atom::*f)(T) const, T t ) const;
     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 );
     192  template <typename res, typename typ> res SumPerAtom(res (typ::*f)() ) const;
     193  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  template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) , T t ) const;
     197  template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) const, T t ) const;
    199198
    200199  /// remove atoms from molecule.
  • src/molecule_template.hpp

    r9eefda r4455f4  
    156156
    157157// zero arguments
    158 template <typename res> res molecule::SumPerAtom(res (atom::*f)() )
     158template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() )
    159159{
    160160  res result = 0;
     
    166166  return result;
    167167};
    168 template <typename res> res molecule::SumPerAtom(res (atom::*f)() const )
     168template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const )
    169169{
    170170  res result = 0;
     
    176176  return result;
    177177};
    178 template <typename res> res molecule::SumPerAtom(res (atom::*f)() ) const
     178template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) const
    179179{
    180180  res result = 0;
     
    186186  return result;
    187187};
    188 template <typename res> res molecule::SumPerAtom(res (atom::*f)() const ) const
     188template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) const
    189189{
    190190  res result = 0;
     
    197197};
    198198// one argument
    199 template <typename T, typename res> res molecule::SumPerAtom(res (atom::*f)(T), T t )
     199template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t )
    200200{
    201201  res result = 0;
     
    207207  return result;
    208208};
    209 template <typename T, typename res> res molecule::SumPerAtom(res (atom::*f)(T) const, T t )
     209template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t )
    210210{
    211211  res result = 0;
     
    217217  return result;
    218218};
    219 template <typename T, typename res> res molecule::SumPerAtom(res (atom::*f)(T), T t ) const
     219template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) const
    220220{
    221221  res result = 0;
     
    227227  return result;
    228228};
    229 template <typename T, typename res> res molecule::SumPerAtom(res (atom::*f)(T) const, T t ) const
     229template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) const
    230230{
    231231  res result = 0;
     
    357357
    358358// zero arguments
    359 template <typename res> void molecule::ActOnAllAtoms( res (atom::*f)())
     359template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)())
    360360{
    361361  atom *Walker = start;
     
    365365  }
    366366};
    367 template <typename res> void molecule::ActOnAllAtoms( res (atom::*f)() const)
     367template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const)
    368368{
    369369  atom *Walker = start;
     
    373373  }
    374374};
    375 template <typename res> void molecule::ActOnAllAtoms( res (atom::*f)()) const
     375template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const
    376376{
    377377  atom *Walker = start;
     
    381381  }
    382382};
    383 template <typename res> void molecule::ActOnAllAtoms( res (atom::*f)() const) const
     383template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const
    384384{
    385385  atom *Walker = start;
     
    390390};
    391391// one argument
    392 template <typename res, typename T> void molecule::ActOnAllAtoms( res (atom::*f)(T), T t )
     392template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t )
    393393{
    394394  atom *Walker = start;
     
    398398  }
    399399};
    400 template <typename res, typename T> void molecule::ActOnAllAtoms( res (atom::*f)(T) const, T t )
     400template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t )
    401401{
    402402  atom *Walker = start;
     
    406406  }
    407407};
    408 template <typename res, typename T> void molecule::ActOnAllAtoms( res (atom::*f)(T), T t ) const
     408template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
    409409{
    410410  atom *Walker = start;
     
    414414  }
    415415};
    416 template <typename res, typename T> void molecule::ActOnAllAtoms( res (atom::*f)(T) const, T t ) const
     416template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const
    417417{
    418418  atom *Walker = start;
     
    423423};
    424424// two argument
    425 template <typename res, typename T, typename U> void molecule::ActOnAllAtoms( res (atom::*f)(T, U), T t, U u )
     425template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u )
    426426{
    427427  atom *Walker = start;
     
    431431  }
    432432};
    433 template <typename res, typename T, typename U> void molecule::ActOnAllAtoms( res (atom::*f)(T, U) const, T t, U u )
     433template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u )
    434434{
    435435  atom *Walker = start;
     
    439439  }
    440440};
    441 template <typename res, typename T, typename U> void molecule::ActOnAllAtoms( res (atom::*f)(T, U), T t, U u ) const
     441template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const
    442442{
    443443  atom *Walker = start;
     
    447447  }
    448448};
    449 template <typename res, typename T, typename U> void molecule::ActOnAllAtoms( res (atom::*f)(T, U) const, T t, U u ) const
     449template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const
    450450{
    451451  atom *Walker = start;
     
    456456};
    457457// three argument
    458 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v)
     458template <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)
    459459{
    460460  atom *Walker = start;
     
    464464  }
    465465};
    466 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V) const, T t, U u, V v)
     466template <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)
    467467{
    468468  atom *Walker = start;
     
    472472  }
    473473};
    474 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V), T t, U u, V v) const
     474template <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
    475475{
    476476  atom *Walker = start;
     
    480480  }
    481481};
    482 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V) const, T t, U u, V v) const
     482template <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
    483483{
    484484  atom *Walker = start;
     
    489489};
    490490// four arguments
    491 template <typename res, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V, W), T t, U u, V v, W w)
     491template <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)
    492492{
    493493  atom *Walker = start;
     
    497497  }
    498498};
    499 template <typename res, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V, W) const, T t, U u, V v, W w)
     499template <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)
    500500{
    501501  atom *Walker = start;
     
    505505  }
    506506};
    507 template <typename res, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V, W), T t, U u, V v, W w) const
     507template <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
    508508{
    509509  atom *Walker = start;
     
    513513  }
    514514};
    515 template <typename res, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (atom::*f)(T, U, V, W) const, T t, U u, V v, W w) const
     515template <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
    516516{
    517517  atom *Walker = start;
     
    525525
    526526// for atom ints
    527 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, void (*Setor)(T *, T *) )
     527template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) )
    528528{
    529529  atom *Walker = start;
     
    534534  }
    535535};
    536 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, void (*Setor)(T *, T *), T value )
     536template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value )
    537537{
    538538  atom *Walker = start;
     
    542542  }
    543543};
    544 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, void (*Setor)(T *, T *), T *value )
     544template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value )
    545545{
    546546  atom *Walker = start;
     
    550550  }
    551551};
    552 // for element ints inside atom class
     552// for element ints
    553553template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) )
    554554{
     
    576576  }
    577577};
    578 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, T (atom::*Setor)(Vector &), Vector atom::*value )
     578
     579template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(Vector &), Vector atom::*value )
    579580{
    580581  atom *Walker = start;
     
    584585  }
    585586};
    586 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int TesselPoint::*index, T (atom::*Setor)(Vector &), Vector &vect )
     587template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(Vector &), Vector &vect )
    587588{
    588589  atom *Walker = start;
     
    593594};
    594595
    595 template <typename T> void molecule::SetAtomValueToIndexedArray ( T *array, int TesselPoint::*index, T atom::*value )
     596template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value )
    596597{
    597598  atom *Walker = start;
     
    603604};
    604605
    605 template <typename T> void molecule::SetAtomValueToIndexedArray ( T *array, int element::*index, T atom::*value )
    606 {
    607   atom *Walker = start;
    608   while (Walker->next != end) {
    609     Walker = Walker->next;
    610     Walker->*value = array[(Walker->type->*index)];
    611     //cout << Verbose(2) << *Walker << " gets " << (Walker->*value) << endl;
    612   }
    613 };
    614 template <typename T> void molecule::SetAtomValueToValue ( T value, T atom::*ptr )
     606template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr )
    615607{
    616608  atom *Walker = start;
  • src/tesselation.cpp

    r9eefda r4455f4  
    1616
    1717class molecule;
     18
     19// =========================================== ParticleInfo ====================================
     20
     21/** Constructor of ParticleInfo.
     22 */
     23ParticleInfo::ParticleInfo() : nr(-1), Name(NULL) {};
     24
     25/** Destructor of ParticleInfo.
     26 */
     27ParticleInfo::~ParticleInfo()
     28{
     29  Free(&Name);
     30};
    1831
    1932// ======================================== Points on Boundary =================================
  • src/tesselation.hpp

    r9eefda r4455f4  
    2525
    2626#include "vector.hpp"
     27#include "helpers.hpp"
    2728
    2829/****************************************** forward declarations *****************************/
     
    144145// =========================================================== class TESSELPOINT ===========================================
    145146
     147class ParticleInfo {
     148public:
     149  int nr;       // index to easierly identify
     150  char *Name;   // some name to reference to on output
     151
     152  ParticleInfo();
     153  ~ParticleInfo();
     154
     155  ostream & operator << (ostream &ost);
     156
     157private:
     158};
     159
     160ostream & operator << (ostream &ost, const ParticleInfo &a);
     161
    146162/** Is a single point of the set of Vectors, also a super-class to be inherited and and its functions to be implemented.
    147163 */
    148 class TesselPoint {
     164class TesselPoint : virtual public ParticleInfo {
    149165public:
    150166  TesselPoint();
     
    152168
    153169  Vector *node;   // pointer to position of the dot in space
    154   int nr;       // index to easierly identify
    155   char *Name;   // some name to reference to on output
    156170
    157171  virtual ostream & operator << (ostream &ost);
Note: See TracChangeset for help on using the changeset viewer.