ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
core/constraints/ShapeBasedConstraint.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-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#pragma once
21
22#include "BoxGeometry.hpp"
23#include "Constraint.hpp"
24#include "Observable_stat.hpp"
25#include "Particle.hpp"
26#include "ParticleRange.hpp"
28#include "system/System.hpp"
29
30#include <shapes/NoWhere.hpp>
31#include <shapes/Shape.hpp>
32
33#include <utils/Vector.hpp>
34
35#include <memory>
36#include <utility>
37
38namespace Constraints {
39
41public:
43 : part_rep{}, m_shape{std::make_shared<Shapes::NoWhere>()},
44 m_penetrable{false}, m_only_positive{false}, m_local_force{},
45 m_outer_normal_force{}, m_system{system} {}
46
47 void add_energy(const Particle &p, const Utils::Vector3d &folded_pos,
48 double time, Observable_stat &energy) const override;
49
50 ParticleForce force(const Particle &p, const Utils::Vector3d &folded_pos,
51 double time) override;
52
53 bool fits_in_box(Utils::Vector3d const &) const override { return true; }
54
55 /** @brief Calculate the minimum distance between all particle pairs. */
56 double min_dist(BoxGeometry const &box_geo,
57 ParticleRange const &particles) const;
58
59 /** @brief Calculate distance from the constraint */
60 void calc_dist(Utils::Vector3d const &pos, double &dist,
61 Utils::Vector3d &vec) const {
62 m_shape->calculate_dist(pos, dist, vec);
63 }
64
65 void set_shape(std::shared_ptr<Shapes::Shape> const &shape) {
66 m_shape = shape;
67 }
68
69 Shapes::Shape const &shape() const { return *m_shape; }
70
71 void reset_force() override {
72 m_local_force = Utils::Vector3d{0, 0, 0};
73 m_outer_normal_force = 0.0;
74 }
75
76 bool &only_positive() { return m_only_positive; }
77 bool &penetrable() { return m_penetrable; }
78 int &type() { return part_rep.type(); }
79 Utils::Vector3d &velocity() { return part_rep.v(); }
80
81 void set_type(int type) {
82 part_rep.type() = type;
83 m_system.nonbonded_ias->make_particle_type_exist(type);
84 }
85
87 double total_normal_force() const;
88
89private:
90 Particle part_rep;
91 std::shared_ptr<Shapes::Shape> m_shape;
92 bool m_penetrable;
93 bool m_only_positive;
94 Utils::Vector3d m_local_force;
95 double m_outer_normal_force;
96 System::System const &m_system;
97
98 auto const &get_ia_param(int type) const {
99 return m_system.nonbonded_ias->get_ia_param(type, part_rep.type());
100 }
101};
102
103} // namespace Constraints
Vector implementation and trait types for boost qvm interoperability.
__global__ float * force
__shared__ int pos[MAXDEPTH *THREADS5/WARPSIZE]
void calc_dist(Utils::Vector3d const &pos, double &dist, Utils::Vector3d &vec) const
Calculate distance from the constraint.
bool fits_in_box(Utils::Vector3d const &) const override
double min_dist(BoxGeometry const &box_geo, ParticleRange const &particles) const
Calculate the minimum distance between all particle pairs.
void add_energy(const Particle &p, const Utils::Vector3d &folded_pos, double time, Observable_stat &energy) const override
void set_shape(std::shared_ptr< Shapes::Shape > const &shape)
Observable for the pressure and energy.
A range of particles.
Main system class.
std::shared_ptr< InteractionsNonBonded > nonbonded_ias
Various procedures concerning interactions between particles.
Force information on a particle.
Definition Particle.hpp:290
Struct holding all information for one particle.
Definition Particle.hpp:393
auto const & v() const
Definition Particle.hpp:431
auto const & type() const
Definition Particle.hpp:416