45#include "visitors/AtomVisitor.hpp"
52#include "types/FixedChargeAdapter.hpp"
53#include "types/FluctuatingChargeAdapter.hpp"
54#include "types/GayBerneAdapter.hpp"
55#include "types/MultipoleAdapter.hpp"
73 void BaseAtomVisitor::setVisited(
Atom* atom) {
74 std::shared_ptr<GenericData> data;
75 data = atom->getPropertyByName(
"VISITED");
78 if (data ==
nullptr) {
79 data = std::make_shared<GenericData>();
80 data->setID(
"VISITED");
81 atom->addProperty(data);
85 bool BaseAtomVisitor::isVisited(
Atom* atom) {
86 std::shared_ptr<GenericData> data;
87 data = atom->getPropertyByName(
"VISITED");
88 return data ==
nullptr ? false :
true;
93 void DefaultAtomVisitor::visit(
Atom* atom) {
94 std::shared_ptr<AtomData> atomData;
95 std::shared_ptr<AtomInfo> atomInfo;
96 AtomType* atype = atom->getAtomType();
98 if (isVisited(atom))
return;
100 atomInfo = std::make_shared<AtomInfo>();
101 atomInfo->atomTypeName = atom->getType();
102 atomInfo->globalID = atom->getGlobalIndex();
103 atomInfo->pos = atom->getPos();
104 atomInfo->vel = atom->getVel();
105 atomInfo->frc = atom->getFrc();
106 atomInfo->vec = V3Zero;
107 atomInfo->hasVelocity =
true;
108 atomInfo->hasForce =
true;
109 atomInfo->hasGlobalID =
true;
112 if (fca.isFixedCharge()) {
113 atomInfo->hasCharge =
true;
114 atomInfo->charge = fca.getCharge();
118 if (fqa.isFluctuatingCharge()) {
119 atomInfo->hasCharge =
true;
120 atomInfo->charge += atom->getFlucQPos();
123 if ((storageLayout_ & DataStorage::dslElectricField) &&
124 (atype->isElectrostatic())) {
125 atomInfo->hasElectricField =
true;
126 atomInfo->eField = atom->getElectricField();
129 atomData = std::make_shared<AtomData>();
130 atomData->setID(
"ATOMDATA");
131 atomData->addAtomInfo(atomInfo);
133 atom->addProperty(atomData);
139 std::shared_ptr<AtomData> atomData;
140 std::shared_ptr<AtomInfo> atomInfo;
141 AtomType* atype = datom->getAtomType();
143 if (isVisited(datom))
return;
145 atomInfo = std::make_shared<AtomInfo>();
146 atomInfo->atomTypeName = datom->getType();
147 atomInfo->globalID = datom->getGlobalIndex();
148 atomInfo->pos = datom->getPos();
149 atomInfo->vel = datom->getVel();
150 atomInfo->frc = datom->getFrc();
151 atomInfo->hasVelocity =
true;
152 atomInfo->hasForce =
true;
153 atomInfo->hasGlobalID =
true;
156 if (fca.isFixedCharge()) {
157 atomInfo->hasCharge =
true;
158 atomInfo->charge = fca.getCharge();
162 if (fqa.isFluctuatingCharge()) {
163 atomInfo->hasCharge =
true;
164 atomInfo->charge += datom->getFlucQPos();
167 if ((storageLayout_ & DataStorage::dslElectricField) &&
168 (atype->isElectrostatic())) {
169 atomInfo->hasElectricField =
true;
170 atomInfo->eField = datom->getElectricField();
176 if (gba.isGayBerne()) {
177 atomInfo->hasVector =
true;
178 atomInfo->vec = datom->getA().transpose() * V3Z;
179 }
else if (ma.isDipole()) {
180 atomInfo->hasVector =
true;
181 atomInfo->vec = datom->getDipole();
182 }
else if (ma.isQuadrupole()) {
183 atomInfo->hasVector =
true;
184 atomInfo->vec = datom->getA().transpose() * V3Z;
187 atomData = std::make_shared<AtomData>();
188 atomData->setID(
"ATOMDATA");
189 atomData->addAtomInfo(atomInfo);
191 datom->addProperty(atomData);
196 const std::string DefaultAtomVisitor::toString() {
202 "--------------------------------------------------------------\n");
205 snprintf(buffer, 65535,
"Visitor name: %s\n", visitorName.c_str());
208 snprintf(buffer, 65535,
209 "Visitor Description: copy atom infomation into atom data\n");
214 "--------------------------------------------------------------\n");
AtomType is what OpenMD looks to for unchanging data about an atom.
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
int getAtomStorageLayout()
Returns the storage layouts (computed by SimCreator)
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.