Changeset 734816 for src/linkedcell.cpp


Ignore:
Timestamp:
Apr 9, 2010, 9:55:39 AM (15 years ago)
Author:
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:
dcea0f
Parents:
fe238c
Message:

LinkedNodes is now declared inside LinkedCell and some new functions.

  • as prepraratory measure we placed LinkedNodes as typedef into LinkedCell class. This caused same namespace changes elsewhere where LinkedNodes is used.
  • new function GetallNeighbours() which performs going through linked cells.
  • new function GetPointsInsideaSphere() which performs going through linked cells and returns all neighbours up to a given distance to a given center.

Note: New functions are not yet used elsewhere. Unit test has to be written beforehand.

Signed-off-by: heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/linkedcell.cpp

    rfe238c r734816  
    220220 * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[] are out of bounds.
    221221 */
    222 const LinkedNodes* LinkedCell::GetCurrentCell() const
     222const LinkedCell::LinkedNodes* LinkedCell::GetCurrentCell() const
    223223{
    224224  if (CheckBounds()) {
     
    234234 * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[]+relative[] are out of bounds.
    235235 */
    236 const LinkedNodes* LinkedCell::GetRelativeToCurrentCell(const int relative[NDIM]) const
     236const LinkedCell::LinkedNodes* LinkedCell::GetRelativeToCurrentCell(const int relative[NDIM]) const
    237237{
    238238  if (CheckBounds(relative)) {
     
    302302};
    303303
     304/** Returns a list with all neighbours from the current LinkedCell::index.
     305 * \param distance (if no distance, then adjacent cells are taken)
     306 * \return list of tesselpoints
     307 */
     308LinkedCell::LinkedNodes* LinkedCell::GetallNeighbours(const double distance = 0) const
     309{
     310  int N[NDIM], Nlower[NDIM], Nupper[NDIM];
     311  TesselPoint *Walker = NULL;
     312  LinkedNodes *TesselList = new LinkedNodes;
     313
     314  // then go through the current and all neighbouring cells and check the contained points for possible candidates
     315  //Log() << Verbose(1) << "LC Intervals:";
     316  const int step = (distance == 0) ? 1 : (int)floor(distance/RADIUS)+1;
     317  for (int i=0;i<NDIM;i++) {
     318    Nlower[i] = ((N[i]-step) >= 0) ? N[i]-step : 0;
     319    Nupper[i] = ((N[i]+step) < N[i]) ? N[i]+step : N[i]-step;
     320    //Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] ";
     321  }
     322  //Log() << Verbose(0) << endl;
     323  for (n[0] = Nlower[0]; n[0] <= Nupper[0]; n[0]++)
     324    for (n[1] = Nlower[1]; n[1] <= Nupper[1]; n[1]++)
     325      for (n[2] = Nlower[2]; n[2] <= Nupper[2]; n[2]++) {
     326        const LinkedNodes *List = GetCurrentCell();
     327        //Log() << Verbose(1) << "Current cell is " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl;
     328        if (List != NULL) {
     329          for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     330            Walker = *Runner;
     331            TesselList->push_back(Walker);
     332          }
     333        }
     334      }
     335  return TesselList;
     336};
     337
     338
     339/** Returns a list of all TesselPoint with distance less than \a radius to \a *Center.
     340 * \param radius radius of sphere
     341 * \param *center center of sphere
     342 * \return list of all points inside sphere
     343 */
     344LinkedCell::LinkedNodes* LinkedCell::GetPointsInsideSphere(const double radius, const Vector * const center) const
     345{
     346  int N[NDIM], Nlower[NDIM], Nupper[NDIM];
     347  const double radiusSquared = radius*radius;
     348  TesselPoint *Walker = NULL;
     349  LinkedNodes *TesselList = new LinkedNodes;
     350
     351  if (SetIndexToVector(center)) {
     352    for(int i=0;i<NDIM;i++) // store indices of this cell
     353    N[i] = n[i];
     354    //Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << index << "." << endl;
     355  } else {
     356    DoeLog(1) && (eLog()<< Verbose(1) << "Vector " << *center << " is outside of LinkedCell's bounding box." << endl);
     357    return TesselList;
     358  }
     359  // then go through the current and all neighbouring cells and check the contained points for possible candidates
     360  //Log() << Verbose(1) << "LC Intervals:";
     361  for (int i=0;i<NDIM;i++) {
     362    Nlower[i] = ((N[i]-1) >= 0) ? N[i]-1 : 0;
     363    Nupper[i] = ((N[i]+1) < N[i]) ? N[i]+1 : N[i]-1;
     364    //Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] ";
     365  }
     366  //Log() << Verbose(0) << endl;
     367  for (n[0] = Nlower[0]; n[0] <= Nupper[0]; n[0]++)
     368    for (n[1] = Nlower[1]; n[1] <= Nupper[1]; n[1]++)
     369      for (n[2] = Nlower[2]; n[2] <= Nupper[2]; n[2]++) {
     370        const LinkedNodes *List = GetCurrentCell();
     371        //Log() << Verbose(1) << "Current cell is " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl;
     372        if (List != NULL) {
     373          for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     374            Walker = *Runner;
     375            if ((center->DistanceSquared(Walker->node) - radiusSquared) > MYEPSILON) {
     376              TesselList->push_back(Walker);
     377            }
     378          }
     379        }
     380      }
     381  return TesselList;
     382};
Note: See TracChangeset for help on using the changeset viewer.