OpenLB 1.8.1
Loading...
Searching...
No Matches
contactFunctions.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/*
25 * This file contains functions used for the particle-wall and particle-particle contact force calculation.
26*/
27
28#ifndef CONTACT_FUNCTIONS_H
29#define CONTACT_FUNCTIONS_H
30
31#include <numbers>
32
33namespace olb {
34
35namespace particles {
36
37namespace contact {
38
39template <typename T>
40constexpr T evalEffectiveYoungModulus(T E1, T E2, T nu1, T nu2)
41{
42 const T denominator = (1 - nu1 * nu1) / E1 + (1 - nu2 * nu2) / E2;
43 return T {1} / denominator;
44}
45
47template <typename T>
48constexpr T evalDampingFactor(const T coefficientOfRestitution,
49 const T initialRelativeVelocityMagnitude)
50{
51 // This case should never happen, but could for example due to initial conditions
52 if (initialRelativeVelocityMagnitude <= 0) {
53 return 0;
54 }
55 return 1.5 * (1 - coefficientOfRestitution) *
56 (11 - coefficientOfRestitution) / (1 + 9 * coefficientOfRestitution) /
57 initialRelativeVelocityMagnitude;
58}
59
60template <typename T, typename PARTICLETYPE>
62 T const physDeltaX)
63{
64 constexpr unsigned D = PARTICLETYPE::d;
65
67 constexpr T factor = []() {
68 static_assert(D == 2 || D == 3, "Only D=2 and D=3 are supported");
69 return T{0.5} * (D == 3 ? std::numbers::sqrt3_v<T> : std::numbers::sqrt2_v<T>);
70 }();
71 return factor * physDeltaX +
73 }
74 else {
75 return T {0};
76 }
77
78 __builtin_unreachable();
79}
80
81template <typename T>
82T evalCircumRadius(T const contactDetectionDistance, T const circumRadius,
83 T const epsilon)
84{
85 return circumRadius - epsilon + util::max(epsilon, contactDetectionDistance);
86}
87
88template <typename T, typename PARTICLETYPE>
89T evalCircumRadius(Particle<T, PARTICLETYPE>& particle, T const physDeltaX,
90 T const circumRadius, T const epsilon)
91{
92 const T contactDetectionDistance =
93 evalContactDetectionDistance(particle, physDeltaX);
94 return evalCircumRadius(contactDetectionDistance, circumRadius, epsilon);
95}
96
97template <typename T, typename PARTICLETYPE>
98T evalCircumRadius(Particle<T, PARTICLETYPE>& particle, T const physDeltaX)
99{
100 using namespace descriptors;
101 auto sIndicator = particle.template getField<SURFACE, SINDICATOR>();
102 return evalCircumRadius(particle, physDeltaX, sIndicator->getCircumRadius(),
103 sIndicator->getEpsilon());
104}
105
106template <typename CONTACTTYPE>
107void cleanContacts(std::vector<CONTACTTYPE>& contacts)
108{
109 contacts.erase(std::remove_if(contacts.begin(), contacts.end(),
110 [](const CONTACTTYPE& contact) {
111 return contact.isEmpty();
112 }),
113 contacts.end());
114}
115
116template <typename CONTACTTYPE>
117void resetResponsibleRank(CONTACTTYPE& contact)
118{
119 contact.setResponsibleRank(std::numeric_limits<int>::max());
120}
121
122template <typename CONTACTTYPE>
123bool isResponsibleRankSet(CONTACTTYPE& contact)
124{
125 return contact.getResponsibleRank() < std::numeric_limits<int>::max();
126}
127
128} // namespace contact
129} // namespace particles
130} // namespace olb
131#endif
T getEnlargementForContact(Particle< T, PARTICLETYPE > particle)
constexpr bool providesContactMaterial()
void cleanContacts(std::vector< CONTACTTYPE > &contacts)
void resetResponsibleRank(CONTACTTYPE &contact)
bool isResponsibleRankSet(CONTACTTYPE &contact)
T evalCircumRadius(T const contactDetectionDistance, T const circumRadius, T const epsilon)
constexpr T evalEffectiveYoungModulus(T E1, T E2, T nu1, T nu2)
T evalContactDetectionDistance(Particle< T, PARTICLETYPE > &particle, T const physDeltaX)
constexpr T evalDampingFactor(const T coefficientOfRestitution, const T initialRelativeVelocityMagnitude)
Calculates the damping factor according to Carvalho & Martins (2019) (10.1016/j.mechmachtheory....
Expr max(Expr a, Expr b)
Definition expr.cpp:245
Top level namespace for all of OpenLB.