OpenLB 1.7
Loading...
Searching...
No Matches
contactContainer.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2021 Jan E. Marquardt, Mathias J. Krause
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program 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
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef PARTICLE_CONTACT_CONTAINER_HH
25#define PARTICLE_CONTACT_CONTAINER_HH
26
27#include "contactContainer.h"
28#include "contactFunctions.h"
29
30namespace olb {
31namespace particles {
32namespace contact {
33
34template <typename T, typename PARTICLECONTACTTYPE, typename WALLCONTACTTYPE>
36 int resizeParticleContactTo, int resizeWallContactsTo)
37{
38 particleContacts.resize(resizeParticleContactTo);
39 wallContacts.resize(resizeWallContactsTo);
40}
41
42template <typename T, typename PARTICLECONTACTTYPE, typename WALLCONTACTTYPE>
43void ContactContainer<T, PARTICLECONTACTTYPE,
44 WALLCONTACTTYPE>::combineContacts()
45{
46 for (auto it = std::begin(particleContacts); it != std::end(particleContacts);
47 ++it) {
48 for (auto it2 = it + 1; it2 != std::end(particleContacts); ++it2) {
49 // combineWith must check if the particle ids are the same
50 it->combineWith(*it2);
51 }
52 }
53
54 for (auto it = std::begin(wallContacts); it != std::end(wallContacts); ++it) {
55 for (auto it2 = it + 1; it2 != std::end(wallContacts); ++it2) {
56 // combineWith must check if the contacts are the same
57 it->combineWith(*it2);
58 }
59 }
60}
61
62template <typename T, typename PARTICLECONTACTTYPE, typename WALLCONTACTTYPE>
63void ContactContainer<T, PARTICLECONTACTTYPE,
64 WALLCONTACTTYPE>::cleanParticleContacts()
65{
66 particles::contact::cleanContacts(particleContacts);
67}
68
69template <typename T, typename PARTICLECONTACTTYPE, typename WALLCONTACTTYPE>
70void ContactContainer<T, PARTICLECONTACTTYPE,
71 WALLCONTACTTYPE>::cleanWallContacts()
72{
74}
75
76template <typename T, typename PARTICLECONTACTTYPE, typename WALLCONTACTTYPE>
78{
79 cleanParticleContacts();
80 cleanWallContacts();
81}
82
83template <typename T, typename PARTICLECONTACTTYPE, typename WALLCONTACTTYPE>
84void ContactContainer<T, PARTICLECONTACTTYPE,
85 WALLCONTACTTYPE>::clearParticleContacts()
86{
87 const std::size_t capacity = particleContacts.capacity();
88 particleContacts.clear();
89 particleContacts.reserve(capacity / 2);
90}
91
92template <typename T, typename PARTICLECONTACTTYPE, typename WALLCONTACTTYPE>
93void ContactContainer<T, PARTICLECONTACTTYPE,
94 WALLCONTACTTYPE>::clearWallContacts()
95{
96 const std::size_t capacity = wallContacts.capacity();
97 wallContacts.clear();
98 wallContacts.reserve(capacity / 2);
99}
100
101template <typename T, typename PARTICLECONTACTTYPE, typename WALLCONTACTTYPE>
103{
104 clearParticleContacts();
105 clearWallContacts();
106}
107
108template <typename T, typename PARTICLECONTACTTYPE, typename WALLCONTACTTYPE>
112{
113 particleContacts.clear();
114 particleContacts.reserve(container.particleContacts.size());
115 for (size_t i = 0; i < container.particleContacts.size(); ++i) {
116 particleContacts.push_back(container.particleContacts[i]);
117 }
118
119 wallContacts.clear();
120 wallContacts.reserve(container.wallContacts.size());
121 for (size_t i = 0; i < container.wallContacts.size(); ++i) {
122 wallContacts.push_back(container.wallContacts[i]);
123 }
124
125 return *this;
126}
127
128} // namespace contact
129} // namespace particles
130} // namespace olb
131#endif
void cleanContacts(std::vector< CONTACTTYPE > &contacts)
Top level namespace for all of OpenLB.
std::vector< PARTICLECONTACTTYPE > particleContacts
resizeable vector containing all particle-particle contacts
ContactContainer(int resizeParticleContactTo=0, int resizeWallContactsTo=0)
Constructor.
void cleanContacts()
Clean contacts - remove "empty" contacts.
void clearContacts()
Clear contacts - remove all content.
ContactContainer< T, PARTICLECONTACTTYPE, WALLCONTACTTYPE > & operator=(ContactContainer< T, PARTICLECONTACTTYPE, WALLCONTACTTYPE > &container)
std::vector< WALLCONTACTTYPE > wallContacts
resizeable vector containg all particle-wall contacts