ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
Slitpore.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
4 * Max-Planck-Institute for Polymer Research, Theory Group
5 *
6 * This file is part of ESPResSo.
7 *
8 * ESPResSo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * ESPResSo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include <shapes/Slitpore.hpp>
23
24#include <utils/Vector.hpp>
25#include <utils/math/sqr.hpp>
26
27#include <cmath>
28
29namespace Shapes {
31 Utils::Vector3d &vec) const {
32 using std::sqrt;
33
34 // the left circles
35 Utils::Vector2d c11 = {dividing_plane() - m_pore_width / 2 -
36 m_upper_smoothing_radius,
37 m_pore_mouth - m_upper_smoothing_radius};
38 Utils::Vector2d c12 = {
39 dividing_plane() - m_pore_width / 2 + m_lower_smoothing_radius,
40 m_pore_mouth - m_pore_length + m_lower_smoothing_radius};
41 // the right circles
42 Utils::Vector2d c21 = {dividing_plane() + m_pore_width / 2 +
43 m_upper_smoothing_radius,
44 m_pore_mouth - m_upper_smoothing_radius};
45 Utils::Vector2d c22 = {
46 dividing_plane() + m_pore_width / 2 - m_lower_smoothing_radius,
47 m_pore_mouth - m_pore_length + m_lower_smoothing_radius};
48
49 if (pos[2] > m_pore_mouth + m_channel_width / 2) {
50 // Feel the upper wall
51 dist = m_pore_mouth + m_channel_width - pos[2];
52 vec[0] = vec[1] = 0;
53 vec[2] = -dist;
54 return;
55 }
56
57 if (pos[0] < c11[0] || pos[0] > c21[0]) {
58 // Feel the lower wall of the channel
59 dist = pos[2] - m_pore_mouth;
60 vec[0] = vec[1] = 0;
61 vec[2] = dist;
62 return;
63 }
64
65 if (pos[2] > c11[1]) {
66 // Feel the upper smoothing
67 if (pos[0] < dividing_plane()) {
68 dist = sqrt(Utils::sqr(c11[0] - pos[0]) + Utils::sqr(c11[1] - pos[2])) -
69 m_upper_smoothing_radius;
70 vec[0] = -(c11[0] - pos[0]) * (dist) / (dist + m_upper_smoothing_radius);
71 vec[1] = 0;
72 vec[2] = -(c11[1] - pos[2]) * (dist) / (dist + m_upper_smoothing_radius);
73 return;
74 }
75 dist = sqrt(Utils::sqr(c21[0] - pos[0]) + Utils::sqr(c21[1] - pos[2])) -
76 m_upper_smoothing_radius;
77 vec[0] = -(c21[0] - pos[0]) * (dist) / (dist + m_upper_smoothing_radius);
78 vec[1] = 0;
79 vec[2] = -(c21[1] - pos[2]) * (dist) / (dist + m_upper_smoothing_radius);
80 return;
81 }
82
83 if (pos[2] > c12[1]) {
84 // Feel the pore wall
85 if (pos[0] < dividing_plane()) {
86 dist = pos[0] - (dividing_plane() - m_pore_width / 2);
87 vec[0] = dist;
88 vec[1] = vec[2] = 0;
89 return;
90 }
91 dist = (dividing_plane() + m_pore_width / 2) - pos[0];
92 vec[0] = -dist;
93 vec[1] = vec[2] = 0;
94 return;
95 }
96
97 if (pos[0] > c12[0] && pos[0] < c22[0]) {
98 // Feel the pore end wall
99 dist = pos[2] - (m_pore_mouth - m_pore_length);
100 vec[0] = vec[1] = 0;
101 vec[2] = dist;
102 return;
103 }
104
105 // Feel the lower smoothing
106 if (pos[0] < dividing_plane()) {
107 dist = -sqrt(Utils::sqr(c12[0] - pos[0]) + Utils::sqr(c12[1] - pos[2])) +
108 m_lower_smoothing_radius;
109 vec[0] = (c12[0] - pos[0]) * (dist) / (-dist + m_lower_smoothing_radius);
110 vec[1] = 0;
111 vec[2] = (c12[1] - pos[2]) * (dist) / (-dist + m_lower_smoothing_radius);
112 return;
113 }
114 dist = -sqrt(Utils::sqr(c22[0] - pos[0]) + Utils::sqr(c22[1] - pos[2])) +
115 m_lower_smoothing_radius;
116 vec[0] = (c22[0] - pos[0]) * (dist) / (-dist + m_lower_smoothing_radius);
117 vec[1] = 0;
118 vec[2] = (c22[1] - pos[2]) * (dist) / (-dist + m_lower_smoothing_radius);
119}
120} // namespace Shapes
Vector implementation and trait types for boost qvm interoperability.
__shared__ int pos[MAXDEPTH *THREADS5/WARPSIZE]
void calculate_dist(const Utils::Vector3d &pos, double &dist, Utils::Vector3d &vec) const override
Definition Slitpore.cpp:30
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
Definition sqr.hpp:26