OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
OtherVisitor.hpp
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the appropriate papers when you publish your
33 * work. Good starting points are:
34 *
35 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
36 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
37 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
38 * [4] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
39 * [5] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
40 * [6] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
41 * [7] Lamichhane, Newman & Gezelter, J. Chem. Phys. 141, 134110 (2014).
42 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
43 */
44
45#ifndef VISITORS_OTHERVISITOR_HPP
46#define VISITORS_OTHERVISITOR_HPP
47
48#include <memory>
49#include <set>
50#include <string>
51#include <vector>
52
54#include "selection/SelectionEvaluator.hpp"
55#include "selection/SelectionManager.hpp"
56#include "visitors/AtomData.hpp"
57#include "visitors/BaseVisitor.hpp"
58
59namespace OpenMD {
60
61 class SimInfo;
62
64 public:
65 using BaseVisitor::visit;
66 WrappingVisitor(SimInfo* info, bool useCom = true) :
67 BaseVisitor(), useCom_(useCom) {
68 this->info = info;
69 visitorName = "WrappingVisitor";
70 }
71 virtual void visit(Atom* atom);
72 virtual void visit(DirectionalAtom* datom);
73 virtual void visit(RigidBody* rb);
74
75 virtual const std::string toString();
76
77 virtual void update();
78
79 private:
80 void internalVisit(StuntDouble* sd);
81 SimInfo* info {nullptr};
82 Vector3d origin_;
83 bool useCom_ {false};
84 };
85
87 public:
88 using BaseVisitor::visit;
90 virtual void visit(Atom* atom);
91 virtual void visit(DirectionalAtom* datom);
92 virtual void visit(RigidBody* rb);
93
94 virtual const std::string toString();
95
96 protected:
97 void internalVisit(StuntDouble* sd);
98 void replicate(std::vector<std::shared_ptr<AtomInfo>>& infoList,
99 std::shared_ptr<AtomData> data, const Mat3x3d& box);
100
101 private:
102 std::vector<Vector3d> dir;
103 SimInfo* info {nullptr};
104 Vector3i replicateOpt;
105 };
106
107 class XYZVisitor : public BaseVisitor {
108 public:
109 using BaseVisitor::visit;
110
111 XYZVisitor(SimInfo* info);
112
113 XYZVisitor(SimInfo* info, const std::string& script);
114
115 virtual void visit(Atom* atom);
116 virtual void visit(DirectionalAtom* datom);
117 virtual void visit(RigidBody* rb);
118
119 virtual void update();
120
121 virtual const std::string toString();
122
123 void writeFrame(std::ostream& outStream);
124 void clear() { frame.clear(); }
125 void doPositions(bool pos) { doPositions_ = pos; }
126 void doVelocities(bool vel) { doVelocities_ = vel; }
127 void doForces(bool frc) { doForces_ = frc; }
128 void doVectors(bool vec) { doVectors_ = vec; }
129 void doCharges(bool chg) { doCharges_ = chg; }
130 void doElectricFields(bool efl) { doElectricFields_ = efl; }
131 void doGlobalIDs(bool gid) { doGlobalIDs_ = gid; }
132
133 protected:
134 void internalVisit(StuntDouble* sd);
135 bool isSelected(StuntDouble* sd);
136
137 private:
138 std::string trimmedName(const std::string& atomType);
139
140 SimInfo* info {nullptr};
141 SelectionManager seleMan;
142 SelectionEvaluator evaluator;
143 std::vector<std::string> frame;
144 bool doPositions_ {false};
145 bool doVelocities_ {false};
146 bool doForces_ {false};
147 bool doVectors_ {false};
148 bool doCharges_ {false};
149 bool doElectricFields_ {false};
150 bool doGlobalIDs_ {false};
151 };
152
154 public:
155 using BaseVisitor::visit;
156 PrepareVisitor() : BaseVisitor() { visitorName = "prepareVisitor"; }
157
158 virtual void visit(Atom* atom) { internalVisit(atom); }
159 virtual void visit(DirectionalAtom* datom) {
160 internalVisit(reinterpret_cast<Atom*>(datom));
161 }
162 virtual void visit(RigidBody* rb) { internalVisit(rb); }
163
164 virtual const std::string toString();
165
166 protected:
167 void internalVisit(Atom* atom);
168 void internalVisit(RigidBody* rb);
169 };
170
172 public:
173 using BaseVisitor::visit;
175 virtual void visit(Atom*) {}
176 virtual void visit(DirectionalAtom*) {}
177 virtual void visit(RigidBody* rb);
178
179 virtual const std::string toString();
180
181 private:
182 std::string trimmedName(const std::string& atomType);
183
184 std::set<std::string> waterTypeList;
185 };
186} // namespace OpenMD
187
188#endif // _OTHERVISITOR_H_
"selection/SelectionEvaluator"
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
Definition SimInfo.hpp:93
"Don't move, or you're dead! Stand up! Captain, we've got them!"
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.