votca 2024.2-dev
Loading...
Searching...
No Matches
nblist_3body.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 includes
19#include <iostream>
20
21// Local VOTCA includes
23#include "votca/csg/topology.h"
24
25namespace votca {
26namespace csg {
27
28NBList_3Body::NBList_3Body() : do_exclusions_(false), match_function_(nullptr) {
31}
32
34
36 bool do_exclusions) {
40 do_exclusions_ = do_exclusions;
41
42 if (list1.empty()) {
43 return;
44 }
45 if (list2.empty()) {
46 return;
47 }
48 if (list3.empty()) {
49 return;
50 }
51
52 // check if all bead lists "have" the same topology
53 assert(&(list1.getTopology()) == &(list2.getTopology()));
54 assert(&(list1.getTopology()) == &(list3.getTopology()));
55 assert(&(list2.getTopology()) == &(list3.getTopology()));
56 const Topology &top = list1.getTopology();
57
58 // builds neighbor lists for all cases, where all list are of different bead
59 // typess (list1 neq list2 neq list3), list2 and list3 are of the same type
60 // (list1 neq (list2 = list3)) or all three lists are the same
61 // (list1=list2=list3)!
62 for (iter1 = list1.begin(); iter1 != list1.end(); ++iter1) {
63
64 // in all cases iterate over the full bead lists list1 and list2
65 // if both lists are the same (the 3 bead types are the same),
66 // still necessary as both permutations (1,2,*) (2,1,*) included in neighbor
67 // list! (i,jneqi,k>j)
68 iter2 = list2.begin();
69
70 for (; iter2 != list2.end(); ++iter2) {
71
72 // do not include the same beads twice in one triple!
73 if (*iter1 == *iter2) {
74 continue;
75 }
76
77 // if list2 and list3 are the same, set iter3 to "iter2+1" (i,jneqi,k>j)
78 if (&list2 == &list3) {
79 iter3 = iter2;
80 ++iter3;
81 } else {
82 iter3 = list3.begin();
83 }
84
85 for (; iter3 != list3.end(); ++iter3) {
86
87 // do not include the same beads twice in one triple!
88 if (*iter1 == *iter3) {
89 continue;
90 }
91 if (*iter2 == *iter3) {
92 continue;
93 }
94
95 Eigen::Vector3d u = (*iter1)->getPos();
96 Eigen::Vector3d v = (*iter2)->getPos();
97 Eigen::Vector3d z = (*iter3)->getPos();
98
99 Eigen::Vector3d r12 = top.BCShortestConnection(u, v);
100 Eigen::Vector3d r13 = top.BCShortestConnection(u, z);
101 Eigen::Vector3d r23 = top.BCShortestConnection(v, z);
102 double d12 = r12.norm();
103 double d13 = r13.norm();
104 double d23 = r23.norm();
105 // to do: at the moment use only one cutoff value
106 // to do: so far only check the distance between bead 1 (central bead)
107 // and bead2 and bead 3
108 if ((d12 < cutoff_) && (d13 < cutoff_)) {
111 if (do_exclusions_) {
112 if ((top.getExclusions().IsExcluded(*iter1, *iter2)) ||
113 (top.getExclusions().IsExcluded(*iter1, *iter3)) ||
114 (top.getExclusions().IsExcluded(*iter2, *iter3))) {
115 continue;
116 }
117 }
118 if ((*match_function_)(*iter1, *iter2, *iter3, r12, r13, r23, d12,
119 d13, d23)) {
120 if (!FindTriple(*iter1, *iter2, *iter3)) {
121 AddTriple(triple_creator_(*iter1, *iter2, *iter3, r12, r13, r23));
122 }
123 }
124 }
125 }
126 }
127 }
128}
129
130} // namespace csg
131} // 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
bool do_exclusions_
take into account exclusions from topolgoy
static bool match_always(Bead *, Bead *, Bead *, const Eigen::Vector3d &, const Eigen::Vector3d &, const Eigen::Vector3d &, const double, const double, const double)
standard match function
void SetMatchFunction(T *object, bool(T::*fkt)(Bead *, Bead *, Bead *, const Eigen::Vector3d &, const Eigen::Vector3d &, const Eigen::Vector3d &, const double dist12, const double dist13, const double dist23))
match function for class member functions
triple_creator_t triple_creator_
the current bead pair creator function
std::unique_ptr< Functor > match_function_
virtual void Generate(BeadList &list1, BeadList &list2, BeadList &list3, bool do_exclusions=true)
void setTripleType()
function to use a user defined triple type
double cutoff_
cutoff (at the moment use only one cutoff value)
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
BeadTriple * FindTriple(Bead *e1, Bead *e2, Bead *e3)
Definition triplelist.h:83
base class for all analysis tools
Definition basebead.h:33