48#include "visitors/AtomVisitor.hpp"
55#include "types/FixedChargeAdapter.hpp"
56#include "types/FluctuatingChargeAdapter.hpp"
57#include "types/GayBerneAdapter.hpp"
58#include "types/MultipoleAdapter.hpp"
63 storageLayout_ = info->getAtomStorageLayout();
66 void BaseAtomVisitor::visit(RigidBody*) {
76 void BaseAtomVisitor::setVisited(Atom* atom) {
77 std::shared_ptr<GenericData> data;
78 data = atom->getPropertyByName(
"VISITED");
81 if (data ==
nullptr) {
82 data = std::make_shared<GenericData>();
83 data->setID(
"VISITED");
84 atom->addProperty(data);
88 bool BaseAtomVisitor::isVisited(Atom* atom) {
89 std::shared_ptr<GenericData> data;
90 data = atom->getPropertyByName(
"VISITED");
91 return data ==
nullptr ? false :
true;
96 void DefaultAtomVisitor::visit(Atom* atom) {
97 std::shared_ptr<AtomData> atomData;
98 std::shared_ptr<AtomInfo> atomInfo;
99 AtomType* atype = atom->getAtomType();
101 if (isVisited(atom))
return;
103 atomInfo = std::make_shared<AtomInfo>();
104 atomInfo->atomTypeName = atom->getType();
105 atomInfo->globalID = atom->getGlobalIndex();
106 atomInfo->pos = atom->getPos();
107 atomInfo->vel = atom->getVel();
108 atomInfo->frc = atom->getFrc();
109 atomInfo->vec = V3Zero;
110 atomInfo->hasVelocity =
true;
111 atomInfo->hasForce =
true;
112 atomInfo->hasGlobalID =
true;
114 FixedChargeAdapter fca = FixedChargeAdapter(atype);
115 if (fca.isFixedCharge()) {
116 atomInfo->hasCharge =
true;
117 atomInfo->charge = fca.getCharge();
120 FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atype);
121 if (fqa.isFluctuatingCharge()) {
122 atomInfo->hasCharge =
true;
123 atomInfo->charge += atom->getFlucQPos();
126 if ((storageLayout_ & DataStorage::dslElectricField) &&
127 (atype->isElectrostatic())) {
128 atomInfo->hasElectricField =
true;
129 atomInfo->eField = atom->getElectricField();
132 atomData = std::make_shared<AtomData>();
133 atomData->setID(
"ATOMDATA");
134 atomData->addAtomInfo(atomInfo);
136 atom->addProperty(atomData);
141 void DefaultAtomVisitor::visit(DirectionalAtom* datom) {
142 std::shared_ptr<AtomData> atomData;
143 std::shared_ptr<AtomInfo> atomInfo;
144 AtomType* atype = datom->getAtomType();
146 if (isVisited(datom))
return;
148 atomInfo = std::make_shared<AtomInfo>();
149 atomInfo->atomTypeName = datom->getType();
150 atomInfo->globalID = datom->getGlobalIndex();
151 atomInfo->pos = datom->getPos();
152 atomInfo->vel = datom->getVel();
153 atomInfo->frc = datom->getFrc();
154 atomInfo->hasVelocity =
true;
155 atomInfo->hasForce =
true;
156 atomInfo->hasGlobalID =
true;
158 FixedChargeAdapter fca = FixedChargeAdapter(atype);
159 if (fca.isFixedCharge()) {
160 atomInfo->hasCharge =
true;
161 atomInfo->charge = fca.getCharge();
164 FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atype);
165 if (fqa.isFluctuatingCharge()) {
166 atomInfo->hasCharge =
true;
167 atomInfo->charge += datom->getFlucQPos();
170 if ((storageLayout_ & DataStorage::dslElectricField) &&
171 (atype->isElectrostatic())) {
172 atomInfo->hasElectricField =
true;
173 atomInfo->eField = datom->getElectricField();
176 GayBerneAdapter gba = GayBerneAdapter(atype);
177 MultipoleAdapter ma = MultipoleAdapter(atype);
179 if (gba.isGayBerne()) {
180 atomInfo->hasVector =
true;
181 atomInfo->vec = datom->getA().transpose() * V3Z;
182 }
else if (ma.isDipole()) {
183 atomInfo->hasVector =
true;
184 atomInfo->vec = datom->getDipole();
185 }
else if (ma.isQuadrupole()) {
186 atomInfo->hasVector =
true;
187 atomInfo->vec = datom->getA().transpose() * V3Z;
190 atomData = std::make_shared<AtomData>();
191 atomData->setID(
"ATOMDATA");
192 atomData->addAtomInfo(atomInfo);
194 datom->addProperty(atomData);
199 const std::string DefaultAtomVisitor::toString() {
205 "--------------------------------------------------------------\n");
208 snprintf(buffer, 65535,
"Visitor name: %s\n", visitorName.c_str());
211 snprintf(buffer, 65535,
212 "Visitor Description: copy atom infomation into atom data\n");
217 "--------------------------------------------------------------\n");
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.