OpenLB 1.7
Loading...
Searching...
No Matches
particleContact.h
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_H
25#define PARTICLE_CONTACT_H
26
27#include "contactFunctions.h"
28#include "contactHelpers.h"
29#include "core/blockStructure.h"
30#include "core/util.h"
31#include <array>
32#include <limits>
33#include <utility>
34
35namespace olb {
36namespace particles {
37namespace contact {
38
39template <unsigned D>
41 static_assert(D == 2 || D == 3, "Only D=2 and D=3 are supported");
42 static const std::vector<unsigned int> indicesDim;
43 static const std::vector<unsigned int> indicesPart;
44 static const std::vector<unsigned int> indicesSingle;
45};
46
47template <>
48const std::vector<unsigned int> ParticleContact<2>::indicesDim({0, 1});
49template <>
50const std::vector<unsigned int> ParticleContact<3>::indicesDim({0, 1, 2});
51template <unsigned D>
52const std::vector<unsigned int> ParticleContact<D>::indicesPart({0, 1});
53template <unsigned D>
54const std::vector<unsigned int> ParticleContact<D>::indicesSingle({0});
55
56// Contact type to be used, if particle contact should be ignored (e.g., if only wall contact is of interest)
57// TODO: struct IgnoreParticleContact : ParticleContact {};
58
60template <typename T, unsigned D, bool CONVEX>
62private:
64 std::array<PhysR<T, D>, 2> particlePositions;
66 PhysR<T, D> min;
68 PhysR<T, D> max;
70 std::array<std::size_t, 2> ids;
72 std::array<T, 1> dampingFactor = {-1};
74 std::array<bool, 1> particlePositionUpdated = {false};
76 std::array<bool, 1> newContact = {true};
78 std::array<int, 1> responsibleRank = {std::numeric_limits<int>::max()};
79
81 static const std::size_t serialSize =
82 sizeof(particlePositionUpdated) + sizeof(newContact) +
83 sizeof(particlePositions) + sizeof(min) + sizeof(max) + sizeof(ids) +
84 sizeof(responsibleRank) + sizeof(dampingFactor);
85
86 template <typename F>
87 std::size_t processWithCommunicatables(F f);
88
89public:
90 static_assert(D == 2 || D == 3, "Only D=2 and D=3 are supported");
95 const std::array<std::size_t, 2>& particleIDs);
102
104 constexpr const std::array<PhysR<T, D>, 2>& getParticlePositions() const;
106 constexpr const PhysR<T, D>& getParticlePosition(const std::size_t& id) const;
108 constexpr const PhysR<T, D>& getMin() const;
110 constexpr const PhysR<T, D>& getMax() const;
112 constexpr const std::array<std::size_t, 2>& getIDs() const;
114 constexpr const T getDampingFactor() const;
116 constexpr const int& getResponsibleRank() const;
117
119 constexpr void
120 setParticlePositions(const std::array<PhysR<T, D>, 2>& positions);
122 constexpr void setParticlePosition(const PhysR<T, D>& position,
123 const std::size_t& id);
125 constexpr void setDampingFactor(const T dampingFactor);
127 constexpr void
128 setDampingFactorFromInitialVelocity(const T coefficientOfRestitution,
129 const T initialRelativeVelocityMagnitude);
131 constexpr void setResponsibleRank(const int& rank);
132
134 constexpr void resetMinMax();
136 constexpr void updateMinMax(const PhysR<T, D>& positionInsideTheContact);
138 constexpr void increaseMinMax(const Vector<T, D>& increaseBy);
139
141 constexpr void
144 constexpr bool isEmpty() const;
146 constexpr bool isNew() const;
148 constexpr void isNew(const bool newContact);
150 constexpr bool isParticlePositionUpdated() const;
151 // Set if the particle position is up-to-date
152 constexpr void setParticlePositionUpdated(bool updated);
159
161 std::size_t serialize(std::uint8_t* buffer);
163 std::size_t deserialize(std::uint8_t* buffer);
165 constexpr static std::size_t getSerialSize() { return serialSize; };
166
168 void print();
169};
170
171} // namespace contact
172} // namespace particles
173} // namespace olb
174#endif
Plain old scalar vector.
Definition vector.h:47
Top level namespace for all of OpenLB.
An object holding data for a contact which is described analog to Nassauer and Kuna (2013)
constexpr void setDampingFactor(const T dampingFactor)
Set damping factor for contact.
constexpr const std::array< std::size_t, 2 > & getIDs() const
Read access to particle IDs.
constexpr void increaseMinMax(const Vector< T, D > &increaseBy)
Increase bounding box size.
constexpr const PhysR< T, D > & getParticlePosition(const std::size_t &id) const
Return particle position.
constexpr void setParticlePositions(const std::array< PhysR< T, D >, 2 > &positions)
Set particle positions.
constexpr bool isNew() const
Returns if the contact is a new contact.
constexpr void updateMinMax(const PhysR< T, D > &positionInsideTheContact)
Update min and max with given position inside the contact.
constexpr const int & getResponsibleRank() const
Read access to the responsible rank.
constexpr void setDampingFactorFromInitialVelocity(const T coefficientOfRestitution, const T initialRelativeVelocityMagnitude)
Set damping factor from the magnitude of the initial relative impact velocity in direction of contact...
ParticleContactArbitraryFromOverlapVolume< T, D, CONVEX > & operator=(const ParticleContactArbitraryFromOverlapVolume< T, D, CONVEX > &pc)
Copy assignment.
constexpr bool isParticlePositionUpdated() const
Returns if the particle position is up-to-date.
constexpr void setParticlePosition(const PhysR< T, D > &position, const std::size_t &id)
Set position of specific particle.
static constexpr std::size_t getSerialSize()
Get serial size.
constexpr const std::array< PhysR< T, D >, 2 > & getParticlePositions() const
Read access to particle positions.
constexpr const PhysR< T, D > & getMax() const
Read access to max.
constexpr bool isEmpty() const
Returns if contact holds data.
std::size_t deserialize(std::uint8_t *buffer)
Deserialize contact data and save in object.
constexpr const PhysR< T, D > & getMin() const
Read access to min.
constexpr void combineWith(ParticleContactArbitraryFromOverlapVolume< T, D, CONVEX > &pc)
Combining two contacts, if the particle ids are the same.
constexpr const T getDampingFactor() const
Read access to damping factor.
constexpr void resetMinMax()
Reset min and max to default values.
std::size_t serialize(std::uint8_t *buffer)
Serialize contact data.
constexpr void setResponsibleRank(const int &rank)
Set processor that is responsible for contact treatment.
static const std::vector< unsigned int > indicesDim
static const std::vector< unsigned int > indicesSingle
static const std::vector< unsigned int > indicesPart
Set of functions commonly used in LB computations – header file.