votca 2024.2-dev
Loading...
Searching...
No Matches
nblist.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18// Standard library includes
19#include <iostream>
20
21// Local VOTCA includes
22#include "votca/csg/nblist.h"
23#include "votca/csg/topology.h"
24
25namespace votca {
26namespace csg {
27
28NBList::NBList() : do_exclusions_(false), match_function_(nullptr) {
31}
32
34 // TODO: NBList destructor
35}
36
37void NBList::Generate(BeadList &list1, BeadList &list2, bool do_exclusions) {
40 do_exclusions_ = do_exclusions;
41
42 if (list1.empty()) {
43 return;
44 }
45 if (list2.empty()) {
46 return;
47 }
48
49 assert(&(list1.getTopology()) == &(list2.getTopology()));
50 const Topology &top = list1.getTopology();
51
52 for (iter1 = list1.begin(); iter1 != list1.end(); ++iter1) {
53 if (&list1 == &list2) {
54 iter2 = iter1;
55 ++iter2;
56 } else {
57 iter2 = list2.begin();
58 }
59
60 if (iter2 == list2.end()) {
61 continue;
62 }
63 if (*iter1 == *iter2) {
64 continue;
65 }
66
67 for (; iter2 != list2.end(); ++iter2) {
68 Eigen::Vector3d u = (*iter1)->getPos();
69 Eigen::Vector3d v = (*iter2)->getPos();
70
71 Eigen::Vector3d r = top.BCShortestConnection(u, v);
72 double d = r.norm();
73 if (d < cutoff_) {
74 if (do_exclusions_) {
75 if (top.getExclusions().IsExcluded(*iter1, *iter2)) {
76 continue;
77 }
78 }
79 if ((*match_function_)(*iter1, *iter2, r, d)) {
80 if (!FindPair(*iter1, *iter2)) {
81 AddPair(pair_creator_(*iter1, *iter2, r));
82 }
83 }
84 }
85 }
86 }
87}
88
89} // namespace csg
90} // namespace votca
const Topology & getTopology() const
Definition beadlist.h:63
typename std::vector< Bead * >::iterator iterator
Definition beadlist.h:58
iterator begin()
Definition beadlist.h:60
bool empty() const
Definition beadlist.h:54
bool IsExcluded(Bead *bead1, Bead *bead2) const
virtual void Generate(BeadList &list1, BeadList &list2, bool do_exclusions=true)
Generate the neighbour list based on two bead lists (e.g. bead types)
Definition nblist.cc:37
std::unique_ptr< Functor > match_function_
Definition nblist.h:150
bool do_exclusions_
take into account exclusions from topolgoy
Definition nblist.h:93
~NBList() override
Definition nblist.cc:33
void setPairType()
function to use a user defined pair type
Definition nblist.h:154
void SetMatchFunction(T *object, bool(T::*fkt)(Bead *, Bead *, const Eigen::Vector3d &, double dist))
match function for class member functions
Definition nblist.h:159
static bool match_always(Bead *, Bead *, const Eigen::Vector3d &, double)
standard match function
Definition nblist.h:81
pair_creator_t pair_creator_
the current bead pair creator function
Definition nblist.h:104
double cutoff_
cutoff
Definition nblist.h:91
BeadPair * FindPair(Bead *e1, Bead *e2)
Definition pairlist.h:93
topology of the whole system
Definition topology.h:81
ExclusionList & getExclusions()
Definition topology.h:391
Eigen::Vector3d BCShortestConnection(const Eigen::Vector3d &r_i, const Eigen::Vector3d &r_j) const
calculate shortest vector connecting two points
Definition topology.cc:238
base class for all analysis tools
Definition basebead.h:33