Changeset 0f4538 for src


Ignore:
Timestamp:
Aug 3, 2009, 4:45:38 PM (15 years ago)
Author:
Saskia Metzler <metzler@…>
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:
ee1b16
Parents:
9c20aa
Message:

new function LinkedCell::GetNeighbourBounds()

  • LinkedCell::GetNeighbourBounds() needed as atom or vector to seek nearest neighbour for must not necessarily be contained in the LinkedCell grid itself. Hence, we have to use specific bounds for the NN search which this function returns.
Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/linkedcell.cpp

    r9c20aa r0f4538  
    129129
    130130/** Calculates the index for a given atom *Walker.
    131  * \param *Walker atom to set index to
     131 * \param Walker atom to set index to
    132132 * \return if the atom is also found in this cell - true, else - false
    133133 */
    134 bool LinkedCell::SetIndexToAtom(atom *Walker)
     134bool LinkedCell::SetIndexToAtom(const atom &Walker)
    135135{
    136136        bool status = false;
    137137        for (int i=0;i<NDIM;i++) {
    138                 n[i] = (int)floor((Walker->x.x[i] - min.x[i])/RADIUS);
     138                n[i] = (int)floor((Walker.x.x[i] - min.x[i])/RADIUS);
    139139        }
     140
    140141        index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
    141142        if (CheckBounds()) {
    142143                for (LinkedAtoms::iterator Runner = LC[index].begin(); Runner != LC[index].end(); Runner++)
    143                         status = status || ((*Runner) == Walker);
     144                        status = status || ((*Runner) == &Walker);
    144145                return status;
    145146        } else {
    146                 cerr << Verbose(1) << "ERROR: Atom "<< *Walker << " at " << Walker->x << " is out of bounds." << endl;
     147                cerr << Verbose(1) << "WARN: Atom "<< Walker << " at " << Walker.x << " is out of bounds." << endl;
    147148                return false;
    148149        }
     150};
     151
     152/** Calculates the interval bounds of the linked cell grid.
     153 * \param *lower lower bounds
     154 * \param *upper upper bounds
     155 */
     156void LinkedCell::GetNeighbourBounds(int lower[NDIM], int upper[NDIM])
     157{
     158  for (int i=0;i<NDIM;i++) {
     159    lower[i] = ((n[i]-1) >= 0) ? n[i]-1 : 0;
     160    upper[i] = ((n[i]+1) < N[i]) ? n[i]+1 : N[i]-1;
     161    //cout << " [" << Nlower[i] << "," << Nupper[i] << "] ";
     162    // check for this axis whether the point is outside of our grid
     163    if (n[i] < 0)
     164      upper[i] = lower[i];
     165    if (n[i] > N[i])
     166      lower[i] = upper[i];
     167
     168    //cout << "axis " << i << " has bounds [" << lower[i] << "," << upper[i] << "]" << endl;
     169  }
    149170};
    150171
     
    153174 * \return Vector is inside bounding box - true, else - false
    154175 */
    155 bool LinkedCell::SetIndexToVector(Vector *x)
     176bool LinkedCell::SetIndexToVector(const Vector *x)
    156177{
    157178        bool status = true;
  • src/linkedcell.hpp

    r9c20aa r0f4538  
    1111#define LinkedAtoms list <atom *>
    1212
    13 class LinkedCell{
     13class LinkedCell {
    1414        public:
    1515                Vector max;                      // upper boundary
     
    2525                ~LinkedCell();
    2626                LinkedAtoms* GetCurrentCell();
    27                 bool SetIndexToAtom(atom *Walker);
    28                 bool SetIndexToVector(Vector *x);
     27                bool SetIndexToAtom(const atom &Walker);
     28                bool SetIndexToVector(const Vector *x);
     29    void GetNeighbourBounds(int lower[NDIM], int upper[NDIM]);
    2930                bool CheckBounds();
    3031
Note: See TracChangeset for help on using the changeset viewer.