Changeset 8cd903


Ignore:
Timestamp:
Sep 28, 2009, 6:38:06 PM (16 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:
f7f7a4
Parents:
d04966
Message:

LinkedCell has another constructor initialised from LinkedNodes (list of Nodes).

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/linkedcell.cpp

    rd04966 r8cd903  
    9696    //cout << Verbose(2) << *Walker << " goes into cell " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl;
    9797    set->GoToNext();
     98  }
     99  cout << "done."  << endl;
     100  cout << Verbose(1) << "End of LinkedCell" << endl;
     101};
     102
     103
     104/** Puts all atoms in \a *mol into a linked cell list with cell's lengths of \a RADIUS
     105 * \param *set LCNodeSet class with all LCNode's
     106 * \param RADIUS edge length of cells
     107 */
     108LinkedCell::LinkedCell(LinkedNodes *set, double radius)
     109{
     110  class TesselPoint *Walker = NULL;
     111  RADIUS = radius;
     112  LC = NULL;
     113  for(int i=0;i<NDIM;i++)
     114    N[i] = 0;
     115  index = -1;
     116  max.Zero();
     117  min.Zero();
     118  cout << Verbose(1) << "Begin of LinkedCell" << endl;
     119  if (set->empty()) {
     120    cerr << "ERROR: set contains no linked cell nodes!" << endl;
     121    return;
     122  }
     123  // 1. find max and min per axis of atoms
     124  LinkedNodes::iterator Runner = set->begin();
     125  for (int i=0;i<NDIM;i++) {
     126    max.x[i] = (*Runner)->node->x[i];
     127    min.x[i] = (*Runner)->node->x[i];
     128  }
     129  for (LinkedNodes::iterator Runner = set->begin(); Runner != set->end(); Runner++) {
     130    Walker = *Runner;
     131    for (int i=0;i<NDIM;i++) {
     132      if (max.x[i] < Walker->node->x[i])
     133        max.x[i] = Walker->node->x[i];
     134      if (min.x[i] > Walker->node->x[i])
     135        min.x[i] = Walker->node->x[i];
     136    }
     137  }
     138  cout << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl;
     139
     140  // 2. find then number of cells per axis
     141  for (int i=0;i<NDIM;i++) {
     142    N[i] = (int)floor((max.x[i] - min.x[i])/RADIUS)+1;
     143  }
     144  cout << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl;
     145
     146  // 3. allocate the lists
     147  cout << Verbose(2) << "Allocating cells ... ";
     148  if (LC != NULL) {
     149    cout << Verbose(1) << "ERROR: Linked Cell list is already allocated, I do nothing." << endl;
     150    return;
     151  }
     152  LC = new LinkedNodes[N[0]*N[1]*N[2]];
     153  for (index=0;index<N[0]*N[1]*N[2];index++) {
     154    LC [index].clear();
     155  }
     156  cout << "done."  << endl;
     157
     158  // 4. put each atom into its respective cell
     159  cout << Verbose(2) << "Filling cells ... ";
     160  for (LinkedNodes::iterator Runner = set->begin(); Runner != set->end(); Runner++) {
     161    Walker = *Runner;
     162    for (int i=0;i<NDIM;i++) {
     163      n[i] = (int)floor((Walker->node->x[i] - min.x[i])/RADIUS);
     164    }
     165    index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
     166    LC[index].push_back(Walker);
     167    //cout << Verbose(2) << *Walker << " goes into cell " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl;
    98168  }
    99169  cout << "done."  << endl;
  • src/linkedcell.hpp

    rd04966 r8cd903  
    4444    LinkedCell();
    4545    LinkedCell(PointCloud *set, double RADIUS);
     46    LinkedCell(LinkedNodes *set, double radius);
    4647    ~LinkedCell();
    4748    LinkedNodes* GetCurrentCell();
Note: See TracChangeset for help on using the changeset viewer.