OpenLB 1.7
Loading...
Searching...
No Matches
wallContact.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 WALL_CONTACT_H
25#define WALL_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> indicesSingle;
44};
45
46template <>
47const std::vector<unsigned int> WallContact<2>::indicesDim({0, 1});
48template <>
49const std::vector<unsigned int> WallContact<3>::indicesDim({0, 1, 2});
50template <unsigned D>
51const std::vector<unsigned int> WallContact<D>::indicesSingle({0});
52
53// Contact type to be used, if wall contact should be ignored (e.g., if only particle-particle contact is of interest)
54// TODO: struct IgnoreWallContact : WallContact {};
55
56template <typename T, unsigned D, bool CONVEX>
58private:
60 PhysR<T, D> particlePosition;
62 PhysR<T, D> min;
64 PhysR<T, D> max;
66 std::array<std::size_t, 1> particleID;
68 std::array<unsigned, 1> wallID;
70 std::array<T, 1> dampingFactor = {-1};
72 std::array<bool, 1> particlePositionUpdated = {false};
74 std::array<bool, 1> newContact = {true};
76 std::array<int, 1> responsibleRank = {std::numeric_limits<int>::max()};
77
79 static const std::size_t serialSize =
80 sizeof(particlePositionUpdated) + sizeof(newContact) +
81 sizeof(particlePosition) + sizeof(min) + sizeof(max) +
82 sizeof(particleID) + sizeof(wallID) + sizeof(responsibleRank) +
83 sizeof(dampingFactor);
84
85 template <typename F>
86 std::size_t processWithCommunicatables(F f);
87
88public:
89 static_assert(D == 2 || D == 3, "Only D=2 and D=3 are supported");
93 WallContactArbitraryFromOverlapVolume(std::size_t particleID,
94 unsigned wallID);
101
103 constexpr const PhysR<T, D>& getParticlePosition() const;
105 constexpr const PhysR<T, D>& getMin() const;
107 constexpr const PhysR<T, D>& getMax() const;
109 constexpr const std::size_t& getParticleID() const;
111 constexpr unsigned getWallID() const;
113 constexpr T getDampingFactor() const;
115 constexpr const int& getResponsibleRank() const;
116
118 constexpr void setParticlePosition(const PhysR<T, D>& particlePosition);
120 constexpr void setDampingFactor(const T dampingFactor);
122 constexpr void
123 setDampingFactorFromInitialVelocity(const T coefficientOfRestitution,
124 const T initialRelativeVelocityMagnitude);
126 constexpr void setResponsibleRank(const int& rank);
127
129 constexpr void resetMinMax();
131 constexpr void updateMinMax(const PhysR<T, D>& positionInsideTheContact);
133 constexpr void increaseMinMax(const Vector<T, D>& increaseBy);
134
136 constexpr void
139 constexpr bool isEmpty() const;
141 constexpr bool isNew() const;
143 constexpr void isNew(const bool newContact);
145 constexpr bool isParticlePositionUpdated() const;
146 // Set if the particle position is up-to-date
147 constexpr void setParticlePositionUpdated(bool updated);
154
156 std::size_t serialize(std::uint8_t* buffer);
158 std::size_t deserialize(std::uint8_t* buffer);
160 constexpr static std::size_t getSerialSize() { return serialSize; };
161
163 void print();
164};
165
166} // namespace contact
167} // namespace particles
168} // namespace olb
169#endif
Plain old scalar vector.
Definition vector.h:47
Top level namespace for all of OpenLB.
constexpr bool isParticlePositionUpdated() const
Returns if the particle position is up-to-date.
constexpr void setResponsibleRank(const int &rank)
Set processor that is responsible for contact treatment.
constexpr void setDampingFactor(const T dampingFactor)
Set damping factor for contact.
constexpr void setParticlePosition(const PhysR< T, D > &particlePosition)
Set particle position.
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...
constexpr const std::size_t & getParticleID() const
Read access to particle ID.
constexpr const PhysR< T, D > & getMin() const
Read access to min.
constexpr T getDampingFactor() const
Read access to damping factor.
std::size_t serialize(std::uint8_t *buffer)
Serialize contact data.
static constexpr std::size_t getSerialSize()
Get serial size.
constexpr void resetMinMax()
Reset min and max to default values.
constexpr unsigned getWallID() const
Read access to wall matreial.
constexpr const int & getResponsibleRank() const
Read access to the responsible rank.
constexpr const PhysR< T, D > & getParticlePosition() const
Return particle position.
WallContactArbitraryFromOverlapVolume< T, D, CONVEX > & operator=(const WallContactArbitraryFromOverlapVolume< T, D, CONVEX > &contact)
Copy assignment.
constexpr bool isEmpty() const
Returns if contact holds data.
constexpr const PhysR< T, D > & getMax() const
Read access to max.
std::size_t deserialize(std::uint8_t *buffer)
Deserialize contact data and save in object.
constexpr void combineWith(WallContactArbitraryFromOverlapVolume< T, D, CONVEX > &contact)
Combining two contacts, if the particle IDs are the same.
constexpr bool isNew() const
Returns if the contact is a new contact.
constexpr void increaseMinMax(const Vector< T, D > &increaseBy)
Increase bounding box size.
constexpr void updateMinMax(const PhysR< T, D > &positionInsideTheContact)
Update min and max with given position inside the contact.
static const std::vector< unsigned int > indicesDim
Definition wallContact.h:42
static const std::vector< unsigned int > indicesSingle
Definition wallContact.h:43
Set of functions commonly used in LB computations – header file.