votca 2024-dev
Loading...
Searching...
No Matches
basebead.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2021 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#ifndef VOTCA_CSG_BASEBEAD_H
18#define VOTCA_CSG_BASEBEAD_H
19#pragma once
20
21// Standard includes
22#include <cassert>
23#include <memory>
24
25// VOTCA includes
27#include <votca/tools/eigen.h>
28#include <votca/tools/name.h>
29#include <votca/tools/types.h>
30
31namespace TOOLS = votca::tools;
32
33namespace votca {
34namespace csg {
35
44class BaseBead {
45 public:
49 virtual ~BaseBead() = default;
50
52 Index getId() const noexcept { return id_; }
53
55 void setId(const Index &id) noexcept { id_ = id; }
56
58 std::string getName() const { return name_.getName(); }
59
61 void setName(std::string name) { return name_.setName(name); }
62
68 void setMoleculeId(const Index &molecule_id) noexcept {
69 molecule_id_ = molecule_id;
70 }
71
78 Index getMoleculeId() const noexcept { return molecule_id_; }
79
84 virtual const std::string getType() const noexcept { return type_; }
85
90 virtual void setType(const std::string &type) noexcept { type_ = type; }
91
98 std::string getElement() const noexcept { return element_symbol_; }
99
104 virtual const double &getMass() const noexcept { return mass_; }
105
110 virtual void setMass(const double &m) noexcept { mass_ = m; }
111
116 virtual void setPos(const Eigen::Vector3d &bead_position);
117
122 virtual const Eigen::Vector3d &getPos() const;
123
128 virtual Eigen::Vector3d &Pos() {
129 assert(bead_position_set_ && "Position is not set.");
130 return bead_position_;
131 }
132
133 virtual const Eigen::Vector3d &Pos() const {
134 assert(bead_position_set_ && "Position is not set.");
135 return bead_position_;
136 }
137
139 bool HasPos() const noexcept { return bead_position_set_; }
140
142 void HasPos(const bool &true_or_false) noexcept {
143 bead_position_set_ = true_or_false;
144 }
145
146 protected:
147 BaseBead() = default;
148
154
155 double mass_ = 0.0;
156 Eigen::Vector3d bead_position_;
157
158 bool bead_position_set_ = false;
159};
160
161inline void BaseBead::setPos(const Eigen::Vector3d &bead_position) {
162 bead_position_set_ = true;
163 bead_position_ = bead_position;
164}
165
166inline const Eigen::Vector3d &BaseBead::getPos() const {
167 assert(bead_position_set_ &&
168 "Cannot get bead position as it has not been set.");
169 return bead_position_;
170}
171} // namespace csg
172} // namespace votca
173
174#endif // VOTCA_CSG_BASEBEAD_H
information about a base bead
Definition basebead.h:44
virtual void setMass(const double &m) noexcept
Definition basebead.h:110
virtual const std::string getType() const noexcept
Definition basebead.h:84
virtual Eigen::Vector3d & Pos()
Definition basebead.h:128
void setName(std::string name)
Sets the name of the bead.
Definition basebead.h:61
std::string getElement() const noexcept
Returns the element type of the bead.
Definition basebead.h:98
virtual const Eigen::Vector3d & getPos() const
Definition basebead.h:166
std::string getName() const
Gets the name of the bead.
Definition basebead.h:58
virtual const Eigen::Vector3d & Pos() const
Definition basebead.h:133
virtual void setPos(const Eigen::Vector3d &bead_position)
Definition basebead.h:161
Index getMoleculeId() const noexcept
Get the id of the molecule the bead is a part of, if the molecule id has not been set return topology...
Definition basebead.h:78
virtual ~BaseBead()=default
std::string element_symbol_
Definition basebead.h:152
void setId(const Index &id) noexcept
Sets the id of the bead.
Definition basebead.h:55
virtual void setType(const std::string &type) noexcept
Definition basebead.h:90
void setMoleculeId(const Index &molecule_id) noexcept
assign the bead to a molecule with the provided id
Definition basebead.h:68
std::string type_
Definition basebead.h:149
virtual const double & getMass() const noexcept
Definition basebead.h:104
void HasPos(const bool &true_or_false) noexcept
Definition basebead.h:142
bool HasPos() const noexcept
Definition basebead.h:139
TOOLS::Name name_
Definition basebead.h:153
Eigen::Vector3d bead_position_
Definition basebead.h:156
Index getId() const noexcept
Gets the id of the bead.
Definition basebead.h:52
Name object.
Definition name.h:38
void setName(const std::string &name)
Definition name.h:46
const std::string & getName() const
Definition name.h:50
const std::string unassigned_element
Used to indicate that a valid element variable has not been assigned.
Definition constants.h:67
const Index unassigned_residue_id
Used to indicate a valid residue id has not been assigned.
Definition constants.h:79
const Index unassigned_molecule_id
Used to indicate a valid molecule id has not been assigned.
Definition constants.h:82
const std::string unassigned_bead_type
Used to indicate that a valid bead type variable has not been assigned.
Definition constants.h:70
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26