48#include "visitors/LipidTransVisitor.hpp"
52#include "types/MultipoleAdapter.hpp"
53#include "utils/simError.h"
56 LipidTransVisitor::LipidTransVisitor(
SimInfo* info,
57 const std::string& originSeleScript,
58 const std::string& refSeleScript) :
60 info_(info), originEvaluator_(info), originSeleMan_(info),
61 refEvaluator_(info), refSeleMan_(info), refSd_(NULL) {
62 visitorName =
"LipidTransVisitor";
64 originEvaluator_.loadScriptString(originSeleScript);
65 if (!originEvaluator_.isDynamic()) {
66 originSeleMan_.setSelectionSet(originEvaluator_.evaluate());
67 if (originSeleMan_.getSelectionCount() == 1) {
70 dynamic_cast<DirectionalAtom*>(originSeleMan_.beginSelected(i));
71 if (originDatom_ == NULL) {
72 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
73 "LipidTransVisitor: origin selection must select an "
80 painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
81 "LipidTransVisitor: origin selection must select an directional "
88 refEvaluator_.loadScriptString(refSeleScript);
89 if (!refEvaluator_.isDynamic()) {
90 refSeleMan_.setSelectionSet(refEvaluator_.evaluate());
91 if (refSeleMan_.getSelectionCount() == 1) {
93 refSd_ = refSeleMan_.beginSelected(i);
101 void LipidTransVisitor::update() {
102 Vector3d ref = refSd_->getPos();
103 origin_ = originDatom_->getPos();
104 Vector3d v1 = ref - origin_;
105 info_->getSnapshotManager()->getCurrentSnapshot()->wrapVector(v1);
107 MultipoleAdapter ma = MultipoleAdapter(originDatom_->getAtomType());
110 zaxis = originDatom_->getDipole();
112 zaxis = originDatom_->getA().transpose() * V3Z;
115 Vector3d xaxis =
cross(v1, zaxis);
116 Vector3d yaxis =
cross(zaxis, xaxis);
122 rotMat_.setRow(0, xaxis);
123 rotMat_.setRow(1, yaxis);
124 rotMat_.setRow(2, zaxis);
127 void LipidTransVisitor::internalVisit(StuntDouble* sd) {
128 std::shared_ptr<GenericData> data;
129 std::shared_ptr<AtomData> atomData;
130 std::shared_ptr<AtomInfo> atomInfo;
131 std::vector<std::shared_ptr<AtomInfo>>::iterator i;
133 data = sd->getPropertyByName(
"ATOMDATA");
135 if (data !=
nullptr) {
136 atomData = std::dynamic_pointer_cast<AtomData>(data);
138 if (atomData ==
nullptr)
return;
142 Snapshot* currSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
144 for (atomInfo = atomData->beginAtomInfo(i); atomInfo;
145 atomInfo = atomData->nextAtomInfo(i)) {
146 Vector3d tmp = atomInfo->pos - origin_;
147 currSnapshot->wrapVector(tmp);
148 atomInfo->pos = rotMat_ * tmp;
150 atomInfo->vec = rotMat_ * atomInfo->vec;
154 const std::string LipidTransVisitor::toString() {
160 "------------------------------------------------------------------\n");
163 snprintf(buffer, 65535,
"Visitor name: %s\n", visitorName.c_str());
166 snprintf(buffer, 65535,
"Visitor Description: rotate the whole system\n");
171 "------------------------------------------------------------------\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.
Vector3< Real > cross(const Vector3< Real > &v1, const Vector3< Real > &v2)
Returns the cross product of two Vectors.