source: src/LinkedCell/LinkedCell_View.cpp@ 143263

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
Last change on this file since 143263 was 94d5ac6, checked in by Frederik Heber <heber@…>, 12 years ago

FIX: As we use GSL internally, we are as of now required to use GPL v2 license.

  • GNU Scientific Library is used at every place in the code, especially the sub-package LinearAlgebra is based on it which in turn is used really everywhere in the remainder of MoleCuilder. Hence, we have to use the GPL license for the whole of MoleCuilder. In effect, GPL's COPYING was present all along and stated the terms of the GPL v2 license.
  • Hence, I added the default GPL v2 disclaimer to every source file and removed the note about a (actually missing) LICENSE file.
  • also, I added a help-redistribute action which again gives the disclaimer of the GPL v2.
  • also, I changed in the disclaimer that is printed at every program start in builder_init.cpp.
  • TEST: Added check on GPL statement present in every module to test CodeChecks project-disclaimer.
  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2012 University of Bonn. All rights reserved.
5 *
6 *
7 * This file is part of MoleCuilder.
8 *
9 * MoleCuilder is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * MoleCuilder is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/*
24 * LinkedCell_View.cpp
25 *
26 * Created on: Nov 15, 2011
27 * Author: heber
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35#include "CodePatterns/MemDebug.hpp"
36
37#include "LinkedCell_View.hpp"
38
39#include <algorithm>
40
41#include "CodePatterns/Assert.hpp"
42#include "CodePatterns/Log.hpp"
43
44#include "Atom/TesselPoint.hpp"
45#include "Box.hpp"
46#include "LinearAlgebra/Vector.hpp"
47#include "LinkedCell.hpp"
48#include "LinkedCell_Model.hpp"
49#include "LinkedCell_View_ModelWrapper.hpp"
50#include "tripleIndex.hpp"
51
52using namespace LinkedCell;
53
54// static multimap instance
55LinkedCell_View::ModelInstanceMap LinkedCell_View::RAIIMap;
56
57/** Constructor of class LinkedCell_View.
58 *
59 * We add ourselves to RAIIMap here.
60 */
61LinkedCell_View::LinkedCell_View(const LinkedCell_Model &_LC) :
62 LC( new LinkedCell_View_ModelWrapper(&_LC) )
63{
64 // add us to RAII counting map
65#ifndef NDEBUG
66 std::pair< ModelInstanceMap::iterator, bool> inserter =
67#endif
68 RAIIMap.insert( this );
69 ASSERT( inserter.second,
70 "LinkedCell_View::LinkedCell_View() - we "+toString(this)+" are already present in RAIIMap.");
71 LOG(3, "INFO: Placing instance "+toString(this)+" into RAIIMap.");
72}
73
74/** Copy Constructor of class LinkedCell_View.
75 *
76 * We add ourselves to RAIIMap here.
77 */
78LinkedCell_View::LinkedCell_View(const LinkedCell_View &_view) :
79 LC( new LinkedCell_View_ModelWrapper(_view.LC->getModel()) )
80{
81 if (this != &_view) {
82 // add us to RAII counting map
83 #ifndef NDEBUG
84 std::pair< ModelInstanceMap::iterator, bool> inserter =
85 #endif
86 RAIIMap.insert( this );
87 ASSERT( inserter.second,
88 "LinkedCell_View::LinkedCell_View(&view) - we "+toString(this)+" are already present in RAIIMap.");
89 LOG(3, "INFO: Placing instance "+toString(this)+" copied from "+toString(&_view)+" into RAIIMap.");
90 }
91}
92
93/** Destructor of class LinkedCell_View.
94 *
95 * We remove ourselves from RAIIMap here.
96 */
97LinkedCell_View::~LinkedCell_View()
98{
99 ModelInstanceMap::iterator iter = RAIIMap.find(this);
100 ASSERT( iter != RAIIMap.end(),
101 "LinkedCell_View::~LinkedCell_View() - there is no instance "
102 +toString(this)+" in RAIIMap.");
103 if (iter != RAIIMap.end()) {
104 RAIIMap.erase(iter);
105 LOG(3, "INFO: Removing instance "+toString(this)+" from RAIIMap.");
106 } else {
107 ELOG(1, "Failed to remove instance "+toString(this)+" from RAIIMap.");
108 }
109 delete LC;
110}
111
112/** Return at least as many points as are inside a sphere of \a radius around \a center.
113 *
114 * \sa LinkedCell_View::getPointsInsideSphere()
115 *
116 * @param radius radius of sphere
117 * @param center center of sphere
118 * @return a list containing at least all points inside described sphere
119 */
120LinkedList LinkedCell_View::getAllNeighbors(const double radius, const Vector &center) const
121{
122 LinkedList TesselList; // we do not need a set, as nodes are uniquely associated to a cell.
123
124 const LinkedCell_Model * const LCmodel = LC->getModel(); // get quick ref to model
125 // get relative bounds
126 const tripleIndex step = LCmodel->getStep(radius);
127 const tripleIndex index = LCmodel->getIndexToVector(center);
128 LinkedCell_Model::LinkedCellNeighborhoodBounds neighbors =
129 LCmodel->getNeighborhoodBounds(index, step);
130
131 tripleIndex n;
132 for (n[0] = 0; n[0] < neighbors.second[0]; n[0]++)
133 for (n[1] = 0; n[1] < neighbors.second[1]; n[1]++)
134 for (n[2] = 0; n[2] < neighbors.second[2]; n[2]++) {
135 tripleIndex absolute_n = neighbors.first + n;
136 if (!LCmodel->checkArrayBounds(absolute_n))
137 LCmodel->applyBoundaryConditions(absolute_n);
138 const LinkedCell &List = LCmodel->getCell(absolute_n);
139 LOG(3, "INFO: Current cell is " << neighbors.first << " plus " << n << ", yielding " << absolute_n << ".");
140 for (LinkedCell::const_iterator Runner = List.begin(); Runner != List.end(); Runner++)
141 TesselList.insert(*Runner);
142 }
143 return TesselList;
144}
145
146LinkedList LinkedCell_View::getPointsInsideSphere(const double radius, const Vector &center) const
147{
148 // get overly much points
149 const LinkedList TesselList = getAllNeighbors(radius, center);
150 LinkedList ReturnList;
151
152 // remove all unnecessary ones
153 const Box& domain = LC->getModel()->getDomain();
154 for (LinkedList::const_iterator iter = TesselList.begin(); iter != TesselList.end(); ++iter) {
155 if (domain.periodicDistanceSquared(center, (*iter)->getPosition()) <= radius*radius)
156 ReturnList.insert(*iter);
157 }
158
159 return ReturnList;
160}
Note: See TracBrowser for help on using the repository browser.