ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
ibm_volcons.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 <boost/serialization/access.hpp>
23
24#include <cassert>
25#include <stdexcept>
26#include <vector>
27
28/** Parameters for IBM volume conservation bond */
29struct IBMVolCons {
30 /** ID of the large soft particle to which this node belongs */
31 unsigned int softID;
32 /** Reference volume */
33 double volRef;
34 /** Spring constant for volume force */
35 double kappaV;
36
37 double cutoff() const { return 0.; }
38
39 static constexpr int num = 0;
40
41 IBMVolCons(int softID, double kappaV) {
42 if (softID < 0) {
43 throw std::domain_error("IBMVolCons parameter 'softID' has to be >= 0");
44 }
45 this->softID = static_cast<unsigned int>(softID);
46 this->kappaV = kappaV;
47 // NOTE: We cannot compute the reference volume here because not all
48 // interactions are setup and thus we do not know which triangles belong to
49 // this softID. Calculate it later in the init function of
50 // \ref ImmersedBoundaries::init_volume_conservation()
51 volRef = 0.;
52 m_volumes = nullptr;
53 }
54
55 double get_current_volume() const {
56 double volume = 0.;
57 if (m_volumes) {
58 assert(static_cast<std::size_t>(softID) < m_volumes->size());
59 volume = (*m_volumes)[softID];
60 }
61 return volume;
62 }
63
64 void set_volumes_view(std::vector<double> const &volumes) {
65 m_volumes = &volumes;
66 }
67 void unset_volumes_view() { m_volumes = nullptr; }
68
69private:
70 std::vector<double> const *m_volumes;
71};
Parameters for IBM volume conservation bond.
double cutoff() const
IBMVolCons(int softID, double kappaV)
void set_volumes_view(std::vector< double > const &volumes)
double kappaV
Spring constant for volume force.
double get_current_volume() const
double volRef
Reference volume.
static constexpr int num
unsigned int softID
ID of the large soft particle to which this node belongs.
void unset_volumes_view()