Changeset e41951


Ignore:
Timestamp:
Oct 7, 2009, 2:29:57 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:
f66195
Parents:
23b830
git-author:
Frederik Heber <heber@…> (10/07/09 14:26:53)
git-committer:
Frederik Heber <heber@…> (10/07/09 14:29:57)
Message:

used forward declaration to untangle atom and bond declarations, molecule::CreateListOfBondsPerAtom() uses ActOnAllAtoms

  • a major problem is two classes depending on one another and we've often made constraints in order to accommodate for this. But there is an easier solution: Have forward declarations of the other class in each header file, only include the true other header file in each implementation (i.e. cpp file).
  • This was done with atom and bond class to allow for a new function atom::OutputBondOfAtom()
  • molecule::CreateListOfBondsPerAtom() uses ActOnAllAtoms with this new function.
Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/atom.cpp

    r23b830 re41951  
    66
    77#include "atom.hpp"
     8#include "bond.hpp"
    89#include "memoryallocator.hpp"
    910
     
    120121 * \param *out stream to output to
    121122 * \param *comment commentary after '#' sign
     123  * \return true - \a *out present, false - \a *out is NULL
    122124 */
    123125bool atom::Output(ofstream *out, int ElementNo, int AtomNo, const char *comment) const
     
    157159/** Output of a single atom as one lin in xyz file.
    158160 * \param *out stream to output to
     161  * \return true - \a *out present, false - \a *out is NULL
    159162 */
    160163bool atom::OutputXYZLine(ofstream *out) const
     
    169172/** Output of a single atom as one lin in xyz file.
    170173 * \param *out stream to output to
     174 * \param *ElementNo array with ion type number in the config file this atom's element shall have
     175 * \param *AtomNo array with atom number in the config file this atom shall have, is increase by one automatically
     176 * \param step Trajectory time step to output
     177  * \return true - \a *out present, false - \a *out is NULL
    171178 */
    172179bool atom::OutputTrajectory(ofstream *out, int *ElementNo, int *AtomNo, int step) const
     
    189196/** Output of a single atom as one lin in xyz file.
    190197 * \param *out stream to output to
     198 * \param step Trajectory time step to output
     199 * \return true - \a *out present, false - \a *out is NULL
    191200 */
    192201bool atom::OutputTrajectoryXYZ(ofstream *out, int step) const
     
    202211};
    203212
     213/** Prints all bonds of this atom from given global lists.
     214 * \param *out stream to output to
     215 * \param *NumberOfBondsPerAtom array with number of bonds per atomic index
     216 * \param ***ListOfBondsPerAtom array per atomic index of array with pointer to bond
     217 * \return true - \a *out present, false - \a *out is NULL
     218 */
     219bool atom::OutputBondOfAtom(ofstream *out, int *NumberOfBondsPerAtom, bond ***ListOfBondsPerAtom) const
     220{
     221  if (out != NULL) {
     222    *out << Verbose(4) << "Atom " << Name << "/" << nr << " with " << NumberOfBondsPerAtom[nr] << " bonds: ";
     223    int TotalDegree = 0;
     224    for (int j=0;j<NumberOfBondsPerAtom[nr];j++) {
     225      *out << *ListOfBondsPerAtom[nr][j] << "\t";
     226      TotalDegree += ListOfBondsPerAtom[nr][j]->BondDegree;
     227    }
     228    *out << " -- TotalDegree: " << TotalDegree << endl;
     229    return true;
     230  } else
     231    return false;
     232};
     233
    204234ostream & operator << (ostream &ost, const atom &a)
    205235{
  • src/atom.hpp

    r23b830 re41951  
    2323#include "tesselation.hpp"
    2424#include "vector.hpp"
     25
     26class bond;
    2527
    2628/** Single atom.
     
    6567  bool OutputTrajectory(ofstream *out, int *ElementNo, int *AtomNo, int step) const;
    6668  bool OutputTrajectoryXYZ(ofstream *out, int step) const;
     69  bool OutputBondOfAtom(ofstream *out, int *NumberOfBondsPerAtom, bond ***ListOfBondsPerAtom) const;
    6770
    6871  void EqualsFather ( atom *ptr, atom **res );
  • src/bond.cpp

    r23b830 re41951  
    55 */
    66
     7#include "atom.hpp"
    78#include "bond.hpp"
    89
  • src/bond.hpp

    r23b830 re41951  
    1616#endif
    1717
    18 #include "atom.hpp"
     18class atom;
    1919
    2020/** Bonds between atoms.
  • src/molecule.cpp

    r23b830 re41951  
    734734bool molecule::OutputTrajectories(ofstream *out)
    735735{
    736   atom *walker = NULL;
    737736  int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
    738737  CountElements();
     
    799798bool molecule::OutputTrajectoriesXYZ(ofstream *out)
    800799{
    801   int No = 0;
    802800  time_t now;
    803801
     
    818816bool molecule::OutputXYZ(ofstream *out) const
    819817{
    820   atom *walker = NULL;
    821   int AtomNo = 0;
    822818  time_t now;
    823819
     
    918914{
    919915  bond *Binder = NULL;
    920   atom *Walker = NULL;
    921   int TotalDegree;
    922916  *out << Verbose(1) << "Begin of Creating ListOfBondsPerAtom: AtomCount = " << AtomCount << "\tBondCount = " << BondCount << "\tNoNonBonds = " << NoNonBonds << "." << endl;
    923917
     
    960954  // output list for debugging
    961955  *out << Verbose(3) << "ListOfBondsPerAtom for each atom:" << endl;
    962   Walker = start;
    963   while (Walker->next != end) {
    964     Walker = Walker->next;
    965     *out << Verbose(4) << "Atom " << Walker->Name << "/" << Walker->nr << " with " << NumberOfBondsPerAtom[Walker->nr] << " bonds: ";
    966     TotalDegree = 0;
    967     for (int j=0;j<NumberOfBondsPerAtom[Walker->nr];j++) {
    968       *out << *ListOfBondsPerAtom[Walker->nr][j] << "\t";
    969       TotalDegree += ListOfBondsPerAtom[Walker->nr][j]->BondDegree;
    970     }
    971     *out << " -- TotalDegree: " << TotalDegree << endl;
    972   }
     956  ActOnAllAtoms( &atom::OutputBondOfAtom, out, NumberOfBondsPerAtom, ListOfBondsPerAtom );
     957
    973958  *out << Verbose(1) << "End of Creating ListOfBondsPerAtom." << endl << endl;
    974959};
    975 
    976960
    977961/** Blows the 6-dimensional \a cell_size array up to a full NDIM by NDIM matrix.
Note: See TracChangeset for help on using the changeset viewer.