Changeset af2c424 for src/linkedcell.cpp
- Timestamp:
- Aug 28, 2010, 12:57:56 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, Candidate_v1.7.0, 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:
- c449d9
- Parents:
- 21585f
- git-author:
- Frederik Heber <heber@…> (08/27/10 20:58:40)
- git-committer:
- Frederik Heber <heber@…> (08/28/10 00:57:56)
- File:
-
- 1 edited
-
src/linkedcell.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/linkedcell.cpp
r21585f raf2c424 25 25 #include "Helpers/Log.hpp" 26 26 #include "molecule.hpp" 27 #include "PointCloud.hpp" 27 28 #include "tesselation.hpp" 28 29 #include "LinearAlgebra/Vector.hpp" … … 30 31 // ========================================================= class LinkedCell =========================================== 31 32 33 /** Constructor for class LinkedCell::LinkedNodes. 34 */ 35 LinkedCell::LinkedNodes::LinkedNodes() 36 {} 37 38 /** Destructor for class LinkedCell::LinkedNodes. 39 */ 40 LinkedCell::LinkedNodes::~LinkedNodes() 41 {} 42 43 TesselPoint * LinkedCell::LinkedNodes::getValue (const_iterator &rhs) const 44 { 45 return *rhs; 46 } 47 48 TesselPoint * LinkedCell::LinkedNodes::getValue (iterator &rhs) const 49 { 50 return *rhs; 51 } 32 52 33 53 /** Constructor for class LinkedCell. … … 48 68 * \param RADIUS edge length of cells 49 69 */ 50 LinkedCell::LinkedCell(const PointCloud * constset, const double radius) :70 LinkedCell::LinkedCell(const PointCloud & set, const double radius) : 51 71 LC(NULL), 52 72 RADIUS(radius), … … 60 80 min.Zero(); 61 81 DoLog(1) && (Log() << Verbose(1) << "Begin of LinkedCell" << endl); 62 if ( (set == NULL) || (set->IsEmpty())) {82 if (set.IsEmpty()) { 63 83 DoeLog(1) && (eLog()<< Verbose(1) << "set is NULL or contains no linked cell nodes!" << endl); 64 84 return; 65 85 } 66 86 // 1. find max and min per axis of atoms 67 set ->GoToFirst();68 Walker = set ->GetPoint();87 set.GoToFirst(); 88 Walker = set.GetPoint(); 69 89 for (int i=0;i<NDIM;i++) { 70 90 max[i] = Walker->at(i); 71 91 min[i] = Walker->at(i); 72 92 } 73 set ->GoToFirst();74 while (!set ->IsEnd()) {75 Walker = set ->GetPoint();93 set.GoToFirst(); 94 while (!set.IsEnd()) { 95 Walker = set.GetPoint(); 76 96 for (int i=0;i<NDIM;i++) { 77 97 if (max[i] < Walker->at(i)) … … 80 100 min[i] = Walker->at(i); 81 101 } 82 set ->GoToNext();102 set.GoToNext(); 83 103 } 84 104 DoLog(2) && (Log() << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl); … … 105 125 // 4. put each atom into its respective cell 106 126 DoLog(2) && (Log() << Verbose(2) << "Filling cells ... "); 107 set ->GoToFirst();108 while (!set ->IsEnd()) {109 Walker = set ->GetPoint();127 set.GoToFirst(); 128 while (!set.IsEnd()) { 129 Walker = set.GetPoint(); 110 130 for (int i=0;i<NDIM;i++) { 111 131 n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS)); … … 114 134 LC[index].push_back(Walker); 115 135 //Log() << Verbose(2) << *Walker << " goes into cell " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl; 116 set ->GoToNext();136 set.GoToNext(); 117 137 } 118 138 DoLog(0) && (Log() << Verbose(0) << "done." << endl); … … 120 140 }; 121 141 122 123 /** Puts all atoms in \a *mol into a linked cell list with cell's lengths of \a RADIUS124 * \param *set LCNodeSet class with all LCNode's125 * \param RADIUS edge length of cells126 */127 LinkedCell::LinkedCell(LinkedNodes *set, const double radius) :128 LC(NULL),129 RADIUS(radius),130 index(-1)131 {132 class TesselPoint *Walker = NULL;133 for(int i=0;i<NDIM;i++)134 N[i] = 0;135 max.Zero();136 min.Zero();137 DoLog(1) && (Log() << Verbose(1) << "Begin of LinkedCell" << endl);138 if (set->empty()) {139 DoeLog(1) && (eLog()<< Verbose(1) << "set contains no linked cell nodes!" << endl);140 return;141 }142 // 1. find max and min per axis of atoms143 LinkedNodes::iterator Runner = set->begin();144 for (int i=0;i<NDIM;i++) {145 max[i] = (*Runner)->at(i);146 min[i] = (*Runner)->at(i);147 }148 for (LinkedNodes::iterator Runner = set->begin(); Runner != set->end(); Runner++) {149 Walker = *Runner;150 for (int i=0;i<NDIM;i++) {151 if (max[i] < Walker->at(i))152 max[i] = Walker->at(i);153 if (min[i] > Walker->at(i))154 min[i] = Walker->at(i);155 }156 }157 DoLog(2) && (Log() << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl);158 159 // 2. find then number of cells per axis160 for (int i=0;i<NDIM;i++) {161 N[i] = static_cast<int>(floor((max[i] - min[i])/RADIUS)+1);162 }163 DoLog(2) && (Log() << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl);164 165 // 3. allocate the lists166 DoLog(2) && (Log() << Verbose(2) << "Allocating cells ... ");167 if (LC != NULL) {168 DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl);169 return;170 }171 ASSERT(N[0]*N[1]*N[2] < MAX_LINKEDCELLNODES, "Number linked of linked cell nodes exceded hard-coded limit, use greater edge length!");172 LC = new LinkedNodes[N[0]*N[1]*N[2]];173 for (index=0;index<N[0]*N[1]*N[2];index++) {174 LC [index].clear();175 }176 DoLog(0) && (Log() << Verbose(0) << "done." << endl);177 178 // 4. put each atom into its respective cell179 DoLog(2) && (Log() << Verbose(2) << "Filling cells ... ");180 for (LinkedNodes::iterator Runner = set->begin(); Runner != set->end(); Runner++) {181 Walker = *Runner;182 for (int i=0;i<NDIM;i++) {183 n[i] = static_cast<int>(floor((Walker->at(i) - min[i])/RADIUS));184 }185 index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];186 LC[index].push_back(Walker);187 //Log() << Verbose(2) << *Walker << " goes into cell " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl;188 }189 DoLog(0) && (Log() << Verbose(0) << "done." << endl);190 DoLog(1) && (Log() << Verbose(1) << "End of LinkedCell" << endl);191 };192 142 193 143 /** Destructor for class LinkedCell.
Note:
See TracChangeset
for help on using the changeset viewer.
