ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
shapes/include/shapes/SimplePore.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef SHAPES_SIMPLE_PORE_HPP
21#define SHAPES_SIMPLE_PORE_HPP
22
23#include "Shape.hpp"
24#include <utils/Vector.hpp>
25
26#include <utility>
27
28namespace Shapes {
29class SimplePore : public Shape {
30 double m_rad;
31 double m_length;
32 double m_smoothing_rad;
33 Utils::Vector3d m_center;
34 Utils::Vector3d m_axis;
35
36 /* Center of smoothing circle */
37 double c_r;
38 double c_z;
39 double m_half_length;
40 /** Unit vector in z direction */
42
43 /** Alternative e_r for corner case */
44 Utils::Vector3d e_r_axis;
45
46 /** @brief Calculate derived parameters. */
47 void precalc() {
48 m_half_length = 0.5 * m_length;
49
50 e_z = m_axis / m_axis.norm();
51
52 /* Find a vector orthogonal to e_z, since {1,0,0} and
53 {0,1,0} are independent, e_z can not be parallel to both
54 of them. Then we can do Gram-Schmidt */
55 if ((Utils::Vector3d{1., 0., 0} * e_z) < 1.)
56 e_r_axis =
57 Utils::Vector3d{1., 0., 0} - (e_z * Utils::Vector3d{1., 0., 0}) * e_z;
58 else
59 e_r_axis =
60 Utils::Vector3d{0., 1., 0} - (e_z * Utils::Vector3d{0., 1., 0}) * e_z;
61
62 e_r_axis.normalize();
63
64 c_r = m_rad + m_smoothing_rad;
65 c_z = m_half_length - m_smoothing_rad;
66 }
67
68 std::pair<double, double> dist_half_pore(double r, double z) const;
69
70public:
71 SimplePore() : m_axis({1., 0., 0}) { precalc(); }
72
73 double radius() const { return m_rad; }
74 void set_radius(double const &radius) {
75 m_rad = radius;
76 precalc();
77 }
78
79 double length() const { return m_length; }
80 void set_length(double const &length) {
81 m_length = length;
82 precalc();
83 }
84
85 double smoothing_radius() const { return m_smoothing_rad; }
87 m_smoothing_rad = smoothing_radius;
88 precalc();
89 }
90
91 Utils::Vector3d const &axis() const { return m_axis; }
93 m_axis = axis;
94 precalc();
95 }
96
97 Utils::Vector3d &center() { return m_center; }
98
99 void calculate_dist(const Utils::Vector3d &pos, double &dist,
100 Utils::Vector3d &vec) const override;
101};
102} // namespace Shapes
103
104#endif
Vector implementation and trait types for boost qvm interoperability.
Utils::Vector3d const & axis() const
void set_axis(Utils::Vector3d const &axis)
void set_length(double const &length)
void calculate_dist(const Utils::Vector3d &pos, double &dist, Utils::Vector3d &vec) const override
void set_smoothing_radius(double const &smoothing_radius)
void set_radius(double const &radius)
Vector & normalize()
Definition Vector.hpp:147
T norm() const
Definition Vector.hpp:138