Changeset 734816 for src/linkedcell.cpp
- Timestamp:
- Apr 9, 2010, 9:55:39 AM (15 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/linkedcell.cpp ¶
rfe238c r734816 220 220 * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[] are out of bounds. 221 221 */ 222 const Linked Nodes* LinkedCell::GetCurrentCell() const222 const LinkedCell::LinkedNodes* LinkedCell::GetCurrentCell() const 223 223 { 224 224 if (CheckBounds()) { … … 234 234 * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[]+relative[] are out of bounds. 235 235 */ 236 const Linked Nodes* LinkedCell::GetRelativeToCurrentCell(const int relative[NDIM]) const236 const LinkedCell::LinkedNodes* LinkedCell::GetRelativeToCurrentCell(const int relative[NDIM]) const 237 237 { 238 238 if (CheckBounds(relative)) { … … 302 302 }; 303 303 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 */ 308 LinkedCell::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 */ 344 LinkedCell::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.